LDA++
Public Member Functions | Friends | List of all members
ldaplusplus::numpy_format::NumpyOutput< Scalar > Class Template Reference

#include <NumpyFormat.hpp>

Public Member Functions

 NumpyOutput (const Scalar *data, std::vector< size_t > shape, bool fortran)
 
template<int Rows, int Cols, int Options>
 NumpyOutput (const Eigen::Matrix< Scalar, Rows, Cols, Options > &matrix)
 
std::string dtype () const
 
const char * data () const
 
const std::vector< size_t > & shape () const
 
bool fortran_contiguous () const
 

Friends

std::ostream & operator<< (std::ostream &os, const NumpyOutput &data)
 

Detailed Description

template<typename Scalar>
class ldaplusplus::numpy_format::NumpyOutput< Scalar >

NumpyOutput provides an easy way to serialize a contiguous array using the numpy format.

Examples:

MatrixXf x = MatrixXf::Random(10, 20);
std::cout << numpy_format::NumpyOutput<float>(x);

Constructor & Destructor Documentation

template<typename Scalar >
ldaplusplus::numpy_format::NumpyOutput< Scalar >::NumpyOutput ( const Scalar *  data,
std::vector< size_t >  shape,
bool  fortran 
)
inline

Construct a NumpyOutput object from raw data.

Parameters
dataThe contiguous in memory data
shapeThe logical array shape of the data
fortranWether the data is row major (false) or column major (true) order
template<typename Scalar >
template<int Rows, int Cols, int Options>
ldaplusplus::numpy_format::NumpyOutput< Scalar >::NumpyOutput ( const Eigen::Matrix< Scalar, Rows, Cols, Options > &  matrix)
inline

Construct a NumpyOutput object from any Eigen Matrix.

Parameters
matrixThe matrix containing the data

Member Function Documentation

template<typename Scalar >
const char* ldaplusplus::numpy_format::NumpyOutput< Scalar >::data ( ) const
inline

Return the data as a constant character array.

template<typename Scalar >
std::string ldaplusplus::numpy_format::NumpyOutput< Scalar >::dtype ( ) const
inline

Return the numpy dtype for the data including the endianess.

template<typename Scalar >
bool ldaplusplus::numpy_format::NumpyOutput< Scalar >::fortran_contiguous ( ) const
inline

Wether the data is fortran contiguous (column major) or C contiguous (row major).

template<typename Scalar >
const std::vector<size_t>& ldaplusplus::numpy_format::NumpyOutput< Scalar >::shape ( ) const
inline

Return a vector containing the shape of the numpy array (rows, columns, etc).

Friends And Related Function Documentation

template<typename Scalar >
std::ostream& operator<< ( std::ostream &  os,
const NumpyOutput< Scalar > &  data 
)
friend

This operator implements the npy format for a block of NumpyOutput of type Scalar.


The documentation for this class was generated from the following file: