Loading Documentation/Examples/Matrices/DenseMatrixExample_setElement.cpp +17 −3 Original line number Diff line number Diff line #include <iostream> #include <TNL/Algorithms/ParallelFor.h> #include <TNL/Matrices/DenseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Pointers/SharedPointer.h> #include <TNL/Pointers/SmartPointersRegister.h> template< typename Device > void setElements() { TNL::Matrices::DenseMatrix< double, Device > matrix( 5, 5 ); TNL::Pointers::SharedPointer< TNL::Matrices::DenseMatrix< double, Device > > matrix( 5, 5 ); for( int i = 0; i < 5; i++ ) matrix.setElement( i, i, i ); matrix->setElement( i, i, i ); std::cout << "Matrix set from the host:" << std::endl; std::cout << *matrix << std::endl; auto f = [=] __cuda_callable__ ( int i ) mutable { matrix->setElement( i, i, -i ); }; 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; std::cout << matrix << std::endl; } int main( int argc, char* argv[] ) Loading src/TNL/Matrices/DenseMatrix.h +1 −1 Original line number Diff line number Diff line Loading @@ -366,7 +366,7 @@ class DenseMatrix : public Matrix< Real, Device, Index > * \param column is columns index of the element. * \param value is the value the element will be set to. * \param thisElementMultiplicator is multiplicator the original matrix element * value is multiplied by before addition of given e value. * value is multiplied by before addition of given \e value. */ __cuda_callable__ void addElement( const IndexType row, Loading Loading
Documentation/Examples/Matrices/DenseMatrixExample_setElement.cpp +17 −3 Original line number Diff line number Diff line #include <iostream> #include <TNL/Algorithms/ParallelFor.h> #include <TNL/Matrices/DenseMatrix.h> #include <TNL/Devices/Host.h> #include <TNL/Pointers/SharedPointer.h> #include <TNL/Pointers/SmartPointersRegister.h> template< typename Device > void setElements() { TNL::Matrices::DenseMatrix< double, Device > matrix( 5, 5 ); TNL::Pointers::SharedPointer< TNL::Matrices::DenseMatrix< double, Device > > matrix( 5, 5 ); for( int i = 0; i < 5; i++ ) matrix.setElement( i, i, i ); matrix->setElement( i, i, i ); std::cout << "Matrix set from the host:" << std::endl; std::cout << *matrix << std::endl; auto f = [=] __cuda_callable__ ( int i ) mutable { matrix->setElement( i, i, -i ); }; 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; std::cout << matrix << std::endl; } int main( int argc, char* argv[] ) Loading
src/TNL/Matrices/DenseMatrix.h +1 −1 Original line number Diff line number Diff line Loading @@ -366,7 +366,7 @@ class DenseMatrix : public Matrix< Real, Device, Index > * \param column is columns index of the element. * \param value is the value the element will be set to. * \param thisElementMultiplicator is multiplicator the original matrix element * value is multiplied by before addition of given e value. * value is multiplied by before addition of given \e value. */ __cuda_callable__ void addElement( const IndexType row, Loading