Commit f354eea7 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Replaced save and load methods on Array and ArrayView with operator<< and operator>>

parent 3b27d05a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ struct SpmvBenchmark
      MatrixType matrix;
      VectorType vector;
      matrix.load( parameters.getParameter< String >( "input-matrix" ) );
      vector.load( parameters.getParameter< String >( "input-vector" ) );
      File( parameters.getParameter< String >( "input-vector" ), std::ios_base::in ) >> vector;

      typename MatrixType::CompressedRowLengthsVector rowLengths;
      matrix.getCompressedRowLengths( rowLengths );
+2 −2
Original line number Diff line number Diff line
@@ -333,8 +333,8 @@ struct LinearSolversBenchmark
      SharedPointer< MatrixType > matrixPointer;
      VectorType x0, b;
      matrixPointer->load( parameters.getParameter< String >( "input-matrix" ) );
      x0.load( parameters.getParameter< String >( "input-dof" ) );
      b.load( parameters.getParameter< String >( "input-rhs" ) );
      File( parameters.getParameter< String >( "input-dof" ), std::ios_base::in ) >> x0;
      File( parameters.getParameter< String >( "input-rhs" ), std::ios_base::in ) >> b;

      typename MatrixType::CompressedRowLengthsVector rowLengths;
      matrixPointer->getCompressedRowLengths( rowLengths );
+7 −5
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ void arrayExample()
   /***
    * You may also assign value to all array elements ...
    */
   a2 = 0.0;
   a2 = 0;
   std::cout << "a2 = " << a2 << std::endl;

   /***
@@ -56,10 +56,12 @@ void arrayExample()
   a1.swap( a2 );

   /***
    * Of course, you may save it to file and load again
    * You may save it to file and load again
    */
   a1.save( "a1.tnl" );
   a2.load( "a1.tnl" );
   File( "a1.tnl", std::ios_base::out ) << a1;
   File( "a1.tnl", std::ios_base::in ) >> a2;

   std::remove( "a1.tnl" );

   if( a2 != a1 )
      std::cerr << "Something is wrong!!!" << std::endl;
+4 −3
Original line number Diff line number Diff line
@@ -57,10 +57,11 @@ void arrayViewExample()
   a1.swap( a3 );

   /***
    * Of course, you may save it to file and load again
    * You may save it to file and load again
    */
   a1.save( "a1.tnl" );
   a2.load( "a1.tnl" );
   File( "a1.tnl", std::ios_base::out ) << a1;
   File( "a1.tnl", std::ios_base::in ) >> a2;

   std::remove( "a1.tnl" );

   if( a2 != a1 )
+2 −1
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@ namespace py = pybind11;
template< typename ArrayType >
void export_Array(py::module & m, const char* name)
{
    auto array = py::class_<ArrayType, TNL::Object>(m, name, py::buffer_protocol())
//    auto array = py::class_<ArrayType, TNL::Object>(m, name, py::buffer_protocol())
    auto array = py::class_<ArrayType>(m, name, py::buffer_protocol())
        .def(py::init<>())
        .def(py::init<int>())
        .def_static("getType",              &ArrayType::getType)
Loading