Hi, Bill
Thanks a lot for quick responding.
I have just started learning J. It seems to work fine. But I
cannot imagine how this code works well.
Does J support dynamic loading C or Fortran object file? If so, I
would like to know the syntax for invoking C or Fortran subprograms.
I want a simple J function with arguments of 'function name' and
function arguments.
'compile object fie (foo.so) function_name + ?*?*?*?*?'&cd
arg1;arg2; ,arg3
I do not understand ?'s
Toshinari Kamakura
On 2007/04/07, at 15:50, bill lam wrote:
kamakura wrote:
Hi,
Thanks a lot.
It is very nice for me. Basically I use R statistical software,
but it does not support sparse arrays. I recently noticed that J
and R are communicate each other. R is very good especially for
statistical computing with over 500 hundred libraries.
I sometimes use fortran or C programs through R with dyn.load
and .Fortran.
---------- foo.c----------------------------
void foo(int *n, double *x, double *sum)
{
int i;
for (i = 0, *sum = 0.0; i < *n ; i++) {
*sum += x[i];
}
}
--------------------------------------------
R CMD SHLIB foo.c
in R
>dyn.load("directory/foo.so")
>out<-.C("foo", as.integer(5), as.double(1:5), as.double(0))
On 2007/04/07, at 8:42, Roger Hui wrote:
> out
[[1]]
[1] 5
[[2]]
[1] 1 2 3 4 5
[[3]]
[1] 15
However, when I try to use C or Fortran code, I must do the
following:
R CMD Rserve
load '~system/packages/stats/rdsock.ijs'
'' conew 'prdsock'
+-+
|4|
+-+
Rcmd 'dyn.load("/Users/kamakura/work/foo.so")'
Rget'.C("foo", as.integer(5), as.double(1:5), as.double(0))'
+-+---------+--+
|5|1 2 3 4 5|15|
+-+---------+--+
I hope that the powerful J can handle this directly.
Kamakura san, may be I misread your question, I think that this
works for J,
'/Users/kamakura/work/foo.so foo + n *i *d *d'&cd (,5) ; ((0.5-0.5)
+>:i.5) ; ,0.5
--
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm