guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/01: Final names for new array functions


From: Daniel Llorens
Subject: [Guile-commits] 01/01: Final names for new array functions
Date: Mon, 9 Jan 2017 08:02:11 +0000 (UTC)

lloda pushed a commit to branch master
in repository guile.

commit 7e93950552cd9e85a1f3eb73faf16e8423b0fbbe
Author: Daniel Llorens <address@hidden>
Date:   Mon Dec 26 21:41:17 2016 +0100

    Final names for new array functions
    
    Globally rename (array-from* -> array-slice), (array-from ->
    array-cell-ref), (array-amend! -> array-cell-set!), (array-for-each-cell
    -> array-slice-for-each).
---
 doc/ref/api-data.texi           |  156 +++++++++++++++++++++++----------------
 libguile/array-map.c            |   18 ++---
 libguile/array-map.h            |    4 +-
 libguile/arrays.c               |   50 ++++++-------
 libguile/arrays.h               |    6 +-
 test-suite/tests/array-map.test |   10 +--
 test-suite/tests/arrays.test    |   48 ++++++------
 7 files changed, 160 insertions(+), 132 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 58e9f43..1b3170e 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -7761,37 +7761,57 @@ have smaller rank than @var{array}.
 @node Arrays as arrays of arrays
 @subsubsection Arrays as arrays of arrays
 
