6 /* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "libguile/__scm.h"
27 #include "libguile/print.h"
28 #include "libguile/array-handle.h"
32 /* This file contains the definitions for arrays and bit vectors.
33 Uniform numeric vectors are now in srfi-4.c.
39 SCM_API SCM
scm_array_p (SCM v
);
40 SCM_API SCM
scm_typed_array_p (SCM v
, SCM type
);
41 SCM_API SCM
scm_make_array (SCM fill
, SCM bounds
);
42 SCM_API SCM
scm_make_typed_array (SCM type
, SCM fill
, SCM bounds
);
43 SCM_API SCM
scm_from_contiguous_typed_array (SCM type
, SCM bounds
,
46 SCM_API SCM
scm_array_rank (SCM ra
);
47 SCM_API
size_t scm_c_array_rank (SCM ra
);
48 SCM_API SCM
scm_array_dimensions (SCM ra
);
49 SCM_API SCM
scm_shared_array_root (SCM ra
);
50 SCM_API SCM
scm_shared_array_offset (SCM ra
);
51 SCM_API SCM
scm_shared_array_increments (SCM ra
);
52 SCM_API SCM
scm_make_shared_array (SCM oldra
, SCM mapfunc
, SCM dims
);
53 SCM_API SCM
scm_transpose_array (SCM ra
, SCM args
);
54 SCM_API SCM
scm_array_in_bounds_p (SCM v
, SCM args
);
55 SCM_API SCM
scm_array_ref (SCM v
, SCM args
);
56 SCM_API SCM
scm_array_set_x (SCM v
, SCM obj
, SCM args
);
57 SCM_API SCM
scm_array_contents (SCM ra
, SCM strict
);
58 SCM_API SCM
scm_uniform_array_read_x (SCM ra
, SCM port_or_fd
,
60 SCM_API SCM
scm_uniform_array_write (SCM v
, SCM port_or_fd
,
62 SCM_API SCM
scm_array_to_list (SCM v
);
63 SCM_API SCM
scm_list_to_array (SCM ndim
, SCM lst
);
64 SCM_API SCM
scm_list_to_typed_array (SCM type
, SCM ndim
, SCM lst
);
65 SCM_API SCM
scm_array_type (SCM ra
);
67 SCM_API
int scm_is_array (SCM obj
);
68 SCM_API
int scm_is_typed_array (SCM obj
, SCM type
);
70 SCM_API SCM
scm_ra2contig (SCM ra
, int copy
);
74 typedef struct scm_i_t_array
76 SCM v
; /* the contents of the array, e.g., a vector or uniform vector. */
80 SCM_API scm_t_bits scm_i_tc16_array
;
82 #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 16)
84 #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_i_tc16_array, a)
85 #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 17))
86 #define SCM_I_ARRAY_CONTP(x) (SCM_CELL_WORD_0(x) & SCM_I_ARRAY_FLAG_CONTIGUOUS)
88 #define SCM_I_ARRAY_MEM(a) ((scm_i_t_array *) SCM_CELL_WORD_1 (a))
89 #define SCM_I_ARRAY_V(a) (SCM_I_ARRAY_MEM (a)->v)
90 #define SCM_I_ARRAY_BASE(a) (SCM_I_ARRAY_MEM (a)->base)
91 #define SCM_I_ARRAY_DIMS(a) \
92 ((scm_t_array_dim *)((char *) SCM_I_ARRAY_MEM (a) + sizeof (scm_i_t_array)))
94 SCM_INTERNAL SCM
scm_i_make_array (int ndim
);
95 SCM_INTERNAL SCM
scm_i_read_array (SCM port
, int c
);
97 SCM_INTERNAL
void scm_init_arrays (void);
99 #endif /* SCM_UNIF_H */