<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/3805be8a550d5c992f50ef38d54d300a"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-01-15T15:09:23"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??"
  prev="2003/01/f7d3348fa774e58992aece85eddb448a"
  next="2003/01/c93ae47484a0ce585b8050618e59f3d0"
  prev-in-thread="2003/01/bcec04263a1c7a487d0b250728b97452"
  prev-thread="2003/01/b3381ea52ca855463acfe1b560847b5a"
  next-thread="2003/01/ae290911e3ac98ba444f0ad41ede595f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] C -&gt; CAML linking: loosing values in arrays??">
<msg 
  url="2003/01/ebd86b28c2ef28b50a46fde80caaf934"
  from="Daniel Andor &lt;da209@c...&gt;"
  author="Daniel Andor"
  date="2003-01-11T19:08:35"
  subject="[Caml-list] C -&gt; CAML linking: loosing values in arrays??">
<msg 
  url="2003/01/a3f8af61dda21ed4c9413a149d64bf07"
  from="Artem Prisyznuk &lt;tema@s...&gt;"
  author="Artem Prisyznuk"
  date="2003-01-12T00:15:49"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??">
<msg 
  url="2003/01/bcec04263a1c7a487d0b250728b97452"
  from="Daniel Andor &lt;da209@c...&gt;"
  author="Daniel Andor"
  date="2003-01-12T01:03:19"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??">
</msg>
</msg>
<msg 
  url="2003/01/3805be8a550d5c992f50ef38d54d300a"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-01-15T15:09:23"
  subject="Re: [Caml-list] C -&gt; CAML linking: loosing values in arrays??">
</msg>
</msg>
</thread>

<contents>
On Saturday, January 11, 2003, at 08:07 PM, Daniel Andor wrote:

&gt; parameters.  Since it's for numerics, I want to pass arrays of doubles.

&gt;   return alloc_array(make_float,p);

You cannot use alloc_array to return a value of type [float array].
This is because arrays of floating-point numbers are not represented
like the other array types in O'Caml: they are allocated in-line,
without the usual pointer indirection.

You will have to allocate the array with [alloc], then fill in the
elements with [Store_double_field]:

#define NUM_DIMS 4
value make_float_array(double *ds)
{
   int i;
   value res;

   res = alloc (NUM_DIMS*Double_wosize, Double_array_tag);
   for (i=0; i&lt;NUM_DIMS; i++){
     Store_double_field (res, i, ds[i]);
   }
   return res;
}


-- Damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

