1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

13 commits

Author SHA1 Message Date
Daniel Llorens
ab1ca17986 Remove double indirection in array-fill!
* 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>
2013-04-05 22:54:14 +02:00
Daniel Llorens
b5159a471a Tests for array-copy!
* test-suite/tests/arrays.test: tests for arguments of rank 0, 1 and 2.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05 22:54:14 +02:00
Andy Wingo
118ff892be deprecate generalized vectors in favor of arrays
* libguile/generalized-arrays.h:
* libguile/generalized-arrays.c (scm_c_array_length):
  (scm_array_length): New functions.

* module/ice-9/deprecated.scm:
* libguile/generalized-vectors.c:
* libguile/generalized-vectors.h:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_generalized_vector_p)
  (scm_generalized_vector_length, scm_generalized_vector_ref)
  (scm_generalized_vector_set_x, scm_generalized_vector_to_list):
  Deprecate.

* libguile/uniform.c (scm_uniform_vector_to_list): Use
  scm_array_to_list.

* module/ice-9/boot-9.scm (case): Arrays are generalized vectors.

* module/srfi/srfi-4/gnu.scm (define-any->vector): Use the array
  functions instead of the generalized-vector functions.

* test-suite/tests/arrays.test: Remove generalized-vector->list test;
  covered by array->list test.

* test-suite/tests/bitvectors.test:
* test-suite/tests/bytevectors.test:
* test-suite/tests/srfi-4.test: Adapt to test using array interfaces
  instead of generalized-vector interfaces.

* doc/ref/api-compound.texi: Remove generalized vector docs.
* doc/ref/api-data.texi:
* doc/ref/srfi-modules.texi: Adapt.
2013-02-18 16:57:15 +01:00
Andy Wingo
336c921146 optimize access to arrays of rank 1 or 2
* 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.
2013-02-18 16:38:24 +01:00
Ludovic Courtès
1d4e6ee301 Fix `generalized-vector->list' indexing bug with shared arrays.
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.
2012-11-03 00:20:57 +01:00
Ludovic Courtès
80aeb9af0d test-suite: Add a nameless form of `pass-if-equal'.
* test-suite/test-suite/lib.scm (pass-if-equal): Add a nameless pattern.
* test-suite/tests/arrays.test ("array->list"): Use `pass-if-equal'.
2012-11-02 23:43:45 +01:00
Andy Wingo
2b414e247f fix generalized-vector-{ref,set!} for slices
* 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.
2011-12-22 17:03:04 -05:00
Andy Wingo
e48a2f8705 add docs and tests for array->list
* libguile/generalized-arrays.c (scm_array_to_list): Add docs.
* test-suite/tests/arrays.test ("array->list"): Add tests.
2010-04-07 21:04:37 +02:00
Andy Wingo
a587d6a973 more fixes to equal? for arrays
* 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.
2010-04-01 00:25:06 +02:00
Andy Wingo
e275b8a220 rename unif.test to arrays.test
* test-suite/tests/arrays.test: Move all unif.test here. Unif.test was
  mostly testing arrays anyway. Incorporate the existing arrays.test.

* test-suite/tests/unif.test: Deleted.
* test-suite/Makefile.am: Update.
2010-03-31 21:17:05 +02:00
Andy Wingo
3ffd1ba96e fix equal? between an array and a non-array
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.
2010-03-31 00:05:01 +02:00
Andy Wingo
d26383f427 Revert "fix equal? between an array and a non-array"
This reverts commit 9d031d4d57.
2010-03-30 23:51:40 +02:00
Andy Wingo
9d031d4d57 fix equal? between an array and a non-array
* 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.
2010-03-30 21:23:06 +02:00