00001 #include "Teuchos_SerialDenseMatrix.hpp"
00002 #include "Teuchos_Version.hpp"
00003
00004 int main(int argc, char* argv[])
00005 {
00006 std::cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
00007
00008
00009
00010 Teuchos::SerialDenseMatrix<int,double> Empty_Matrix;
00011
00012 Teuchos::SerialDenseMatrix<int,double> My_Matrix( 3, 4 );
00013
00014 Teuchos::SerialDenseMatrix<int,double> My_Copy1( My_Matrix ),
00015
00016 My_Copy2( Teuchos::Copy, My_Matrix, 3, 3 ),
00017
00018 My_Copy3( Teuchos::View, My_Matrix, 2, 3, 1, 1 );
00019
00020
00021 int rows, cols, stride;
00022 rows = My_Copy3.numRows();
00023 cols = My_Copy3.numCols();
00024 stride = My_Copy3.stride();
00025
00026
00027 Empty_Matrix.shape( 3, 3 );
00028 My_Matrix.reshape( 3, 3 );
00029
00030
00031 My_Matrix.random();
00032 My_Copy1.putScalar( 1.0 );
00033 My_Copy2(1,1) = 10.0;
00034 Empty_Matrix = My_Matrix;
00035
00036
00037 Teuchos::SerialDenseMatrix<int,double> My_Prod( 3, 2 );
00038
00039 My_Prod.multiply( Teuchos::NO_TRANS, Teuchos::TRANS,
00040 1.0, My_Matrix, My_Copy3, 0.0 );
00041 My_Copy2 += My_Matrix;
00042 My_Copy2.scale( 0.5 );
00043
00044
00045 double *My_Array=0, *My_Column=0;
00046 My_Array = My_Matrix.values();
00047 My_Column = My_Matrix[2];
00048
00049
00050 double norm_one, norm_inf, norm_fro;
00051 norm_one = My_Matrix.normOne();
00052 norm_inf = My_Matrix.normInf();
00053 norm_fro = My_Matrix.normFrobenius();
00054
00055
00056
00057 if (Empty_Matrix == My_Matrix) {
00058 std::cout<< "The matrices are the same!" <<std::endl;
00059 }
00060
00061 if (My_Copy2 != My_Matrix) {
00062 std::cout<< "The matrices are different!" <<std::endl;
00063 }
00064
00065
00066 std::cout<< My_Matrix << std::endl;
00067
00068 return 0;
00069 }