diff options
Diffstat (limited to 'Build/source/utils/asymptote/runarray.in')
-rw-r--r-- | Build/source/utils/asymptote/runarray.in | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Build/source/utils/asymptote/runarray.in b/Build/source/utils/asymptote/runarray.in index a5e4692247f..0f1502f6abb 100644 --- a/Build/source/utils/asymptote/runarray.in +++ b/Build/source/utils/asymptote/runarray.in @@ -1102,7 +1102,7 @@ array* :array3Transpose(array *a, array *perm) return c; } -// In a boolean array, find the index of the nth true value or -1 if not found +// Find the index of the nth true value in a boolean array or -1 if not found. // If n is negative, search backwards. Int find(boolarray *a, Int n=1) { @@ -1121,6 +1121,19 @@ Int find(boolarray *a, Int n=1) return j; } +// Find all indices of true values in a boolean array. +Intarray *findall(boolarray *a) +{ + size_t size=checkArray(a); + array *b=new array(0); + for(size_t i=0; i < size; i++) { + if(read<bool>(a,i)) { + b->push((Int) i); + } + } + return b; +} + // construct vector obtained by replacing those elements of b for which the // corresponding elements of a are false by the corresponding element of c. array* :arrayConditional(array *a, array *b, array *c) |