Update Gnulib to v0.0-6827-g39c3009; use the `dirfd' module.
[bpt/guile.git] / libguile / arrays.h
1 /* classes: h_files */
2
3 #ifndef SCM_ARRAY_H
4 #define SCM_ARRAY_H
5
6 /* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
7 *
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.
12 *
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.
17 *
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
21 * 02110-1301 USA
22 */
23
24 \f
25
26 #include "libguile/__scm.h"
27 #include "libguile/print.h"
28
29 \f
30
31 /* Multidimensional arrays. Woo hoo!
32 Also see ....
33 */
34
35
36 /** Arrays */
37
38 SCM_API SCM scm_make_array (SCM fill, SCM bounds);
39 SCM_API SCM scm_from_contiguous_array (SCM bounds, const SCM *elts,
40 size_t len);
41 SCM_API SCM scm_make_typed_array (SCM type, SCM fill, SCM bounds);
42 SCM_API SCM scm_from_contiguous_typed_array (SCM type, SCM bounds,
43 const void *bytes,
44 size_t byte_len);
45 SCM_API SCM scm_shared_array_root (SCM ra);
46 SCM_API SCM scm_shared_array_offset (SCM ra);
47 SCM_API SCM scm_shared_array_increments (SCM ra);
48 SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims);
49 SCM_API SCM scm_transpose_array (SCM ra, SCM args);
50 SCM_API SCM scm_array_contents (SCM ra, SCM strict);
51 SCM_API SCM scm_list_to_array (SCM ndim, SCM lst);
52 SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst);
53
54 /* internal. */
55
56 typedef struct scm_i_t_array
57 {
58 SCM v; /* the contents of the array, e.g., a vector or uniform vector. */
59 unsigned long base;
60 } scm_i_t_array;
61
62 #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0)
63
64 #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc7_array, a)
65 #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x)>>17))
66 #define SCM_I_ARRAY_CONTP(x) (SCM_CELL_WORD_0 (x) & (SCM_I_ARRAY_FLAG_CONTIGUOUS << 16))
67
68 #define SCM_I_ARRAY_MEM(a) ((scm_i_t_array *) SCM_CELL_WORD_1 (a))
69 #define SCM_I_ARRAY_V(a) (SCM_I_ARRAY_MEM (a)->v)
70 #define SCM_I_ARRAY_BASE(a) (SCM_I_ARRAY_MEM (a)->base)
71 #define SCM_I_ARRAY_DIMS(a) \
72 ((scm_t_array_dim *)((char *) SCM_I_ARRAY_MEM (a) + sizeof (scm_i_t_array)))
73
74 SCM_INTERNAL SCM scm_i_make_array (int ndim);
75 SCM_INTERNAL int scm_i_print_array (SCM array, SCM port, scm_print_state *pstate);
76 SCM_INTERNAL SCM scm_i_read_array (SCM port, int c);
77
78 SCM_INTERNAL void scm_init_arrays (void);
79
80 #endif /* SCM_ARRAYS_H */
81
82 /*
83 Local Variables:
84 c-file-style: "gnu"
85 End:
86 */