2009年2月5日木曜日

liboctave かけ算

ColumnVector x(3); x(0)=1.0; x(1)=2.0; x(2)=3.0;
RowVector y(3); y(0)=3.0; y(1)=2.0; y(2)=1.0;
Matrix A(2,3);
A(0,0)=1.0; A(0,1)=2.0; A(0,2)=3.0;
A(1,0)=4.0; A(1,1)=3.0; A(1,2)=2.0;
double a(2.0);
cout << "x=" << endl << x;
cout << "y=" << endl << y << endl;
cout << "A=" << endl << A;
cout << "a=" << a << endl;
cout << "A*x=" << endl << A*x;
cout << "y*x= "<< y*x << endl;
cout << "x*y= " << endl << x*y;
cout << "y*(x*y)= " << endl << y*(x*y) << endl;
cout << "a*x=" << endl << a*x;
cout << "a*y=" << endl << a*y << endl;
cout << "a*A=" << endl << a*A;