1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-05 17:20:18 +02:00

New export (array-for-each-cell-in-order)

* libguile/arrays.h (array-for-each-cell-in-order): Declare.

* libguile/arrays.c (array-for-each-cell-in-order): Define.
This commit is contained in:
Daniel Llorens 2015-12-09 12:57:19 +01:00
parent a8dd99d0de
commit ffd949e597
2 changed files with 14 additions and 1 deletions

View file

@ -594,6 +594,7 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
{ {
// FIXME replace stack by scm_gc_malloc_pointerless() // FIXME replace stack by scm_gc_malloc_pointerless()
int const N = scm_ilength(a_); int const N = scm_ilength(a_);
int const frank = scm_to_int(frank_);
scm_t_array_handle ah[N]; scm_t_array_handle ah[N];
SCM a[N]; SCM a[N];
scm_t_array_dim * as[N]; scm_t_array_dim * as[N];
@ -606,7 +607,6 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
rank[n] = scm_array_handle_rank(ah+n); rank[n] = scm_array_handle_rank(ah+n);
} }
// checks. // checks.
int const frank = scm_to_int(frank_);
ssize_t s[frank]; ssize_t s[frank];
char const * msg = NULL; char const * msg = NULL;
if (frank<0) if (frank<0)
@ -757,6 +757,17 @@ SCM_DEFINE (scm_array_for_each_cell, "array-for-each-cell", 2, 0, 1,
#undef FUNC_NAME #undef FUNC_NAME
SCM_DEFINE (scm_array_for_each_cell_in_order, "array-for-each-cell-in-order", 2, 0, 1,
(SCM frank_, SCM op, SCM a_),
"Same as array-for-each-cell, but visit the cells sequentially\n"
"and in row-major order.\n")
#define FUNC_NAME s_scm_array_for_each_cell_in_order
{
return scm_array_for_each_cell (frank_, op, a_);
}
#undef FUNC_NAME
/* args are RA . DIMS */ /* args are RA . DIMS */
SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1, SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
(SCM ra, SCM args), (SCM ra, SCM args),
@ -1131,6 +1142,7 @@ scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
return scm_i_print_array_dimension (&h, 0, 0, port, pstate); return scm_i_print_array_dimension (&h, 0, 0, port, pstate);
} }
void void
scm_init_arrays () scm_init_arrays ()
{ {

View file

@ -53,6 +53,7 @@ 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_from (SCM ra, SCM indices);
SCM_API SCM scm_array_amend_x (SCM ra, SCM b, SCM indices); SCM_API SCM scm_array_amend_x (SCM ra, SCM b, SCM indices);
SCM_API SCM scm_array_for_each_cell (SCM frank, SCM op, SCM args); 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_list_to_array (SCM ndim, SCM lst); 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); SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst);