Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
b29058ff DH |
3 | #ifndef SCM_UNIF_H |
4 | #define SCM_UNIF_H | |
5 | ||
21959222 | 6 | /* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004 Free Software Foundation, Inc. |
b29058ff | 7 | * |
73be1d9e MV |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. | |
b29058ff | 12 | * |
73be1d9e | 13 | * This library is distributed in the hope that it will be useful, |
0f2d19dd | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
b29058ff | 17 | * |
73be1d9e MV |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
d3a6bc94 | 22 | |
0f2d19dd JB |
23 | \f |
24 | ||
b4309c3c | 25 | #include "libguile/__scm.h" |
0f2d19dd JB |
26 | |
27 | \f | |
1d7bdb25 | 28 | |
20930f28 MV |
29 | /* This file contains the definitions for arrays and bit vectors. |
30 | Uniform numeric vectors are now in srfi-4.c. | |
31 | */ | |
32 | ||
33 | ||
34 | /** Arrays */ | |
35 | ||
4cf8074f MV |
36 | typedef struct scm_t_array_dim |
37 | { | |
38 | ssize_t lbnd; | |
39 | ssize_t ubnd; | |
40 | ssize_t inc; | |
41 | } scm_t_array_dim; | |
1d7bdb25 | 42 | |
92c2555f | 43 | typedef struct scm_t_array |
0f2d19dd | 44 | { |
1d7bdb25 | 45 | SCM v; /* the contents of the array, e.g., a vector or uniform vector. */ |
c014a02e | 46 | unsigned long base; |
92c2555f | 47 | } scm_t_array; |
0f2d19dd | 48 | |
33b001fd | 49 | SCM_API scm_t_bits scm_tc16_array; |
02339e5b | 50 | SCM_API scm_t_bits scm_tc16_enclosed_array; |
e038c042 DH |
51 | |
52 | #define SCM_ARRAY_FLAG_CONTIGUOUS (1 << 16) | |
53 | ||
54 | #define SCM_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc16_array, a) | |
02339e5b | 55 | #define SCM_ENCLOSED_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc16_enclosed_array, a) |
2635d5ef | 56 | #define SCM_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 17)) |
e038c042 DH |
57 | #define SCM_ARRAY_CONTP(x) (SCM_CELL_WORD_0 (x) & SCM_ARRAY_FLAG_CONTIGUOUS) |
58 | #define SCM_SET_ARRAY_CONTIGUOUS_FLAG(x) \ | |
59 | (SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) | SCM_ARRAY_FLAG_CONTIGUOUS)) | |
60 | #define SCM_CLR_ARRAY_CONTIGUOUS_FLAG(x) \ | |
61 | (SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) & ~SCM_ARRAY_FLAG_CONTIGUOUS)) | |
0f2d19dd | 62 | |
92c2555f | 63 | #define SCM_ARRAY_MEM(a) ((scm_t_array *) SCM_CELL_WORD_1 (a)) |
405aaef9 DH |
64 | #define SCM_ARRAY_V(a) (SCM_ARRAY_MEM (a)->v) |
65 | #define SCM_ARRAY_BASE(a) (SCM_ARRAY_MEM (a)->base) | |
92c2555f | 66 | #define SCM_ARRAY_DIMS(a) ((scm_t_array_dim *)((char *) SCM_ARRAY_MEM (a) + sizeof (scm_t_array))) |
1be6b49c | 67 | |
33b001fd | 68 | SCM_API SCM scm_array_p (SCM v, SCM prot); |
f301dbf3 MV |
69 | SCM_API SCM scm_typed_array_p (SCM v, SCM type); |
70 | SCM_API SCM scm_make_array (SCM fill, SCM bounds); | |
71 | SCM_API SCM scm_make_typed_array (SCM type, SCM fill, SCM bounds); | |
33b001fd MV |
72 | SCM_API SCM scm_array_rank (SCM ra); |
73 | SCM_API SCM scm_array_dimensions (SCM ra); | |
74 | SCM_API SCM scm_shared_array_root (SCM ra); | |
75 | SCM_API SCM scm_shared_array_offset (SCM ra); | |
76 | SCM_API SCM scm_shared_array_increments (SCM ra); | |
33b001fd MV |
77 | SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims); |
78 | SCM_API SCM scm_transpose_array (SCM ra, SCM args); | |
79 | SCM_API SCM scm_enclose_array (SCM ra, SCM axes); | |
80 | SCM_API SCM scm_array_in_bounds_p (SCM v, SCM args); | |
e0e49670 | 81 | SCM_API SCM scm_array_ref (SCM v, SCM args); |
33b001fd MV |
82 | SCM_API SCM scm_array_set_x (SCM v, SCM obj, SCM args); |
83 | SCM_API SCM scm_array_contents (SCM ra, SCM strict); | |
02339e5b MV |
84 | SCM_API SCM scm_uniform_array_read_x (SCM ra, SCM port_or_fd, |
85 | SCM start, SCM end); | |
86 | SCM_API SCM scm_uniform_array_write (SCM v, SCM port_or_fd, | |
87 | SCM start, SCM end); | |
20930f28 | 88 | SCM_API SCM scm_array_to_list (SCM v); |
f301dbf3 MV |
89 | SCM_API SCM scm_list_to_array (SCM ndim, SCM lst); |
90 | SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst); | |
91 | SCM_API SCM scm_array_type (SCM ra); | |
92 | ||
93 | SCM_API int scm_is_array (SCM obj); | |
94 | SCM_API int scm_is_typed_array (SCM obj, SCM type); | |
20930f28 MV |
95 | |
96 | SCM_API SCM scm_i_read_array (SCM port, int c); | |
97 | ||
6e708ef2 MV |
98 | typedef struct { |
99 | SCM array; | |
100 | size_t base; | |
101 | scm_t_array_dim *dims; | |
102 | scm_t_array_dim dim0; | |
103 | } scm_t_array_handle; | |
104 | ||
105 | SCM_API void scm_array_get_handle (SCM array, scm_t_array_handle *h); | |
106 | SCM_API size_t scm_array_handle_rank (scm_t_array_handle *h); | |
107 | SCM_API scm_t_array_dim *scm_array_handle_dims (scm_t_array_handle *h); | |
cdd6e0a8 MV |
108 | SCM_API SCM scm_array_handle_ref (scm_t_array_handle *h, ssize_t pos); |
109 | SCM_API void scm_array_handle_set (scm_t_array_handle *h, ssize_t pos, SCM val); | |
6e708ef2 MV |
110 | SCM_API const SCM *scm_array_handle_elements (scm_t_array_handle *h); |
111 | SCM_API SCM *scm_array_handle_writable_elements (scm_t_array_handle *h); | |
cdd6e0a8 | 112 | SCM_API void scm_array_handle_release (scm_t_array_handle *h); |
6e708ef2 | 113 | |
20930f28 MV |
114 | \f |
115 | /** Bit vectors */ | |
116 | ||
117 | SCM_API SCM scm_bitvector_p (SCM vec); | |
118 | SCM_API SCM scm_bitvector (SCM bits); | |
119 | SCM_API SCM scm_make_bitvector (SCM len, SCM fill); | |
120 | SCM_API SCM scm_bitvector_length (SCM vec); | |
121 | SCM_API SCM scm_bitvector_ref (SCM vec, SCM idx); | |
122 | SCM_API SCM scm_bitvector_set_x (SCM vec, SCM idx, SCM val); | |
123 | SCM_API SCM scm_list_to_bitvector (SCM list); | |
124 | SCM_API SCM scm_bitvector_to_list (SCM vec); | |
125 | SCM_API SCM scm_bitvector_fill_x (SCM vec, SCM val); | |
126 | ||
33b001fd MV |
127 | SCM_API SCM scm_bit_count (SCM item, SCM seq); |
128 | SCM_API SCM scm_bit_position (SCM item, SCM v, SCM k); | |
129 | SCM_API SCM scm_bit_set_star_x (SCM v, SCM kv, SCM obj); | |
130 | SCM_API SCM scm_bit_count_star (SCM v, SCM kv, SCM obj); | |
131 | SCM_API SCM scm_bit_invert_x (SCM v); | |
21959222 | 132 | |
20930f28 MV |
133 | SCM_API int scm_is_bitvector (SCM obj); |
134 | SCM_API SCM scm_c_make_bitvector (size_t len, SCM fill); | |
135 | SCM_API size_t scm_c_bitvector_length (SCM vec); | |
136 | SCM_API SCM scm_c_bitvector_ref (SCM vec, size_t idx); | |
137 | SCM_API void scm_c_bitvector_set_x (SCM vec, size_t idx, SCM val); | |
f0b91039 MV |
138 | SCM_API const scm_t_uint32 *scm_array_handle_bit_elements (scm_t_array_handle *h); |
139 | SCM_API scm_t_uint32 *scm_array_handle_bit_writable_elements (scm_t_array_handle *h); | |
140 | SCM_API size_t scm_array_handle_bit_elements_offset (scm_t_array_handle *h); | |
141 | SCM_API const scm_t_uint32 *scm_bitvector_elements (SCM vec, | |
142 | scm_t_array_handle *h, | |
cdd6e0a8 | 143 | size_t *offp, |
f0b91039 MV |
144 | size_t *lenp, |
145 | ssize_t *incp); | |
146 | SCM_API scm_t_uint32 *scm_bitvector_writable_elements (SCM vec, | |
147 | scm_t_array_handle *h, | |
cdd6e0a8 | 148 | size_t *offp, |
f0b91039 MV |
149 | size_t *lenp, |
150 | ssize_t *incp); | |
bfad4005 | 151 | |
21959222 MV |
152 | /* deprecated. */ |
153 | ||
6e708ef2 MV |
154 | #if SCM_ENABLE_DEPRECATED |
155 | ||
21959222 | 156 | SCM_API SCM scm_make_uve (long k, SCM prot); |
6e708ef2 MV |
157 | SCM_API SCM scm_array_prototype (SCM ra); |
158 | SCM_API SCM scm_list_to_uniform_array (SCM ndim, SCM prot, SCM lst); | |
159 | SCM_API SCM scm_dimensions_to_uniform_array (SCM dims, SCM prot, SCM fill); | |
160 | ||
161 | #endif | |
162 | ||
21959222 MV |
163 | SCM_API SCM scm_make_ra (int ndim); |
164 | SCM_API void scm_ra_set_contp (SCM ra); | |
165 | SCM_API SCM scm_cvref (SCM v, unsigned long pos, SCM last); | |
166 | SCM_API SCM scm_istr2bve (SCM str); | |
167 | SCM_API int scm_raprin1 (SCM exp, SCM port, scm_print_state *pstate); | |
02339e5b MV |
168 | SCM_API long scm_aind (SCM ra, SCM args, const char *what); |
169 | SCM_API SCM scm_shap2ra (SCM args, const char *what); | |
02339e5b | 170 | SCM_API SCM scm_ra2contig (SCM ra, int copy); |
21959222 | 171 | |
2d4d7f27 | 172 | SCM_API SCM scm_i_cvref (SCM v, size_t p, int enclosed); |
20930f28 | 173 | |
33b001fd | 174 | SCM_API void scm_init_unif (void); |
0f2d19dd | 175 | |
b29058ff | 176 | #endif /* SCM_UNIF_H */ |
89e00824 ML |
177 | |
178 | /* | |
179 | Local Variables: | |
180 | c-file-style: "gnu" | |
181 | End: | |
182 | */ |