mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-03 13:20:26 +02:00
Don't use array handles in scm_c_array_rank
* libguile/arrays.c (scm_c_array_rank): moved from libguile/generalized-arrays.c. Don't use array handles, but follow the same type check sequence as the other array functions (shared-array-root, etc). (scm_array_rank): moved from libguile/generalized-arrays.h. * libguile/arrays.h: move prototypes here.
This commit is contained in:
parent
3aafc2c857
commit
ed6c65507a
4 changed files with 35 additions and 35 deletions
|
@ -64,6 +64,27 @@
|
||||||
(SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) & ~(SCM_I_ARRAY_FLAG_CONTIGUOUS << 16)))
|
(SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) & ~(SCM_I_ARRAY_FLAG_CONTIGUOUS << 16)))
|
||||||
|
|
||||||
|
|
||||||
|
size_t
|
||||||
|
scm_c_array_rank (SCM array)
|
||||||
|
{
|
||||||
|
if (SCM_I_ARRAYP (array))
|
||||||
|
return SCM_I_ARRAY_NDIM (array);
|
||||||
|
else if (scm_is_array (array))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
scm_wrong_type_arg_msg ("array-rank", SCM_ARG1, array, "array");
|
||||||
|
}
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_array_rank, "array-rank", 1, 0, 0,
|
||||||
|
(SCM array),
|
||||||
|
"Return the number of dimensions of the array @var{array.}\n")
|
||||||
|
#define FUNC_NAME s_scm_array_rank
|
||||||
|
{
|
||||||
|
return scm_from_size_t (scm_c_array_rank (array));
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
||||||
SCM_DEFINE (scm_shared_array_root, "shared-array-root", 1, 0, 0,
|
SCM_DEFINE (scm_shared_array_root, "shared-array-root", 1, 0, 0,
|
||||||
(SCM ra),
|
(SCM ra),
|
||||||
"Return the root vector of a shared array.")
|
"Return the root vector of a shared array.")
|
||||||
|
|
|
@ -56,6 +56,9 @@ SCM_API SCM scm_array_amend_x (SCM ra, SCM b, SCM indices);
|
||||||
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);
|
||||||
|
|
||||||
|
SCM_API size_t scm_c_array_rank (SCM ra);
|
||||||
|
SCM_API SCM scm_array_rank (SCM ra);
|
||||||
|
|
||||||
/* internal. */
|
/* internal. */
|
||||||
|
|
||||||
#define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0) /* currently unused */
|
#define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0) /* currently unused */
|
||||||
|
|
|
@ -104,27 +104,6 @@ SCM_DEFINE (scm_typed_array_p, "typed-array?", 2, 0, 0,
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
size_t
|
|
||||||
scm_c_array_rank (SCM array)
|
|
||||||
{
|
|
||||||
scm_t_array_handle handle;
|
|
||||||
size_t res;
|
|
||||||
|
|
||||||
scm_array_get_handle (array, &handle);
|
|
||||||
res = scm_array_handle_rank (&handle);
|
|
||||||
scm_array_handle_release (&handle);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM_DEFINE (scm_array_rank, "array-rank", 1, 0, 0,
|
|
||||||
(SCM array),
|
|
||||||
"Return the number of dimensions of the array @var{array.}\n")
|
|
||||||
#define FUNC_NAME s_scm_array_rank
|
|
||||||
{
|
|
||||||
return scm_from_size_t (scm_c_array_rank (array));
|
|
||||||
}
|
|
||||||
#undef FUNC_NAME
|
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
scm_c_array_length (SCM array)
|
scm_c_array_length (SCM array)
|
||||||
|
|
|
@ -41,9 +41,6 @@ SCM_INTERNAL SCM scm_array_p_2 (SCM);
|
||||||
SCM_API int scm_is_typed_array (SCM obj, SCM type);
|
SCM_API int scm_is_typed_array (SCM obj, SCM type);
|
||||||
SCM_API SCM scm_typed_array_p (SCM v, SCM type);
|
SCM_API SCM scm_typed_array_p (SCM v, SCM type);
|
||||||
|
|
||||||
SCM_API size_t scm_c_array_rank (SCM ra);
|
|
||||||
SCM_API SCM scm_array_rank (SCM ra);
|
|
||||||
|
|
||||||
SCM_API size_t scm_c_array_length (SCM ra);
|
SCM_API size_t scm_c_array_length (SCM ra);
|
||||||
SCM_API SCM scm_array_length (SCM ra);
|
SCM_API SCM scm_array_length (SCM ra);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue