arrays.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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,
  5. * 2010, 2012 Free Software Foundation, Inc.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 3 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #include "libguile/__scm.h"
  23. #include "libguile/print.h"
  24. /* Multidimensional arrays. Woo hoo!
  25. Also see ....
  26. */
  27. /** Arrays */
  28. SCM_API SCM scm_make_array (SCM fill, SCM bounds);
  29. SCM_API SCM scm_from_contiguous_array (SCM bounds, const SCM *elts,
  30. size_t len);
  31. SCM_API SCM scm_make_typed_array (SCM type, SCM fill, SCM bounds);
  32. SCM_API SCM scm_from_contiguous_typed_array (SCM type, SCM bounds,
  33. const void *bytes,
  34. size_t byte_len);
  35. SCM_API SCM scm_shared_array_root (SCM ra);
  36. SCM_API SCM scm_shared_array_offset (SCM ra);
  37. SCM_API SCM scm_shared_array_increments (SCM ra);
  38. SCM_API SCM scm_make_shared_array (SCM oldra, SCM mapfunc, SCM dims);
  39. SCM_API SCM scm_transpose_array (SCM ra, SCM args);
  40. SCM_API SCM scm_array_contents (SCM ra, SCM strict);
  41. SCM_API SCM scm_list_to_array (SCM ndim, SCM lst);
  42. SCM_API SCM scm_list_to_typed_array (SCM type, SCM ndim, SCM lst);
  43. /* internal. */
  44. #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0)
  45. #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc7_array, a)
  46. #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x)>>17))
  47. #define SCM_I_ARRAY_CONTP(x) (SCM_CELL_WORD_0 (x) & (SCM_I_ARRAY_FLAG_CONTIGUOUS << 16))
  48. #define SCM_I_ARRAY_V(a) SCM_CELL_OBJECT_1 (a)
  49. #define SCM_I_ARRAY_BASE(a) ((size_t) SCM_CELL_WORD_2 (a))
  50. #define SCM_I_ARRAY_DIMS(a) ((scm_t_array_dim *) SCM_CELL_OBJECT_LOC (a, 3))
  51. #define SCM_I_ARRAY_SET_V(a, v) SCM_SET_CELL_OBJECT_1(a, v)
  52. #define SCM_I_ARRAY_SET_BASE(a, base) SCM_SET_CELL_WORD_2(a, base)
  53. SCM_INTERNAL SCM scm_i_make_array (int ndim);
  54. SCM_INTERNAL int scm_i_print_array (SCM array, SCM port, scm_print_state *pstate);
  55. SCM_INTERNAL void scm_init_arrays (void);
  56. #endif /* SCM_ARRAYS_H */
  57. /*
  58. Local Variables:
  59. c-file-style: "gnu"
  60. End:
  61. */