00001 #include "Teuchos_SerialDenseMatrix.hpp"
00002 #include "Teuchos_SerialDenseVector.hpp"
00003 #include "Teuchos_SerialDenseSolver.hpp"
00004 #include "Teuchos_RCP.hpp"
00005 #include "Teuchos_Version.hpp"
00006
00007 int main(int argc, char* argv[])
00008 {
00009 std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
00010
00011
00012
00013 Teuchos::SerialDenseMatrix<int,double> Empty_Matrix;
00014
00015 Teuchos::SerialDenseMatrix<int,double> My_Matrix( 3, 4 );
00016
00017 Teuchos::SerialDenseMatrix<int,double> My_Copy1( My_Matrix ),
00018
00019 My_Copy2( Teuchos::Copy, My_Matrix, 3, 3 ),
00020
00021 My_Copy3( Teuchos::View, My_Matrix, 2, 3, 1, 1 );
00022
00023 Teuchos::SerialDenseVector<int,double> x(3), y(3);
00024
00025
00026 int rows, cols, stride;
00027 rows = My_Copy3.numRows();
00028 cols = My_Copy3.numCols();
00029 stride = My_Copy3.stride();
00030
00031
00032 Empty_Matrix.shape( 3, 3 );
00033 My_Matrix.reshape( 3, 3 );
00034
00035
00036 My_Matrix.random();
00037 My_Copy1.putScalar( 1.0 );
00038 My_Copy2(1,1) = 10.0;
00039 Empty_Matrix = My_Matrix;
00040 x = 1.0;
00041 y = 1.0;
00042
00043
00044 double d;
00045 Teuchos::SerialDenseMatrix<int,double> My_Prod( 3, 2 );
00046
00047 My_Prod.multiply( Teuchos::NO_TRANS, Teuchos::TRANS,
00048 1.0, My_Matrix, My_Copy3, 0.0 );
00049 My_Copy2 += My_Matrix;
00050 My_Copy2.scale( 0.5 );
00051 d = x.dot( y );
00052
00053
00054 double *My_Array=0, *My_Column=0;
00055 My_Array = My_Matrix.values();
00056 My_Column = My_Matrix[2];
00057
00058
00059 double norm_one, norm_inf, norm_fro;
00060 norm_one = My_Matrix.normOne();
00061 norm_inf = My_Matrix.normInf();
00062 norm_fro = My_Matrix.normFrobenius();
00063
00064
00065
00066 if (Empty_Matrix == My_Matrix) {
00067 std::cout<< "The matrices are the same!" <<std::endl;
00068 }
00069
00070 if (My_Copy2 != My_Matrix) {
00071 std::cout<< "The matrices are different!" <<std::endl;
00072 }
00073
00074
00075 Teuchos::SerialDenseSolver<int,double> My_Solver;
00076 Teuchos::SerialDenseMatrix<int,double> X(3,1), B(3,1);
00077 X.putScalar(1.0);
00078 B.multiply( Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, My_Matrix, X, 0.0 );
00079 X.putScalar(0.0);
00080
00081 int info = 0;
00082 My_Solver.setMatrix( Teuchos::rcp( &My_Matrix, false ) );
00083 My_Solver.setVectors( Teuchos::rcp( &X, false ), Teuchos::rcp( &B, false ) );
00084 info = My_Solver.factor();
00085 if (info != 0)
00086 std::cout << "Teuchos::SerialDenseSolver::factor() returned : " << info << std::endl;
00087 info = My_Solver.solve();
00088 if (info != 0)
00089 std::cout << "Teuchos::SerialDenseSolver::solve() returned : " << info << std::endl;
00090
00091
00092 std::cout<< std::endl << My_Matrix << std::endl;
00093 std::cout<< X << std::endl;
00094
00095 return 0;
00096 }