Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
b29058ff DH |
3 | #ifndef SCM_UNIF_H |
4 | #define SCM_UNIF_H | |
5 | ||
e038c042 | 6 | /* Copyright (C) 1995,1996,1997,1999,2000,2001 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 GH |
28 | |
29 | /* | |
2dbec7b5 | 30 | an array SCM is a non-immediate pointing to a heap cell where: |
1d7bdb25 | 31 | |
2dbec7b5 GH |
32 | CAR: bits 0-15 hold the smob type id: scm_tc16_array |
33 | bit 16 is the SCM_ARRAY_FLAG_CONTIGUOUS flag | |
34 | bits 17-31 hold the dimension (0 -- 32767) | |
35 | CDR: pointer to a malloced block containing an scm_t_array structure | |
92c2555f | 36 | followed by an scm_t_array_dim structure for each dimension. |
1d7bdb25 GH |
37 | */ |
38 | ||
92c2555f | 39 | typedef struct scm_t_array |
0f2d19dd | 40 | { |
1d7bdb25 | 41 | SCM v; /* the contents of the array, e.g., a vector or uniform vector. */ |
c014a02e | 42 | unsigned long base; |
92c2555f | 43 | } scm_t_array; |
0f2d19dd | 44 | |
92c2555f | 45 | typedef struct scm_t_array_dim |
0f2d19dd | 46 | { |
c014a02e ML |
47 | long lbnd; |
48 | long ubnd; | |
49 | long inc; | |
92c2555f | 50 | } scm_t_array_dim; |
1be6b49c | 51 | |
33b001fd | 52 | SCM_API scm_t_bits scm_tc16_array; |
e038c042 DH |
53 | |
54 | #define SCM_ARRAY_FLAG_CONTIGUOUS (1 << 16) | |
55 | ||
56 | #define SCM_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc16_array, a) | |
2635d5ef | 57 | #define SCM_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 17)) |
e038c042 DH |
58 | #define SCM_ARRAY_CONTP(x) (SCM_CELL_WORD_0 (x) & SCM_ARRAY_FLAG_CONTIGUOUS) |
59 | #define SCM_SET_ARRAY_CONTIGUOUS_FLAG(x) \ | |
60 | (SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) | SCM_ARRAY_FLAG_CONTIGUOUS)) | |
61 | #define SCM_CLR_ARRAY_CONTIGUOUS_FLAG(x) \ | |
62 | (SCM_SET_CELL_WORD_0 ((x), SCM_CELL_WORD_0 (x) & ~SCM_ARRAY_FLAG_CONTIGUOUS)) | |
0f2d19dd | 63 | |
92c2555f | 64 | #define SCM_ARRAY_MEM(a) ((scm_t_array *) SCM_CELL_WORD_1 (a)) |
405aaef9 DH |
65 | #define SCM_ARRAY_V(a) (SCM_ARRAY_MEM (a)->v) |
66 | #define SCM_ARRAY_BASE(a) (SCM_ARRAY_MEM (a)->base) | |
92c2555f | 67 | #define SCM_ARRAY_DIMS(a) ((scm_t_array_dim *)((char *) SCM_ARRAY_MEM (a) + sizeof (scm_t_array))) |
1be6b49c | 68 | |
c014a02e | 69 | #define SCM_I_MAX_LENGTH ((unsigned long) (-1L) >> 8) |
1d7bdb25 | 70 | |
3db4adfc | 71 | #define SCM_UVECTOR_BASE(x) ((void *) (SCM_CELL_WORD_1 (x))) |
6a0476fd | 72 | #define SCM_SET_UVECTOR_BASE(v, b) (SCM_SET_CELL_WORD_1 ((v), (b))) |
1be6b49c | 73 | #define SCM_UVECTOR_MAX_LENGTH SCM_I_MAX_LENGTH |
c014a02e | 74 | #define SCM_UVECTOR_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) |
34d19ef6 HWN |
75 | #define SCM_MAKE_UVECTOR_TAG(l, t) (((l) << 8) + (t)) |
76 | #define SCM_SET_UVECTOR_LENGTH(v, l, t) (SCM_SET_CELL_WORD_0 ((v), SCM_MAKE_UVECTOR_TAG(l, t))) | |
2d349e67 | 77 | |
b5c2579a | 78 | #define SCM_BITVECTOR_P(x) (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_bvect)) |
bab246f3 | 79 | #define SCM_BITVECTOR_BASE(x) ((unsigned long *) (SCM_CELL_WORD_1 (x))) |
6a0476fd | 80 | #define SCM_SET_BITVECTOR_BASE(v, b) (SCM_SET_CELL_WORD_1 ((v), (b))) |
1be6b49c | 81 | #define SCM_BITVECTOR_MAX_LENGTH SCM_I_MAX_LENGTH |
c014a02e | 82 | #define SCM_BITVECTOR_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) |
0b2f15c3 MV |
83 | #define SCM_MAKE_BITVECTOR_TAG(l) (((l) << 8) + scm_tc7_bvect) |
84 | #define SCM_SET_BITVECTOR_LENGTH(v, l) (SCM_SET_CELL_WORD_0 ((v), SCM_MAKE_BITVECTOR_TAG (l))) | |
3db4adfc | 85 | |
0f2d19dd | 86 | \f |
0f2d19dd | 87 | |
33b001fd | 88 | SCM_API SCM scm_make_uve (long k, SCM prot); |
33b001fd MV |
89 | SCM_API SCM scm_array_p (SCM v, SCM prot); |
90 | SCM_API SCM scm_array_rank (SCM ra); | |
91 | SCM_API SCM scm_array_dimensions (SCM ra); | |
92 | SCM_API SCM scm_shared_array_root (SCM ra); | |
93 | SCM_API SCM scm_shared_array_offset (SCM ra); | |
94 | SCM_API SCM scm_shared_array_increments (SCM ra); | |
95 | SCM_API long scm_aind (SCM ra, SCM args, const char *what); | |
96 | SCM_API SCM scm_make_ra (int ndim); | |
97 | SCM_API SCM scm_shap2ra (SCM args, const char *what); | |
98 | SCM_API SCM scm_dimensions_to_uniform_array (SCM dims, SCM prot, SCM fill); | |
99 | SCM_API void scm_ra_set_contp (SCM ra); | |
100 | SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims); | |
101 | SCM_API SCM scm_transpose_array (SCM ra, SCM args); | |
102 | SCM_API SCM scm_enclose_array (SCM ra, SCM axes); | |
103 | SCM_API SCM scm_array_in_bounds_p (SCM v, SCM args); | |
e0e49670 | 104 | SCM_API SCM scm_array_ref (SCM v, SCM args); |
33b001fd MV |
105 | SCM_API SCM scm_cvref (SCM v, unsigned long pos, SCM last); |
106 | SCM_API SCM scm_array_set_x (SCM v, SCM obj, SCM args); | |
107 | SCM_API SCM scm_array_contents (SCM ra, SCM strict); | |
108 | SCM_API SCM scm_ra2contig (SCM ra, int copy); | |
109 | SCM_API SCM scm_uniform_array_read_x (SCM ra, SCM port_or_fd, SCM start, SCM end); | |
110 | SCM_API SCM scm_uniform_array_write (SCM v, SCM port_or_fd, SCM start, SCM end); | |
111 | SCM_API SCM scm_bit_count (SCM item, SCM seq); | |
112 | SCM_API SCM scm_bit_position (SCM item, SCM v, SCM k); | |
113 | SCM_API SCM scm_bit_set_star_x (SCM v, SCM kv, SCM obj); | |
114 | SCM_API SCM scm_bit_count_star (SCM v, SCM kv, SCM obj); | |
115 | SCM_API SCM scm_bit_invert_x (SCM v); | |
cc95e00a | 116 | SCM_API SCM scm_istr2bve (SCM str); |
cd328b4f | 117 | SCM_API SCM scm_array_to_list (SCM v); |
33b001fd MV |
118 | SCM_API SCM scm_list_to_uniform_array (SCM ndim, SCM prot, SCM lst); |
119 | SCM_API int scm_raprin1 (SCM exp, SCM port, scm_print_state *pstate); | |
120 | SCM_API SCM scm_array_prototype (SCM ra); | |
121 | SCM_API void scm_init_unif (void); | |
0f2d19dd | 122 | |
b29058ff | 123 | #endif /* SCM_UNIF_H */ |
89e00824 ML |
124 | |
125 | /* | |
126 | Local Variables: | |
127 | c-file-style: "gnu" | |
128 | End: | |
129 | */ |