Loading Documentation/Examples/Matrices/DenseMatrix/DenseMatrixExample_getElement.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ void getElements() for( int i = 0; i < 5; i++ ) { for( int j = 0; j < 5; j++ ) std::cout << std::setw( 5 ) << std::ios::right << matrix.getElement( i, i ); std::cout << std::setw( 5 ) << matrix.getElement( i, j ); std::cout << std::endl; } } Loading Documentation/Examples/Matrices/DenseMatrix/DenseMatrixExample_setElement.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include <TNL/Algorithms/ParallelFor.h> #include <TNL/Matrices/DenseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Pointers/SharedPointer.h> #include <TNL/Pointers/SmartPointersRegister.h> Loading @@ -18,12 +19,17 @@ void setElements() auto f = [=] __cuda_callable__ ( int i ) mutable { matrix->setElement( i, i, -i ); }; /*** * For the case when Device is CUDA device we need to synchronize smart * pointers. To avoid this you may use DenseMatrixView. See * DenseMatrixView::getRow example for details. */ TNL::Pointers::synchronizeSmartPointersOnDevice< Device >(); TNL::Algorithms::ParallelFor< Device >::exec( 0, 5, f ); std::cout << "Matrix set from its native device:" << std::endl; std::cout << *matrix << std::endl; } int main( int argc, char* argv[] ) Loading Documentation/Examples/Matrices/SparseMatrix/CMakeLists.txt +49 −60 Original line number Diff line number Diff line Loading @@ -39,35 +39,30 @@ IF( BUILD_CUDA ) ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getCompressedRowLengths.out OUTPUT SparseMatrixExample_getCompressedRowLengths.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getElementsCount_cuda SparseMatrixExample_getElementsCount.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElementsCount_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElementsCount.out # OUTPUT SparseMatrixExample_getElementsCount.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getConstRow_cuda SparseMatrixExample_getConstRow.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out # OUTPUT SparseMatrixExample_getConstRow.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getRow_cuda SparseMatrixExample_getRow.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out # OUTPUT SparseMatrixExample_getRow.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElement_cuda SparseMatrixExample_setElement.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out # OUTPUT SparseMatrixExample_setElement.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_addElement_cuda SparseMatrixExample_addElement.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out # OUTPUT SparseMatrixExample_addElement.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getElement_cuda SparseMatrixExample_getElement.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out # OUTPUT SparseMatrixExample_getElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_getConstRow_cuda SparseMatrixExample_getConstRow.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out OUTPUT SparseMatrixExample_getConstRow.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_getRow_cuda SparseMatrixExample_getRow.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out OUTPUT SparseMatrixExample_getRow.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElement_cuda SparseMatrixExample_setElement.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out OUTPUT SparseMatrixExample_setElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_addElement_cuda SparseMatrixExample_addElement.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out OUTPUT SparseMatrixExample_addElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_getElement_cuda SparseMatrixExample_getElement.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out OUTPUT SparseMatrixExample_getElement.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_rowsReduction_cuda SparseMatrixExample_rowsReduction.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_rowsReduction_cuda > Loading Loading @@ -190,35 +185,30 @@ ELSE() ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getCompressedRowLengths.out OUTPUT SparseMatrixExample_getCompressedRowLengths.out ) # ADD_EXECUTABLE( SparseMatrixExample_getElementsCount SparseMatrixExample_getElementsCount.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElementsCount > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElementsCount.out # OUTPUT SparseMatrixExample_getElementsCount.out ) ADD_EXECUTABLE( SparseMatrixExample_getConstRow SparseMatrixExample_getConstRow.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out OUTPUT SparseMatrixExample_getConstRow.out ) # ADD_EXECUTABLE( SparseMatrixExample_getConstRow SparseMatrixExample_getConstRow.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out # OUTPUT SparseMatrixExample_getConstRow.out ) ADD_EXECUTABLE( SparseMatrixExample_getRow SparseMatrixExample_getRow.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out OUTPUT SparseMatrixExample_getRow.out ) # ADD_EXECUTABLE( SparseMatrixExample_getRow SparseMatrixExample_getRow.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out # OUTPUT SparseMatrixExample_getRow.out ) ADD_EXECUTABLE( SparseMatrixExample_setElement SparseMatrixExample_setElement.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out OUTPUT SparseMatrixExample_setElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_setElement SparseMatrixExample_setElement.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out # OUTPUT SparseMatrixExample_setElement.out ) ADD_EXECUTABLE( SparseMatrixExample_addElement SparseMatrixExample_addElement.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out OUTPUT SparseMatrixExample_addElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_addElement SparseMatrixExample_addElement.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out # OUTPUT SparseMatrixExample_addElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_getElement SparseMatrixExample_getElement.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out # OUTPUT SparseMatrixExample_getElement.out ) ADD_EXECUTABLE( SparseMatrixExample_getElement SparseMatrixExample_getElement.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out OUTPUT SparseMatrixExample_getElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_rowsReduction SparseMatrixExample_rowsReduction.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_rowsReduction > Loading Loading @@ -311,12 +301,11 @@ ADD_CUSTOM_TARGET( RunSparseMatricesExamples ALL DEPENDS SparseMatrixExample_setElements.out SparseMatrixExample_setElements_map.out SparseMatrixExample_getCompressedRowLengths.out # SparseMatrixExample_getElementsCount.out # SparseMatrixExample_getConstRow.out # SparseMatrixExample_getRow.out # SparseMatrixExample_setElement.out # SparseMatrixExample_addElement.out # SparseMatrixExample_getElement.out SparseMatrixExample_getConstRow.out SparseMatrixExample_getRow.out SparseMatrixExample_setElement.out SparseMatrixExample_addElement.out SparseMatrixExample_getElement.out # SparseMatrixExample_rowsReduction.out # SparseMatrixExample_allRowsReduction.out # SparseMatrixExample_forRows.out Loading Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_addElement.cpp 0 → 100644 +30 −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 addElements() { TNL::Matrices::SparseMatrix< double, Device > matrix( { 5, 5, 5, 5, 5 }, 5 ); for( int i = 0; i < 5; i++ ) matrix.setElement( i, i, i ); std::cout << "Initial matrix is: " << std::endl << matrix << std::endl; for( int i = 0; i < 5; i++ ) for( int j = 0; j < 5; j++ ) matrix.addElement( i, j, 1.0, 5.0 ); std::cout << "Matrix after addition is: " << std::endl << matrix << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Add elements on host:" << std::endl; addElements< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Add elements on CUDA device:" << std::endl; addElements< TNL::Devices::Cuda >(); #endif } Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_addElement.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_addElement.cpp No newline at end of file Loading
Documentation/Examples/Matrices/DenseMatrix/DenseMatrixExample_getElement.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ void getElements() for( int i = 0; i < 5; i++ ) { for( int j = 0; j < 5; j++ ) std::cout << std::setw( 5 ) << std::ios::right << matrix.getElement( i, i ); std::cout << std::setw( 5 ) << matrix.getElement( i, j ); std::cout << std::endl; } } Loading
Documentation/Examples/Matrices/DenseMatrix/DenseMatrixExample_setElement.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include <TNL/Algorithms/ParallelFor.h> #include <TNL/Matrices/DenseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Devices/Cuda.h> #include <TNL/Pointers/SharedPointer.h> #include <TNL/Pointers/SmartPointersRegister.h> Loading @@ -18,12 +19,17 @@ void setElements() auto f = [=] __cuda_callable__ ( int i ) mutable { matrix->setElement( i, i, -i ); }; /*** * For the case when Device is CUDA device we need to synchronize smart * pointers. To avoid this you may use DenseMatrixView. See * DenseMatrixView::getRow example for details. */ TNL::Pointers::synchronizeSmartPointersOnDevice< Device >(); TNL::Algorithms::ParallelFor< Device >::exec( 0, 5, f ); std::cout << "Matrix set from its native device:" << std::endl; std::cout << *matrix << std::endl; } int main( int argc, char* argv[] ) Loading
Documentation/Examples/Matrices/SparseMatrix/CMakeLists.txt +49 −60 Original line number Diff line number Diff line Loading @@ -39,35 +39,30 @@ IF( BUILD_CUDA ) ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getCompressedRowLengths.out OUTPUT SparseMatrixExample_getCompressedRowLengths.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getElementsCount_cuda SparseMatrixExample_getElementsCount.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElementsCount_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElementsCount.out # OUTPUT SparseMatrixExample_getElementsCount.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getConstRow_cuda SparseMatrixExample_getConstRow.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out # OUTPUT SparseMatrixExample_getConstRow.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getRow_cuda SparseMatrixExample_getRow.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out # OUTPUT SparseMatrixExample_getRow.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElement_cuda SparseMatrixExample_setElement.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out # OUTPUT SparseMatrixExample_setElement.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_addElement_cuda SparseMatrixExample_addElement.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out # OUTPUT SparseMatrixExample_addElement.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_getElement_cuda SparseMatrixExample_getElement.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement_cuda > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out # OUTPUT SparseMatrixExample_getElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_getConstRow_cuda SparseMatrixExample_getConstRow.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out OUTPUT SparseMatrixExample_getConstRow.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_getRow_cuda SparseMatrixExample_getRow.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out OUTPUT SparseMatrixExample_getRow.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_setElement_cuda SparseMatrixExample_setElement.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out OUTPUT SparseMatrixExample_setElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_addElement_cuda SparseMatrixExample_addElement.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out OUTPUT SparseMatrixExample_addElement.out ) CUDA_ADD_EXECUTABLE( SparseMatrixExample_getElement_cuda SparseMatrixExample_getElement.cu ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement_cuda > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out OUTPUT SparseMatrixExample_getElement.out ) # CUDA_ADD_EXECUTABLE( SparseMatrixExample_rowsReduction_cuda SparseMatrixExample_rowsReduction.cu ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_rowsReduction_cuda > Loading Loading @@ -190,35 +185,30 @@ ELSE() ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getCompressedRowLengths.out OUTPUT SparseMatrixExample_getCompressedRowLengths.out ) # ADD_EXECUTABLE( SparseMatrixExample_getElementsCount SparseMatrixExample_getElementsCount.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElementsCount > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElementsCount.out # OUTPUT SparseMatrixExample_getElementsCount.out ) ADD_EXECUTABLE( SparseMatrixExample_getConstRow SparseMatrixExample_getConstRow.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out OUTPUT SparseMatrixExample_getConstRow.out ) # ADD_EXECUTABLE( SparseMatrixExample_getConstRow SparseMatrixExample_getConstRow.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getConstRow > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getConstRow.out # OUTPUT SparseMatrixExample_getConstRow.out ) ADD_EXECUTABLE( SparseMatrixExample_getRow SparseMatrixExample_getRow.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out OUTPUT SparseMatrixExample_getRow.out ) # ADD_EXECUTABLE( SparseMatrixExample_getRow SparseMatrixExample_getRow.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getRow > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getRow.out # OUTPUT SparseMatrixExample_getRow.out ) ADD_EXECUTABLE( SparseMatrixExample_setElement SparseMatrixExample_setElement.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out OUTPUT SparseMatrixExample_setElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_setElement SparseMatrixExample_setElement.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_setElement > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_setElement.out # OUTPUT SparseMatrixExample_setElement.out ) ADD_EXECUTABLE( SparseMatrixExample_addElement SparseMatrixExample_addElement.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out OUTPUT SparseMatrixExample_addElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_addElement SparseMatrixExample_addElement.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_addElement > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_addElement.out # OUTPUT SparseMatrixExample_addElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_getElement SparseMatrixExample_getElement.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement > # ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out # OUTPUT SparseMatrixExample_getElement.out ) ADD_EXECUTABLE( SparseMatrixExample_getElement SparseMatrixExample_getElement.cpp ) ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_getElement > ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}/SparseMatrixExample_getElement.out OUTPUT SparseMatrixExample_getElement.out ) # ADD_EXECUTABLE( SparseMatrixExample_rowsReduction SparseMatrixExample_rowsReduction.cpp ) # ADD_CUSTOM_COMMAND( COMMAND SparseMatrixExample_rowsReduction > Loading Loading @@ -311,12 +301,11 @@ ADD_CUSTOM_TARGET( RunSparseMatricesExamples ALL DEPENDS SparseMatrixExample_setElements.out SparseMatrixExample_setElements_map.out SparseMatrixExample_getCompressedRowLengths.out # SparseMatrixExample_getElementsCount.out # SparseMatrixExample_getConstRow.out # SparseMatrixExample_getRow.out # SparseMatrixExample_setElement.out # SparseMatrixExample_addElement.out # SparseMatrixExample_getElement.out SparseMatrixExample_getConstRow.out SparseMatrixExample_getRow.out SparseMatrixExample_setElement.out SparseMatrixExample_addElement.out SparseMatrixExample_getElement.out # SparseMatrixExample_rowsReduction.out # SparseMatrixExample_allRowsReduction.out # SparseMatrixExample_forRows.out Loading
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_addElement.cpp 0 → 100644 +30 −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 addElements() { TNL::Matrices::SparseMatrix< double, Device > matrix( { 5, 5, 5, 5, 5 }, 5 ); for( int i = 0; i < 5; i++ ) matrix.setElement( i, i, i ); std::cout << "Initial matrix is: " << std::endl << matrix << std::endl; for( int i = 0; i < 5; i++ ) for( int j = 0; j < 5; j++ ) matrix.addElement( i, j, 1.0, 5.0 ); std::cout << "Matrix after addition is: " << std::endl << matrix << std::endl; } int main( int argc, char* argv[] ) { std::cout << "Add elements on host:" << std::endl; addElements< TNL::Devices::Host >(); #ifdef HAVE_CUDA std::cout << "Add elements on CUDA device:" << std::endl; addElements< TNL::Devices::Cuda >(); #endif }
Documentation/Examples/Matrices/SparseMatrix/SparseMatrixExample_addElement.cu 0 → 120000 +1 −0 Original line number Diff line number Diff line SparseMatrixExample_addElement.cpp No newline at end of file