This fixes a compiler issue where (uniform-array->bytevector #2f64())
failed because of the stricter definition of uniform-vector? on this branch.
Perhaps it would be better if uniform-array->bytevector didn't require
a contiguous argument.
* libguile/arrays.c: (scm_array_contents): return the root regardless of
the value of SCM_I_ARRAY_DIMS (ra)->inc.
* test-suite/tests/arrays.test: check.
* module/language/glil/compile-assembly.scm: pass (array-contents x)
to uniform-array->bytevector instead of x, when x is a typed array.
* test-suite/tests/arrays.test: test an instance of the above that
failed in Guile 2.0.9.
* test-suite/tests/arrays.test: move array-copy! tests to ramap.test.
* test-suite/tests/ramap.test: check the dissimilar matching behavior of
array-copy! and array-map! with arguments of different size.
* compile-assembly.scm
- vector-fold2: handle rank 1 arrays, since this is called with
the result of array-contents which need not be a vector.
- dump-constants: fix uses of vector-fold2. Replace vector-length
on result of array-contents by array-length.
* libguile/arrays.c
- scm_array_contents: branch cases not on scm_is_generalized_vector but
on SCM_I_ARRAYP. Thus lbnd!=0, which could happen with
scm_is_generalized_vector, never appears in the output.
* test-suite/tests/arrays.test
- tests for array-contents.
This patch fixes the bug (vector-ref #1@1(1 2 3) 1) => 2.
* libguile/vectors.c: (scm_is_vector): just as scm_is_simple_vector.
* libguile/filesys.c, libguile/random.c, libguile/stime.c, libguile/trees.c,
libguile/validate.h: use scm_is_vector instead of scm_is_simple_vector.
* libguile/sort.c
- scm_restricted_vector_sort_x: use scm_array_handle_writable_elements
instead of scm_vector_writable_elements, to work with non-vector
rank-1 array objects.
- scm_sort_x: check for scm_is_array instead of scm_is_vector. Rank
check is in restricted_vector_sort_x.
- scm_sort: ditto.
- scm_stable_sort_x: like scm_restricted_vector_sort_x.
- scm_stable_sort: like scm_sort.
* test-suite/tests/arrays.test: fix header.
* test-suite/tests/random.test: new coverage test covering
random:normal-vector!
* test-suite/Makefile.am: include random.test in make check.
This fixes an inconsistency where uniform-vector? of a shared array could
be true but -ref operations failed to account correctly for lbnd.
* libguile/uniform.c
- scm_is_uniform_vector: SCM_I_ARRAYP disqualifies obj as uniform vector.
- scm_c_uniform_vector_length: lbnd is known 0, so don't use it.
- scm_c_uniform_vector_ref: lbnd/base/inc are known to be 0/0/1.
- scm_c_uniform_vector_set_x!: idem.
- scm_uniform_vector_writable_elements: check uvec's type.
* test-suite/tests/arrays.test
- group the exception types at the top.
- check that uniform-vector functions do not accept general arrays.
* test-suite/tests/arrays.test: dependence reordering: first sanity, then
make-array, then array-equal?, then make-shared-array, shared-array-root,
then the rest, many of which use make-shared-array.
* libguile/arrays.c (scm_transpose_array)
- Use scm_c_array_rank(), which contains an implicit is_array test.
- Handle the rank 0 case.
* test-suite/tests/arrays.test
- Add test for rank 0 case.
- Add failure test for non array argument.
* libguile/array-map.c: new function rafill, like scm_array_fill_int,
but factors GVSET out of the loop. Use it in scm_array_fill_x instead of
scm_array_fill_int.
* test-suite/tests/arrays.test: add test for array-fill! with stride != 1.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* libguile/array-handle.c (scm_array_handle_pos_1):
(scm_array_handle_pos_2): New functions.
* libguile/generalized-arrays.c (scm_c_array_ref_1, scm_c_array_ref_2):
(scm_c_array_set_1_x, scm_c_array_set_2_x): New functions.
(scm_i_array_ref, scm_i_array_set_x): New subr bindings for array-ref
and array-set! that avoid consing for arrays of rank 1 or 2.
* test-suite/tests/arrays.test ("array-set!"): Fix expected exception
for wrong number of indices.
Fixes <http://bugs.gnu.org/12465>.
Reported by Daniel Llorens <daniel.llorens@bluewin.ch>.
* libguile/generalized-vectors.c (scm_generalized_vector_to_list): Fix
initial value of POS; pass the `h.base + pos', not just `pos' as the
`vref' argument.
* test-suite/tests/arrays.test ("array->list")["http://bugs.gnu.org/12465
- ok", "http://bugs.gnu.org/12465 - bad]: New tests.
("generalized-vector->list"): New test prefix.
* libguile/generalized-vectors.c (scm_c_generalized_vector_ref):
(scm_c_generalized_vector_set_x): Fix for the case in which base was
not 1, lbnd was not 0, or inc was not 1.
* test-suite/tests/arrays.test (array): Add a test. Thanks to Daniel
Llorens for the report.
* libguile/array-map.c (array_compare, scm_array_equal_p): Rewrite as
something that operates on the generic array handle infrastructure.
Based on array->list.
(scm_i_array_equal_p): Change the docs, as array-equal? is now the same
as equal?, except that it typechecks its args.
* doc/ref/api-compound.texi (Array Procedures): Update array-equal?
docs.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_raequal): Deprecate.
* libguile/bytevectors.c (scm_bytevector_eq_p): Bugfix: bytevectors are
bytevector=? only if their element type is the same.
* libguile/eq.c (scm_equal_p): Only dispatch to scm_array_equal_p if
both args are arrays (generically).
* test-suite/tests/arrays.test ("equal?"): Add some more tests.
OK let's try again. While the thanks go to Daniel Llorens del Río for
the tip, the blame continues going to me :)
* test-suite/Makefile.am:
* test-suite/tests/arrays.test: Add a test.
* libguile/array-map.c (raeql): Handle a few 0-dimensional cases. If the
shapes of the arrays don't match, just return #f instead of raising
an error.
* libguile/eq.c (scm_equal_p): Only call scm_array_equal_p if both
arguments are generalized arrays; otherwise they are not equal. Thanks
to Daniel Llorens del Río for the tip.
* test-suite/Makefile.am:
* test-suite/tests/arrays.test: Add a test.