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

double compareRefFile(const SimpleMatrix &data, std::string filename, double epsilon, Index index = Index(), SP::SimpleMatrix *ref = 0, 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.

Return

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

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.

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

Specialization to read a SiconosMatrix.

Return

true if read ok, else false …

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

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

  • [inout] m: the SiconosMatrix to be filled

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

Specialization to write a SiconosMatrix.

Return

true if read ok, else false …

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

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

  • [in] m: the SiconosMatrix to write

  • [in] outputType: 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”.