Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WRScpp for other platforms other than x86_64-apple-darwin13.1.0 #3

Open
JauntyJJS opened this issue Dec 8, 2014 · 15 comments
Open

Comments

@JauntyJJS
Copy link

Hi,

After installing the package WRScpp, I tried to use the package by calling library(WRScpp).
However, the following error is received.

Error: package 'WRScpp' was built for x86_64-apple-darwin13.1.0

May I ask if this package will be usable in other platforms in the near future say

Platform: x86_64-w64-mingw32/x64 (64-bit)

Regards,
Jeremy

@mrxiaohe
Copy link
Owner

Hi Jeremy,

Sorry for the late reply. I am not familiar with your platform. Is your platform a PC? If so, can you try this: https://github.com/mrxiaohe/WRScppWin

@JauntyJJS
Copy link
Author

Hi Xiao He,

Sorry for the mistake on the platform.
That is actually the name of a gcc compiler that supports 32bit and 64 bit Windows.
I have tried to download the package using the link provided in Windows and it works.
Thank you for that

Meanwhile, may I ask if this package also support installation in a Linux platform as well ?

@mrxiaohe
Copy link
Owner

Hi Jeremy,

I don't have a Linux machine to compile the package. Sorry!

Best,
Xiao

@JoeJohnston
Copy link

@mrxiaohe Thanks for providing the raw files and doing the hard work on this. 👍

I was able to compile it on a linux machine (Linux Mint 17 Qiana (GNU/Linux 3.13.0-24-generic x86_64)) using the raw code, but I had to make some adjustments to the robustmethods_CPP.cpp file and the robustmethods_CPP.R files. I'm not sure if I did it correctly as this is the first time I have built a package from source by hand in R and I am relatively new to R and C++ in general. I'll be happy to share my experience, but I can't confirm that I've done everything correctly or that I even remember exactly what I did. There is a lot in there that I don't fully understand.

