2017-04-25 4 views
0

ODE_vector型のオブジェクトをarmadillo vecに変換しようとしています。そのため、新しいオブジェクトはarmadilloライブラリの線形代数機能を継承します。問題の簡単な例として、私は、これはC++アレイを使用して実証され持っています:高度なコンストラクタを使用して配列をarmadillo vecに変換する

#include <iostream> 
#include <random> 
#include <armadillo> 

using namespace std; 
using namespace arma; 

int main() { 

double b1 = 0.2; 
double b2 = 0.1; 
const double state[2] = {b1, b2}; 

rowvec B(&state[0], 2); 
cout << B << endl; 

mat A(2,2); A.fill(0.2); A.diag().ones(); 
cout << A << endl; 

cout << B(0) * A(0,0) << endl; // x 

return 0; 

} 

このスクリプトを実行すると、以下を返すように、B1とB2に含まれるデータは、Bの要素に保存されている:

:私は

cout << B * A << endl; 

して上に線xを交換する場合は、私はBが標準アルマジロ線形代数の機能を継承していない示唆エラーが出

0.2000 
    0.1000 

    1.0000 0.2000 
    0.2000 1.0000 

0.2 
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o 
[100%] Linking CXX executable untitled 
CMakeFiles/untitled.dir/main.cpp.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)': 
/usr/include/armadillo_bits/wrapper_blas.hpp:36: undefined reference to `wrapper_dgemv_' 
CMakeFiles/untitled.dir/main.cpp.o: In function `void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)': 
/usr/include/armadillo_bits/wrapper_blas.hpp:71: undefined reference to `wrapper_dgemm_' 
collect2: error: ld returned 1 exit status 
CMakeFiles/untitled.dir/build.make:94: recipe for target 'untitled' failed 
make[3]: *** [untitled] Error 1 
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/untitled.dir/all' failed 
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2 
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/untitled.dir/rule' failed 
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2 
Makefile:118: recipe for target 'untitled' failed 
make: *** [untitled] Error 2 

高度なコンストラクタ(arma documentation)を正しく使用してこれを動作させる方法を説明できる人はいますか?

ありがとうございます。

答えて

0

乗算には正しい形式が必要です。タイプBは2×1であり、Aは2×2である。私はそれは簡単なことだったら

mat B(&state[0], 1,2); 

または

rowvec B(&state[0], 2); 
+0

に変更します!!私はアルマジロクラスの様々な組み合わせを試しましたが、それは問題を解決しません。混乱を避けるために質問を編集し、提案に感謝します。 –

+0

ビルドでBLASを有効にしてもよろしいですか?私にとっては、上記の 'x'行の2つの がうまく機能しました。 –

+0

あなたは正しいです!それは適切にリンクされていなかった、それはCMakeの問題だった...同様の問題を抱えている人なら、このリンクをチェックしてみてください:https://intellij-support.jetbrains.com/hc/en-us/community/posts/205823019 - エラー - コンパイルコード - アルマジロと助けてよろしく! –

関連する問題