Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
b29058ff DH |
3 | #ifndef SCM_UNIF_H |
4 | #define SCM_UNIF_H | |
5 | ||
86d88a22 | 6 | /* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009 Free Software Foundation, Inc. |
b29058ff | 7 | * |
73be1d9e | 8 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
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. | |
b29058ff | 12 | * |
53befeb7 NJ |
13 | * This library is distributed in the hope that it will be useful, but |
14 | * 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 | |
53befeb7 NJ |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
21 | * 02110-1301 USA | |
73be1d9e | 22 | */ |
d3a6bc94 | 23 | |
0f2d19dd JB |
24 | \f |
25 | ||
b4309c3c | 26 | #include "libguile/__scm.h" |
9598a406 | 27 | #include "libguile/print.h" |
c53c0893 | 28 | #include "libguile/array-handle.h" |
0f2d19dd JB |
29 | |
30 | \f | |
1d7bdb25 | 31 | |
20930f28 MV |
32 | /* This file contains the definitions for arrays and bit vectors. |
33 | Uniform numeric vectors are now in srfi-4.c. | |
34 | */ | |
35 | ||
36 | ||
37 | /** Arrays */ | |
38 | ||
86d88a22 | 39 | SCM_API SCM scm_array_p (SCM v); |
f301dbf3 MV |
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); | |
782a82ee AW |
43 | SCM_API SCM scm_from_contiguous_typed_array (SCM type, SCM bounds, |
44 | const void *bytes, | |
45 | size_t byte_len); | |
33b001fd | 46 | SCM_API SCM scm_array_rank (SCM ra); |
04b87de5 | 47 | SCM_API size_t scm_c_array_rank (SCM ra); |
33b001fd MV |
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); | |
33b001fd MV |
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_enclose_array (SCM ra, SCM axes); | |
55 | SCM_API SCM scm_array_in_bounds_p (SCM v, SCM args); | |
e0e49670 | 56 | SCM_API SCM scm_array_ref (SCM v, SCM args); |
33b001fd MV |
57 | SCM_API SCM scm_array_set_x (SCM v, SCM obj, SCM args); |
58 | SCM_API SCM scm_array_contents (SCM ra, SCM strict); | |
02339e5b MV |
59 | SCM_API SCM scm_uniform_array_read_x (SCM ra, SCM port_or_fd, |
60 | SCM start, SCM end); | |
61 | SCM_API SCM scm_uniform_array_write (SCM v, SCM port_or_fd, | |
62 | SCM start, SCM end); | |
20930f28 | 63 | SCM_API SCM scm_array_to_list (SCM v); |
f301dbf3 MV |
64 | SCM_API SCM scm_list_to_array (SCM ndim, SCM lst); |
65 | SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst); | |
66 | SCM_API SCM scm_array_type (SCM ra); | |
67 | ||
68 | SCM_API int scm_is_array (SCM obj); | |
69 | SCM_API int scm_is_typed_array (SCM obj, SCM type); | |
20930f28 | 70 | |
0cd6cb2f | 71 | SCM_API SCM scm_ra2contig (SCM ra, int copy); |
20930f28 | 72 | |
0cd6cb2f MV |
73 | /* internal. */ |
74 | ||
04b87de5 MV |
75 | typedef struct scm_i_t_array |
76 | { | |
77 | SCM v; /* the contents of the array, e.g., a vector or uniform vector. */ | |
78 | unsigned long base; | |
79 | } scm_i_t_array; | |
80 | ||
81 | SCM_API scm_t_bits scm_i_tc16_array; | |
82 | SCM_API scm_t_bits scm_i_tc16_enclosed_array; | |
83 | ||
84 | #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 16) | |
85 | ||
86 | #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_i_tc16_array, a) | |
87 | #define SCM_I_ENCLOSED_ARRAYP(a) \ | |
88 | SCM_TYP16_PREDICATE (scm_i_tc16_enclosed_array, a) | |
89 | #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 17)) | |
90 | #define SCM_I_ARRAY_CONTP(x) (SCM_CELL_WORD_0(x) & SCM_I_ARRAY_FLAG_CONTIGUOUS) | |
91 | ||
92 | #define SCM_I_ARRAY_MEM(a) ((scm_i_t_array *) SCM_CELL_WORD_1 (a)) | |
93 | #define SCM_I_ARRAY_V(a) (SCM_I_ARRAY_MEM (a)->v) | |
94 | #define SCM_I_ARRAY_BASE(a) (SCM_I_ARRAY_MEM (a)->base) | |
95 | #define SCM_I_ARRAY_DIMS(a) \ | |
96 | ((scm_t_array_dim *)((char *) SCM_I_ARRAY_MEM (a) + sizeof (scm_i_t_array))) | |
97 | ||
b6149d8d | 98 | SCM_INTERNAL SCM scm_i_make_array (int ndim, int enclosed); |
102dbb6f LC |
99 | SCM_INTERNAL SCM scm_i_cvref (SCM v, size_t p, int enclosed); |
100 | SCM_INTERNAL SCM scm_i_read_array (SCM port, int c); | |
0cd6cb2f | 101 | |
2fa901a5 | 102 | SCM_INTERNAL void scm_init_arrays (void); |
0f2d19dd | 103 | |
b29058ff | 104 | #endif /* SCM_UNIF_H */ |
89e00824 ML |
105 | |
106 | /* | |
107 | Local Variables: | |
108 | c-file-style: "gnu" | |
109 | End: | |
110 | */ |