Guest User

Untitled

a guest
Feb 16th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. From 87d522c5529b79bcd1df9cb27fffa7cca6270c32 Mon Sep 17 00:00:00 2001
  2. From: Gabriel Scherer <gabriel.scherer@inria.fr>
  3. Date: Wed, 7 Aug 2013 14:03:45 +0200
  4. Subject: [PATCH] PR#6126: in the Bigarray description, use the new `caml_ba`
  5. prefix
  6.  
  7. ---
  8. manual/library/libbigarray.etex | 60 +++++++++++++++++++--------------------
  9. 1 file changed, 30 insertions(+), 30 deletions(-)
  10.  
  11. diff --git a/manual/library/libbigarray.etex b/manual/library/libbigarray.etex
  12. index e6e6adf..b0a0568 100644
  13. --- a/manual/library/libbigarray.etex
  14. +++ b/manual/library/libbigarray.etex
  15. @@ -75,29 +75,29 @@ below.
  16. \subsection{Accessing an OCaml bigarray from C or Fortran}
  17.  
  18. If \var{v} is a OCaml "value" representing a big array, the expression
  19. -"Data_bigarray_val("\var{v}")" returns a pointer to the data part of the array.
  20. +"Caml_ba_data_val("\var{v}")" returns a pointer to the data part of the array.
  21. This pointer is of type "void *" and can be cast to the appropriate C
  22. type for the array (e.g. "double []", "char [][10]", etc).
  23.  
  24. Various characteristics of the OCaml big array can be consulted from C
  25. as follows:
  26. \begin{tableau}{|l|l|}{C expression}{Returns}
  27. -\entree{"Bigarray_val("\var{v}")->num_dims"}{number of dimensions}
  28. -\entree{"Bigarray_val("\var{v}")->dim["\var{i}"]"}{\var{i}-th dimension}
  29. -\entree{"Bigarray_val("\var{v}")->flags & BIGARRAY_KIND_MASK"}{kind of array elements}
  30. +\entree{"Caml_ba_array_val("\var{v}")->num_dims"}{number of dimensions}
  31. +\entree{"Caml_ba_array_val("\var{v}")->dim["\var{i}"]"}{\var{i}-th dimension}
  32. +\entree{"Caml_ba_array_val("\var{v}")->flags & BIGARRAY_KIND_MASK"}{kind of array elements}
  33. \end{tableau}
  34. The kind of array elements is one of the following constants:
  35. \begin{tableau}{|l|l|}{Constant}{Element kind}
  36. -\entree{"BIGARRAY_FLOAT32"}{32-bit single-precision floats}
  37. -\entree{"BIGARRAY_FLOAT64"}{64-bit double-precision floats}
  38. -\entree{"BIGARRAY_SINT8"}{8-bit signed integers}
  39. -\entree{"BIGARRAY_UINT8"}{8-bit unsigned integers}
  40. -\entree{"BIGARRAY_SINT16"}{16-bit signed integers}
  41. -\entree{"BIGARRAY_UINT16"}{16-bit unsigned integers}
  42. -\entree{"BIGARRAY_INT32"}{32-bit signed integers}
  43. -\entree{"BIGARRAY_INT64"}{64-bit signed integers}
  44. -\entree{"BIGARRAY_CAML_INT"}{31- or 63-bit signed integers}
  45. -\entree{"BIGARRAY_NATIVE_INT"}{32- or 64-bit (platform-native) integers}
  46. +\entree{"CAML_BA_FLOAT32"}{32-bit single-precision floats}
  47. +\entree{"CAML_BA_FLOAT64"}{64-bit double-precision floats}
  48. +\entree{"CAML_BA_SINT8"}{8-bit signed integers}
  49. +\entree{"CAML_BA_UINT8"}{8-bit unsigned integers}
  50. +\entree{"CAML_BA_SINT16"}{16-bit signed integers}
  51. +\entree{"CAML_BA_UINT16"}{16-bit unsigned integers}
  52. +\entree{"CAML_BA_INT32"}{32-bit signed integers}
  53. +\entree{"CAML_BA_INT64"}{64-bit signed integers}
  54. +\entree{"CAML_BA_CAML_INT"}{31- or 63-bit signed integers}
  55. +\entree{"CAML_BA_NATIVE_INT"}{32- or 64-bit (platform-native) integers}
  56. \end{tableau}
  57. %
  58. The following example shows the passing of a two-dimensional big array
  59. @@ -108,12 +108,12 @@ to a C function and a Fortran function.
  60.  
  61. value caml_stub(value bigarray)
  62. {
  63. - int dimx = Bigarray_val(bigarray)->dim[0];
  64. - int dimy = Bigarray_val(bigarray)->dim[1];
  65. + int dimx = Caml_ba_array_val(bigarray)->dim[0];
  66. + int dimy = Caml_ba_array_val(bigarray)->dim[1];
  67. /* C passes scalar parameters by value */
  68. - my_c_function(Data_bigarray_val(bigarray), dimx, dimy);
  69. + my_c_function(Caml_ba_data_val(bigarray), dimx, dimy);
  70. /* Fortran passes all parameters by reference */
  71. - my_fortran_function_(Data_bigarray_val(bigarray), &dimx, &dimy);
  72. + my_fortran_function_(Caml_ba_data_val(bigarray), &dimx, &dimy);
  73. return Val_unit;
  74. }
  75. \end{verbatim}
  76. @@ -121,25 +121,25 @@ to a C function and a Fortran function.
  77. \subsection{Wrapping a C or Fortran array as an OCaml big array}
  78.  
  79. A pointer \var{p} to an already-allocated C or Fortran array can be
  80. -wrapped and returned to OCaml as a big array using the "alloc_bigarray"
  81. -or "alloc_bigarray_dims" functions.
  82. +wrapped and returned to OCaml as a big array using the "caml_ba_alloc"
  83. +or "caml_ba_alloc_dims" functions.
  84. \begin{itemize}
  85. \item
  86. -"alloc_bigarray("\var{kind} "|" \var{layout}, \var{numdims}, \var{p}, \var{dims}")"
  87. +"caml_ba_alloc("\var{kind} "|" \var{layout}, \var{numdims}, \var{p}, \var{dims}")"
  88.  
  89. Return an OCaml big array wrapping the data pointed to by \var{p}.
  90. -\var{kind} is the kind of array elements (one of the "BIGARRAY_"
  91. -kind constants above). \var{layout} is "BIGARRAY_C_LAYOUT" for an
  92. -array with C layout and "BIGARRAY_FORTRAN_LAYOUT" for an array with
  93. +\var{kind} is the kind of array elements (one of the "CAML_BA_"
  94. +kind constants above). \var{layout} is "CAML_BA_C_LAYOUT" for an
  95. +array with C layout and "CAML_BA_FORTRAN_LAYOUT" for an array with
  96. Fortran layout. \var{numdims} is the number of dimensions in the
  97. array. \var{dims} is an array of \var{numdims} long integers, giving
  98. the sizes of the array in each dimension.
  99.  
  100. \item
  101. -"alloc_bigarray_dims("\var{kind} "|" \var{layout}, \var{numdims},
  102. +"caml_ba_alloc_dims("\var{kind} "|" \var{layout}, \var{numdims},
  103. \var{p}, "(long) "\nth{dim}{1}, "(long) "\nth{dim}{2}, \ldots, "(long) "\nth{dim}{numdims}")"
  104.  
  105. -Same as "alloc_bigarray", but the sizes of the array in each dimension
  106. +Same as "caml_ba_alloc", but the sizes of the array in each dimension
  107. are listed as extra arguments in the function call, rather than being
  108. passed as an array.
  109. \end{itemize}
  110. @@ -154,14 +154,14 @@ Fortran arrays can be made available to OCaml.
  111. {
  112. long dims[2];
  113. dims[0] = 100; dims[1] = 200;
  114. - return alloc_bigarray(BIGARRAY_NATIVE_INT | BIGARRAY_C_LAYOUT,
  115. - 2, my_c_array, dims);
  116. + return caml_ba_alloc(CAML_BA_NATIVE_INT | CAML_BA_C_LAYOUT,
  117. + 2, my_c_array, dims);
  118. }
  119.  
  120. value caml_get_fortran_array(value unit)
  121. {
  122. - return alloc_bigarray_dims(BIGARRAY_FLOAT32 | BIGARRAY_FORTRAN_LAYOUT,
  123. - 2, my_fortran_array_, 300L, 400L);
  124. + return caml_ba_alloc_dims(CAML_BA_FLOAT32 | CAML_BA_FORTRAN_LAYOUT,
  125. + 2, my_fortran_array_, 300L, 400L);
  126. }
  127. \end{verbatim}
  128.  
  129. --
  130. 1.7.10.4
Add Comment
Please, Sign In to add comment