Konstantin L. Metlov wrote:
> What I'm missing is the possibility to pass a pointer to the integrand 
> function (written in J) into the Fortran or C code (called from J).
> 
> I've seen the lab on callbacks, but they are only allowed to return a scalar 
> integer result, while I'd like to be able to receive and pass back to Fortran 
> (or C) a vector (of floats) or, even better, a general array. Is there 
> another 
> interface for writing external (defined in DLLs) adverbs (or conjunctions), 
> taking a function (verb) as an argument ?

I'm completely ignorant in your problem domain, but it might use integer
argument to pass an address of any J noun using this verb.

iad=: 3 : 0
y=. y.
SZI=. IF64{4 8
ple=. 15!:6 <y
pa=. memr ple, SZI, 1, JPTR
''$pa+memr pa, 0, 1, JPTR
)

for example, p will be a pointer to memory block of content of array a.

a=: %: i. 3 4
p=. iad 'a'

   memr p, 0 12 8
0 1 1.41421356 1.73205081 2 2.23606798 2.44948974 2.64575131 2.82842712 3
3.16227766 3.31662479
   ,a
0 1 1.41421356 1.73205081 2 2.23606798 2.44948974 2.64575131 2.82842712 3
3.16227766 3.31662479

In this manner it is possible to pass general array to C/Fortran, of course
C/Fortran has more work to do in order to decode a boxed array.

To pass array in the other direction C/Fortran -> J, to just pass the pointer to
the array and use memr in J to read its content.

-- 
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to