Loading Documentation/Examples/Matrices/SparseMatrix/CMakeLists.txt +22 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,16 @@ IF( BUILD_CUDA ) ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_1.out OUTPUT SparseMatrixExample_Constructor_init_list_1.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_init_list_2_cuda SparseMatrixExample_Constructor_init_list_2.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_init_list_2_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map_cuda SparseMatrixExample_Constructor_std_map.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out OUTPUT SparseMatrixExample_Constructor_std_map.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElements_cuda SparseMatrixExample_setElements.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElements_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElements.out Loading Loading @@ -130,6 +140,16 @@ ELSE() ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_1.out OUTPUT SparseMatrixExample_Constructor_init_list_1.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_init_list_2 SparseMatrixExample_Constructor_init_list_2.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_init_list_2 > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map SparseMatrixExample_Constructor_std_map.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out OUTPUT SparseMatrixExample_Constructor_std_map.out ) # ADD_EXECUTABLE( SparseMatrixExample_setElements SparseMatrixExample_setElements.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElements > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElements.out Loading Loading @@ -254,6 +274,8 @@ ENDIF() ADD_CUSTOM_TARGET( RunSparseMatricesExamples ALL DEPENDS SparseMatrixExample_Constructor_init_list_1.out SparseMatrixExample_Constructor_init_list_2.out SparseMatrixExample_Constructor_std_map.out # SparseMatrixExample_setElements.out # SparseMatrixExample_getCompressedRowLengths.out # SparseMatrixExample_getElementsCount.out Loading Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_1.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ template< typename Device > void initializerListExample() { TNL::Matrices::SparseMatrix< double, Device > matrix { { 1, 2, 3, 4, 5 } }; { 1, 2, 3, 4, 5 }, 6 }; for( int row = 0; row < matrix.getRows(); i++ ) for( int row = 0; row < matrix.getRows(); row++ ) for( int column = 0; column <= row; column++ ) matrix.setElement( row, column, row - column + 1 ); std::cout << "General sparse matrix: " << std::endl << matrix << std::endl; Loading Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_1.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_Constructor_init_list_1.cpp No newline at end of file Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_2.cpp 0 → 100644 +28 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Devices/Host.h> template< typename Device > void initializerListExample() { TNL::Matrices::SparseMatrix< double, Device > matrix ( 5, 5, { { 0, 0, 2.0 }, { 1, 0, -1.0 }, { 1, 1, 2.0 }, { 1, 2, -1.0 }, { 2, 1, -1.0 }, { 2, 2, 2.0 }, { 2, 3, -1.0 }, { 3, 2, -1.0 }, { 3, 3, 2.0 }, { 3, 4, -1.0 }, { 4, 4, 2.0 } } ); std::cout << "General sparse matrix: " << std::endl << matrix << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Creating matrices on CPU ... " << std::endl; initializerListExample< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Creating matrices on CUDA GPU ... " << std::endl; initializerListExample< TNL::Devices::Cuda >(); #endif } Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_2.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_Constructor_init_list_2.cpp No newline at end of file Loading
Documentation/Examples/Matrices/SparseMatrix/CMakeLists.txt +22 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,16 @@ IF( BUILD_CUDA ) ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_1.out OUTPUT SparseMatrixExample_Constructor_init_list_1.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_init_list_2_cuda SparseMatrixExample_Constructor_init_list_2.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_init_list_2_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map_cuda SparseMatrixExample_Constructor_std_map.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out OUTPUT SparseMatrixExample_Constructor_std_map.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElements_cuda SparseMatrixExample_setElements.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElements_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElements.out Loading Loading @@ -130,6 +140,16 @@ ELSE() ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_1.out OUTPUT SparseMatrixExample_Constructor_init_list_1.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_init_list_2 SparseMatrixExample_Constructor_init_list_2.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_init_list_2 > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_init_list_2.out OUTPUT SparseMatrixExample_Constructor_init_list_2.out ) ADD_EXECUTABLE( SparseMatrixExample_Constructor_std_map SparseMatrixExample_Constructor_std_map.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_Constructor_std_map > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_Constructor_std_map.out OUTPUT SparseMatrixExample_Constructor_std_map.out ) # ADD_EXECUTABLE( SparseMatrixExample_setElements SparseMatrixExample_setElements.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElements > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElements.out Loading Loading @@ -254,6 +274,8 @@ ENDIF() ADD_CUSTOM_TARGET( RunSparseMatricesExamples ALL DEPENDS SparseMatrixExample_Constructor_init_list_1.out SparseMatrixExample_Constructor_init_list_2.out SparseMatrixExample_Constructor_std_map.out # SparseMatrixExample_setElements.out # SparseMatrixExample_getCompressedRowLengths.out # SparseMatrixExample_getElementsCount.out Loading
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_1.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -7,9 +7,9 @@ template< typename Device > void initializerListExample() { TNL::Matrices::SparseMatrix< double, Device > matrix { { 1, 2, 3, 4, 5 } }; { 1, 2, 3, 4, 5 }, 6 }; for( int row = 0; row < matrix.getRows(); i++ ) for( int row = 0; row < matrix.getRows(); row++ ) for( int column = 0; column <= row; column++ ) matrix.setElement( row, column, row - column + 1 ); std::cout << "General sparse matrix: " << std::endl << matrix << std::endl; Loading
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_1.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_Constructor_init_list_1.cpp No newline at end of file
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_2.cpp 0 → 100644 +28 −0 Original line number Diff line number Diff line #include <iostream> #include <TNL/Matrices/SparseMatrix.h> #include <TNL/Devices/Host.h> template< typename Device > void initializerListExample() { TNL::Matrices::SparseMatrix< double, Device > matrix ( 5, 5, { { 0, 0, 2.0 }, { 1, 0, -1.0 }, { 1, 1, 2.0 }, { 1, 2, -1.0 }, { 2, 1, -1.0 }, { 2, 2, 2.0 }, { 2, 3, -1.0 }, { 3, 2, -1.0 }, { 3, 3, 2.0 }, { 3, 4, -1.0 }, { 4, 4, 2.0 } } ); std::cout << "General sparse matrix: " << std::endl << matrix << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Creating matrices on CPU ... " << std::endl; initializerListExample< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Creating matrices on CUDA GPU ... " << std::endl; initializerListExample< TNL::Devices::Cuda >(); #endif }
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_Constructor_init_list_2.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_Constructor_init_list_2.cpp No newline at end of file