Commit b6be0ba6 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixed device definition in LambdaMatrix.

parent 3986178a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,13 +21,13 @@ int main( int argc, char* argv[] )
   /***
    * Matrix construction with explicit type definition.
    */
   using MatrixType = decltype( TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::AnyDevice, int >::create( matrixElements1, rowLengths ) );
   using MatrixType = decltype( TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::Host, int >::create( matrixElements1, rowLengths ) );
   MatrixType m1( size, size, matrixElements1, rowLengths );

   /***
    * Matrix construction using 'auto'.
    */
   auto m2 = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::AnyDevice, int >::create( matrixElements2, rowLengths );
   auto m2 = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::Host, int >::create( matrixElements2, rowLengths );
   m2.setDimensions( size, size );

   std::cout << "The first lambda matrix: " << std::endl << m1 << std::endl;
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ void forRowsExample()
         value = TNL::max( rowIdx - columnIdx + 1, 0 );
   };

   using MatrixFactory = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::AnyDevice, int >;
   using MatrixFactory = TNL::Matrices::LambdaMatrixFactory< double, Device, int >;
   auto matrix = MatrixFactory::create( 5, 5, matrixElements, rowLengths );

   TNL::Matrices::DenseMatrix< double, Device > denseMatrix( 5, 5 );
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ int main( int argc, char* argv[] )
   };

   const int size = 5;
   auto matrix = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::AnyDevice, int >::create( size, size, matrixElements, rowLengths );
   auto matrix = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::Host, int >::create( size, size, matrixElements, rowLengths );

   TNL::Containers::Vector< int > rowLengthsVector;
   matrix.getCompressedRowLengths( rowLengthsVector );
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ int main( int argc, char* argv[] )
   };

   const int size = 5;
   auto matrix = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::AnyDevice, int >::create( size, size, matrixElements, rowLengths );
   auto matrix = TNL::Matrices::LambdaMatrixFactory< double, TNL::Devices::Host, int >::create( size, size, matrixElements, rowLengths );

   std::cout << "Matrix looks as:" << std::endl << matrix << std::endl;
   std::cout << "Non-zero elements count is: " << matrix.getNonzeroElementsCount() << std::endl;
+4 −5
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#pragma once

#include <TNL/String.h>
#include <TNL/Devices/AnyDevice.h>
#include <TNL/Devices/Host.h>

namespace TNL {
namespace Matrices {
@@ -40,14 +40,13 @@ namespace Matrices {
 *    where \e rows is the number of matrix rows, \e columns is the number of matrix columns and \e row is an index of the row being queried.
 *
 * \tparam Real is a type of matrix elements values.
 * \tparam Device is a device on which the lambda functions can evaluated. 
 *    Devices::AnyDevice can be used for lambdas with no restriction.
 * \tparam Device is a device on which the lambda functions will be evaluated. 
 * \ẗparam Index is a type used for indexing.
 */
template< typename MatrixElementsLambda,
          typename CompressedRowLengthsLambda,
          typename Real = double,
          typename Device = Devices::AnyDevice,
          typename Device = Devices::Host,
          typename Index = int >
class LambdaMatrix
{
@@ -352,7 +351,7 @@ std::ostream& operator<< ( std::ostream& str, const LambdaMatrix< MatrixElements
 * \param compressedRowLengthsLambda
 */
template< typename Real = double,
          typename Device = Devices::AnyDevice,
          typename Device = Devices::Host,
          typename Index = int >
struct LambdaMatrixFactory
{
Loading