Registered Member
|
I would solve this system with sparse matrix: this code is without sparse matrix
MatrixXd A= MatrixXd(13,13); MatrixXd b = MatrixXd(13,3); MatrixXd x1= MatrixXd(13,3); A.setZero(); b.setZero(); x1.setZero(); A(0,0)=1; A(0,5)=2; A(0,5)=1; x1(0,0)=3; x1(1,0)=-1; x1(0,0)=2; A(1,7)=1; A(1,8)=5; A(1,9)=-2; x1(1,0)=5; x1(1,1)=-5; x1(1,2)=1; A(2,0)=-1; A(2,3)=2; A(2,10)=-1; x1(2,0)=-1; x1(2,1)=-1;x1(2,2)=-1; A(3,4)=2; A(3,8)=-2; A(3,12)=3; x1(3,0)=0; x1(3,1)=1; x1(3,2)=2; A(4,1)=-3; A(4,3)=-1; A(4,6)=-1; x1(4,0)=3; x1(4,1)=-1; x1(4,2)=-2; A(5,4)=-1; A(5,5)=3; A(5,11)=7; x1(5,0)=1; x1(5,1)=-1; x1(5,2)=2; A(6,6)=2; A(6,7)=1; A(6,9)=-3; x1(6,0)=2; x1(6,1)=-3; x1(6,2)=4; A(7,3)=1; A(7,9)=-4; A(7,11)=3; x1(7,0)=3; x1(7,1)=3; x1(7,2)=2; A(8,8)=-4; A(8,1)=-2; A(8,3)=3; x1(8,0)=4; x1(8,1)=4; x1(8,2)=3; A(9,5)=-5; A(9,9)=-2; A(9,10)=-1; x1(9,0)=5; x1(9,1)=-7; x1(9,2)=2; A(10,0)=-1; A(10,9)=2; A(10,12)=1; x1(10,0)=6; x1(10,1)=7;x1(10,2)=5; A(11,1)=-3; A(11,2)=2; A(11,3)=1; x1(11,0)=7; x1(11,1)=8;x1(11,2)=2; A(12,9)=-5; A(12,8)=2; A(12,1)=-1; x1(12,0)=8; x1(12,1)=1;x1(12,2)=7; b=A*x1; MatrixXd x = A.fullPivLu().solve(b); Someone could write a piece of code to solve this system with sparse matrix I tried follow http://eigen.tuxfamily.org/dox/TutorialSparse.html but the result is wrong... |
Moderator
|
You should rather show us what you tried.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]