xt_wang@cse.concordia.ca
2005-Jan-05 06:21 UTC
[Rd] How to connect R with a C code which includes Atlas
Hello, everybody, Happy New Year! I am a graduate student from Concordia University. I meet a problem when I am working on my thesis. I hope I will get help from you. I have a mathematical model which was already implemented by using R language. However, part of this model includes fixed point iteration algorithm and calculation of large linear equations which n will get to 5000. Because of limitation of memory, R is not enough to support this kind of calculation. Now, I use C language with Matlab C library to implement this part of model and solve this problem. But the problem is that I can not connect my C program with R code since C program include Matlab.h. The function I used from matlab is Cholesky algorithm which is applied to calculate inv(C)*b where C is a symmetric positive definite matrix. Since R is not easy to connect with C which include Maltab C library, and I find Atlas is optimized linear algebra library and possible to be used by R, do you think it is possible for me to replace matlab by using Atlas function in my C code, and finally the C code can be connected with R dynamically? That means I can run a R program -> which include C code-> which include Atlas automatically. If it is possible, could you please tell me how can I realize the dynamic link? Thanks for your help in advance! Yours, Maggie Wang
Prof Brian Ripley
2005-Jan-05 07:37 UTC
[Rd] How to connect R with a C code which includes Atlas
On Wed, 5 Jan 2005 xt_wang@cse.concordia.ca wrote:> Hello, everybody, > > Happy New Year! > > I am a graduate student from Concordia University. I meet a problem when > I am working on my thesis. I hope I will get help from you. > > I have a mathematical model which was already implemented by using R > language. However, part of this model includes fixed point iteration > algorithm and calculation of large linear equations which n will get to > 5000. Because of limitation of memory, R is not enough to support this > kind of calculation. Now, I use C language with Matlab C library to > implement this part of model and solve this problem. But the problem is > that I can not connect my C program with R code since C program include > Matlab.h. > > The function I used from matlab is Cholesky algorithm which is applied > to calculate inv(C)*b where C is a symmetric positive definite matrix. > Since R is not easy to connect with C which include Maltab C library, > and I find Atlas is optimized linear algebra library and possible to be > used by R, do you think it is possible for me to replace matlab by using > Atlas function in my C code, and finally the C code can be connected > with R dynamically? That means I can run a R program -> which include C > code-> which include Atlas automatically. If it is possible, could you > please tell me how can I realize the dynamic link?Certainly. Just put your C code into a package and include $(BLAS_LIBS) when you build the package: see `Writing R Extensions'. Note that ATLAS is an optimized BLAS, the B standing for Basic. For a Choleski decomposition you could use LAPACK as the R sources do and that will in turn use ATLAS if you built R against ATLAS. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
xt_wang@cse.concordia.ca
2005-Jan-05 23:59 UTC
[Rd] How to connect R with a C code which includes Atlas
If it is possible to link a C code with Atlas into R. Is it possible to link a C code with Matlab into R? On Wed, 5 Jan 2005 xt_wang@cse.concordia.ca wrote:> Hello, everybody, > > Happy New Year! > > I am a graduate student from Concordia University. I meet a problem when > I am working on my thesis. I hope I will get help from you. > > I have a mathematical model which was already implemented by using R > language. However, part of this model includes fixed point iteration > algorithm and calculation of large linear equations which n will get to > 5000. Because of limitation of memory, R is not enough to support this > kind of calculation. Now, I use C language with Matlab C library to > implement this part of model and solve this problem. But the problem is > that I can not connect my C program with R code since C program include > Matlab.h. > > The function I used from matlab is Cholesky algorithm which is applied > to calculate inv(C)*b where C is a symmetric positive definite matrix. > Since R is not easy to connect with C which include Maltab C library, > and I find Atlas is optimized linear algebra library and possible to be > used by R, do you think it is possible for me to replace matlab by using > Atlas function in my C code, and finally the C code can be connected > with R dynamically? That means I can run a R program -> which include C > code-> which include Atlas automatically. If it is possible, could you > please tell me how can I realize the dynamic link?Certainly. Just put your C code into a package and include $(BLAS_LIBS) when you build the package: see `Writing R Extensions'. Note that ATLAS is an optimized BLAS, the B standing for Basic. For a Choleski decomposition you could use LAPACK as the R sources do and that will in turn use ATLAS if you built R against ATLAS.