1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-20 05:25:37 +01:00

more templatisation/cleaning of data types

This commit is contained in:
Antonin Portelli 2014-04-07 19:29:47 +01:00
parent f79533c5ce
commit a6b96b34bb
6 changed files with 53 additions and 33 deletions

View File

@ -35,14 +35,13 @@ BEGIN_NAMESPACE
template <typename T>
class Dataset: public StatArray<T>
{
private:
typedef StatArray<T> Base;
public:
// constructors
Dataset(void) = default;
Dataset(const Index size);
template <typename FileType>
Dataset(const std::string &listFileName, const std::string &dataName);
using Base::Base;
EIGEN_EXPR_CTOR(Dataset, Dataset<T>, StatArray<T>, ArrayExpr)
// destructor
virtual ~Dataset(void) = default;
// IO
@ -58,7 +57,12 @@ private:
/******************************************************************************
* Dataset template implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
// constructors ////////////////////////////////////////////////////////////////
template <typename T>
Dataset<T>::Dataset(const Index size)
: StatArray<T>(size)
{}
template <typename T>
template <typename FileType>
Dataset<T>::Dataset(const std::string &listFileName,

View File

@ -76,16 +76,13 @@ template <typename Derived>
using MatExpr = Eigen::MatrixBase<Derived>;
template <typename T, int nRow = dynamic, int nCol = dynamic>
using Mat = Eigen::Matrix<T, nRow, nCol>;
using MatBase = Eigen::Matrix<T, nRow, nCol>;
typedef Mat<int> IMat;
typedef Mat<long int> LMat;
typedef Mat<double> DMatBase;
typedef Mat<std::complex<double>> CMat;
typedef MatBase<double> DMatBase;
// vector types
template <typename T>
using Vec = Mat<T, dynamic, 1>;
using Vec = MatBase<T, dynamic, 1>;
typedef Vec<int> IVec;
typedef Vec<long int> LVec;
@ -118,7 +115,7 @@ template <typename Derived>
using ConstMap = Eigen::Map<const Derived>;
// Index type //////////////////////////////////////////////////////////////////
typedef DMatBase::Index Index;
typedef MatBase<double>::Index Index;
// Placeholder type ////////////////////////////////////////////////////////////
struct PlaceHolder {};

View File

@ -26,12 +26,9 @@ using namespace Latan;
/******************************************************************************
* DMat implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
DMat::DMat(const Index nRow, const Index nCol)
: Base(nRow, nCol)
{}
IoObject::IoType DMat::getType(void) const
// IO //////////////////////////////////////////////////////////////////////////
template <>
IoObject::IoType Mat<double>::getType(void) const
{
return IoType::dMat;
}

View File

@ -30,24 +30,44 @@ for (Latan::Index i = 0; i < mat.rows(); ++i)
BEGIN_NAMESPACE
/******************************************************************************
* double matrix type *
* matrix type *
******************************************************************************/
class DMat: public DMatBase, public IoObject
template <typename T>
class Mat: public MatBase<T>, public IoObject
{
private:
typedef DMatBase Base;
public:
// constructors
DMat(void) = default;
DMat(const Index nRow, const Index nCol);
EIGEN_EXPR_CTOR(DMat, DMat, Base, MatExpr)
Mat(void) = default;
Mat(const Index nRow, const Index nCol);
EIGEN_EXPR_CTOR(Mat, Mat<T>, MatBase<T>, MatExpr)
// destructor
virtual ~DMat(void) = default;
virtual ~Mat(void) = default;
// IO
virtual IoType getType(void) const;
};
// type aliases
typedef Mat<int> IMat;
typedef Mat<long int> LMat;
typedef Mat<double> DMat;
typedef Mat<std::complex<double>> CMat;
/******************************************************************************
* Mat template implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
template <typename T>
Mat<T>::Mat(const Index nRow, const Index nCol)
: MatBase<T>(nRow, nCol)
{}
// IO //////////////////////////////////////////////////////////////////////////
template <typename T>
IoObject::IoType Mat<T>::getType(void) const
{
return IoType::noType;
}
END_NAMESPACE
#endif // Latan_Mat_hpp_

View File

@ -80,11 +80,12 @@ private:
}
public:
// constructors
using Sample<Mat<T>>::Sample;
MatSample(void) = default;
MatSample(const Index nSample);
MatSample(const Index nSample, const Index nRow, const Index nCol);
MatSample(ConstBlock &sampleBlock);
MatSample(ConstBlock &&sampleBlock);
EIGEN_EXPR_CTOR(MatSample, MatSample<T>, Sample<Mat<T>>, ArrayExpr)
// destructor
virtual ~MatSample(void) = default;
// assignement operator
@ -253,10 +254,15 @@ MatSample<T>::BlockTemplate<S>::operator=(const S &&sample)
* DMatSample implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
template <typename T>
MatSample<T>::MatSample(const Index nSample)
: Sample<Mat<T>>(nSample)
{}
template <typename T>
MatSample<T>::MatSample(const Index nSample, const Index nRow,
const Index nCol)
: Sample<Mat<T>>(nSample)
: MatSample(nSample)
{
resizeMat(nRow, nCol);
}

View File

@ -35,7 +35,7 @@ BEGIN_NAMESPACE
template <typename T, Index os = 0>
class StatArray: public Array<T, dynamic, 1>
{
private:
protected:
typedef Array<T, dynamic, 1> Base;
public:
// constructors
@ -75,10 +75,6 @@ namespace ReducOp
template <typename T>
inline T sum(const T &a, const T &b);
// matrix specializations
template <>
inline DMat prod(const DMat &a, const DMat &b);
template <>
inline DMat tensProd(const DMat &v1, const DMat &v2);
}
// Sample types