-The functions in this section allow you to treat an array of rank
address@hidden as an array of lower rank @math{n-k} where the elements are
-themselves arrays (`cells') of rank @math{k}. This replicates some of
-the functionality of `enclosed arrays', a feature of old Guile that was
-removed before @w{version 2.0}. However, these functions do not require
-a special type and operate on any array.
-
-When we operate on an array in this way, we speak of the first @math{k}
-dimensions of the array as the @math{k}-`frame' of the array, while the
-last @math{n-k} dimensions are the dimensions of the
address@hidden'. For example, a 2D-array (a matrix) can be seen as a
-1D array of rows. In this case, the rows are the 1-cells of the array.
-
address@hidden {Scheme Procedure} array-from array idx @dots{}
address@hidden {C Function} scm_array_from (array, idxlist)
-If the length of @var{idxlist} equals the rank @math{n} of
address@hidden, return the element at @code{(idx @dots{})}, just like
address@hidden(array-ref array idx @dots{})}. If, however, the length @math{k}
-of @var{idxlist} is shorter than @math{n}, then return the shared
address@hidden(n-k)}-rank cell of @var{array} given by @var{idxlist}.
address@hidden array cell
+
+Mathematically, one can see an array of rank @math{n} (an
address@hidden) as an array of lower rank where the elements are
+themselves arrays (`cells').
+
address@hidden array frame
address@hidden frame rank
+
+We speak of the first @math{n-k} dimensions of the array as the
address@hidden' of the array, while the last @math{k} dimensions are
+the dimensions of the @math{k}-`cells'. For example, a 3-array can be
+seen as a 2-array of vectors (1-arrays) or as a 1-array of matrices
+(2-arrays). In each case, the vectors or matrices are the 1-cells or
+2-cells of the array. This terminology originates in the J language.
+
address@hidden array slice
address@hidden prefix slice
+
+The more vague concept of a `slice' refers to a subset of the array
+where some indices are fixed and others are left free. As a Guile data
+object, a cell is the same as a `prefix slice' (the first @math{n-k}
+indices into the original array are fixed), except that a 0-cell is not
+a shared array of the original array, but a 0-slice (where all the
+indices into the original array are fixed) is.
+
address@hidden enclosed array
+
+Before @w{version 2.0}, Guile had a feature called `enclosed arrays' to
+create special `array of arrays' objects. The functions in this section
+do not need special types; instead, the frame rank is stated in each
+function call, either implicitly or explicitly.
+
address@hidden {Scheme Procedure} array-cell-ref array idx @dots{}
address@hidden {C Function} scm_array_cell_ref (array, idxlist)
+If the length of @var{idxlist} equals the rank @math{n} of @var{array},
+return the element at @code{(idx @dots{})}, just like @code{(array-ref
+array idx @dots{})}. If, however, the length @math{k} of @var{idxlist}
+is smaller than @math{n}, then return the @math{(n-k)}-cell of
address@hidden given by @var{idxlist}, as a shared array.
 
 For example:
 
 @lisp
-(array-from #2((a b) (c d)) 0) @result{} #(a b)
-(array-from #2((a b) (c d)) 1) @result{} #(c d)
-(array-from #2((a b) (c d)) 1 1) @result{} d
-(array-from #2((a b) (c d))) @result{} #2((a b) (c d))
+(array-cell-ref #2((a b) (c d)) 0) @result{} #(a b)
+(array-cell-ref #2((a b) (c d)) 1) @result{} #(c d)
+(array-cell-ref #2((a b) (c d)) 1 1) @result{} d
+(array-cell-ref #2((a b) (c d))) @result{} #2((a b) (c d))
 @end lisp
 
address@hidden(apply array-from array indices)} is equivalent to
address@hidden(apply array-cell-ref array indices)} is equivalent to
 
 @lisp
 (let ((len (length indices)))
@@ -7802,28 +7822,27 @@ For example:
            (drop (array-dimensions a) len))))
 @end lisp
 
-The name `from' comes from the J language.
 @end deffn
 
address@hidden {Scheme Procedure} array-from* array idx @dots{}
address@hidden {C Function} scm_array_from_s (array, idxlist)
-Like @code{(array-from array idx @dots{})}, but return a 0-rank shared
-array if the length of @var{idxlist} matches the rank of
address@hidden This can be useful when using @var{ARRAY} as a place to
-write into.
address@hidden {Scheme Procedure} array-slice array idx @dots{}
address@hidden {C Function} scm_array_slice (array, idxlist)
+Like @code{(array-cell-ref array idx @dots{})}, but return a 0-rank
+shared array into @var{ARRAY} if the length of @var{idxlist} matches the
+rank of @var{array}. This can be useful when using @var{ARRAY} as a
+place to write to.
 
 Compare:
 
 @lisp
-(array-from #2((a b) (c d)) 1 1) @result{} d
-(array-from* #2((a b) (c d)) 1) @result{} #0(d)
+(array-cell-ref #2((a b) (c d)) 1 1) @result{} d
+(array-slice #2((a b) (c d)) 1 1) @result{} #0(d)
 (define a (make-array 'a 2 2))
-(array-fill! (array-from* a 1 1) 'b)
+(array-fill! (array-slice a 1 1) 'b)
 a @result{} #2((a a) (a b)).
-(array-fill! (array-from a 1 1) 'b) @result{} error: not an array
+(array-fill! (array-cell-ref a 1 1) 'b) @result{} error: not an array
 @end lisp
 
address@hidden(apply array-from* array indices)} is equivalent to
address@hidden(apply array-slice array indices)} is equivalent to
 
 @lisp
 (apply make-shared-array a
@@ -7833,12 +7852,12 @@ a @result{} #2((a a) (a b)).
 @end deffn
 
 
address@hidden {Scheme Procedure} array-amend! array x idx @dots{}
address@hidden {C Function} scm_array_amend_x (array, x, idxlist)
address@hidden {Scheme Procedure} array-cell-set! array x idx @dots{}
address@hidden {C Function} scm_array_cell_set_x (array, x, idxlist)
 If the length of @var{idxlist} equals the rank @math{n} of
 @var{array}, set the element at @code{(idx @dots{})} of @var{array} to
 @var{x}, just like @code{(array-set! array x idx @dots{})}. If,
-however, the length @math{k} of @var{idxlist} is shorter than
+however, the length @math{k} of @var{idxlist} is smaller than
 @math{n}, then copy the @math{(n-k)}-rank array @var{x}
 into the @math{(n-k)}-cell of @var{array} given by
 @var{idxlist}. In this case, the last @math{(n-k)} dimensions of
@@ -7849,64 +7868,68 @@ This function returns the modified @var{array}.
 For example:
 
 @lisp
-(array-amend! (make-array 'a 2 2) b 1 1) @result{} #2((a a) (a b))
-(array-amend! (make-array 'a 2 2) #(x y) 1) @result{} #2((a a) (x y))
+(array-cell-set! (make-array 'a 2 2) b 1 1)
+  @result{} #2((a a) (a b))
+(array-cell-set! (make-array 'a 2 2) #(x y) 1)
+  @result{} #2((a a) (x y))
 @end lisp
 
-Note that @code{array-amend!} will expect elements, not arrays, when the
-destination has rank 0. One can work around this using
address@hidden instead.
+Note that @code{array-cell-set!} will expect elements, not arrays, when
+the destination has rank 0. Use @code{array-slice} for the opposite
+behavior.
 
 @lisp
-(array-amend! (make-array 'a 2 2) #0(b) 1 1) @result{} #2((a a) (a #0(b)))
-(let ((a (make-array 'a 2 2))) (array-copy! #0(b) (array-from* a 1 1)) a) 
@result{} #2((a a) (a b))
+(array-cell-set! (make-array 'a 2 2) #0(b) 1 1)
+  @result{} #2((a a) (a #0(b)))
+(let ((a (make-array 'a 2 2)))
+  (array-copy! #0(b) (array-slice a 1 1)) a)
+  @result{} #2((a a) (a b))
 @end lisp
 
address@hidden(apply array-amend! array x indices)} is equivalent to
address@hidden(apply array-cell-set! array x indices)} is equivalent to
 
 @lisp
 (let ((len (length indices)))
   (if (= (array-rank array) len)
     (apply array-set! array x indices)
-    (array-copy! x (apply array-from array indices)))
+    (array-copy! x (apply array-cell-ref array indices)))
   array)
 @end lisp
 
-The name `amend' comes from the J language.
 @end deffn
 
 
address@hidden {Scheme Procedure} array-for-each-cell frame-rank op x @dots{}
address@hidden {C Function} scm_array_for_each_cell (array, frame_rank, op, 
xlist)
address@hidden {Scheme Procedure} array-slice-for-each frame-rank op x @dots{}
address@hidden {C Function} scm_array_slice_for_each (array, frame_rank, op, 
xlist)
 Each @var{x} must be an array of rank ≥ @var{frame-rank}, and
 the first @var{frame-rank} dimensions of each @var{x} must all be the
-same. @var{array-for-each-cell} calls @var{op} with each set of
+same. @var{array-slice-for-each} calls @var{op} with each set of
 (rank(@var{x}) - @var{frame-rank})-cells from @var{x}, in unspecified order.
 
address@hidden allows you to loop over cells of any rank
-without having to carry an index list or construct slices manually. The
-cells passed to @var{op} are shared arrays of @var{X} so it is possible
-to write to them.
address@hidden allows you to loop over cells of any rank
+without having to carry an index list or construct shared arrays
+manually. The slices passed to @var{op} are always shared arrays of
address@hidden, even if they are of rank 0, so it is possible to write to them.
 
 This function returns an unspecified value.
 
 For example, to sort the rows of rank-2 array @code{a}:
 
 @lisp
-(array-for-each-cell 1 (lambda (x) (sort! x <)) a)
+(array-slice-for-each 1 (lambda (x) (sort! x <)) a)
 @end lisp
 
-As another example, let @code{a} be a rank-2 array where each row is a 
2-vector @math{(x,y)}.
-Let's compute the arguments of these vectors and store them in rank-1 array 
@code{b}.
+As another example, let @code{a} be a rank-2 array where each row is a
+2-element vector @math{(x,y)}.  Let's compute the arguments of these
+vectors and store them in rank-1 array @code{b}.
 @lisp
-(array-for-each-cell 1
+(array-slice-for-each 1
   (lambda (a b)
     (array-set! b (atan (array-ref a 1) (array-ref a 0))))
   a b)
 @end lisp
 
address@hidden(apply array-for-each-cell frame-rank op x)} is functionally
-equivalent to
address@hidden(apply array-slice-for-each frame-rank op x)} is equivalent to
 
 @lisp
 (let ((frame (take (array-dimensions (car x)) frank)))
@@ -7916,11 +7939,16 @@ equivalent to
     (error))
   (array-index-map!
     (apply make-shared-array (make-array #t) (const '()) frame)
-    (lambda i (apply op (map (lambda (x) (apply array-from* x i)) x)))))
+    (lambda i (apply op (map (lambda (x) (apply array-slice x i)) x)))))
 @end lisp
 
 @end deffn
 
address@hidden {Scheme Procedure} array-slice-for-each-in-order frame-rank op x 
@dots{}
address@hidden {C Function} scm_array_slice_for_each_in_order (array, 
frame_rank, op, xlist)
+Same as @code{array-slice-for-each}, but the arguments are traversed
+sequentially and in row-major order.
address@hidden deffn
 
 @node Accessing Arrays from C
 @subsubsection Accessing Arrays from C
diff --git a/libguile/array-map.c b/libguile/array-map.c
index 19e85c3..c2825bc 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -655,7 +655,7 @@ scm_i_array_rebase (SCM a, size_t base)
 
 static inline size_t padtoptr(size_t d) { return (d + (sizeof (void *) - 1)) & 
~(sizeof (void *) - 1); }
 
-SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
+SCM_DEFINE (scm_array_slice_for_each, "array-slice-for-each", 2, 0, 1,
             (SCM frame_rank, SCM op, SCM args),
             "Apply @var{op} to each of the cells of rank 
rank(@var{arg})address@hidden"
             "of the arrays @var{args}, in unspecified order. The first\n"
@@ -665,17 +665,17 @@ SCM_DEFINE (scm_array_for_each_cell, 
"array-for-each-cell", 2, 0, 1,
             "For example:\n"
             "@lisp\n"
             ";; Sort the rows of rank-2 array A.\n\n"
-            "(array-for-each-cell 1 (lambda (x) (sort! x <)) a)\n"
+            "(array-slice-for-each 1 (lambda (x) (sort! x <)) a)\n"
             "\n"
             ";; Compute the arguments of the (x y) vectors in the rows of 
rank-2\n"
             ";; array XYS and store them in rank-1 array ANGLES. Inside OP,\n"
             ";; XY is a rank-1 (2-1) array, and ANGLE is a rank-0 (1-1) 
array.\n\n"
-            "(array-for-each-cell 1 \n"
+            "(array-slice-for-each 1 \n"
             "  (lambda (xy angle)\n"
             "    (array-set! angle (atan (array-ref xy 1) (array-ref xy 
0))))\n"
             "  xys angles)\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_for_each_cell
+#define FUNC_NAME s_scm_array_slice_for_each
 {
   int const N = scm_ilength (args);
   int const frank = scm_to_int (frame_rank);
@@ -787,7 +787,7 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 
2, 0, 1,
     {
       for (n=0; n!=N; ++n)
         scm_array_handle_release(ah+n);
-      scm_misc_error("array-for-each-cell", msg, scm_cons_star(frame_rank, 
args));
+      scm_misc_error("array-slice-for-each", msg, scm_cons_star(frame_rank, 
args));
     }
   /* prepare moving cells. */
   for (n=0; n!=N; ++n)
@@ -884,13 +884,13 @@ SCM_DEFINE (scm_array_for_each_cell, 
"array-for-each-cell", 2, 0, 1,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_array_for_each_cell_in_order, "array-for-each-cell-in-order", 
2, 0, 1,
+SCM_DEFINE (scm_array_slice_for_each_in_order, 
"array-slice-for-each-in-order", 2, 0, 1,
             (SCM frank, SCM op, SCM a),
-            "Same as array-for-each-cell, but visit the cells sequentially\n"
+            "Same as array-slice-for-each, but visit the cells sequentially\n"
             "and in row-major order.\n")
-#define FUNC_NAME s_scm_array_for_each_cell_in_order
+#define FUNC_NAME s_scm_array_slice_for_each_in_order
 {
-  return scm_array_for_each_cell (frank, op, a);
+  return scm_array_slice_for_each (frank, op, a);
 }
 #undef FUNC_NAME
 
diff --git a/libguile/array-map.h b/libguile/array-map.h
index acfdd5e..12351d1 100644
--- a/libguile/array-map.h
+++ b/libguile/array-map.h
@@ -37,8 +37,8 @@ SCM_API SCM scm_array_map_x (SCM ra0, SCM proc, SCM lra);
 SCM_API SCM scm_array_for_each (SCM proc, SCM ra0, SCM lra);
 SCM_API SCM scm_array_index_map_x (SCM ra, SCM proc);
 SCM_API SCM scm_array_equal_p (SCM ra0, SCM ra1);
-SCM_API SCM scm_array_for_each_cell (SCM frank, SCM op, SCM args);
-SCM_API SCM scm_array_for_each_cell_in_order (SCM frank, SCM op, SCM args);
+SCM_API SCM scm_array_slice_for_each (SCM frank, SCM op, SCM args);
+SCM_API SCM scm_array_slice_for_each_in_order (SCM frank, SCM op, SCM args);
 
 SCM_INTERNAL SCM scm_i_array_rebase (SCM a, size_t base);
 SCM_INTERNAL void scm_init_array_map (void);
diff --git a/libguile/arrays.c b/libguile/arrays.c
index b17c415..8b8bc48 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -468,19 +468,19 @@ array_from_get_o (scm_t_array_handle *handle, size_t k, 
scm_t_array_dim *s, ssiz
     }
 }
 
-SCM_DEFINE (scm_array_from_s, "array-from*", 1, 0, 1,
+SCM_DEFINE (scm_array_slice, "array-slice", 1, 0, 1,
            (SCM ra, SCM indices),
             "Return the array slice @address@hidden ..., ...]\n"
             "The rank of @var{ra} must equal to the number of indices or 
larger.\n\n"
-            "See also @code{array-ref}, @code{array-from}, 
@code{array-amend!}.\n\n"
-            "@code{array-from*} may return a rank-0 array. For example:\n"
+            "See also @code{array-ref}, @code{array-cell-ref}, 
@code{array-cell-set!}.\n\n"
+            "@code{array-slice} may return a rank-0 array. For example:\n"
             "@lisp\n"
-            "(array-from* #2((1 2 3) (4 5 6)) 1 1) @result{} #0(5)\n"
-            "(array-from* #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
-            "(array-from* #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
-            "(array-from* #0(5) @result{} #0(5).\n"
+            "(array-slice #2((1 2 3) (4 5 6)) 1 1) @result{} #0(5)\n"
+            "(array-slice #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
+            "(array-slice #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
+            "(array-slice #0(5) @result{} #0(5).\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_from_s
+#define FUNC_NAME s_scm_array_slice
 {
   SCM o, i = indices;
   size_t ndim, k;
@@ -506,20 +506,20 @@ SCM_DEFINE (scm_array_from_s, "array-from*", 1, 0, 1,
 #undef FUNC_NAME
 
 
-SCM_DEFINE (scm_array_from, "array-from", 1, 0, 1,
+SCM_DEFINE (scm_array_cell_ref, "array-cell-ref", 1, 0, 1,
            (SCM ra, SCM indices),
             "Return the element at the @code{(@var{indices} ...)} position\n"
             "in array @var{ra}, or the array slice @address@hidden ..., ...]\n"
             "if the rank of @var{ra} is larger than the number of indices.\n\n"
-            "See also @code{array-ref}, @code{array-from*}, 
@code{array-amend!}.\n\n"
-            "@code{array-from} never returns a rank 0 array. For example:\n"
+            "See also @code{array-ref}, @code{array-slice}, 
@code{array-cell-set!}.\n\n"
+            "@code{array-cell-ref} never returns a rank 0 array. For 
example:\n"
             "@lisp\n"
-            "(array-from #2((1 2 3) (4 5 6)) 1 1) @result{} 5\n"
-            "(array-from #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
-            "(array-from #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 6))\n"
-            "(array-from #0(5) @result{} 5.\n"
+            "(array-cell-ref #2((1 2 3) (4 5 6)) 1 1) @result{} 5\n"
+            "(array-cell-ref #2((1 2 3) (4 5 6)) 1) @result{} #(4 5 6)\n"
+            "(array-cell-ref #2((1 2 3) (4 5 6))) @result{} #2((1 2 3) (4 5 
6))\n"
+            "(array-cell-ref #0(5) @result{} 5.\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_from
+#define FUNC_NAME s_scm_array_cell_ref
 {
   SCM o, i = indices;
   size_t ndim, k;
@@ -548,25 +548,25 @@ SCM_DEFINE (scm_array_from, "array-from", 1, 0, 1,
 #undef FUNC_NAME
 
 
-SCM_DEFINE (scm_array_amend_x, "array-amend!", 2, 0, 1,
+SCM_DEFINE (scm_array_cell_set_x, "array-cell-set!", 2, 0, 1,
             (SCM ra, SCM b, SCM indices),
             "Set the array slice @address@hidden ..., ...] to @var{b}\n."
-            "Equivalent to @code{(array-copy! @var{b} (apply array-from 
@var{ra} @var{indices}))}\n"
+            "Equivalent to @code{(array-copy! @var{b} (apply array-cell-ref 
@var{ra} @var{indices}))}\n"
             "if the number of indices is smaller than the rank of @var{ra}; 
otherwise\n"
             "equivalent to @code{(apply array-set! @var{ra} @var{b} 
@var{indices})}.\n"
             "This function returns the modified array @var{ra}.\n\n"
-            "See also @code{array-ref}, @code{array-from}, 
@code{array-from*}.\n\n"
+            "See also @code{array-ref}, @code{array-cell-ref}, 
@code{array-slice}.\n\n"
             "For example:\n"
             "@lisp\n"
             "(define A (list->array 2 '((1 2 3) (4 5 6))))\n"
-            "(array-amend! A #0(99) 1 1) @result{} #2((1 2 3) (4 #0(99) 6))\n"
-            "(array-amend! A 99 1 1) @result{} #2((1 2 3) (4 99 6))\n"
-            "(array-amend! A #(a b c) 0) @result{} #2((a b c) (4 99 6))\n"
-            "(array-amend! A #2((x y z) (9 8 7))) @result{} #2((x y z) (9 8 
7))\n\n"
+            "(array-cell-set! A #0(99) 1 1) @result{} #2((1 2 3) (4 #0(99) 
6))\n"
+            "(array-cell-set! A 99 1 1) @result{} #2((1 2 3) (4 99 6))\n"
+            "(array-cell-set! A #(a b c) 0) @result{} #2((a b c) (4 99 6))\n"
+            "(array-cell-set! A #2((x y z) (9 8 7))) @result{} #2((x y z) (9 8 
7))\n\n"
             "(define B (make-array 0))\n"
-            "(array-amend! B 15) @result{} #0(15)\n"
+            "(array-cell-set! B 15) @result{} #0(15)\n"
             "@end lisp")
-#define FUNC_NAME s_scm_array_amend_x
+#define FUNC_NAME s_scm_array_cell_set_x
 {
   SCM o, i = indices;
   size_t ndim, k;
diff --git a/libguile/arrays.h b/libguile/arrays.h
index 37eea69..b56abef 100644
--- a/libguile/arrays.h
+++ b/libguile/arrays.h
@@ -49,9 +49,9 @@ SCM_API SCM scm_shared_array_increments (SCM ra);
 SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims);
 SCM_API SCM scm_transpose_array (SCM ra, SCM args);
 SCM_API SCM scm_array_contents (SCM ra, SCM strict);
-SCM_API SCM scm_array_from_s (SCM ra, SCM indices);
-SCM_API SCM scm_array_from (SCM ra, SCM indices);
-SCM_API SCM scm_array_amend_x (SCM ra, SCM b, SCM indices);
+SCM_API SCM scm_array_slice (SCM ra, SCM indices);
+SCM_API SCM scm_array_cell_ref (SCM ra, SCM indices);
+SCM_API SCM scm_array_cell_set_x (SCM ra, SCM b, SCM indices);
 
 SCM_API SCM scm_list_to_array (SCM ndim, SCM lst);
 SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst);
diff --git a/test-suite/tests/array-map.test b/test-suite/tests/array-map.test
index 3095b78..3471841 100644
--- a/test-suite/tests/array-map.test
+++ b/test-suite/tests/array-map.test
@@ -509,29 +509,29 @@
         (array-for-each (lambda (b c) (set! a (cons* b c a))) b c)))))
 
 ;;;
-;;; array-for-each-cell
+;;; array-slice-for-each
 ;;;
 
-(with-test-prefix "array-for-each-cell"
+(with-test-prefix "array-slice-for-each"
 
   (pass-if-equal "1 argument frame rank 1"
       #2((1 3 9) (2 7 8))
       (let* ((a (list->array 2 '((9 1 3) (7 8 2)))))
-        (array-for-each-cell 1 (lambda (a) (sort! a <)) a)
+        (array-slice-for-each 1 (lambda (a) (sort! a <)) a)
         a))
 
   (pass-if-equal "2 arguments frame rank 1"
       #f64(8 -1)
       (let* ((x (list->typed-array 'f64 2 '((9 1) (7 8))))
              (y (f64vector 99 99)))
-        (array-for-each-cell 1 (lambda (y x) (array-set! y (- (array-ref x 0) 
(array-ref x 1)))) y x)
+        (array-slice-for-each 1 (lambda (y x) (array-set! y (- (array-ref x 0) 
(array-ref x 1)))) y x)
         y))
 
   (pass-if-equal "regression: zero-sized frame loop without unrolling"
       99
     (let* ((x 99)
            (o (make-array 0. 0 3 2)))
-      (array-for-each-cell 2
+      (array-slice-for-each 2
         (lambda (o a0 a1)
           (set! x 0))
         o
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
index 4c943dd..1df77b1 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -298,110 +298,110 @@
 
 
 ;;;
-;;; array-from*
+;;; array-slice
 ;;;
 
-(with-test-prefix/c&e "array-from*"
+(with-test-prefix/c&e "array-slice"
 
   (pass-if "vector I"
     (let ((v (vector 1 2 3)))
-      (array-fill! (array-from* v 1) 'a)
+      (array-fill! (array-slice v 1) 'a)
       (array-equal? v #(1 a 3))))
 
   (pass-if "vector II"
     (let ((v (vector 1 2 3)))
-      (array-copy! #(a b c) (array-from* v))
+      (array-copy! #(a b c) (array-slice v))
       (array-equal? v #(a b c))))
 
   (pass-if "array I"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-fill! (array-from* a 1 1) 'a)
+      (array-fill! (array-slice a 1 1) 'a)
       (array-equal? a #2((1 2 3) (4 a 6)))))
 
   (pass-if "array II"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #(a b c) (array-from* a 1))
+      (array-copy! #(a b c) (array-slice a 1))
       (array-equal? a #2((1 2 3) (a b c)))))
 
   (pass-if "array III"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #2((a b c) (x y z)) (array-from* a))
+      (array-copy! #2((a b c) (x y z)) (array-slice a))
       (array-equal? a #2((a b c) (x y z)))))
 
   (pass-if "rank 0 array"
     (let ((a (make-array 77)))
-      (array-fill! (array-from* a) 'a)
+      (array-fill! (array-slice a) 'a)
       (array-equal? a #0(a)))))
 
 
 ;;;
-;;; array-from
+;;; array-cell-ref
 ;;;
 
-(with-test-prefix/c&e "array-from"
+(with-test-prefix/c&e "array-cell-ref"
 
   (pass-if "vector I"
     (let ((v (vector 1 2 3)))
-      (equal? 2 (array-from v 1))))
+      (equal? 2 (array-cell-ref v 1))))
 
   (pass-if "vector II"
     (let ((v (vector 1 2 3)))
-      (array-copy! #(a b c) (array-from v))
+      (array-copy! #(a b c) (array-cell-ref v))
       (array-equal? v #(a b c))))
 
   (pass-if "array I"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (equal? 5 (array-from a 1 1))))
+      (equal? 5 (array-cell-ref a 1 1))))
 
   (pass-if "array II"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #(a b c) (array-from a 1))
+      (array-copy! #(a b c) (array-cell-ref a 1))
       (array-equal? a #2((1 2 3) (a b c)))))
 
   (pass-if "array III"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (array-copy! #2((a b c) (x y z)) (array-from a))
+      (array-copy! #2((a b c) (x y z)) (array-cell-ref a))
       (array-equal? a #2((a b c) (x y z)))))
 
   (pass-if "rank 0 array"
     (let ((a (make-array 77)))
-      (equal? (array-from a) 77))))
+      (equal? (array-cell-ref a) 77))))
 
 
 ;;;
-;;; array-amend!
+;;; array-cell-set!
 ;;;
 
-(with-test-prefix/c&e "array-amend!"
+(with-test-prefix/c&e "array-cell-set!"
 
   (pass-if "vector I"
     (let ((v (vector 1 2 3)))
-      (and (eq? v (array-amend! v 'x 1))
+      (and (eq? v (array-cell-set! v 'x 1))
            (array-equal? v #(1 x 3)))))
 
   (pass-if "vector II"
     (let ((v (vector 1 2 3)))
-      (and (eq? v (array-amend! (array-from v) #(a b c)))
+      (and (eq? v (array-cell-set! (array-cell-ref v) #(a b c)))
            (array-equal? v #(a b c)))))
 
   (pass-if "array I"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (and (eq? a (array-amend! a 'x 1 1))
+      (and (eq? a (array-cell-set! a 'x 1 1))
            (array-equal? a #2((1 2 3) (4 x 6))))))
 
   (pass-if "array II"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (and (eq? a (array-amend! a #(a b c) 1))
+      (and (eq? a (array-cell-set! a #(a b c) 1))
            (array-equal? a #2((1 2 3) (a b c))))))
 
   (pass-if "array III"
     (let ((a (list->array 2 '((1 2 3) (4 5 6)))))
-      (and (eq? a (array-amend! a #2((a b c) (x y z))))
+      (and (eq? a (array-cell-set! a #2((a b c) (x y z))))
            (array-equal? a #2((a b c) (x y z))))))
 
   (pass-if "rank 0 array"
     (let ((a (make-array 77)))
-      (and (eq? a (array-amend! a 99))
+      (and (eq? a (array-cell-set! a 99))
            (array-equal? a #0(99))))))
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]