File kernel/src/utils/SiconosAlgebra/ioMatrix.hpp

File kernel/src/utils/SiconosAlgebra/ioMatrix.hpp#

Go to the source code of this file

input/output for SiconosMatrix

namespace ioMatrix#

io object specialization

Functions

bool read(const std::string &fileName, const std::string &mode, SiconosMatrix &m)#

Read a SiconosMatrix.

Parameters:
  • fileName[in] the name of the file to read

  • mode[in] the storage type used in the file (either ascii or binary)

  • m[inout] the SiconosMatrix to be filled

Returns:

true if read ok, else false …

bool write(const std::string &fileName, const std::string &mode, const SiconosMatrix &m, const std::string &outputType = "python")#

Write a SiconosMatrix.

Parameters:
  • fileName[in] the name of the file to write in

  • mode[in] the storage type used in the file (either ascii or binary)

  • m[in] the SiconosMatrix to write

  • outputType[in] type of output:

    • ”python”(default): row col a00 a01 a02 … a10 …

    • ”noDim”: a00 a01 a02 … a10 … Reading input format is the one corresponding to “python”.

Returns:

true if read ok, else false …

double compareRefFile(const SimpleMatrix &data, std::string filename, double epsilon, Index index = Index(), SP::SimpleMatrix *ref = nullptr, std::string mode = "ascii", bool verbose = true)#

Function to load data from a file and compare it with the provided data.

Returns the measured difference between files if the file was loaded and the comparison was performed, which must be >= 0.0, otherwise -1.0 is returned. Caller needs to check diff <= epsilon to verify the result.

Parameters:
  • data – The data to compare against the file.

  • filename – The name of the file to load and compare.

  • epsilon – The comparison threshold.

  • index – An optional list of column indexes, size==0 indicates all columns.

  • ref – If provided, loaded matrix is returned in this pointer.

  • mode – Mode string to pass to ioMatrix::read.

  • verbose – True to print verbose output.

Returns:

Positive or 0.0 if the file was loaded and the comparison was performed, otherwise -1.