libigl v2.5.0
Loading...
Searching...
No Matches
readDMAT.h File Reference
#include "igl_inline.h"
#include <string>
#include <vector>
#include <Eigen/Core>
#include "readDMAT.cpp"

Go to the source code of this file.

Namespaces

namespace  igl
 

Functions

template<typename DerivedW >
bool igl::readDMAT (const std::string file_name, Eigen::PlainObjectBase< DerivedW > &W)
 Read a matrix from an .dmat file.
 
template<typename Scalar >
bool igl::readDMAT (const std::string file_name, std::vector< std::vector< Scalar > > &W)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Detailed Description

.dmat - dense matrices


A .dmat file contains a dense matrix in column major order. It can contain ASCII or binary data. Note that it is uncompressed so binary only reduces the file size by 50%. But writing and reading binary is usually faster. In MATLAB, binary is almost 100x faster.

ASCII

The first line is a header containing:

[#cols] [#rows]

Then the coefficients are printed in column-major order separated by spaces.

Binary

Binary files will also contain the ascii header, but it should read:

0 0

Then there should be another header containing the size of the binary part:

[#cols] [#rows]

Then coefficients are written in column-major order in Little-endian 8-byte double precision IEEE floating point format.

Note: Line endings must be ‘’
'akachar(10)` aka line feeds.

Example:

 The matrix m = [1 2 3; 4 5 6];

corresponds to a .dmat file containing:

  3 2
  1 4 2 5 3 6