summaryrefslogtreecommitdiff
path: root/libguile/array-map.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-27Preallocate index list in scm_array_index_map_xDaniel Llorens1-17/+17
* 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.
2014-01-27Rename scm_t_array_handle.array to .rootDaniel Llorens1-4/+4
Globally rename this field (after shared-array-root), since it's not an array.
2014-01-27Don't use ASET in scm_array_index_map_xDaniel Llorens1-5/+5
* libguile/array-map.c: (scm_array_index_map_x): replace ASET by direct use of handle->impl.
2014-01-27In scm_ramapc, only check unrolled axes for emptinessDaniel Llorens1-69/+50
* 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.
2014-01-27Fix scm_ramapc bugs with 0-inc arraysDaniel Llorens1-4/+5
* 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!.
2014-01-27Fix corner cases of scm_ramapcDaniel Llorens1-206/+151
* 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!.
2014-01-27Rewrite scm_ramapc()Daniel Llorens1-128/+129
* 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.
2014-01-27Simplify ASET in array-map.cDaniel Llorens1-1/+1
* libguile/array-map.c: (ASET): this is only ever used with a true vector type, so remove use of inc/base/lbnd.
2014-01-27Inline ASET in array-index-map! for rank 1 argumentsDaniel Llorens1-8/+14
* libguile/array-map.c: (scm_array_index_map_x): branch to special case on rank 1, instead of !SCM_I_ARRAYP (ra). Inline ASET in this case.
2014-01-27Factor out make1array() in scm_ramapc()Daniel Llorens1-96/+93
* libguile/array-map.c: (scm_ramapc): factor out vector->array conversion to aux function make1array.
2014-01-27Raw pointer loop in array-copy! for vector/vector caseDaniel Llorens1-5/+16
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.
2014-01-27Have array impl->vref, vset take SCM, not handlesDaniel Llorens1-9/+9
* libguile/array-handle.h - scm_i_t_array_ref, scm_i_t_array_set take SCM. - scm_array_handle_ref, scm_array_handle_set: pass h->array. * libguile/array-map.c - AREF, ASET, rafill, racp, ramap, rafe: pass storage vector SCM instead of handle. * libguile/bitvector.c - bitvector_handle_ref, bitvector_handle_set_x: take bitvector arg. * libguile/bytevectors.c - bv_handle_ref, bv_handle_set_x: take bytevector arg. - scm_i_print_bytevectors: don't use array handles. * libguile/deprecated.c - scm_generalized_vector_to_list: pass h.array. * libguile/strings.c - string_handle_ref, string_handle_set: take string arg. * libguile/uniform.c - scm_c_uniform_vector_ref, scm_c_uniform_vector_set_x: pass h.array. * libguile/vectors.c - vector_handle_ref, vector_handle_set: take vector arg.
2014-01-27Fix array map functions with empty argumentsDaniel Llorens1-77/+50
* 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.
2014-01-27Fix empty array bug in array-index-map!Daniel Llorens1-8/+15
* 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.
2014-01-27Replace SCM_IMP in array-map.cDaniel Llorens1-1/+2
* libguile/array-map.c - scm_ramapc: check scm_array_contents with scm_is_false.
2014-01-27Fix rank-1 indirection in array-map.cDaniel Llorens1-2/+2
* array-map.c: (AREF, ASET): fix buggy indirection carried over from old generalized_vector-ref/set!.
2014-01-27Fix bad uses of base and lbnd on rank 1 arraysDaniel Llorens1-14/+13
* 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.
2014-01-27Don't use generalized-vector in array-map.c (II)Daniel Llorens1-25/+24
* libguile/array-map.c - replace scm_is_generalized_vector by scm_is_array && !SCM_I_ARRAY_P. - replace scm_c_generalized_vector_length by scm_c_array_length. - remove header.
2014-01-27Don't use generalized-vector in array-map.c (I)Daniel Llorens1-21/+37
* 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.
2013-04-14Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-78/+118
Conflicts: GUILE-VERSION libguile/array-map.c libguile/fports.h libguile/gc.h libguile/inline.h libguile/ports.c libguile/ports.h libguile/print.c libguile/r6rs-ports.c libguile/read.c test-suite/tests/00-socket.test
2013-04-07Don't use scm_generalized_vector_get_handle() in array-map.cDaniel Llorens1-6/+6
* libguile/array-map.c: (rafill, racp, ramap, rafe): use scm_array_get_handle() instead of scm_generalized_get_vector_handle(). Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05Deprecate scm_array_fill_int()Daniel Llorens1-21/+20
* libguile/array-map.h, libgule/array-map.c: move scm_array_fill_int to the deprecated section. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05Remove double indirection in array-fill!Daniel Llorens1-2/+19
* 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-03Remove double indirection for 1st arg of array-for-eachDaniel Llorens1-23/+22
* libguile/array-map.c: (rafe): factor GVREF out of rank-1 loop for ra0.
2013-04-03Remove double indirection in array-map! with <2 argsDaniel Llorens1-12/+20
* libguile/array-map.c: (ramap): factor GVSET/GVREF out of rank-1 loop for ra0 and the first element of ras.
2013-04-03Avoid per-element cons for 1-arg case of array-map!Daniel Llorens1-19/+26
* libguile/array-map.c: (ramap): special case when ras is a 1-element list.
2013-04-03Deprecate dead code in array-map.cDaniel Llorens1-2/+3
* libguile/array-map.c, libguile/array-map.h: deprecate scm_ra_eqp, scm_ra_lessp, scm_ra_leqp, scm_ra_grp, scm_ra_greqp, scm_ra_sum, scm_ra_product, scm_ra_difference, scm_ra_divide, scm_array_identity. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-03Remove double indirection in element access in array-copy!Daniel Llorens1-11/+20
* libguile/array-map.c: (racp): factor scm_generalized_vector_ref, scm_generalized_vector_set_x out of the rank-1 loop. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2012-02-08Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-13/+14
Conflicts: GUILE-VERSION libguile/gc-malloc.c libguile/ports.c
2012-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-13/+14
* libguile/alist.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/bitvectors.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/generalized-arrays.c: * libguile/hashtab.c: * libguile/ioext.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/promises.c: * libguile/simpos.c: * libguile/socket.c: * libguile/srfi-1.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/symbols.c: * libguile/threads.c: * libguile/weak-table.c: * libguile/weak-vector.c: Make the variable names in the C docstrings more consistent. Replace a few instances of @var with @code when appropriate.
2012-01-10Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-2/+1
Conflicts: libguile/__scm.h libguile/array-map.c libguile/procprop.c libguile/tags.h module/ice-9/deprecated.scm module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm test-suite/standalone/test-num2integral.c test-suite/tests/regexp.test
2012-01-09allocate a tc7 to arraysAndy Wingo1-2/+1
* libguile/tags.h (scm_tc7_array): Allocate a tag for arrays. * libguile/arrays.h (SCM_I_ARRAYP): Change to use scm_tc7_array. The previous definition was not externally usable because scm_i_tc16_array was internal. (scm_i_print_array): Declare, though internally. * libguile/arrays.c (scm_i_make_array): Use scm_cell with the tc7 instead of NEWSMOB. (scm_i_print_array): Make not static. (SCM_ARRAY_IMPLEMENTATION): Adapt. (scm_init_arrays): Remove array smob declaration. * libguile/eq.c (scm_equal_p): Refactor to put the string, pointer, and bytevector cases in the switch. Add a case for arrays. * libguile/goops.c: Add <array> declarations. * libguile/print.c (iprin1): Call scm_i_print_array as needed. * libguile/evalext.c (scm_self_evaluating_p): Add a case for arrays.
2011-10-24check for pairs with scm_is_pair, not scm_nimpAndy Wingo1-5/+5
* libguile/array-map.c (scm_ra_matchp, scm_ramapc): * libguile/dynwind.c (scm_swap_bindings): * libguile/hooks.c (hook_print, scm_c_run_hook, scm_c_run_hookn): * libguile/objprop.c (scm_object_property, scm_set_object_property_x): Use !scm_is_pair as the termination condition, not scm_imp.
2011-02-13Change `scm_ramapc' prototype to avoid empty declarators (bug #23681).Ludovic Courtès1-1/+4
* libguile/array-map.h (scm_ramapc): Change `cproc' to `void *' instead of using empty declarators. * libguile/array-map.c (scm_ramapc): Adjust accordingly.
2010-04-01more fixes to equal? for arraysAndy Wingo1-116/+38
* 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-03-31fix equal? between an array and a non-arrayAndy Wingo1-7/+15
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-01-07provide missing prototypesAndy Wingo1-1/+2
* libguile/array-map.c: * libguile/chars.c: * libguile/eq.c: * libguile/strorder.c: Provide declarations missing after the asubrs/rpsubrs -> gsubr conversion.
2009-12-05decruftify scm_sys_protectsAndy Wingo1-10/+3
* libguile/root.h * libguile/root.c (scm_sys_protects): It used to be that for some reason we'd define a special array of "protected" values. This was a little silly, always, but with the BDW GC it's completely unnecessary. Also many of these variables were unused, and none of them were good API. So remove this array, and either eliminate, make static, or make internal the various values. * libguile/snarf.h: No need to generate calls to scm_permanent_object. * guile-readline/readline.c (scm_init_readline): No need to call scm_permanent_object. * libguile/array-map.c (ramap, rafe): Remove the dubious nullvect optimizations. * libguile/async.c (scm_init_async): No need to init scm_asyncs, it is no more. * libguile/eval.c (scm_init_eval): No need to init scm_listofnull, it is no more. * libguile/gc.c: Make scm_protects a static var. (scm_storage_prehistory): Change the sanity check to use the address of protects. (scm_init_gc_protect_object): No need to clear the scm_sys_protects, as it is no more. * libguile/keywords.c: Make the keyword obarray a static var. * libguile/numbers.c: Make flo0 a static var. * libguile/objprop.c: Make object_whash a static var. * libguile/properties.c: Make properties_whash a static var. * libguile/srcprop.h: * libguile/srcprop.c: Make scm_source_whash a global with internal linkage. * libguile/strings.h: * libguile/strings.c: Make scm_nullstr a global with internal linkage. * libguile/vectors.c (scm_init_vectors): No need to init scm_nullvect, it's unused.
2009-12-04remove rpsubrsAndy Wingo1-1/+3
* libguile/tags.h: Remove rpsubrs (I chose to interpret the terse name as "recursive predicate subrs"). Just use gsubrs with rest arguments, or do a fold yourself. * libguile/array-map.c (scm_i_array_equal_p): Do the comparison in order, why not. * libguile/chars.c: * libguile/eq.c: * libguile/numbers.c: * libguile/strorder.c: Add 0,2,1 gsubr wrappers for rpsubrs like eq?, <, etc. * libguile/goops.c (scm_class_of) * libguile/procprop.c (scm_i_procedure_arity) * libguile/procs.c (scm_thunk_p) * libguile/vm.c (apply_foreign): Remove rpsubr cases. * test-suite/tests/numbers.test ("=", "<"): Turn a couple xfails into passes.
2009-12-03remove asubrsAndy Wingo1-213/+15
* libguile/tags.h (scm_tcs_subrs, scm_tc7_asubr): Remove definitions. * libguile/goops.c (scm_class_of) * libguile/procprop.c (scm_i_procedure_arity) * libguile/procs.c (scm_thunk_p) * libguile/vm.c (apply_foreign): Remove cases for asubrs. * libguile/array-map.c: Gut all of the optimizations, because there are no more asubrs, soon won't be rpsubrs, and all of this should happen on the Scheme level, ideally.
2009-12-03remove scm_tc7_dsubrAndy Wingo1-26/+0
* libguile/tags.h: Remove scm_tc7_dsubr. There are no more users of this. * libguile/array-map.c: * libguile/eval.c: * libguile/eval.i.c: * libguile/goops.c: * libguile/procprop.c: * libguile/procs.h: Remove all dsubr cases.
2009-12-03remove tc7_subr_* and tc7_lsubr_*Andy Wingo1-36/+1
* libguile/tags.h: Remove tc7 #defines for subrs, replacing them with placeholders. These were public, but hopfully unused. I don't see how to usefully deprecate them. * libguile/array-map.c (scm_array_map_x): Remove special cases for certain subr types. This might make things slower for the moment, otoh, native compilation should moot that question. * libguile/eval.i.c: * libguile/eval.c: Remove subr-handling cases. To regain this speed and more won't have to wait for native compilation, though -- this change smooths the way for subr dispatch in the VM. * libguile/gsubr.c (scm_i_gsubr_apply): Fix a bug in which we didn't detect too-many-arguments. This would only show up when using ceval, as only ceval called this function. * test-suite/tests/ramap.test ("array-map!"): Change the expected exception if passed a procedure of the wrong arity. It now gives wrong-num-args. more won't have to wait for native compilation, though -- this change smooths the way for subr dispatch in the VM. * libguile/goops.c (scm_class_of): Remove subr cases. No speed implication. * libguile/objects.c (scm_valid_object_procedure_p): Remove this public but undocumented, and useless, function. I do not think this will affect anyone at all. (scm_set_object_procedure_x): Replace a call to scm_valid_object_procedure_p with scm_procedure_p, and actually wrap with a scm_is_true. * module/oop/goops.scm (initialize-object-procedure): Don't call valid-object-procedure?.
2009-09-09Avoid unneeded `scm_dynwind_free ()'.Ludovic Courtès1-11/+7
* libguile/array-map.c (indices_gc_hint): New variable. (scm_ramapc, scm_array_index_map_x): Avoid `scm_dynwind_free ()' using `scm_gc_malloc_pointerless ()'.
2009-07-19generic vector ops to own fileAndy Wingo1-0/+1
* libguile/Makefile.am: * libguile/vectors.c: * libguile/vectors.h: * libguile/generalized-vectors.c: * libguile/generalized-vectors.h: Move generic vector ops off into their own file too. The implementation is now based on the generic array-handle infrastructure. * libguile.h: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/random.c: * libguile/srfi-4.c: Update includers.
2009-07-19move generic array foo out to its own fileAndy Wingo1-0/+1
* libguile/arrays.h: * libguile/arrays.c: * libguile/generalized-arrays.h: * libguile/generalized-arrays.c: Move some generic functionality out of arrays.c to a new file. * libguile/array-map.c: * libguile/deprecated.c: * libguile/init.c: Update includers.
2009-07-19remove enclosed arraysAndy Wingo1-4/+4
* libguile/arrays.h: * libguile/array-map.c: * libguile/arrays.c: * libguile/deprecated.c: Remove "enclosed arrays". The only user-facing procedures that this affects are scm_enclose_array / enclose-array. If enclosed arrays are added back, it should be through the generic array interface; but really, it sounds like something that would be better implemented in Scheme.
2009-07-19rename unif.[ch] to arrays.[ch]Andy Wingo1-1/+1
* libguile/Makefile.am: * libguile/unif.c: * libguile/unif.h: * libguile/arrays.c: * libguile/arrays.h: Rename unif.[ch] to arrays.[ch]. * libguile.h: * libguile/array-handle.c: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/eq.c: * libguile/gc-card.c: * libguile/gc-malloc.c: * libguile/gc-mark.c: * libguile/gc.c: * libguile/init.c: * libguile/inline.h: * libguile/print.c: * libguile/random.c: * libguile/read.c: * libguile/socket.c: * libguile/sort.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/strports.c: * libguile/vectors.c: * libguile/vectors.h: Update includers.
2009-07-19bitvector exodus from unif.[ch]Andy Wingo1-0/+1
* libguile/Makefile.am: * libguile/unif.c: * libguile/unif.h: * libguile/bitvectors.c: * libguile/bitvectors.h: Move bitvector functionality out of unif.[ch]. * libguile/array-handle.c: * libguile/array-map.c: * libguile/init.c: * libguile/read.c: * libguile/srfi-4.c: * libguile/vectors.c: Oh, what a tangled web we weave...
2009-07-19rename ramap.[ch] to array-map.[ch]Andy Wingo1-0/+1235
* libguile/array-map.c: * libguile/array-map.h: Rename from ramap.c and ramap.h. * libguile.h: * libguile/Makefile.am: * libguile/eq.c: * libguile/init.c: * libguile/sort.c: * libguile/unif.c: * libguile/vectors.c: All referrers changed.