From james.s.muller at gmail.com  Wed Dec 28 02:36:17 2011
From: james.s.muller at gmail.com (James Muller)
Date: Tue, 27 Dec 2011 20:36:17 -0500
Subject: [Rd] Initializing a large data structure to be accessed
 strictly within a shared C library
In-Reply-To: <4EFA6C51.5010300@gmail.com>
References: <CAChCbnoC9PQUPAxLe-Fi6gHG8AN+csz8AVJhw5g6PsO60fg=gg@mail.gmail.com>
	<4EFA6C51.5010300@gmail.com>
Message-ID: <CAChCbnrKD1Bo7oHwTd4GVzzBwCe-nPwYqNFWO74uYcHOoNemKw@mail.gmail.com>

Thanks Duncan, you've unclogged my thinking. For anybody interested,
see below a sketch of the solution.

Cheers,

James


--START SKETCH OF SOLUTION--

#include <R.h>
#include <Rinternals.h>

static typedef struct {
    int nrow, ncol;
    double *data;
} _myparticle_data_struct;
static _myparticle_data_struct myparticle_data;

void myparticle_init() {
    // Before we begin, call this from .Call() to Ralloc() memory and load the
    // data into to myparticle_data.data
}

void myparticle_free() {
    // When we're done with the PSO, .Call() to Free() the data
}

void myparticle_eval(double *value, double *x) {
    // .Call() to evaluate the value *value given vector x[]
}

--END SKETCH OF SOLUTION--



[Rd] Initializing a large data structure to be accessed strictly within a shared C library
James Muller