* libguile/bitvectors.c: match other uses of SCM_ARRAY_IMPLEMENTATION.
* libguile/generalized-arrays.c
(scm_is_array): don't use scm_i_array_implementation_for_obj on arrays.
(scm_is_typed_array): idem. Use impl->get_handle instead of
scm_array_get_handle to avoid calling scm_i_array_implementation_for_obj
twice.
* libguile/arrays.c: remove SCM_ARRAY_IMPLEMENTATION on scm_tc7_array type.
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.
* libguile/array-map.c
- (scm_array_index_map_x): preallocate the index list instead of
constructing it on each rank-1 iteration.
- (ramap, rafe): use SCM_I_ARRAY_V just once.
* libguile/arrays.c
- scm_shared_array_root: check for SCM_I_ARRAYP first.
- scm_i_shap2ra:
* check valid bounds in the '(lbnd ubnd) case. This makes
(make-array 0 '(4 -3)) fail with a 'bad dimension' instead of
with a 'wrong index' error.
* use ssize_t for lbnd/ubnd/inc, not long.
- scm_make_shared_array: use ssize_t for indices, not long.
- scm_transpose_array: use size_t for ndim, not ulong.
- scm_i_print_array: idem.
* libguile/vectors.c: bounds are already checked unless impl is called
directly, so don't check again.
* libguile/strings.c, libguile/bitvectors.c: fix comments.
* libguile/array-map.c: (scm_ramapc)
- Don't check emptiness while preparing ra0, but only after kroll is known,
and only before kroll. len = 0 will be caught by the unrolled loop.
- Use ra0 axis length in unroll check depth for rest args, not ra1's.
- Recover early exit feature when cproc returns 0.
* libguile/array-map.c: (scm_ramapc): Cannot flag empty on the product
inc * dim * dim ... Check every dim.
* test-suite/tests/ramap.test: Tests the 0-inc, non empty case for both
array-map! and array-copy!.
* libguile/array-map.c
- (scm_ramapc): mismatched axes limit unrollk (kroll). Reorganize
the function to do all checking as we go.
- (scm_ra_matchp): unused; remove.
- (find_unrollk): inlined in scm_ramapc; remove.
- (klen): inlined in scm_ramapc; remove.
- (rafill): n is size_t.
- (racp): n is size_t. Use n and not i0end to bound the loop.
- (ramap): Use n and not i0end to bound the loop. This is needed for the rank
0 case to work with the new scm_ramapc, as inc may be set to 0 in that case.
- (rafe): idem.
* test-suite/tests/ramap.test
- check that size mismatch prevents unrolling (matching behavior III) with
both array-copy! and array-map!.
- check that non-contiguous stride in non-ref args prevents unrolling
(rank 2, discontinuous) with both array-copy! and array-map!.
- check rank 0 cases with array-for-each, array-map!.
* libguile/array-map.c
- (cind): replace by cindk, that operates only on the unrolled index set.
- (klen): new function.
- (make1array): take extra inc argument.
- (scm_ramapc): rewrite to unroll as many axes as possible instead of just all
or one.
- (AREF): lbnd is known to be 0: remove.
- (ASET): v is known to come from SCM_I_ARRAY_V; assume base, inc, lbnd.
- (racp): use ssize_t instead of long for the indices.
- (scm_array_index_map_x): build the index list at the last-but-one axis, then
set the car of the last element, instead of building the list at the last axis.
* test-suite/tests/ramap.test
- add array-map! test with offset arguments.
* 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 special case improves
(define a (make-array 1. 1000000 10))
(define b (make-array *unspecified* 1000000 10))
(define c (transpose-array (make-array *unspecified* 10 1000000) 1 0))
,time (array-copy! a b)
,time (array-copy! a c)
from 0.041598s / 0.072561 to 0.012164s / 0.041886s on a i7-3930K.
* libguile/array-map.c: (racp): if both src and dst are on vectors, use
the element pointers to do the copy.
* libguile/array-map.c
- scm_ra_matchp: look for empty axes and return new case 5 if so. Use
array handles to remove the SCM_I_ARRAYP / not branch.
- scm_ramapc: Heed case 5.
* test-suite/tests/ramap.test
- test empty arguments for array-copy! and array-for-each. Note those
that failed in 2.0.9.
* libguile/array-map.c: (scm_array_index_map_x): bail out if any one of the
axes is empty.
* test-suite/tests/ramap.test: add tests for empty array-case of
array-index-map!. The 'f64 case with not-last emtpy axis is broken in 2.0.9.
* libguile/bytevectors.c: (bv_handle_set_x, bv_handle_ref): get length
and element type fields from the bytevector, not from the handle.
* libguile/vectors.c: (vector_handle_set, vector_handle_ref): get length
from the vector, not from the handle.
* libguile/array-handle.c
- scm_array_get_handle: if the object is an array, point impl to
the underlying vector instead of array impl, then fix the axes. Avoid
calling scm_i_array_implementation_for_obj twice.
* libguile/arrays.c
- array_handle_ref, array_handle_set, array_get_handle: remove.
* libguile/bitvectors.c, libguile/bytevectors.c, libguile/strings.c,
libguile/vectors.c: fix base = 0 in the array handle.
* libguile/vectors.c: (vector_handle_set, vector_handle_ref): do not
use h->dims.
* libguile/vectors.c
- (scm_vector_writable_elements): allow any non-uniform rank 1 array,
after the doc. Match the implementation with scm_uniform_vector_elements.
- (scm_vector_elements): after the above.
* libguile/uniform.c
- (scm_uniform_vector_writable_elements): ditto for uniform rank 1 arrays.
* libguile/sort.c
- revert the changes in 7a6fd9, except for the argument type test; allow
what scm_vector_(writable_)elements allows.
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.
* libguile/array-map.c
- rafill, ramap, rafe, racp: object from SCM_I_ARRAY_V always
has base 0, lbnd 0 and inc 1; make use of this.
* libguile/arrays.c
- array_handle_ref, array_handle_set: idem.
- array_get_handle: sanity check.
* libguile/generalized-vectors.c
- scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x:
pos should be base when idx is lbnd. Furthermore, pos should be signed and
have its overflow checked; do this by handling the job to
scm_c_array_ref_1, scm_c_array_set_1_x.
* libguile/generalized-vectors.h
- fix prototypes.
* 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.
* array-map.c: (AREF, ASET): new internal functions replace
scm_c_generalized_vector_ref/set. These remove a redundant check for
rank in the generalized_vector set.