summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runarray.in
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/runarray.in')
-rw-r--r--Build/source/utils/asymptote/runarray.in34
1 files changed, 26 insertions, 8 deletions
diff --git a/Build/source/utils/asymptote/runarray.in b/Build/source/utils/asymptote/runarray.in
index cf04637ce31..83064a05dd2 100644
--- a/Build/source/utils/asymptote/runarray.in
+++ b/Build/source/utils/asymptote/runarray.in
@@ -274,7 +274,7 @@ array *mult(array *a, array *b)
array *ci=new array(nb0);
(*c)[i]=ci;
for(size_t j=0; j < nb0; ++j) {
- T sum=0.0;
+ T sum=T();
size_t kj=j;
for(size_t k=0; k < nb; ++k, kj += nb0)
sum += Ai[k]*B[kj];
@@ -435,6 +435,13 @@ void integeroverflow(size_t i)
buf << "Integer overflow";
error(buf);
}
+
+void checkSize(Int n, Int depth)
+{
+ if(n < 0) error("cannot create a negative length array");
+ if(depth < 0) error("cannot copy to a negative depth");
+}
+
}
// Autogenerated routines:
@@ -499,14 +506,25 @@ array* :newAppendedArray(array* tail, Int n)
return a;
}
-// The function T[] array(int n, T value, int depth=0) produces a array of n
-// copies of x, where each copy is copied up to depth.
-array* :newDuplicateArray(Int n, item value, Int depth=Int_MAX)
+// Produce an array of n deep copies of value.
+array* :copyArray0(Int n, item value, Int depth=Int_MAX)
{
- if(n < 0) error("cannot create a negative length array");
- if(depth < 0) error("cannot copy to a negative depth");
-
- return new array(n, value, depth);
+ checkSize(n,depth);
+ return new array((size_t) n, value, (size_t) 0);
+}
+
+array* :copyArray1(Int n, item value, Int depth=Int_MAX)
+{
+ checkSize(n,depth);
+ if(depth > 1) depth=1;
+ return new array((size_t) n, value, (size_t) depth);
+}
+
+array* :copyArray2(Int n, item value, Int depth=Int_MAX)
+{
+ checkSize(n,depth);
+ if(depth > 2) depth=2;
+ return new array((size_t) n, value, (size_t) depth);
}
// Read an element from an array. Checks for initialization & bounds.