Loading src/Examples/Containers/ArrayViewExample.cpp +7 −8 Original line number Diff line number Diff line #include <iostream> #include <list> #include <vector> #include <TNL/Containers/Array.h> #include <TNL/Containers/ArrayView.h> using namespace TNL; using namespace std; /*** * The following works for any device (CPU, GPU ...). Loading @@ -18,7 +15,8 @@ void arrayViewExample() using IndexType = typename ArrayType::IndexType; using ViewType = Containers::ArrayView< int, Device >; ArrayType _a1( size ), _a2( size ); ViewType a1( _a1 ), a2( _a2 ); ViewType a1 = _a1.getView(); ViewType a2 = _a2.getView(); /*** * You may initiate the array view using setElement Loading @@ -29,7 +27,7 @@ void arrayViewExample() /*** * You may also assign value to all array view elements ... */ a2 = 0.0; a2 = 0; /*** * Simple array view values checks can be done as follows ... Loading @@ -45,7 +43,7 @@ void arrayViewExample() * More efficient way of array view elements manipulation is with the lambda functions */ ArrayType _a3( size ); ViewType a3( _a3 ); ViewType a3 = _a3.getView(); auto f1 = [] __cuda_callable__ ( IndexType i ) -> int { return 2 * i; }; a3.evaluate( f1 ); Loading @@ -63,6 +61,7 @@ void arrayViewExample() */ a1.save( "a1.tnl" ); a2.load( "a1.tnl" ); std::remove( "a1.tnl" ); if( a2 != a1 ) std::cerr << "Something is wrong!!!" << std::endl; Loading Loading
src/Examples/Containers/ArrayViewExample.cpp +7 −8 Original line number Diff line number Diff line #include <iostream> #include <list> #include <vector> #include <TNL/Containers/Array.h> #include <TNL/Containers/ArrayView.h> using namespace TNL; using namespace std; /*** * The following works for any device (CPU, GPU ...). Loading @@ -18,7 +15,8 @@ void arrayViewExample() using IndexType = typename ArrayType::IndexType; using ViewType = Containers::ArrayView< int, Device >; ArrayType _a1( size ), _a2( size ); ViewType a1( _a1 ), a2( _a2 ); ViewType a1 = _a1.getView(); ViewType a2 = _a2.getView(); /*** * You may initiate the array view using setElement Loading @@ -29,7 +27,7 @@ void arrayViewExample() /*** * You may also assign value to all array view elements ... */ a2 = 0.0; a2 = 0; /*** * Simple array view values checks can be done as follows ... Loading @@ -45,7 +43,7 @@ void arrayViewExample() * More efficient way of array view elements manipulation is with the lambda functions */ ArrayType _a3( size ); ViewType a3( _a3 ); ViewType a3 = _a3.getView(); auto f1 = [] __cuda_callable__ ( IndexType i ) -> int { return 2 * i; }; a3.evaluate( f1 ); Loading @@ -63,6 +61,7 @@ void arrayViewExample() */ a1.save( "a1.tnl" ); a2.load( "a1.tnl" ); std::remove( "a1.tnl" ); if( a2 != a1 ) std::cerr << "Something is wrong!!!" << std::endl; Loading