行列計算を仕様としているのですが、コンパイル時にはエラーをはかれないのですが、
実行時に
terminal
1Assertion failed: row >= 0 && row < rows() && col >= 0 && col < cols(), file Eigen/src/Core/DenseCoeffsBase.h, line 365
というエラーが出ます。
-Wall オプションをつけても何も言われません。
どなたか解決方法をご存知の方がいらっしゃいましたら、ご教授ください。
よろしくお願いいたします。
汚いですが、以下にコードを貼るのでよろしくお願いします。
Cul_Matrix.cpp
1#include <iostream> 2#include <chrono> 3 4using namespace std; 5 6#include "Eigen/Core" 7 8#define Roop_Max 50 9 10int main() 11{ 12 Eigen::MatrixXf A=Eigen::MatrixXf::Zero(2,2); 13 Eigen::MatrixXf Ax=Eigen::MatrixXf::Zero(2,1); 14 Eigen::MatrixXf Ax_=Eigen::MatrixXf::Zero(2,1); 15 Eigen::MatrixXf b_Ax_=Eigen::MatrixXf::Zero(2,1); 16 Eigen::MatrixXf x_true=Eigen::MatrixXf::Zero(2,1); 17 Eigen::MatrixXf x=Eigen::MatrixXf::Zero(2,1); 18 Eigen::MatrixXf x_=Eigen::MatrixXf::Zero(2,1); 19 Eigen::MatrixXf b=Eigen::MatrixXf::Zero(2,1); 20 A(0,0) = 1.0; 21 A(0,1) = 2.0; 22 A(1,0) = 3.0; 23 A(1,1) = 4.0; 24 25 b(0,1) = 1.0; 26 b(1,1) = 2.0; 27 28 x = b; 29 30 for ( int i = 0; i < Roop_Max; i++ ) 31 { 32 x_ = x * x; 33 Ax = A * x; 34 Ax_ = A * x_; 35 b_Ax_ = b - Ax_; 36 37 if (Ax == b) 38 { 39 break; 40 } 41 else 42 { 43 x = x + b_Ax_; 44 x_true = x; 45 } 46 47 } 48 49 cout << x_true << endl; 50}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/04 15:25
2019/07/04 16:49
2019/07/07 01:29