Как опытный пользователь R, не имеющий знаний в C ++ и OOP в целом, я хотел бы УЗНАТЬ QR-разложение с библиотекой алгебры матриц Eigen (через R-пакет RccpEigen) из-за его ожидаемой высокой производительности. Когда я запускаю следующий фрагмент кода (первый пример из здесь - я добавил первые 2 строки, которые, однако, не влияют на выходные данные) через 'source Cpp':
sourceCpp(code='
// [[Rcpp::depends(RcppEigen)]]
#include <RcppEigen.h>
#include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
Matrix3f A;
Vector3f b;
A << 1,2,3, 4,5,6, 7,8,10;
b << 3, 3, 4;
cout << "Here is the matrix A:\n" << A << endl;
cout << "Here is the vector b:\n" << b << endl;
Vector3f x = A.colPivHouseholderQr().solve(b);
cout << "The solution is:\n" << x << endl;
}
')
Я получаю следующее (длинное, извините) сообщение:
C:/Rtools/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.3/include" -
DNDEBUG -I"C:/Users/W10PRO~1/DOCUME~1/R/WIN-LI~1/3.6/Rcpp/include" -
I"C:/Users/W10PRO~1/DOCUME~1/R/WIN-LI~1/3.6/RCPPEI~1/include" -
I"C:/Users/W10PRO~1/AppData/Local/Temp/RTMPO2~1/SOURCE~1.3" -O2 -Wall
-mtune=core2 -c file2b0301f29d8.cpp -o file2b0301f29d8.o
file2b0301f29d8.cpp:16:11: warning: missing terminating " character
cout << "Here is the matrix A:
file2b0301f29d8.cpp:16:3: error: missing terminating " character
cout << "Here is the matrix A:
file2b0301f29d8.cpp:17:1: warning: missing terminating " character
" << A << endl;
file2b0301f29d8.cpp:17:1: error: missing terminating " character
file2b0301f29d8.cpp:18:11: warning: missing terminating " character
cout << "Here is the vector b:
^
file2b0301f29d8.cpp:18:3: error: missing terminating " character
cout << "Here is the vector b:
file2b0301f29d8.cpp:19:1: warning: missing terminating " character
" << b << endl;
file2b0301f29d8.cpp:19:1: error: missing terminating " character
file2b0301f29d8.cpp:21:11: warning: missing terminating " character
cout << "The solution is:
file2b0301f29d8.cpp:21:3: error: missing terminating " character
cout << "The solution is:
file2b0301f29d8.cpp:22:1: warning: missing terminating " character
" << x << endl;
file2b0301f29d8.cpp:22:1: error: missing terminating " character
file2b0301f29d8.cpp: In function 'int main()':
file2b0301f29d8.cpp:20:12: error: expected primary-expression before 'x'
Vector3f x = A.colPivHouseholderQr().solve(b);
^
file2b0301f29d8.cpp:23:1: error: expected primary-expression before '}' token
}
make: *** [C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf:215: file2b0301f29d8.o]
Error 1
Error in sourceCpp(code = "\n// [[Rcpp::depends(RcppEigen)]]\n#include
<RcppEigen.h>\n#include <iostream>\n#include <Eigen/Dense>\nusing namespace
std;\nusing namespace Eigen;\n\n// [[Rcpp::export]]\nint main()\n{\n
Matrix3f A;\n Vector3f b;\n A << 1,2,3, 4,5,6, 7,8,10;\n b << 3, 3, 4;\n
cout << \"Here is the matrix A:\n\" << A << endl;\n cout << \"Here is the
vector b:\n\" << b << endl;\n Vector3f x =
A.colPivHouseholderQr().solve(b);\n cout << \"The solution is:\n\" << x <<
endl;\n}\n") :
Error 1 occurred building shared library.
Это моя конфигурация R / C ++ (без компилятора g cc?):
library(Rcpp) # 1.0.3
library(RcppEigen) # v. 0.3.3.7.0
RcppEigen:::eigen_version(FALSE)
3 3 7
find_rtools()
[1] TRUE
evalCpp("2+2")
[1] 4
has_compiler()
[1] TRUE
check_compiler()
[1] TRUE
check_build_tools()
>Your system is ready to build packages!
Sys.which("make")
"C:\\Rtools\\bin\\make.exe"
Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R- 3.6.3\\bin\\x64;C:\\Rtools\\bin; etc
system('gcc -v')
127
sessionInfo()
> R version 3.6.3 (2020-02-29)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows >= 8 x64 (build 9200)
> attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pkgbuild_1.0.6 devtools_2.3.0 usethis_1.6.0 inline_0.3.15
RcppEigen_0.3.3.7.0
[6] Rcpp_1.0.3
loaded via a namespace (and not attached):
....
Любая помощь, пожалуйста? [Почему «система ('g cc -v')» дает 127?]