edit: (I just noticed you made an update to the raw code 23 hours ago. I was using the older version. Some of the adjustments that I made I think would still need to be made in the more recent code (e.g. tsp1reg_C returns only coef (which is unnamed, so temp1$coef is not valid) and not res). Again, I'm new to this, so I may just be using it incorrectly. I may try with this new version this weekend and see if I can document what I have done to get it to work for me with the expected results.)

@mrxiaohe
Copy link
Owner

Hi Joe,

I didn't change the actual functions in the raw file. So it shouldn't affect the performance of any of the functions.

Can you start a repository for the updated code that you are using? Perhaps you can also upload the compiled file. Also it would be great if you could note the changes you made. I will add links to your repository in my repositories, so that people who want a Linux version can get it from you.

@JoeJohnston
Copy link

Hi Xiao He,
I've uploaded the files I used to build the WRScpp for linux here. I uploaded the 64 bit binaries here. Again, not sure I am doing it right. Feel free to let me know how to improve the code.

Best,

Joe

@mrxiaohe
Copy link
Owner

Hey Joe,

I added your links in my WRSCPP Readme. Thank you!

Best,
Xiao

@JoeJohnston
Copy link

Hi Xiao,
While trying to compile my edited code on my Mac, I can ran into errors similar to the ones you mention here. I am wondering how did you resolve those? On Linux, these result in warnings but that doesn't stop it.

Best,

Joe

@mrxiaohe
Copy link
Owner

mrxiaohe commented Mar 2, 2015

Hi Joe,

The strange thing is that after I restarted my computer, I was able to compile the code...I have no idea what was going on. That's why I didn't pursue it further.

What warnings did you get? I got warnings when I compiled the code on my Mac. After I did some investigative Googling, it seemed that the warnings were OK.

@JoeJohnston
Copy link

Here are all the warnings I got when I compile on Linux. They seem to be related to the errors I am getting on my Mac. I restarted my mac and the errors still persist.
Best,

Joe

* installing to library ‘/home/joe/R/x86_64-pc-linux-gnu-library/3.0’
* installing *source* package ‘WRScpp’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/home/joe/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/include" -I"/home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include" -I"/home/joe/R/x86_64-pc-linux-gnu-library/3.0/MASS/include" -I"/home/joe/R/x86_64-pc-linux-gnu-library/3.0/scatterplot3d/include"   -fpic  -O3 -pipe  -g  -c WRScpp.cpp -o WRScpp.o
In file included from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo:126:0,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadilloForward.h:46,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadillo.h:30,
                 from WRScpp.cpp:7:
/home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo_bits/blas_bones.hpp:62:111: warning: declaration of ‘double arma::ddot_(arma::blas_int*, const double*, arma::blas_int*, const double*, arma::blas_int*)’ with C language linkage [enabled by default]
   double arma_fortran(arma_ddot)(blas_int* n, const double* x, blas_int* incx, const double* y, blas_int* incy);
                                                                                                               ^
In file included from /usr/share/R/include/R.h:44:0,
                 from WRScpp.cpp:1:
/usr/share/R/include/R_ext/BLAS.h:58:10: warning: conflicts with previous declaration ‘double ddot_(const int*, const double*, const int*, const double*, const int*)’ [enabled by default]
 F77_NAME(ddot)(const int *n, const double *dx, const int *incx,
          ^
/usr/share/R/include/R_ext/RS.h:82:22: note: in definition of macro ‘F77_CALL’
 # define F77_CALL(x) x ## _
                      ^
/usr/share/R/include/R_ext/BLAS.h:58:1: note: in expansion of macro ‘F77_NAME’
 F77_NAME(ddot)(const int *n, const double *dx, const int *incx,
 ^
In file included from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo:126:0,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadilloForward.h:46,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadillo.h:30,
                 from WRScpp.cpp:7:
/home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo_bits/blas_bones.hpp:67:240: warning: declaration of ‘void arma::zgemv_(const char*, const blas_int*, const blas_int*, const void*, const void*, const blas_int*, const void*, const blas_int*, const void*, void*, const blas_int*)’ with C language linkage [enabled by default]
   void arma_fortran(arma_zgemv)(const char* transA, const blas_int* m, const blas_int* n, const void*   alpha, const void*   A, const blas_int* ldA, const void*   x, const blas_int* incx, const void*   beta, void*   y, const blas_int* incy);
                                                                                                                                                                                                                                                ^
In file included from /usr/share/R/include/R.h:44:0,
                 from WRScpp.cpp:1:
/usr/share/R/include/R_ext/BLAS.h:287:14: warning: conflicts with previous declaration ‘void zgemv_(char*, int*, int*, Rcomplex*, Rcomplex*, int*, Rcomplex*, int*, Rcomplex*, Rcomplex*, int*)’ [enabled by default]
     F77_NAME(zgemv)(char *trans, int *m, int *n, Rcomplex *alpha,
              ^
/usr/share/R/include/R_ext/RS.h:82:22: note: in definition of macro ‘F77_CALL’
 # define F77_CALL(x) x ## _
                      ^
/usr/share/R/include/R_ext/BLAS.h:287:5: note: in expansion of macro ‘F77_NAME’
     F77_NAME(zgemv)(char *trans, int *m, int *n, Rcomplex *alpha,
     ^
In file included from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo:126:0,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadilloForward.h:46,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadillo.h:30,
                 from WRScpp.cpp:7:
/home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo_bits/blas_bones.hpp:72:277: warning: declaration of ‘void arma::zgemm_(const char*, const char*, const blas_int*, const blas_int*, const blas_int*, const void*, const void*, const blas_int*, const void*, const blas_int*, const void*, void*, const blas_int*)’ with C language linkage [enabled by default]
   void arma_fortran(arma_zgemm)(const char* transA, const char* transB, const blas_int* m, const blas_int* n, const blas_int* k, const void*   alpha, const void*   A, const blas_int* ldA, const void*   B, const blas_int* ldB, const void*   beta, void*   C, const blas_int* ldC);
                                                                                                                                                                                                                                                                                     ^
In file included from /usr/share/R/include/R.h:44:0,
                 from WRScpp.cpp:1:
/usr/share/R/include/R_ext/BLAS.h:281:14: warning: conflicts with previous declaration ‘void zgemm_(const char*, const char*, const int*, const int*, const int*, const Rcomplex*, const Rcomplex*, const int*, const Rcomplex*, const int*, const Rcomplex*, Rcomplex*, const int*)’ [enabled by default]
     F77_NAME(zgemm)(const char *transa, const char *transb, const int *m,
              ^
/usr/share/R/include/R_ext/RS.h:82:22: note: in definition of macro ‘F77_CALL’
 # define F77_CALL(x) x ## _
                      ^
/usr/share/R/include/R_ext/BLAS.h:281:5: note: in expansion of macro ‘F77_NAME’
     F77_NAME(zgemm)(const char *transa, const char *transb, const int *m,
     ^
In file included from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo:126:0,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadilloForward.h:46,
                 from /home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/RcppArmadillo.h:30,
                 from WRScpp.cpp:7:
/home/joe/R/x86_64-pc-linux-gnu-library/3.0/RcppArmadillo/include/armadillo_bits/blas_bones.hpp:78:218: warning: declaration of ‘void arma::zherk_(const char*, const char*, const blas_int*, const blas_int*, const double*, const void*, const blas_int*, const double*, void*, const blas_int*)’ with C language linkage [enabled by default]
   void arma_fortran(arma_zherk)(const char* uplo, const char* transA, const blas_int* n, const blas_int* k, const double* alpha, const   void* A, const blas_int* ldA, const double* beta,   void* C, const blas_int* ldC);
                                                                                                                                                                                                                          ^
In file included from /usr/share/R/include/R.h:44:0,
                 from WRScpp.cpp:1:
/usr/share/R/include/R_ext/BLAS.h:319:14: warning: conflicts with previous declaration ‘void zherk_(char*, char*, int*, int*, double*, Rcomplex*, int*, double*, Rcomplex*, int*)’ [enabled by default]
     F77_NAME(zherk)(char *uplo, char *trans, int *n, int *k,
              ^
/usr/share/R/include/R_ext/RS.h:82:22: note: in definition of macro ‘F77_CALL’
 # define F77_CALL(x) x ## _
                      ^
/usr/share/R/include/R_ext/BLAS.h:319:5: note: in expansion of macro ‘F77_NAME’
     F77_NAME(zherk)(char *uplo, char *trans, int *n, int *k,
     ^
g++ -shared -o WRScpp.so WRScpp.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR
installing to /home/joe/R/x86_64-pc-linux-gnu-library/3.0/WRScpp/libs
** R

@mrxiaohe
Copy link
Owner

mrxiaohe commented Mar 7, 2015

Hi Joe,

The problem has to do with the headers included. But the issue is that some of the functions included need some of these headers (I think the functions that compute robust location and scatter estimators need those. covrob, I think). However, if you comment out some of these headers (see below), you won't be able to compile the code because some functions depend on them. I was suggested to include some of those headers in a different file. But I haven't really had the time to try the suggestions... :-/

But also, did you get error messages or warning messages. Often times warning messages are not serious, and you can often still load and use the compiled code.

//#include <R.h>
//#include <float.h>
#include <vector>
#include <string>
//#include <R_ext/Linpack.h>
//#include <R_ext/Applic.h> /* for the QR     routines */
//#include <R_ext/Utils.h>  /* for the *sort() routines */
//#include <stdio.h>
#include <RcppArmadillo.h>

@mrxiaohe mrxiaohe closed this as completed Mar 9, 2015
@mrxiaohe mrxiaohe reopened this Mar 9, 2015
@mrxiaohe
Copy link
Owner

mrxiaohe commented Mar 9, 2015

Hi Joe,

I think I solved the Fortran problem. I created a new branch in the repository for the raw code. You can try compile the code by using the following command in your terminal:

Rscript compiler.R robustmethods_CPP.cpp lower_level.cpp

You need robustmethods_CPP.cpp, lower_level.cpp, and lower_level.h. You might need compiler.R.

Let me know if it worked.

@JoeJohnston
Copy link

Hi Xiao He,
Thanks for you hard work.

It seems to work OK. Still some warnings about undeclared/unused variables, but that's not a big deal. I was able to compile it from Linux, Windows, and Mac. There are still some issues with things like tsreg_c not returning the coefficients and residuals in the expected way (in robustfunctions_cpp.R) and with exporting some of the functions. My WRScpp_test repository has these fixes (I think) and it what I used to compile on all my machines using install_github(repo="JoeJohnston/WRScpp_test").

Best,

Joe

@mrxiaohe
Copy link
Owner

Re: tsreg_C: that is a bit strange because it returns coefs on my computer:

> tsreg_C(rnorm(10), rnorm(10))
$coef
[1]  0.1600009 -0.2620810

$residuals
             [,1]
 [1,] -2.22124227
 [2,]  0.21626728
 [3,]  1.97152065
 [4,]  0.17050548
 [5,] -0.49741296
 [6,]  0.23054892
 [7,] -0.04913903
 [8,]  0.21626728
 [9,]  0.62994977
[10,] -0.03741709

$Strength.Assoc
[1] 0.4766511

$Explanatory.Power
[1] 0.2271962

@JoeJohnston
Copy link

It is strange. When I install your Mac Binary, I have no problem. However, when I use the robustmethods_CPP.cpp and the robustmethods_CPP.R from your raw code, I get Error in temp1$coef : $ operator is invalid for atomic vectors.

As I understand (and I said before, I am no expert) tsreg_C() is defined starting on line 135 in robustmethods_CPP.R, which calls, on line 163, tsp1reg_C, which is defined in robustmethods_CPP.cpp on line 361. This returns, on line 371, the coefficient as an unnamed value and does not return the residuals at all. As such, temp1$ceof and temp$res do not exist. To make it work, I changed line 163 through 165 on robustmethods_CPP.R from

temp1<-.Call("tsp1reg_C", X=x, Y=y, HD=as.integer(HD))
coef<-temp1$coef
res<-temp1$res

to

 coef<-.Call("tsp1reg_C", X=x, Y=y, HD=as.integer(hd))
 res<-y-coef[2]*x-coef[1]

I had also had problems with the call to tsreg_for and I could not get it to work. I ended up changing the lines 168 through 170 from

temp1<-.Call("tsreg_for", X=x, Y=y, IT=as.integer(iter), HD=as.integer(HD))
coef<-c(temp1$alpha,temp1$beta)
res<-temp1$res

to

temp1<-.Call("tsreg_C", X=x,Y=y, IT=as.integer(iter), HD=as.integer(hd))
coef<-temp1$coef
res<-temp1$res

as I noticed that ts_reg_C in robustmethods_CPP.cpp dealt with multivariate regression, though I am not sure if I did this correctly and, to be quite honest, I have no idea what the Gauss-Seidel algorithm is.

There were also some functions in robustmethods_CPP.cpp that I had to export to get to work, though I don't recall exactly which ones.

This is kind of out of topic for the thread. If you want, I can start an issue document on your raw code.

Best,

Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants