mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-10 19:20:44 +01:00
more templatisation/cleaning of data types
This commit is contained in:
parent
f79533c5ce
commit
a6b96b34bb
@ -35,14 +35,13 @@ BEGIN_NAMESPACE
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class Dataset: public StatArray<T>
|
class Dataset: public StatArray<T>
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
typedef StatArray<T> Base;
|
|
||||||
public:
|
public:
|
||||||
// constructors
|
// constructors
|
||||||
Dataset(void) = default;
|
Dataset(void) = default;
|
||||||
|
Dataset(const Index size);
|
||||||
template <typename FileType>
|
template <typename FileType>
|
||||||
Dataset(const std::string &listFileName, const std::string &dataName);
|
Dataset(const std::string &listFileName, const std::string &dataName);
|
||||||
using Base::Base;
|
EIGEN_EXPR_CTOR(Dataset, Dataset<T>, StatArray<T>, ArrayExpr)
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~Dataset(void) = default;
|
virtual ~Dataset(void) = default;
|
||||||
// IO
|
// IO
|
||||||
@ -58,7 +57,12 @@ private:
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Dataset template implementation *
|
* Dataset template implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructor /////////////////////////////////////////////////////////////////
|
// constructors ////////////////////////////////////////////////////////////////
|
||||||
|
template <typename T>
|
||||||
|
Dataset<T>::Dataset(const Index size)
|
||||||
|
: StatArray<T>(size)
|
||||||
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <typename FileType>
|
template <typename FileType>
|
||||||
Dataset<T>::Dataset(const std::string &listFileName,
|
Dataset<T>::Dataset(const std::string &listFileName,
|
||||||
|
@ -76,16 +76,13 @@ template <typename Derived>
|
|||||||
using MatExpr = Eigen::MatrixBase<Derived>;
|
using MatExpr = Eigen::MatrixBase<Derived>;
|
||||||
|
|
||||||
template <typename T, int nRow = dynamic, int nCol = dynamic>
|
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 MatBase<double> DMatBase;
|
||||||
typedef Mat<long int> LMat;
|
|
||||||
typedef Mat<double> DMatBase;
|
|
||||||
typedef Mat<std::complex<double>> CMat;
|
|
||||||
|
|
||||||
// vector types
|
// vector types
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using Vec = Mat<T, dynamic, 1>;
|
using Vec = MatBase<T, dynamic, 1>;
|
||||||
|
|
||||||
typedef Vec<int> IVec;
|
typedef Vec<int> IVec;
|
||||||
typedef Vec<long int> LVec;
|
typedef Vec<long int> LVec;
|
||||||
@ -118,7 +115,7 @@ template <typename Derived>
|
|||||||
using ConstMap = Eigen::Map<const Derived>;
|
using ConstMap = Eigen::Map<const Derived>;
|
||||||
|
|
||||||
// Index type //////////////////////////////////////////////////////////////////
|
// Index type //////////////////////////////////////////////////////////////////
|
||||||
typedef DMatBase::Index Index;
|
typedef MatBase<double>::Index Index;
|
||||||
|
|
||||||
// Placeholder type ////////////////////////////////////////////////////////////
|
// Placeholder type ////////////////////////////////////////////////////////////
|
||||||
struct PlaceHolder {};
|
struct PlaceHolder {};
|
||||||
|
@ -26,12 +26,9 @@ using namespace Latan;
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* DMat implementation *
|
* DMat implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructors ////////////////////////////////////////////////////////////////
|
// IO //////////////////////////////////////////////////////////////////////////
|
||||||
DMat::DMat(const Index nRow, const Index nCol)
|
template <>
|
||||||
: Base(nRow, nCol)
|
IoObject::IoType Mat<double>::getType(void) const
|
||||||
{}
|
|
||||||
|
|
||||||
IoObject::IoType DMat::getType(void) const
|
|
||||||
{
|
{
|
||||||
return IoType::dMat;
|
return IoType::dMat;
|
||||||
}
|
}
|
||||||
|
38
lib/Mat.hpp
38
lib/Mat.hpp
@ -30,24 +30,44 @@ for (Latan::Index i = 0; i < mat.rows(); ++i)
|
|||||||
BEGIN_NAMESPACE
|
BEGIN_NAMESPACE
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* double matrix type *
|
* matrix type *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
template <typename T>
|
||||||
class DMat: public DMatBase, public IoObject
|
class Mat: public MatBase<T>, public IoObject
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
typedef DMatBase Base;
|
|
||||||
public:
|
public:
|
||||||
// constructors
|
// constructors
|
||||||
DMat(void) = default;
|
Mat(void) = default;
|
||||||
DMat(const Index nRow, const Index nCol);
|
Mat(const Index nRow, const Index nCol);
|
||||||
EIGEN_EXPR_CTOR(DMat, DMat, Base, MatExpr)
|
EIGEN_EXPR_CTOR(Mat, Mat<T>, MatBase<T>, MatExpr)
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~DMat(void) = default;
|
virtual ~Mat(void) = default;
|
||||||
// IO
|
// IO
|
||||||
virtual IoType getType(void) const;
|
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
|
END_NAMESPACE
|
||||||
|
|
||||||
#endif // Latan_Mat_hpp_
|
#endif // Latan_Mat_hpp_
|
||||||
|
@ -80,11 +80,12 @@ private:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
// constructors
|
// constructors
|
||||||
using Sample<Mat<T>>::Sample;
|
|
||||||
MatSample(void) = default;
|
MatSample(void) = default;
|
||||||
|
MatSample(const Index nSample);
|
||||||
MatSample(const Index nSample, const Index nRow, const Index nCol);
|
MatSample(const Index nSample, const Index nRow, const Index nCol);
|
||||||
MatSample(ConstBlock &sampleBlock);
|
MatSample(ConstBlock &sampleBlock);
|
||||||
MatSample(ConstBlock &&sampleBlock);
|
MatSample(ConstBlock &&sampleBlock);
|
||||||
|
EIGEN_EXPR_CTOR(MatSample, MatSample<T>, Sample<Mat<T>>, ArrayExpr)
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~MatSample(void) = default;
|
virtual ~MatSample(void) = default;
|
||||||
// assignement operator
|
// assignement operator
|
||||||
@ -253,10 +254,15 @@ MatSample<T>::BlockTemplate<S>::operator=(const S &&sample)
|
|||||||
* DMatSample implementation *
|
* DMatSample implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
// constructors ////////////////////////////////////////////////////////////////
|
// constructors ////////////////////////////////////////////////////////////////
|
||||||
|
template <typename T>
|
||||||
|
MatSample<T>::MatSample(const Index nSample)
|
||||||
|
: Sample<Mat<T>>(nSample)
|
||||||
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
MatSample<T>::MatSample(const Index nSample, const Index nRow,
|
MatSample<T>::MatSample(const Index nSample, const Index nRow,
|
||||||
const Index nCol)
|
const Index nCol)
|
||||||
: Sample<Mat<T>>(nSample)
|
: MatSample(nSample)
|
||||||
{
|
{
|
||||||
resizeMat(nRow, nCol);
|
resizeMat(nRow, nCol);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ BEGIN_NAMESPACE
|
|||||||
template <typename T, Index os = 0>
|
template <typename T, Index os = 0>
|
||||||
class StatArray: public Array<T, dynamic, 1>
|
class StatArray: public Array<T, dynamic, 1>
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
typedef Array<T, dynamic, 1> Base;
|
typedef Array<T, dynamic, 1> Base;
|
||||||
public:
|
public:
|
||||||
// constructors
|
// constructors
|
||||||
@ -75,10 +75,6 @@ namespace ReducOp
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline T sum(const T &a, const T &b);
|
inline T sum(const T &a, const T &b);
|
||||||
// matrix specializations
|
// matrix specializations
|
||||||
template <>
|
|
||||||
inline DMat prod(const DMat &a, const DMat &b);
|
|
||||||
template <>
|
|
||||||
inline DMat tensProd(const DMat &v1, const DMat &v2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample types
|
// Sample types
|
||||||
|
Loading…
x
Reference in New Issue
Block a user