arrays.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. typedef struct scm_i_t_array
  45. {
  46. SCM v; /* the contents of the array, e.g., a vector or uniform vector. */
  47. unsigned long base;
  48. } scm_i_t_array;
  49. #define SCM_I_ARRAY_FLAG_CONTIGUOUS (1 << 0)
  50. #define SCM_I_ARRAYP(a) SCM_TYP16_PREDICATE (scm_tc7_array, a)
  51. #define SCM_I_ARRAY_NDIM(x) ((size_t) (SCM_CELL_WORD_0 (x)>>17))
  52. #define SCM_I_ARRAY_CONTP(x) (SCM_CELL_WORD_0 (x) & (SCM_I_ARRAY_FLAG_CONTIGUOUS << 16))
  53. #define SCM_I_ARRAY_MEM(a) ((scm_i_t_array *) SCM_CELL_WORD_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 int scm_i_print_array (SCM array, SCM port, scm_print_state *pstate);
  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. */