[R] question about dyn.load()
Douglas Bates
bates at stat.wisc.edu
Thu May 13 15:57:49 CEST 2004
xt_wang at cs.concordia.ca writes:
> Hello, everybody,
>
> I met a big problem. What I want is to use c code in R. I have load
> a test code conv.c in R and run it successfully. However, in my real
> code, I use matlab c library (Matrix Inverse function). After I use
> command R CMD SHLIB to share library, I can not use dyn.load to load
> the object in R. undefined symbol: mclCleanupProtectedItems always
> be mentioned.
>
> My question is that whether I can compile, load and use a c code in
> R which includes other library. If I can, How can I do? Could you
> help me find out where is the error during the whole operation? If I
> can not load a c code with other library in R, can I load a c code
> with R library in R ( which include matrix inverse function)? If so,
> where can I find the R library with matrix inverse function that has
> a c interface?
>
> I will appreciate very much if somebody can help me resolve this problem.
>
> Thanks in advance!
>
> Yours,
>
> Maggie
To begin with, you probably don't need a matrix inverse. Although
formulae are frequently written in terms of a matrix inverse they
should be evaluated using a decomposition, such as the LU
decomposition or the QR decomposition, of the coefficient matrix.
If your code does require numerical linear algebra the best approach
is to create an R package for your code and list the LAPACK and BLAS
libraries in the PACKAGE_LIBS macro definition, as described in the
manual Writing R Extensions. Please read that manual. I would also
recommend that you read the sections of the Lapack manual (available
online) that deal with the LU decomposition.
This may seem to be a difficult approach to something as "simple" as
creating a matrix inverse. The reason for the complexity is because
creating a matrix inverse quickly and stably is not simple and usually
unnecessary.
More information about the R-help
mailing list