arrays.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* classes: h_files */
  2. #ifndef SCM_ARRAY_H
  3. #define SCM_ARRAY_H
  4. /* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #include "libguile/__scm.h"
  22. #include "libguile/print.h"
  23. /* Multidimensional arrays. Woo hoo!
  24. Also see ....
  25. */
  26. /** Arrays */
  27. SCM_API SCM scm_make_array (SCM fill, SCM bounds);
  28. SCM_API SCM scm_from_contiguous_array (SCM bounds, const SCM *elts,
  29. size_t len);
  30. SCM_API SCM scm_make_typed_array (SCM type, SCM fill, SCM bounds);
  31. SCM_API SCM scm_from_contiguous_typed_array (SCM type, SCM bounds,
  32. const void *bytes,
  33. size_t byte_len);
  34. SCM_API SCM scm_shared_array_root (SCM ra);
  35. SCM_API SCM scm_shared_array_offset (SCM ra);
  36. SCM_API SCM scm_shared_array_increments (SCM ra);
  37. SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims);
  38. SCM_API SCM scm_transpose_array (SCM ra, SCM args);
  39. SCM_API SCM scm_array_contents (SCM ra, SCM strict);
  40. SCM_API SCM scm_list_to_array (SCM ndim, SCM lst);
  41. SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst);
  42. /* internal. */
  43. typedef struct scm_i_t_array
  44. {
  45. SCM v; /* the contents of the array, e.g., a vector or uniform vector. */
  46. unsigned long base;
  47. } scm_i_t_array;
  48. SCM_INTERNAL scm_t_bits scm_i_tc16_array;
  49. #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0)
  50. #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_i_tc16_array, a)
  51. #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_SMOB_FLAGS (x)>>1))
  52. #define SCM_I_ARRAY_CONTP(x) (SCM_SMOB_FLAGS(x) & SCM_I_ARRAY_FLAG_CONTIGUOUS)
  53. #define SCM_I_ARRAY_MEM(a) ((scm_i_t_array *) SCM_SMOB_DATA_1 (a))
  54. #define SCM_I_ARRAY_V(a) (SCM_I_ARRAY_MEM (a)->v)
  55. #define SCM_I_ARRAY_BASE(a) (SCM_I_ARRAY_MEM (a)->base)
  56. #define SCM_I_ARRAY_DIMS(a) \
  57. ((scm_t_array_dim *)((char *) SCM_I_ARRAY_MEM (a) + sizeof (scm_i_t_array)))
  58. SCM_INTERNAL SCM scm_i_make_array (int ndim);
  59. SCM_INTERNAL SCM scm_i_read_array (SCM port, int c);
  60. SCM_INTERNAL void scm_init_arrays (void);
  61. #endif /* SCM_ARRAYS_H */
  62. /*
  63. Local Variables:
  64. c-file-style: "gnu"
  65. End:
  66. */