2011-03-17 11:42:50 +01:00
|
|
|
|
/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-03-26 00:01:47 +00:00
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#include <stdio.h>
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
#include <errno.h>
|
2001-03-09 23:33:41 +00:00
|
|
|
|
#include <string.h>
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
#include "libguile/__scm.h"
|
|
|
|
|
|
#include "libguile/eq.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/chars.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
|
|
|
|
|
#include "libguile/fports.h"
|
|
|
|
|
|
#include "libguile/feature.h"
|
|
|
|
|
|
#include "libguile/root.h"
|
|
|
|
|
|
#include "libguile/strings.h"
|
2004-08-24 22:12:37 +00:00
|
|
|
|
#include "libguile/srfi-13.h"
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
#include "libguile/srfi-4.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/vectors.h"
|
2009-07-17 00:58:32 +02:00
|
|
|
|
#include "libguile/bitvectors.h"
|
Make bytevectors accessible using the generalized-vector API.
As a side effect, this allows compilation of literal bytevectors
("#vu8(...)"), which gets done by the generic array handling
of the GLIL->assembly compiler.
* doc/ref/api-compound.texi (Generalized Vectors): Mention bytevectors.
(Arrays, Array Syntax): Likewise.
* doc/ref/api-data.texi (Bytevectors as Generalized Vectors): New node.
* libguile/bytevectors.c (scm_i_bytevector_generalized_set_x): New.
* libguile/bytevectors.h (scm_i_bytevector_generalized_set_x): New
declaration.
* libguile/srfi-4.c (scm_i_generalized_vector_type,
scm_array_handle_uniform_element_size,
scm_array_handle_uniform_writable_elements): Add support for
bytevectors.
* libguile/unif.c (type_creator_table): Add `vu8'.
(bytevector_ref, bytevector_set): New functions.
(memoize_ref, memoize_set): Add support for bytevectors.
* libguile/vectors.c (scm_is_generalized_vector,
scm_c_generalized_vector_length, scm_c_generalized_vector_ref,
scm_c_generalized_vector_set_x): Add support for bytevectors.
* test-suite/tests/bytevectors.test ("Generalized Vectors"): New test
set.
2009-06-22 00:51:08 +02:00
|
|
|
|
#include "libguile/bytevectors.h"
|
2004-10-29 14:41:14 +00:00
|
|
|
|
#include "libguile/list.h"
|
2004-11-02 20:15:32 +00:00
|
|
|
|
#include "libguile/dynwind.h"
|
2009-07-18 12:58:37 +02:00
|
|
|
|
#include "libguile/read.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
|
|
|
|
|
|
#include "libguile/validate.h"
|
2009-07-17 01:08:35 +02:00
|
|
|
|
#include "libguile/arrays.h"
|
2009-07-18 12:58:37 +02:00
|
|
|
|
#include "libguile/array-map.h"
|
2009-07-17 19:05:32 +02:00
|
|
|
|
#include "libguile/generalized-vectors.h"
|
2009-07-18 12:58:37 +02:00
|
|
|
|
#include "libguile/generalized-arrays.h"
|
2009-07-18 12:18:15 +02:00
|
|
|
|
#include "libguile/uniform.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
#define SCM_SET_ARRAY_CONTIGUOUS_FLAG(x) \
|
2012-01-09 17:24:57 +01:00
|
|
|
|
(SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) | (SCM_I_ARRAY_FLAG_CONTIGUOUS << 16)))
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
#define SCM_CLR_ARRAY_CONTIGUOUS_FLAG(x) \
|
2012-01-09 17:24:57 +01:00
|
|
|
|
(SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) & ~(SCM_I_ARRAY_FLAG_CONTIGUOUS << 16)))
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-13 03:44:51 +00:00
|
|
|
|
SCM_DEFINE (scm_shared_array_root, "shared-array-root", 1, 0, 0,
|
|
|
|
|
|
(SCM ra),
|
|
|
|
|
|
"Return the root vector of a shared array.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_shared_array_root
|
|
|
|
|
|
{
|
2009-07-17 12:45:24 +02:00
|
|
|
|
if (SCM_I_ARRAYP (ra))
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
return SCM_I_ARRAY_V (ra);
|
2005-01-10 00:15:48 +00:00
|
|
|
|
else if (scm_is_generalized_vector (ra))
|
|
|
|
|
|
return ra;
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_wrong_type_arg_msg (FUNC_NAME, SCM_ARG1, ra, "array");
|
2000-04-13 03:44:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_shared_array_offset, "shared-array-offset", 1, 0, 0,
|
|
|
|
|
|
(SCM ra),
|
|
|
|
|
|
"Return the root vector index of the first element in the array.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_shared_array_offset
|
|
|
|
|
|
{
|
2005-01-10 00:15:48 +00:00
|
|
|
|
scm_t_array_handle handle;
|
|
|
|
|
|
SCM res;
|
|
|
|
|
|
|
|
|
|
|
|
scm_array_get_handle (ra, &handle);
|
|
|
|
|
|
res = scm_from_size_t (handle.base);
|
|
|
|
|
|
scm_array_handle_release (&handle);
|
|
|
|
|
|
return res;
|
2000-04-13 03:44:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_shared_array_increments, "shared-array-increments", 1, 0, 0,
|
|
|
|
|
|
(SCM ra),
|
|
|
|
|
|
"For each dimension, return the distance between elements in the root vector.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_shared_array_increments
|
|
|
|
|
|
{
|
2005-01-10 00:15:48 +00:00
|
|
|
|
scm_t_array_handle handle;
|
2000-04-13 03:44:51 +00:00
|
|
|
|
SCM res = SCM_EOL;
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
size_t k;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_array_dim *s;
|
(scm_tc16_enclosed_array, SCM_ENCLOSED_ARRAYP):
New.
(exactly_one_third, singp): Removed.
(scm_array_p, scm_array_dimensions, scm_shared_array_root,
scm_shared_array_offset, scm_shared_array_increments): Handle
enclosed arrays explicitely.
(scm_array_rank): Likewise. Also, do not return zero for
non-arrays, signal an error instead since arrays with rank zero do
exist.
(scm_i_make_ra): New, for specifying the tag of the new array.
(scm_make_enclosed_array): Use it.
(scm_make_ra): Reimplemented in terms of scm_i_make_ra.
(scm_make_shared_array): Use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
(scm_array_in_bounds_p): Rewritten to be much cleaner.
(scm_i_cvref): New, doing the job of scm_cvref.
(scm_cvref): Use scm_i_cvref.
(scm_array_ref): Do not accept non-arrays when no indices are
given. Use scm_i_cvref to do the actual access.
("uniform-array-set1"): Do not register.
(scm_array_set_x, scm_uniform_array_read_x,
scm_uniform_array_write): Handle enclosed arrays explicitly.
(ra2l): Use scm_i_cvref instead of scm_uniform_vector_ref to also
handle enclosed arrays.
(scm_array_to_list): Handle enclosed arrays explicitly.
(rapr1): Removed.
(scm_i_print_array_dimension): Use scm_i_cvref to also handle
enclosed arrays.
(scm_i_print_enclosed_array): New.
(tag_proto_table, tag_creator_table): Renamed former to latter.
Added "a" and "b" for strings and bitvectors, resp.
(scm_i_tag_to_prototype, scm_i_tag_to_creator): Renamed former to
latter. Tag "a" is in the table now, no need to handle it as a
legacy tag.
(scm_raprin1): Just call scm_iprin1.
(scm_array_creator, scm_array_prototype): Handle enclosed arrays
explicitly.
(scm_init_unif): Initialize scm_tc16_enclosed_array smob.
Use scm_i_print_array as printer for scm_tc16_array.
2004-11-12 18:55:25 +00:00
|
|
|
|
|
2005-01-10 00:15:48 +00:00
|
|
|
|
scm_array_get_handle (ra, &handle);
|
|
|
|
|
|
k = scm_array_handle_rank (&handle);
|
|
|
|
|
|
s = scm_array_handle_dims (&handle);
|
2000-04-13 03:44:51 +00:00
|
|
|
|
while (k--)
|
2005-01-10 00:15:48 +00:00
|
|
|
|
res = scm_cons (scm_from_ssize_t (s[k].inc), res);
|
|
|
|
|
|
scm_array_handle_release (&handle);
|
2000-04-13 03:44:51 +00:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2012-01-09 22:16:49 +01:00
|
|
|
|
SCM
|
2009-07-17 12:45:24 +02:00
|
|
|
|
scm_i_make_array (int ndim)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM ra;
|
2012-01-09 17:24:57 +01:00
|
|
|
|
ra = scm_cell (((scm_t_bits) ndim << 17) + scm_tc7_array,
|
2012-01-09 22:16:49 +01:00
|
|
|
|
(scm_t_bits) scm_gc_malloc (sizeof (scm_i_t_array) +
|
|
|
|
|
|
ndim * sizeof (scm_t_array_dim),
|
|
|
|
|
|
"array"));
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_V (ra) = SCM_BOOL_F;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char s_bad_spec[] = "Bad scm_array dimension";
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
(scm_tc16_enclosed_array, SCM_ENCLOSED_ARRAYP):
New.
(exactly_one_third, singp): Removed.
(scm_array_p, scm_array_dimensions, scm_shared_array_root,
scm_shared_array_offset, scm_shared_array_increments): Handle
enclosed arrays explicitely.
(scm_array_rank): Likewise. Also, do not return zero for
non-arrays, signal an error instead since arrays with rank zero do
exist.
(scm_i_make_ra): New, for specifying the tag of the new array.
(scm_make_enclosed_array): Use it.
(scm_make_ra): Reimplemented in terms of scm_i_make_ra.
(scm_make_shared_array): Use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
(scm_array_in_bounds_p): Rewritten to be much cleaner.
(scm_i_cvref): New, doing the job of scm_cvref.
(scm_cvref): Use scm_i_cvref.
(scm_array_ref): Do not accept non-arrays when no indices are
given. Use scm_i_cvref to do the actual access.
("uniform-array-set1"): Do not register.
(scm_array_set_x, scm_uniform_array_read_x,
scm_uniform_array_write): Handle enclosed arrays explicitly.
(ra2l): Use scm_i_cvref instead of scm_uniform_vector_ref to also
handle enclosed arrays.
(scm_array_to_list): Handle enclosed arrays explicitly.
(rapr1): Removed.
(scm_i_print_array_dimension): Use scm_i_cvref to also handle
enclosed arrays.
(scm_i_print_enclosed_array): New.
(tag_proto_table, tag_creator_table): Renamed former to latter.
Added "a" and "b" for strings and bitvectors, resp.
(scm_i_tag_to_prototype, scm_i_tag_to_creator): Renamed former to
latter. Tag "a" is in the table now, no need to handle it as a
legacy tag.
(scm_raprin1): Just call scm_iprin1.
(scm_array_creator, scm_array_prototype): Handle enclosed arrays
explicitly.
(scm_init_unif): Initialize scm_tc16_enclosed_array smob.
Use scm_i_print_array as printer for scm_tc16_array.
2004-11-12 18:55:25 +00:00
|
|
|
|
/* Increments will still need to be set. */
|
|
|
|
|
|
|
2005-01-11 00:26:23 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
scm_i_shap2ra (SCM args)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_array_dim *s;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM ra, spec, sp;
|
|
|
|
|
|
int ndim = scm_ilength (args);
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
if (ndim < 0)
|
2005-01-11 00:26:23 +00:00
|
|
|
|
scm_misc_error (NULL, s_bad_spec, SCM_EOL);
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
|
2009-07-17 12:45:24 +02:00
|
|
|
|
ra = scm_i_make_array (ndim);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_BASE (ra) = 0;
|
|
|
|
|
|
s = SCM_I_ARRAY_DIMS (ra);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
for (; !scm_is_null (args); s++, args = SCM_CDR (args))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
spec = SCM_CAR (args);
|
2004-07-23 15:43:02 +00:00
|
|
|
|
if (scm_is_integer (spec))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-07-23 15:43:02 +00:00
|
|
|
|
if (scm_to_long (spec) < 0)
|
2005-01-11 00:26:23 +00:00
|
|
|
|
scm_misc_error (NULL, s_bad_spec, SCM_EOL);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
s->lbnd = 0;
|
2004-07-23 15:43:02 +00:00
|
|
|
|
s->ubnd = scm_to_long (spec) - 1;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
s->inc = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (spec) || !scm_is_integer (SCM_CAR (spec)))
|
2005-01-11 00:26:23 +00:00
|
|
|
|
scm_misc_error (NULL, s_bad_spec, SCM_EOL);
|
2004-07-23 15:43:02 +00:00
|
|
|
|
s->lbnd = scm_to_long (SCM_CAR (spec));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
sp = SCM_CDR (spec);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (sp)
|
2004-07-23 15:43:02 +00:00
|
|
|
|
|| !scm_is_integer (SCM_CAR (sp))
|
2004-09-22 17:41:37 +00:00
|
|
|
|
|| !scm_is_null (SCM_CDR (sp)))
|
2005-01-11 00:26:23 +00:00
|
|
|
|
scm_misc_error (NULL, s_bad_spec, SCM_EOL);
|
2004-07-23 15:43:02 +00:00
|
|
|
|
s->ubnd = scm_to_long (SCM_CAR (sp));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
s->inc = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
SCM_DEFINE (scm_make_typed_array, "make-typed-array", 2, 0, 1,
|
|
|
|
|
|
(SCM type, SCM fill, SCM bounds),
|
|
|
|
|
|
"Create and return an array of type @var{type}.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_make_typed_array
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
size_t k, rlen = 1;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_array_dim *s;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM ra;
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
|
2005-01-11 00:26:23 +00:00
|
|
|
|
ra = scm_i_shap2ra (bounds);
|
2001-04-19 09:38:37 +00:00
|
|
|
|
SCM_SET_ARRAY_CONTIGUOUS_FLAG (ra);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
s = SCM_I_ARRAY_DIMS (ra);
|
|
|
|
|
|
k = SCM_I_ARRAY_NDIM (ra);
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
while (k--)
|
|
|
|
|
|
{
|
2000-10-30 17:47:52 +00:00
|
|
|
|
s[k].inc = rlen;
|
2005-01-10 19:06:48 +00:00
|
|
|
|
SCM_ASSERT_RANGE (1, bounds, s[k].lbnd <= s[k].ubnd + 1);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
rlen = (s[k].ubnd - s[k].lbnd + 1) * s[k].inc;
|
|
|
|
|
|
}
|
2000-10-30 17:47:52 +00:00
|
|
|
|
|
2005-01-04 23:31:19 +00:00
|
|
|
|
if (scm_is_eq (fill, SCM_UNSPECIFIED))
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
fill = SCM_UNDEFINED;
|
2000-10-30 17:47:52 +00:00
|
|
|
|
|
2009-07-18 12:58:37 +02:00
|
|
|
|
SCM_I_ARRAY_V (ra) =
|
|
|
|
|
|
scm_make_generalized_vector (type, scm_from_size_t (rlen), fill);
|
2000-10-30 17:47:52 +00:00
|
|
|
|
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
|
2001-05-26 20:51:22 +00:00
|
|
|
|
if (s->ubnd < s->lbnd || (0 == s->lbnd && 1 == s->inc))
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
return SCM_I_ARRAY_V (ra);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2009-06-05 16:31:38 +02:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_from_contiguous_typed_array (SCM type, SCM bounds, const void *bytes,
|
|
|
|
|
|
size_t byte_len)
|
|
|
|
|
|
#define FUNC_NAME "scm_from_contiguous_typed_array"
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t k, rlen = 1;
|
|
|
|
|
|
scm_t_array_dim *s;
|
|
|
|
|
|
SCM ra;
|
|
|
|
|
|
scm_t_array_handle h;
|
2009-09-17 13:52:09 +02:00
|
|
|
|
void *elts;
|
2009-06-05 16:31:38 +02:00
|
|
|
|
size_t sz;
|
|
|
|
|
|
|
|
|
|
|
|
ra = scm_i_shap2ra (bounds);
|
|
|
|
|
|
SCM_SET_ARRAY_CONTIGUOUS_FLAG (ra);
|
|
|
|
|
|
s = SCM_I_ARRAY_DIMS (ra);
|
|
|
|
|
|
k = SCM_I_ARRAY_NDIM (ra);
|
|
|
|
|
|
|
|
|
|
|
|
while (k--)
|
|
|
|
|
|
{
|
|
|
|
|
|
s[k].inc = rlen;
|
|
|
|
|
|
SCM_ASSERT_RANGE (1, bounds, s[k].lbnd <= s[k].ubnd + 1);
|
|
|
|
|
|
rlen = (s[k].ubnd - s[k].lbnd + 1) * s[k].inc;
|
|
|
|
|
|
}
|
2009-07-18 12:58:37 +02:00
|
|
|
|
SCM_I_ARRAY_V (ra) =
|
|
|
|
|
|
scm_make_generalized_vector (type, scm_from_size_t (rlen), SCM_UNDEFINED);
|
2009-06-05 16:31:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scm_array_get_handle (ra, &h);
|
2009-09-17 13:52:09 +02:00
|
|
|
|
elts = h.writable_elements;
|
|
|
|
|
|
sz = scm_array_handle_uniform_element_bit_size (&h);
|
2009-06-05 16:31:38 +02:00
|
|
|
|
scm_array_handle_release (&h);
|
|
|
|
|
|
|
2009-09-17 13:52:09 +02:00
|
|
|
|
if (sz >= 8 && ((sz % 8) == 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (byte_len % (sz / 8))
|
|
|
|
|
|
SCM_MISC_ERROR ("byte length not a multiple of the unit size", SCM_EOL);
|
|
|
|
|
|
if (byte_len / (sz / 8) != rlen)
|
|
|
|
|
|
SCM_MISC_ERROR ("byte length and dimensions do not match", SCM_EOL);
|
|
|
|
|
|
}
|
2009-10-16 11:59:30 +02:00
|
|
|
|
else if (sz < 8)
|
2009-09-17 13:52:09 +02:00
|
|
|
|
{
|
2009-10-15 23:29:50 +02:00
|
|
|
|
/* byte_len ?= ceil (rlen * sz / 8) */
|
|
|
|
|
|
if (byte_len != (rlen * sz + 7) / 8)
|
2009-09-17 13:52:09 +02:00
|
|
|
|
SCM_MISC_ERROR ("byte length and dimensions do not match", SCM_EOL);
|
|
|
|
|
|
}
|
2009-10-16 11:59:30 +02:00
|
|
|
|
else
|
|
|
|
|
|
/* an internal guile error, really */
|
|
|
|
|
|
SCM_MISC_ERROR ("uniform elements larger than 8 bits must fill whole bytes", SCM_EOL);
|
2009-06-05 16:31:38 +02:00
|
|
|
|
|
2009-09-17 13:52:09 +02:00
|
|
|
|
memcpy (elts, bytes, byte_len);
|
2009-06-05 16:31:38 +02:00
|
|
|
|
|
|
|
|
|
|
if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
|
|
|
|
|
|
if (s->ubnd < s->lbnd || (0 == s->lbnd && 1 == s->inc))
|
|
|
|
|
|
return SCM_I_ARRAY_V (ra);
|
|
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2010-01-11 21:47:10 +01:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_from_contiguous_array (SCM bounds, const SCM *elts, size_t len)
|
|
|
|
|
|
#define FUNC_NAME "scm_from_contiguous_array"
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t k, rlen = 1;
|
|
|
|
|
|
scm_t_array_dim *s;
|
|
|
|
|
|
SCM ra;
|
|
|
|
|
|
scm_t_array_handle h;
|
|
|
|
|
|
|
|
|
|
|
|
ra = scm_i_shap2ra (bounds);
|
|
|
|
|
|
SCM_SET_ARRAY_CONTIGUOUS_FLAG (ra);
|
|
|
|
|
|
s = SCM_I_ARRAY_DIMS (ra);
|
|
|
|
|
|
k = SCM_I_ARRAY_NDIM (ra);
|
|
|
|
|
|
|
|
|
|
|
|
while (k--)
|
|
|
|
|
|
{
|
|
|
|
|
|
s[k].inc = rlen;
|
|
|
|
|
|
SCM_ASSERT_RANGE (1, bounds, s[k].lbnd <= s[k].ubnd + 1);
|
|
|
|
|
|
rlen = (s[k].ubnd - s[k].lbnd + 1) * s[k].inc;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (rlen != len)
|
|
|
|
|
|
SCM_MISC_ERROR ("element length and dimensions do not match", SCM_EOL);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_I_ARRAY_V (ra) = scm_c_make_vector (rlen, SCM_UNDEFINED);
|
|
|
|
|
|
scm_array_get_handle (ra, &h);
|
|
|
|
|
|
memcpy (h.writable_elements, elts, rlen * sizeof(SCM));
|
|
|
|
|
|
scm_array_handle_release (&h);
|
|
|
|
|
|
|
|
|
|
|
|
if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
|
|
|
|
|
|
if (s->ubnd < s->lbnd || (0 == s->lbnd && 1 == s->inc))
|
|
|
|
|
|
return SCM_I_ARRAY_V (ra);
|
|
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
SCM_DEFINE (scm_make_array, "make-array", 1, 0, 1,
|
|
|
|
|
|
(SCM fill, SCM bounds),
|
|
|
|
|
|
"Create and return an array.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_make_array
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_make_typed_array (SCM_BOOL_T, fill, bounds);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2005-01-11 00:26:23 +00:00
|
|
|
|
static void
|
|
|
|
|
|
scm_i_ra_set_contp (SCM ra)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
size_t k = SCM_I_ARRAY_NDIM (ra);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
if (k)
|
|
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
long inc = SCM_I_ARRAY_DIMS (ra)[k - 1].inc;
|
1996-10-11 07:58:00 +00:00
|
|
|
|
while (k--)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (inc != SCM_I_ARRAY_DIMS (ra)[k].inc)
|
1996-10-11 07:58:00 +00:00
|
|
|
|
{
|
2001-04-19 09:38:37 +00:00
|
|
|
|
SCM_CLR_ARRAY_CONTIGUOUS_FLAG (ra);
|
1996-10-11 07:58:00 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
inc *= (SCM_I_ARRAY_DIMS (ra)[k].ubnd
|
|
|
|
|
|
- SCM_I_ARRAY_DIMS (ra)[k].lbnd + 1);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2001-04-19 09:38:37 +00:00
|
|
|
|
SCM_SET_ARRAY_CONTIGUOUS_FLAG (ra);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_make_shared_array, "make-shared-array", 2, 0, 1,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM oldra, SCM mapfunc, SCM dims),
|
2012-01-11 23:33:01 -05:00
|
|
|
|
"@code{make-shared-array} can be used to create shared subarrays\n"
|
|
|
|
|
|
"of other arrays. The @var{mapfunc} is a function that\n"
|
|
|
|
|
|
"translates coordinates in the new array into coordinates in the\n"
|
|
|
|
|
|
"old array. A @var{mapfunc} must be linear, and its range must\n"
|
|
|
|
|
|
"stay within the bounds of the old array, but it can be\n"
|
|
|
|
|
|
"otherwise arbitrary. A simple example:\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@lisp\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"(define fred (make-array #f 8 8))\n"
|
|
|
|
|
|
"(define freds-diagonal\n"
|
|
|
|
|
|
" (make-shared-array fred (lambda (i) (list i i)) 8))\n"
|
|
|
|
|
|
"(array-set! freds-diagonal 'foo 3)\n"
|
|
|
|
|
|
"(array-ref fred 3 3) @result{} foo\n"
|
|
|
|
|
|
"(define freds-center\n"
|
|
|
|
|
|
" (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2))\n"
|
|
|
|
|
|
"(array-ref freds-center 0 0) @result{} foo\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@end lisp")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_make_shared_array
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-01-10 01:41:35 +00:00
|
|
|
|
scm_t_array_handle old_handle;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM ra;
|
|
|
|
|
|
SCM inds, indptr;
|
|
|
|
|
|
SCM imap;
|
2005-01-10 01:41:35 +00:00
|
|
|
|
size_t k;
|
|
|
|
|
|
ssize_t i;
|
2006-04-17 00:05:42 +00:00
|
|
|
|
long old_base, old_min, new_min, old_max, new_max;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_array_dim *s;
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_REST_ARGUMENT (dims);
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_PROC (2, mapfunc);
|
2005-01-11 00:26:23 +00:00
|
|
|
|
ra = scm_i_shap2ra (dims);
|
2005-01-10 01:41:35 +00:00
|
|
|
|
|
|
|
|
|
|
scm_array_get_handle (oldra, &old_handle);
|
|
|
|
|
|
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (SCM_I_ARRAYP (oldra))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_V (ra) = SCM_I_ARRAY_V (oldra);
|
2006-04-17 00:05:42 +00:00
|
|
|
|
old_base = old_min = old_max = SCM_I_ARRAY_BASE (oldra);
|
2005-01-10 01:41:35 +00:00
|
|
|
|
s = scm_array_handle_dims (&old_handle);
|
|
|
|
|
|
k = scm_array_handle_rank (&old_handle);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
while (k--)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (s[k].inc > 0)
|
|
|
|
|
|
old_max += (s[k].ubnd - s[k].lbnd) * s[k].inc;
|
|
|
|
|
|
else
|
|
|
|
|
|
old_min += (s[k].ubnd - s[k].lbnd) * s[k].inc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_V (ra) = oldra;
|
2006-04-17 00:05:42 +00:00
|
|
|
|
old_base = old_min = 0;
|
(scm_tc16_enclosed_array, SCM_ENCLOSED_ARRAYP):
New.
(exactly_one_third, singp): Removed.
(scm_array_p, scm_array_dimensions, scm_shared_array_root,
scm_shared_array_offset, scm_shared_array_increments): Handle
enclosed arrays explicitely.
(scm_array_rank): Likewise. Also, do not return zero for
non-arrays, signal an error instead since arrays with rank zero do
exist.
(scm_i_make_ra): New, for specifying the tag of the new array.
(scm_make_enclosed_array): Use it.
(scm_make_ra): Reimplemented in terms of scm_i_make_ra.
(scm_make_shared_array): Use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
(scm_array_in_bounds_p): Rewritten to be much cleaner.
(scm_i_cvref): New, doing the job of scm_cvref.
(scm_cvref): Use scm_i_cvref.
(scm_array_ref): Do not accept non-arrays when no indices are
given. Use scm_i_cvref to do the actual access.
("uniform-array-set1"): Do not register.
(scm_array_set_x, scm_uniform_array_read_x,
scm_uniform_array_write): Handle enclosed arrays explicitly.
(ra2l): Use scm_i_cvref instead of scm_uniform_vector_ref to also
handle enclosed arrays.
(scm_array_to_list): Handle enclosed arrays explicitly.
(rapr1): Removed.
(scm_i_print_array_dimension): Use scm_i_cvref to also handle
enclosed arrays.
(scm_i_print_enclosed_array): New.
(tag_proto_table, tag_creator_table): Renamed former to latter.
Added "a" and "b" for strings and bitvectors, resp.
(scm_i_tag_to_prototype, scm_i_tag_to_creator): Renamed former to
latter. Tag "a" is in the table now, no need to handle it as a
legacy tag.
(scm_raprin1): Just call scm_iprin1.
(scm_array_creator, scm_array_prototype): Handle enclosed arrays
explicitly.
(scm_init_unif): Initialize scm_tc16_enclosed_array smob.
Use scm_i_print_array as printer for scm_tc16_array.
2004-11-12 18:55:25 +00:00
|
|
|
|
old_max = scm_c_generalized_vector_length (oldra) - 1;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2005-01-10 01:41:35 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
inds = SCM_EOL;
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
s = SCM_I_ARRAY_DIMS (ra);
|
|
|
|
|
|
for (k = 0; k < SCM_I_ARRAY_NDIM (ra); k++)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-07-23 15:43:02 +00:00
|
|
|
|
inds = scm_cons (scm_from_long (s[k].lbnd), inds);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
if (s[k].ubnd < s[k].lbnd)
|
|
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (1 == SCM_I_ARRAY_NDIM (ra))
|
2009-07-18 12:58:37 +02:00
|
|
|
|
ra = scm_make_generalized_vector (scm_array_type (ra),
|
|
|
|
|
|
SCM_INUM0, SCM_UNDEFINED);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
else
|
2009-07-18 12:58:37 +02:00
|
|
|
|
SCM_I_ARRAY_V (ra) =
|
|
|
|
|
|
scm_make_generalized_vector (scm_array_type (ra),
|
|
|
|
|
|
SCM_INUM0, SCM_UNDEFINED);
|
2005-01-10 01:41:35 +00:00
|
|
|
|
scm_array_handle_release (&old_handle);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2005-01-10 01:41:35 +00:00
|
|
|
|
|
2001-06-26 15:46:40 +00:00
|
|
|
|
imap = scm_apply_0 (mapfunc, scm_reverse (inds));
|
2005-01-11 00:26:23 +00:00
|
|
|
|
i = scm_array_handle_pos (&old_handle, imap);
|
2006-04-17 00:05:42 +00:00
|
|
|
|
SCM_I_ARRAY_BASE (ra) = new_min = new_max = i + old_base;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
indptr = inds;
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
k = SCM_I_ARRAY_NDIM (ra);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
while (k--)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (s[k].ubnd > s[k].lbnd)
|
|
|
|
|
|
{
|
2004-07-23 15:43:02 +00:00
|
|
|
|
SCM_SETCAR (indptr, scm_sum (SCM_CAR (indptr), scm_from_int (1)));
|
2001-06-26 15:46:40 +00:00
|
|
|
|
imap = scm_apply_0 (mapfunc, scm_reverse (inds));
|
2005-01-11 00:26:23 +00:00
|
|
|
|
s[k].inc = scm_array_handle_pos (&old_handle, imap) - i;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i += s[k].inc;
|
|
|
|
|
|
if (s[k].inc > 0)
|
|
|
|
|
|
new_max += (s[k].ubnd - s[k].lbnd) * s[k].inc;
|
|
|
|
|
|
else
|
|
|
|
|
|
new_min += (s[k].ubnd - s[k].lbnd) * s[k].inc;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
s[k].inc = new_max - new_min + 1; /* contiguous by default */
|
|
|
|
|
|
indptr = SCM_CDR (indptr);
|
|
|
|
|
|
}
|
2005-01-10 01:41:35 +00:00
|
|
|
|
|
|
|
|
|
|
scm_array_handle_release (&old_handle);
|
|
|
|
|
|
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
if (old_min > new_min || old_max < new_max)
|
|
|
|
|
|
SCM_MISC_ERROR ("mapping out of range", SCM_EOL);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM v = SCM_I_ARRAY_V (ra);
|
* weaks.c: Use new vector elements API or simple vector
API, as appropriate.
* srfi-4.h, srfi-4.c, srfi-4.i.c (scm_array_handle_uniform_elements,
scm_array_handle_uniform_writable_elements,
scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
(scm_<foo>vector_elements, scm_<foo>vector_writable_elements): Use
scm_t_array_handle, deliver length and increment.
(scm_array_handle_<foo>_elements,
scm_array_handle_<foo>_writable_elements): New.
* unif.h, unif.c (scm_t_array_handle, scm_array_get_handle,
scm_array_handle_rank, scm_array_handle_dims, scm_array_handle_ref
scm_array_handle_set, scm_array_handle_elements
scm_array_handle_writable_elements, scm_vector_get_handle): New.
(scm_make_uve, scm_array_prototype, scm_list_to_uniform_array,
scm_dimensions_to_uniform_array): Deprecated for real. (scm_array_p,
scm_i_array_p): Use latter for SCM_DEFINE since snarfing wont allow a
mismatch between C and Scheme arglists. (scm_make_shared_array,
scm_enclose_array): Correctly use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
* weaks.h, weaks.c: Use new internal weak vector API from
vectors.h.
* Makefile.am (libguile_la_SOURCES, DOT_X_FILES, DOT_DOC_FILES,
EXTRA_libguile_la_SOURCES): Changed ramap.c and unif.c from being
'extra' to being regular sources.
(noinst_HEADERS): Added quicksort.i.c.
* quicksort.i.c: New file.
* vectors.h, vector.c (SCM_VECTORP, SCM_VECTOR_LENGTH, SCM_VELTS,
SCM_WRITABLE_VELTS, SCM_VECTOR_REF, SCM_VECTOR_SET): Deprecated and
reimplemented. Replaced all uses with scm_vector_elements,
scm_vector_writable_elements, or SCM_SIMPLE_VECTOR_*, as appropriate.
(scm_is_simple_vector, SCM_SIMPLE_VECTOR_LENGTH,
SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, SCM_SIMPLE_VECTOR_LOC):
New. (SCM_VECTOR_BASE, SCM_SET_VECTOR_BASE, SCM_VECTOR_MAX_LENGTH,
SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH, SCM_VELTS_AS_STACKITEMS,
SCM_SETVELTS, SCM_GC_WRITABLE_VELTS): Removed. (scm_vector_copy):
New. (scm_vector_elements, scm_vector_writable_elements): Use
scm_t_array_handle, deliver length and increment. Moved to
unif.h. Changed all uses. (scm_vector_release_elements,
scm_vector_release_writable_elements,
(scm_frame_vector_release_elements,
scm_frame_vector_release_writable_elements): Removed.
(SCM_I_IS_VECTOR, SCM_I_VECTOR_ELTS, SCM_I_VECTOR_WELTS,
SCM_I_VECTOR_LENGTH, scm_i_vector_free): New internal API.
(SCM_I_WVECTP SCM_I_WVECT_LENGTH SCM_I_WVECT_VELTS
SCM_I_WVECT_GC_WVELTS SCM_I_WVECT_TYPE SCM_I_WVECT_GC_CHAIN
SCM_I_SET_WVECT_GC_CHAIN, scm_i_allocate_weak_vector): New, for weak
vectors.
2005-01-02 20:06:08 +00:00
|
|
|
|
size_t length = scm_c_generalized_vector_length (v);
|
2000-10-11 12:24:43 +00:00
|
|
|
|
if (1 == s->inc && 0 == s->lbnd && length == 1 + s->ubnd)
|
|
|
|
|
|
return v;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
if (s->ubnd < s->lbnd)
|
2009-07-18 12:58:37 +02:00
|
|
|
|
return scm_make_generalized_vector (scm_array_type (ra), SCM_INUM0,
|
|
|
|
|
|
SCM_UNDEFINED);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2005-01-11 00:26:23 +00:00
|
|
|
|
scm_i_ra_set_contp (ra);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* args are RA . DIMS */
|
2000-05-18 08:47:52 +00:00
|
|
|
|
SCM_DEFINE (scm_transpose_array, "transpose-array", 1, 0, 1,
|
|
|
|
|
|
(SCM ra, SCM args),
|
2012-01-11 23:33:01 -05:00
|
|
|
|
"Return an array sharing contents with @var{ra}, but with\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"dimensions arranged in a different order. There must be one\n"
|
2012-01-11 23:33:01 -05:00
|
|
|
|
"@var{dim} argument for each dimension of @var{ra}.\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@var{dim0}, @var{dim1}, @dots{} should be integers between 0\n"
|
|
|
|
|
|
"and the rank of the array to be returned. Each integer in that\n"
|
|
|
|
|
|
"range must appear at least once in the argument list.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"The values of @var{dim0}, @var{dim1}, @dots{} correspond to\n"
|
|
|
|
|
|
"dimensions in the array to be returned, their positions in the\n"
|
2012-01-11 23:33:01 -05:00
|
|
|
|
"argument list to dimensions of @var{ra}. Several @var{dim}s\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"may have the same value, in which case the returned array will\n"
|
2012-01-11 23:33:01 -05:00
|
|
|
|
"have smaller rank than @var{ra}.\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"\n"
|
|
|
|
|
|
"@lisp\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"(transpose-array '#2((a b) (c d)) 1 0) @result{} #2((a c) (b d))\n"
|
|
|
|
|
|
"(transpose-array '#2((a b) (c d)) 0 0) @result{} #1(a d)\n"
|
|
|
|
|
|
"(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) @result{}\n"
|
|
|
|
|
|
" #2((a 4) (b 5) (c 6))\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@end lisp")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_transpose_array
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM res, vargs;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_array_dim *s, *r;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
int ndim, i, k;
|
2000-05-18 08:47:52 +00:00
|
|
|
|
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
SCM_VALIDATE_REST_ARGUMENT (args);
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_ASSERT (SCM_NIMP (ra), ra, SCM_ARG1, FUNC_NAME);
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
if (scm_is_generalized_vector (ra))
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
/* Make sure that we are called with a single zero as
|
|
|
|
|
|
arguments.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (scm_is_null (args) || !scm_is_null (SCM_CDR (args)))
|
|
|
|
|
|
SCM_WRONG_NUM_ARGS ();
|
|
|
|
|
|
SCM_VALIDATE_INT_COPY (SCM_ARG2, SCM_CAR (args), i);
|
|
|
|
|
|
SCM_ASSERT_RANGE (SCM_ARG2, SCM_CAR (args), i == 0);
|
|
|
|
|
|
return ra;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-07-17 12:45:24 +02:00
|
|
|
|
if (SCM_I_ARRAYP (ra))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
vargs = scm_vector (args);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (SCM_SIMPLE_VECTOR_LENGTH (vargs) != SCM_I_ARRAY_NDIM (ra))
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
SCM_WRONG_NUM_ARGS ();
|
1996-07-25 22:56:11 +00:00
|
|
|
|
ndim = 0;
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
for (k = 0; k < SCM_I_ARRAY_NDIM (ra); k++)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* weaks.c: Use new vector elements API or simple vector
API, as appropriate.
* srfi-4.h, srfi-4.c, srfi-4.i.c (scm_array_handle_uniform_elements,
scm_array_handle_uniform_writable_elements,
scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
(scm_<foo>vector_elements, scm_<foo>vector_writable_elements): Use
scm_t_array_handle, deliver length and increment.
(scm_array_handle_<foo>_elements,
scm_array_handle_<foo>_writable_elements): New.
* unif.h, unif.c (scm_t_array_handle, scm_array_get_handle,
scm_array_handle_rank, scm_array_handle_dims, scm_array_handle_ref
scm_array_handle_set, scm_array_handle_elements
scm_array_handle_writable_elements, scm_vector_get_handle): New.
(scm_make_uve, scm_array_prototype, scm_list_to_uniform_array,
scm_dimensions_to_uniform_array): Deprecated for real. (scm_array_p,
scm_i_array_p): Use latter for SCM_DEFINE since snarfing wont allow a
mismatch between C and Scheme arglists. (scm_make_shared_array,
scm_enclose_array): Correctly use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
* weaks.h, weaks.c: Use new internal weak vector API from
vectors.h.
* Makefile.am (libguile_la_SOURCES, DOT_X_FILES, DOT_DOC_FILES,
EXTRA_libguile_la_SOURCES): Changed ramap.c and unif.c from being
'extra' to being regular sources.
(noinst_HEADERS): Added quicksort.i.c.
* quicksort.i.c: New file.
* vectors.h, vector.c (SCM_VECTORP, SCM_VECTOR_LENGTH, SCM_VELTS,
SCM_WRITABLE_VELTS, SCM_VECTOR_REF, SCM_VECTOR_SET): Deprecated and
reimplemented. Replaced all uses with scm_vector_elements,
scm_vector_writable_elements, or SCM_SIMPLE_VECTOR_*, as appropriate.
(scm_is_simple_vector, SCM_SIMPLE_VECTOR_LENGTH,
SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, SCM_SIMPLE_VECTOR_LOC):
New. (SCM_VECTOR_BASE, SCM_SET_VECTOR_BASE, SCM_VECTOR_MAX_LENGTH,
SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH, SCM_VELTS_AS_STACKITEMS,
SCM_SETVELTS, SCM_GC_WRITABLE_VELTS): Removed. (scm_vector_copy):
New. (scm_vector_elements, scm_vector_writable_elements): Use
scm_t_array_handle, deliver length and increment. Moved to
unif.h. Changed all uses. (scm_vector_release_elements,
scm_vector_release_writable_elements,
(scm_frame_vector_release_elements,
scm_frame_vector_release_writable_elements): Removed.
(SCM_I_IS_VECTOR, SCM_I_VECTOR_ELTS, SCM_I_VECTOR_WELTS,
SCM_I_VECTOR_LENGTH, scm_i_vector_free): New internal API.
(SCM_I_WVECTP SCM_I_WVECT_LENGTH SCM_I_WVECT_VELTS
SCM_I_WVECT_GC_WVELTS SCM_I_WVECT_TYPE SCM_I_WVECT_GC_CHAIN
SCM_I_SET_WVECT_GC_CHAIN, scm_i_allocate_weak_vector): New, for weak
vectors.
2005-01-02 20:06:08 +00:00
|
|
|
|
i = scm_to_signed_integer (SCM_SIMPLE_VECTOR_REF (vargs, k),
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
0, SCM_I_ARRAY_NDIM(ra));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
if (ndim < i)
|
|
|
|
|
|
ndim = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
ndim++;
|
2009-07-17 12:45:24 +02:00
|
|
|
|
res = scm_i_make_array (ndim);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_V (res) = SCM_I_ARRAY_V (ra);
|
|
|
|
|
|
SCM_I_ARRAY_BASE (res) = SCM_I_ARRAY_BASE (ra);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
for (k = ndim; k--;)
|
|
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_DIMS (res)[k].lbnd = 0;
|
|
|
|
|
|
SCM_I_ARRAY_DIMS (res)[k].ubnd = -1;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
for (k = SCM_I_ARRAY_NDIM (ra); k--;)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* weaks.c: Use new vector elements API or simple vector
API, as appropriate.
* srfi-4.h, srfi-4.c, srfi-4.i.c (scm_array_handle_uniform_elements,
scm_array_handle_uniform_writable_elements,
scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
(scm_<foo>vector_elements, scm_<foo>vector_writable_elements): Use
scm_t_array_handle, deliver length and increment.
(scm_array_handle_<foo>_elements,
scm_array_handle_<foo>_writable_elements): New.
* unif.h, unif.c (scm_t_array_handle, scm_array_get_handle,
scm_array_handle_rank, scm_array_handle_dims, scm_array_handle_ref
scm_array_handle_set, scm_array_handle_elements
scm_array_handle_writable_elements, scm_vector_get_handle): New.
(scm_make_uve, scm_array_prototype, scm_list_to_uniform_array,
scm_dimensions_to_uniform_array): Deprecated for real. (scm_array_p,
scm_i_array_p): Use latter for SCM_DEFINE since snarfing wont allow a
mismatch between C and Scheme arglists. (scm_make_shared_array,
scm_enclose_array): Correctly use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
* weaks.h, weaks.c: Use new internal weak vector API from
vectors.h.
* Makefile.am (libguile_la_SOURCES, DOT_X_FILES, DOT_DOC_FILES,
EXTRA_libguile_la_SOURCES): Changed ramap.c and unif.c from being
'extra' to being regular sources.
(noinst_HEADERS): Added quicksort.i.c.
* quicksort.i.c: New file.
* vectors.h, vector.c (SCM_VECTORP, SCM_VECTOR_LENGTH, SCM_VELTS,
SCM_WRITABLE_VELTS, SCM_VECTOR_REF, SCM_VECTOR_SET): Deprecated and
reimplemented. Replaced all uses with scm_vector_elements,
scm_vector_writable_elements, or SCM_SIMPLE_VECTOR_*, as appropriate.
(scm_is_simple_vector, SCM_SIMPLE_VECTOR_LENGTH,
SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, SCM_SIMPLE_VECTOR_LOC):
New. (SCM_VECTOR_BASE, SCM_SET_VECTOR_BASE, SCM_VECTOR_MAX_LENGTH,
SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH, SCM_VELTS_AS_STACKITEMS,
SCM_SETVELTS, SCM_GC_WRITABLE_VELTS): Removed. (scm_vector_copy):
New. (scm_vector_elements, scm_vector_writable_elements): Use
scm_t_array_handle, deliver length and increment. Moved to
unif.h. Changed all uses. (scm_vector_release_elements,
scm_vector_release_writable_elements,
(scm_frame_vector_release_elements,
scm_frame_vector_release_writable_elements): Removed.
(SCM_I_IS_VECTOR, SCM_I_VECTOR_ELTS, SCM_I_VECTOR_WELTS,
SCM_I_VECTOR_LENGTH, scm_i_vector_free): New internal API.
(SCM_I_WVECTP SCM_I_WVECT_LENGTH SCM_I_WVECT_VELTS
SCM_I_WVECT_GC_WVELTS SCM_I_WVECT_TYPE SCM_I_WVECT_GC_CHAIN
SCM_I_SET_WVECT_GC_CHAIN, scm_i_allocate_weak_vector): New, for weak
vectors.
2005-01-02 20:06:08 +00:00
|
|
|
|
i = scm_to_int (SCM_SIMPLE_VECTOR_REF (vargs, k));
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
s = &(SCM_I_ARRAY_DIMS (ra)[k]);
|
|
|
|
|
|
r = &(SCM_I_ARRAY_DIMS (res)[i]);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
if (r->ubnd < r->lbnd)
|
|
|
|
|
|
{
|
|
|
|
|
|
r->lbnd = s->lbnd;
|
|
|
|
|
|
r->ubnd = s->ubnd;
|
|
|
|
|
|
r->inc = s->inc;
|
|
|
|
|
|
ndim--;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (r->ubnd > s->ubnd)
|
|
|
|
|
|
r->ubnd = s->ubnd;
|
|
|
|
|
|
if (r->lbnd < s->lbnd)
|
|
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_BASE (res) += (s->lbnd - r->lbnd) * r->inc;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
r->lbnd = s->lbnd;
|
|
|
|
|
|
}
|
|
|
|
|
|
r->inc += s->inc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
SCM_WTA_DISPATCH_2, SCM_WTA_DISPATCH_n): Don't call scm_wta, call
scm_wrong_type_arg instead.
(SCM_WNA): Deprecated.
* error.[ch] (scm_wta): Deprecated.
* numbers.c (s_i_log): Minor comment fix.
* read.c (scm_lreadr), unif.c (scm_aind, scm_shap2ra,
scm_make_shared_array, scm_transpose_array, scm_enclose_array,
scm_array_in_bounds_p): Don't use SCM_ASSERT to check for
wrong-num-args or misc errors.
* unif.c (scm_make_shared_array, scm_transpose_array,
scm_enclose_array, scm_array_in_bounds_p, scm_array_set_x):
Validate the rest argument (note: this is only done when guile is
built with SCM_DEBUG_REST_ARGUMENT=1)
(scm_array_in_bounds_p, scm_uniform_vector_ref, scm_array_set_x):
Replace calls to scm_wrong_num_args by SCM_WRONG_NUM_ARGS.
* validate.h (SCM_FUNC_NAME, SCM_VALIDATE_NUMBER_COPY,
SCM_VALIDATE_NUMBER_DEF_COPY): Deprecated.
2001-03-17 13:34:21 +00:00
|
|
|
|
if (ndim > 0)
|
|
|
|
|
|
SCM_MISC_ERROR ("bad argument list", SCM_EOL);
|
2005-01-11 00:26:23 +00:00
|
|
|
|
scm_i_ra_set_contp (res);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
|
|
|
|
|
|
scm_wrong_type_arg_msg (NULL, 0, ra, "array");
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1999-11-30 18:23:52 +00:00
|
|
|
|
/* attempts to unroll an array into a one-dimensional array.
|
|
|
|
|
|
returns the unrolled array or #f if it can't be done. */
|
1999-12-12 02:36:16 +00:00
|
|
|
|
/* if strict is not SCM_UNDEFINED, return #f if returned array
|
1999-11-30 18:23:52 +00:00
|
|
|
|
wouldn't have contiguous elements. */
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_array_contents, "array-contents", 1, 1, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM ra, SCM strict),
|
2012-01-11 23:33:01 -05:00
|
|
|
|
"If @var{ra} may be @dfn{unrolled} into a one dimensional shared\n"
|
|
|
|
|
|
"array without changing their order (last subscript changing\n"
|
|
|
|
|
|
"fastest), then @code{array-contents} returns that shared array,\n"
|
|
|
|
|
|
"otherwise it returns @code{#f}. All arrays made by\n"
|
|
|
|
|
|
"@code{make-array} and @code{make-uniform-array} may be unrolled,\n"
|
|
|
|
|
|
"some arrays made by @code{make-shared-array} may not be. If\n"
|
|
|
|
|
|
"the optional argument @var{strict} is provided, a shared array\n"
|
|
|
|
|
|
"will be returned only if its elements are stored internally\n"
|
|
|
|
|
|
"contiguous in memory.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_array_contents
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM sra;
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
if (scm_is_generalized_vector (ra))
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
return ra;
|
|
|
|
|
|
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (SCM_I_ARRAYP (ra))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
size_t k, ndim = SCM_I_ARRAY_NDIM (ra), len = 1;
|
|
|
|
|
|
if (!SCM_I_ARRAYP (ra) || !SCM_I_ARRAY_CONTP (ra))
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
for (k = 0; k < ndim; k++)
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
len *= SCM_I_ARRAY_DIMS (ra)[k].ubnd - SCM_I_ARRAY_DIMS (ra)[k].lbnd + 1;
|
2009-07-18 12:58:37 +02:00
|
|
|
|
if (!SCM_UNBNDP (strict) && scm_is_true (strict))
|
2000-10-11 12:24:43 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (ndim && (1 != SCM_I_ARRAY_DIMS (ra)[ndim - 1].inc))
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
return SCM_BOOL_F;
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (scm_is_bitvector (SCM_I_ARRAY_V (ra)))
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if (len != scm_c_bitvector_length (SCM_I_ARRAY_V (ra)) ||
|
|
|
|
|
|
SCM_I_ARRAY_BASE (ra) % SCM_LONG_BIT ||
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
len % SCM_LONG_BIT)
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
2000-10-11 12:24:43 +00:00
|
|
|
|
}
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
|
|
|
|
|
|
{
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM v = SCM_I_ARRAY_V (ra);
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
size_t length = scm_c_generalized_vector_length (v);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
if ((len == length) && 0 == SCM_I_ARRAY_BASE (ra) && SCM_I_ARRAY_DIMS (ra)->inc)
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
return v;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
|
2009-07-17 12:45:24 +02:00
|
|
|
|
sra = scm_i_make_array (1);
|
(SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version. Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
|
|
|
|
SCM_I_ARRAY_DIMS (sra)->lbnd = 0;
|
|
|
|
|
|
SCM_I_ARRAY_DIMS (sra)->ubnd = len - 1;
|
|
|
|
|
|
SCM_I_ARRAY_V (sra) = SCM_I_ARRAY_V (ra);
|
|
|
|
|
|
SCM_I_ARRAY_BASE (sra) = SCM_I_ARRAY_BASE (ra);
|
|
|
|
|
|
SCM_I_ARRAY_DIMS (sra)->inc = (ndim ? SCM_I_ARRAY_DIMS (ra)[ndim - 1].inc : 1);
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
return sra;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
(scm_tc16_enclosed_array, SCM_ENCLOSED_ARRAYP):
New.
(exactly_one_third, singp): Removed.
(scm_array_p, scm_array_dimensions, scm_shared_array_root,
scm_shared_array_offset, scm_shared_array_increments): Handle
enclosed arrays explicitely.
(scm_array_rank): Likewise. Also, do not return zero for
non-arrays, signal an error instead since arrays with rank zero do
exist.
(scm_i_make_ra): New, for specifying the tag of the new array.
(scm_make_enclosed_array): Use it.
(scm_make_ra): Reimplemented in terms of scm_i_make_ra.
(scm_make_shared_array): Use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.
(scm_array_in_bounds_p): Rewritten to be much cleaner.
(scm_i_cvref): New, doing the job of scm_cvref.
(scm_cvref): Use scm_i_cvref.
(scm_array_ref): Do not accept non-arrays when no indices are
given. Use scm_i_cvref to do the actual access.
("uniform-array-set1"): Do not register.
(scm_array_set_x, scm_uniform_array_read_x,
scm_uniform_array_write): Handle enclosed arrays explicitly.
(ra2l): Use scm_i_cvref instead of scm_uniform_vector_ref to also
handle enclosed arrays.
(scm_array_to_list): Handle enclosed arrays explicitly.
(rapr1): Removed.
(scm_i_print_array_dimension): Use scm_i_cvref to also handle
enclosed arrays.
(scm_i_print_enclosed_array): New.
(tag_proto_table, tag_creator_table): Renamed former to latter.
Added "a" and "b" for strings and bitvectors, resp.
(scm_i_tag_to_prototype, scm_i_tag_to_creator): Renamed former to
latter. Tag "a" is in the table now, no need to handle it as a
legacy tag.
(scm_raprin1): Just call scm_iprin1.
(scm_array_creator, scm_array_prototype): Handle enclosed arrays
explicitly.
(scm_init_unif): Initialize scm_tc16_enclosed_array smob.
Use scm_i_print_array as printer for scm_tc16_array.
2004-11-12 18:55:25 +00:00
|
|
|
|
else
|
|
|
|
|
|
scm_wrong_type_arg_msg (NULL, 0, ra, "array");
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
2009-07-18 12:58:37 +02:00
|
|
|
|
static void
|
|
|
|
|
|
list_to_array (SCM lst, scm_t_array_handle *handle, ssize_t pos, size_t k)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (k == scm_array_handle_rank (handle))
|
|
|
|
|
|
scm_array_handle_set (handle, pos, lst);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_array_dim *dim = scm_array_handle_dims (handle) + k;
|
|
|
|
|
|
ssize_t inc = dim->inc;
|
|
|
|
|
|
size_t len = 1 + dim->ubnd - dim->lbnd, n;
|
|
|
|
|
|
char *errmsg = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
n = len;
|
|
|
|
|
|
while (n > 0 && scm_is_pair (lst))
|
|
|
|
|
|
{
|
|
|
|
|
|
list_to_array (SCM_CAR (lst), handle, pos, k + 1);
|
|
|
|
|
|
pos += inc;
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
n -= 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (n != 0)
|
|
|
|
|
|
errmsg = "too few elements for array dimension ~a, need ~a";
|
|
|
|
|
|
if (!scm_is_null (lst))
|
|
|
|
|
|
errmsg = "too many elements for array dimension ~a, want ~a";
|
|
|
|
|
|
if (errmsg)
|
|
|
|
|
|
scm_misc_error (NULL, errmsg, scm_list_2 (scm_from_ulong (k),
|
|
|
|
|
|
scm_from_size_t (len)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
SCM_DEFINE (scm_list_to_typed_array, "list->typed-array", 3, 0, 0,
|
2005-01-10 19:06:48 +00:00
|
|
|
|
(SCM type, SCM shape, SCM lst),
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
"Return an array of the type @var{type}\n"
|
|
|
|
|
|
"with elements the same as those of @var{lst}.\n"
|
2004-10-29 14:41:14 +00:00
|
|
|
|
"\n"
|
2005-01-10 19:06:48 +00:00
|
|
|
|
"The argument @var{shape} determines the number of dimensions\n"
|
|
|
|
|
|
"of the array and their shape. It is either an exact integer,\n"
|
|
|
|
|
|
"giving the\n"
|
|
|
|
|
|
"number of dimensions directly, or a list whose length\n"
|
|
|
|
|
|
"specifies the number of dimensions and each element specified\n"
|
|
|
|
|
|
"the lower and optionally the upper bound of the corresponding\n"
|
|
|
|
|
|
"dimension.\n"
|
|
|
|
|
|
"When the element is list of two elements, these elements\n"
|
|
|
|
|
|
"give the lower and upper bounds. When it is an exact\n"
|
|
|
|
|
|
"integer, it gives only the lower bound.")
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_to_typed_array
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
SCM row;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM ra;
|
2005-01-09 17:45:59 +00:00
|
|
|
|
scm_t_array_handle handle;
|
2004-10-29 14:41:14 +00:00
|
|
|
|
|
|
|
|
|
|
row = lst;
|
2005-01-10 19:06:48 +00:00
|
|
|
|
if (scm_is_integer (shape))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
size_t k = scm_to_size_t (shape);
|
|
|
|
|
|
shape = SCM_EOL;
|
2004-10-29 14:41:14 +00:00
|
|
|
|
while (k-- > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
shape = scm_cons (scm_length (row), shape);
|
2005-01-10 19:06:48 +00:00
|
|
|
|
if (k > 0 && !scm_is_null (row))
|
2004-10-29 14:41:14 +00:00
|
|
|
|
row = scm_car (row);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
SCM shape_spec = shape;
|
|
|
|
|
|
shape = SCM_EOL;
|
2004-10-29 14:41:14 +00:00
|
|
|
|
while (1)
|
|
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
SCM spec = scm_car (shape_spec);
|
|
|
|
|
|
if (scm_is_pair (spec))
|
|
|
|
|
|
shape = scm_cons (spec, shape);
|
|
|
|
|
|
else
|
|
|
|
|
|
shape = scm_cons (scm_list_2 (spec,
|
|
|
|
|
|
scm_sum (scm_sum (spec,
|
|
|
|
|
|
scm_length (row)),
|
|
|
|
|
|
scm_from_int (-1))),
|
|
|
|
|
|
shape);
|
|
|
|
|
|
shape_spec = scm_cdr (shape_spec);
|
|
|
|
|
|
if (scm_is_pair (shape_spec))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!scm_is_null (row))
|
|
|
|
|
|
row = scm_car (row);
|
|
|
|
|
|
}
|
2004-10-29 14:41:14 +00:00
|
|
|
|
else
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2004-10-29 14:41:14 +00:00
|
|
|
|
|
2005-01-04 23:31:19 +00:00
|
|
|
|
ra = scm_make_typed_array (type, SCM_UNSPECIFIED,
|
|
|
|
|
|
scm_reverse_x (shape, SCM_EOL));
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
|
2005-01-09 17:45:59 +00:00
|
|
|
|
scm_array_get_handle (ra, &handle);
|
2009-07-18 12:58:37 +02:00
|
|
|
|
list_to_array (lst, &handle, 0, 0);
|
2005-01-09 17:45:59 +00:00
|
|
|
|
scm_array_handle_release (&handle);
|
|
|
|
|
|
|
|
|
|
|
|
return ra;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.
* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
|
|
|
|
SCM_DEFINE (scm_list_to_array, "list->array", 2, 0, 0,
|
|
|
|
|
|
(SCM ndim, SCM lst),
|
|
|
|
|
|
"Return an array with elements the same as those of @var{lst}.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_list_to_array
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_list_to_typed_array (SCM_BOOL_T, ndim, lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
/* Print dimension DIM of ARRAY.
|
|
|
|
|
|
*/
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
static int
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_i_print_array_dimension (scm_t_array_handle *h, int dim, int pos,
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
SCM port, scm_print_state *pstate)
|
|
|
|
|
|
{
|
2009-07-18 12:58:37 +02:00
|
|
|
|
if (dim == h->ndims)
|
|
|
|
|
|
scm_iprin1 (scm_array_handle_ref (h, pos), port, pstate);
|
|
|
|
|
|
else
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
{
|
2009-07-18 12:58:37 +02:00
|
|
|
|
ssize_t i;
|
|
|
|
|
|
scm_putc ('(', port);
|
|
|
|
|
|
for (i = h->dims[dim].lbnd; i <= h->dims[dim].ubnd;
|
|
|
|
|
|
i++, pos += h->dims[dim].inc)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_i_print_array_dimension (h, dim+1, pos, port, pstate);
|
|
|
|
|
|
if (i < h->dims[dim].ubnd)
|
|
|
|
|
|
scm_putc (' ', port);
|
|
|
|
|
|
}
|
|
|
|
|
|
scm_putc (')', port);
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-07-18 12:58:37 +02:00
|
|
|
|
/* Print an array.
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2012-01-09 17:24:57 +01:00
|
|
|
|
int
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
scm_i_print_array (SCM array, SCM port, scm_print_state *pstate)
|
|
|
|
|
|
{
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_t_array_handle h;
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
long i;
|
2005-01-10 19:06:48 +00:00
|
|
|
|
int print_lbnds = 0, zero_size = 0, print_lens = 0;
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_array_get_handle (array, &h);
|
|
|
|
|
|
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
scm_putc ('#', port);
|
2009-07-18 12:58:37 +02:00
|
|
|
|
if (h.ndims != 1 || h.dims[0].lbnd != 0)
|
|
|
|
|
|
scm_intprint (h.ndims, 10, port);
|
|
|
|
|
|
if (h.element_type != SCM_ARRAY_ELEMENT_TYPE_SCM)
|
|
|
|
|
|
scm_write (scm_array_handle_element_type (&h), port);
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
|
2009-07-18 12:58:37 +02:00
|
|
|
|
for (i = 0; i < h.ndims; i++)
|
2005-01-10 19:06:48 +00:00
|
|
|
|
{
|
2009-07-18 12:58:37 +02:00
|
|
|
|
if (h.dims[i].lbnd != 0)
|
2005-01-10 19:06:48 +00:00
|
|
|
|
print_lbnds = 1;
|
2009-07-18 12:58:37 +02:00
|
|
|
|
if (h.dims[i].ubnd - h.dims[i].lbnd + 1 == 0)
|
2005-01-10 19:06:48 +00:00
|
|
|
|
zero_size = 1;
|
|
|
|
|
|
else if (zero_size)
|
|
|
|
|
|
print_lens = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (print_lbnds || print_lens)
|
2009-07-18 12:58:37 +02:00
|
|
|
|
for (i = 0; i < h.ndims; i++)
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
if (print_lbnds)
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_putc ('@', port);
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_intprint (h.dims[i].lbnd, 10, port);
|
2005-01-10 19:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (print_lens)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_putc (':', port);
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_intprint (h.dims[i].ubnd - h.dims[i].lbnd + 1,
|
2005-01-10 19:06:48 +00:00
|
|
|
|
10, port);
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-07-18 12:58:37 +02:00
|
|
|
|
if (h.ndims == 0)
|
2005-01-09 15:41:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
/* Rank zero arrays, which are really just scalars, are printed
|
|
|
|
|
|
specially. The consequent way would be to print them as
|
|
|
|
|
|
|
|
|
|
|
|
#0 OBJ
|
|
|
|
|
|
|
|
|
|
|
|
where OBJ is the printed representation of the scalar, but we
|
|
|
|
|
|
print them instead as
|
|
|
|
|
|
|
|
|
|
|
|
#0(OBJ)
|
|
|
|
|
|
|
|
|
|
|
|
to make them look less strange.
|
|
|
|
|
|
|
|
|
|
|
|
Just printing them as
|
|
|
|
|
|
|
|
|
|
|
|
OBJ
|
|
|
|
|
|
|
|
|
|
|
|
would be correct in a way as well, but zero rank arrays are
|
|
|
|
|
|
not really the same as Scheme values since they are boxed and
|
|
|
|
|
|
can be modified with array-set!, say.
|
|
|
|
|
|
*/
|
|
|
|
|
|
scm_putc ('(', port);
|
2009-07-18 12:58:37 +02:00
|
|
|
|
scm_i_print_array_dimension (&h, 0, 0, port, pstate);
|
2005-01-09 15:41:22 +00:00
|
|
|
|
scm_putc (')', port);
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2009-07-18 12:58:37 +02:00
|
|
|
|
return scm_i_print_array_dimension (&h, 0, 0, port, pstate);
|
* srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.
* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors. Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays. Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
|
|
|
|
}
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
2004-10-29 14:41:14 +00:00
|
|
|
|
/* Read an array. This function can also read vectors and uniform
|
|
|
|
|
|
vectors. Also, the conflict between '#f' and '#f32' and '#f64' is
|
|
|
|
|
|
handled here.
|
|
|
|
|
|
|
|
|
|
|
|
C is the first character read after the '#'.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
static int
|
|
|
|
|
|
read_decimal_integer (SCM port, int c, ssize_t *resp)
|
|
|
|
|
|
{
|
|
|
|
|
|
ssize_t sign = 1;
|
|
|
|
|
|
ssize_t res = 0;
|
|
|
|
|
|
int got_it = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (c == '-')
|
|
|
|
|
|
{
|
|
|
|
|
|
sign = -1;
|
|
|
|
|
|
c = scm_getc (port);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while ('0' <= c && c <= '9')
|
|
|
|
|
|
{
|
|
|
|
|
|
res = 10*res + c-'0';
|
|
|
|
|
|
got_it = 1;
|
|
|
|
|
|
c = scm_getc (port);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (got_it)
|
2006-12-12 14:01:40 +00:00
|
|
|
|
*resp = sign * res;
|
2005-01-10 19:06:48 +00:00
|
|
|
|
return c;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-10-29 14:41:14 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_i_read_array (SCM port, int c)
|
|
|
|
|
|
{
|
2005-05-12 06:39:50 +00:00
|
|
|
|
ssize_t rank;
|
2011-07-28 19:04:38 +02:00
|
|
|
|
scm_t_wchar tag_buf[8];
|
2004-10-29 14:41:14 +00:00
|
|
|
|
int tag_len;
|
|
|
|
|
|
|
2011-07-28 19:04:38 +02:00
|
|
|
|
SCM tag, shape = SCM_BOOL_F, elements;
|
2004-10-29 14:41:14 +00:00
|
|
|
|
|
|
|
|
|
|
/* XXX - shortcut for ordinary vectors. Shouldn't be necessary but
|
|
|
|
|
|
the array code can not deal with zero-length dimensions yet, and
|
|
|
|
|
|
we want to allow zero-length vectors, of course.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (c == '(')
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_ungetc (c, port);
|
|
|
|
|
|
return scm_vector (scm_read (port));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Disambiguate between '#f' and uniform floating point vectors.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (c == 'f')
|
|
|
|
|
|
{
|
|
|
|
|
|
c = scm_getc (port);
|
|
|
|
|
|
if (c != '3' && c != '6')
|
|
|
|
|
|
{
|
|
|
|
|
|
if (c != EOF)
|
|
|
|
|
|
scm_ungetc (c, port);
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
rank = 1;
|
2011-07-28 19:04:38 +02:00
|
|
|
|
tag_buf[0] = 'f';
|
2004-10-29 14:41:14 +00:00
|
|
|
|
tag_len = 1;
|
|
|
|
|
|
goto continue_reading_tag;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
/* Read rank.
|
|
|
|
|
|
*/
|
|
|
|
|
|
rank = 1;
|
|
|
|
|
|
c = read_decimal_integer (port, c, &rank);
|
|
|
|
|
|
if (rank < 0)
|
|
|
|
|
|
scm_i_input_error (NULL, port, "array rank must be non-negative",
|
|
|
|
|
|
SCM_EOL);
|
2004-10-29 14:41:14 +00:00
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
/* Read tag.
|
|
|
|
|
|
*/
|
2004-10-29 14:41:14 +00:00
|
|
|
|
tag_len = 0;
|
|
|
|
|
|
continue_reading_tag:
|
2011-07-28 19:04:38 +02:00
|
|
|
|
while (c != EOF && c != '(' && c != '@' && c != ':'
|
|
|
|
|
|
&& tag_len < sizeof tag_buf / sizeof tag_buf[0])
|
2004-10-29 14:41:14 +00:00
|
|
|
|
{
|
2011-07-28 19:04:38 +02:00
|
|
|
|
tag_buf[tag_len++] = c;
|
2004-10-29 14:41:14 +00:00
|
|
|
|
c = scm_getc (port);
|
|
|
|
|
|
}
|
2011-07-28 19:04:38 +02:00
|
|
|
|
if (tag_len == 0)
|
|
|
|
|
|
tag = SCM_BOOL_T;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
tag = scm_string_to_symbol (scm_from_utf32_stringn (tag_buf, tag_len));
|
|
|
|
|
|
if (tag_len == sizeof tag_buf / sizeof tag_buf[0])
|
|
|
|
|
|
scm_i_input_error (NULL, port, "invalid array tag, starting with: ~a",
|
|
|
|
|
|
scm_list_1 (tag));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
/* Read shape.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (c == '@' || c == ':')
|
2004-10-29 14:41:14 +00:00
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
shape = SCM_EOL;
|
2005-01-09 15:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
do
|
2004-10-29 14:41:14 +00:00
|
|
|
|
{
|
2005-01-10 19:06:48 +00:00
|
|
|
|
ssize_t lbnd = 0, len = 0;
|
|
|
|
|
|
SCM s;
|
2005-01-09 15:41:22 +00:00
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
if (c == '@')
|
2005-01-09 15:41:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
c = scm_getc (port);
|
2005-01-10 19:06:48 +00:00
|
|
|
|
c = read_decimal_integer (port, c, &lbnd);
|
2005-01-09 15:41:22 +00:00
|
|
|
|
}
|
2005-01-10 19:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
s = scm_from_ssize_t (lbnd);
|
|
|
|
|
|
|
|
|
|
|
|
if (c == ':')
|
2005-01-09 15:41:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
c = scm_getc (port);
|
2005-01-10 19:06:48 +00:00
|
|
|
|
c = read_decimal_integer (port, c, &len);
|
2006-12-12 14:01:40 +00:00
|
|
|
|
if (len < 0)
|
|
|
|
|
|
scm_i_input_error (NULL, port,
|
|
|
|
|
|
"array length must be non-negative",
|
|
|
|
|
|
SCM_EOL);
|
|
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
s = scm_list_2 (s, scm_from_ssize_t (lbnd+len-1));
|
2005-01-09 15:41:22 +00:00
|
|
|
|
}
|
2005-01-10 19:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
shape = scm_cons (s, shape);
|
|
|
|
|
|
} while (c == '@' || c == ':');
|
|
|
|
|
|
|
|
|
|
|
|
shape = scm_reverse_x (shape, SCM_EOL);
|
2004-10-29 14:41:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Read nested lists of elements.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (c != '(')
|
|
|
|
|
|
scm_i_input_error (NULL, port,
|
|
|
|
|
|
"missing '(' in vector or array literal",
|
|
|
|
|
|
SCM_EOL);
|
|
|
|
|
|
scm_ungetc (c, port);
|
|
|
|
|
|
elements = scm_read (port);
|
|
|
|
|
|
|
2005-01-10 19:06:48 +00:00
|
|
|
|
if (scm_is_false (shape))
|
2005-05-12 06:39:50 +00:00
|
|
|
|
shape = scm_from_ssize_t (rank);
|
2005-01-10 19:06:48 +00:00
|
|
|
|
else if (scm_ilength (shape) != rank)
|
|
|
|
|
|
scm_i_input_error
|
|
|
|
|
|
(NULL, port,
|
|
|
|
|
|
"the number of shape specifications must match the array rank",
|
|
|
|
|
|
SCM_EOL);
|
2004-10-29 14:41:14 +00:00
|
|
|
|
|
2005-01-09 15:41:22 +00:00
|
|
|
|
/* Handle special print syntax of rank zero arrays; see
|
|
|
|
|
|
scm_i_print_array for a rationale.
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (rank == 0)
|
2005-01-10 19:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (!scm_is_pair (elements))
|
|
|
|
|
|
scm_i_input_error (NULL, port,
|
|
|
|
|
|
"too few elements in array literal, need 1",
|
|
|
|
|
|
SCM_EOL);
|
|
|
|
|
|
if (!scm_is_null (SCM_CDR (elements)))
|
|
|
|
|
|
scm_i_input_error (NULL, port,
|
|
|
|
|
|
"too many elements in array literal, want 1",
|
|
|
|
|
|
SCM_EOL);
|
|
|
|
|
|
elements = SCM_CAR (elements);
|
|
|
|
|
|
}
|
2005-01-09 15:41:22 +00:00
|
|
|
|
|
|
|
|
|
|
/* Construct array.
|
|
|
|
|
|
*/
|
2011-07-28 19:04:38 +02:00
|
|
|
|
return scm_list_to_typed_array (tag, shape, elements);
|
2004-10-29 14:41:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-10-29 15:41:26 +00:00
|
|
|
|
|
2009-07-19 15:04:40 +02:00
|
|
|
|
static SCM
|
|
|
|
|
|
array_handle_ref (scm_t_array_handle *h, size_t pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_c_generalized_vector_ref (SCM_I_ARRAY_V (h->array), pos);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
array_handle_set (scm_t_array_handle *h, size_t pos, SCM val)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_c_generalized_vector_set_x (SCM_I_ARRAY_V (h->array), pos, val);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: should be handle for vect? maybe not, because of dims */
|
|
|
|
|
|
static void
|
|
|
|
|
|
array_get_handle (SCM array, scm_t_array_handle *h)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_t_array_handle vh;
|
|
|
|
|
|
scm_array_get_handle (SCM_I_ARRAY_V (array), &vh);
|
|
|
|
|
|
h->element_type = vh.element_type;
|
|
|
|
|
|
h->elements = vh.elements;
|
|
|
|
|
|
h->writable_elements = vh.writable_elements;
|
|
|
|
|
|
scm_array_handle_release (&vh);
|
|
|
|
|
|
|
|
|
|
|
|
h->dims = SCM_I_ARRAY_DIMS (array);
|
|
|
|
|
|
h->ndims = SCM_I_ARRAY_NDIM (array);
|
|
|
|
|
|
h->base = SCM_I_ARRAY_BASE (array);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-01-09 17:24:57 +01:00
|
|
|
|
SCM_ARRAY_IMPLEMENTATION (scm_tc7_array,
|
|
|
|
|
|
0x7f,
|
2009-07-19 15:04:40 +02:00
|
|
|
|
array_handle_ref, array_handle_set,
|
2009-12-15 00:53:13 +01:00
|
|
|
|
array_get_handle)
|
2009-07-19 15:04:40 +02:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
2009-07-17 01:08:35 +02:00
|
|
|
|
scm_init_arrays ()
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_add_feature ("array");
|
(scm_bitvector_p, scm_bitvector,
scm_make_bitvector, scm_bitvector_length, scm_bitvector_ref,
scm_bitvector_set_x, scm_list_to_bitvector, scm_bitvector_to_list,
scm_bitvector_fill_x, scm_is_bitvector, scm_c_make_bitvector,
scm_c_bitvector_length, scm_c_bitvector_ref,
scm_c_bitvector_set_x, scm_bitvector_elements,
scm_bitvector_release, scm_frame_bitvector_release,
scm_tc16_bitvector, bitvector_free, bitvector_print,
bitvector_equalp, count_ones, find_first_one): New.
(scm_bit_count, scm_bit_position, scm_bit_set_star_x,
scm_bit_count_star, scm_bit_invert_x, scm_istr2bve): Rewritten
using the new C API for bitvectors and maybe count_ones or
find_first_one, as appropriate.
(SCM_I_MAX_LENGTH, SCM_BITVECTOR_P, SCM_BITVECTOR_BASE,
SCM_SET_BITVECTOR_BASE, SCM_BITVECTOR_MAX_LENGTH,
SCM_BITVECTOR_LENGTH, SCM_MAKE_BITVECTOR_TAG,
SCM_SET_BITVECTOR_LENGTH): Removed. Replaced all uses with the
new functions from above.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Made non-static for use in
scm_i_generalized_vector_creator.
(scm_make_u1vector): Removed, replaced by scm_make_bitvector.
(scm_make_uve): Validate that the created object is a generalized
vector.
(scm_i_legacy_tag): Removed.
(scm_i_print_array): Do it here.
(scm_raprin1): Only print enclosed arrays.
2004-11-09 16:16:19 +00:00
|
|
|
|
|
2009-07-17 01:08:35 +02:00
|
|
|
|
#include "libguile/arrays.x"
|
2004-10-29 14:41:14 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|