diff options
author | Karl Berry <karl@freefriends.org> | 2010-06-14 23:14:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-06-14 23:14:16 +0000 |
commit | c2175edc7aa44ca0b526f008d473d6f8a8ac4933 (patch) | |
tree | d6c491676b413ad1922481f8c3fc7b64c3afc0a5 /Build/source/utils/asymptote/runarray.in | |
parent | 5d08e9ff4fe5fc836d237ea08e82c82b27d558a2 (diff) |
asy 1.98
git-svn-id: svn://tug.org/texlive/trunk@18982 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/runarray.in')
-rw-r--r-- | Build/source/utils/asymptote/runarray.in | 34 |
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. |