caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Odalric-Ambrym Maillard <odalricambrym.maillard@gmail.com>
To: caml-list@inria.fr
Subject: [Ocaml and C] Passing Arrays and Matrices of floats from Ocaml to C  and back
Date: Thu, 4 Mar 2010 12:07:57 +0100	[thread overview]
Message-ID: <406c33611003040307v2195e006qfe273bf85c7f2c95@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

<caml-list@inria.fr>,


Hello, I have the following problem : I wan to use a Least-squares
Regression solver written in C in a program written in OCaml.

I have something like this in the Ocaml program,
*
let beta = solve_olsr psi_matrix y_train in ...*

where psi_matrix is built using  Array.make_matrix and y_train by Array.make

The dimensions are KxN for psi_matrix and N for y_train, and the output beta
should be a vector of length K (built with Array.make etc).

I have a C function with the following signature :
*
void  olsr(int rows, int columns,
         double **matrix_of_data,
         double *vector_of_data,
         double ** vector_of_coefficients)*

Thus, I need to create a stub function, that will lok like this

*CAMLValue solve_olsr(value ...,value...) {
 CAMLparam...

 CAMLReturn ...
}*

My problem is the following : how do  proceed since the parameters I need to
transmt are vectors or matrices of float (for Caml, i.e. double for C), and
not just integers or floats ? I really do not know how to transfer arrays
and matrix of floats from Caml to C, and back.


It would be great to have an answer.

Thank you,
Odalric-Ambrym

[-- Attachment #2: Type: text/html, Size: 1334 bytes --]

             reply	other threads:[~2010-03-04 11:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04 11:07 Odalric-Ambrym Maillard [this message]
2010-03-04 13:08 ` [Caml-list] " Paolo Donadeo
2010-03-04 14:04   ` Odalric-Ambrym Maillard
2010-03-04 17:02     ` Odalric-Ambrym Maillard
2010-03-04 13:52 ` Christophe TROESTLER

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=406c33611003040307v2195e006qfe273bf85c7f2c95@mail.gmail.com \
    --to=odalricambrym.maillard@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=odalric.maillard@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).