git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@897 b431acfa-c32f-4a4a-93f1-934dc6c82436
105 lines
1.8 KiB
C++
105 lines
1.8 KiB
C++
/*
|
|
* File: Vector.hpp
|
|
* Author: jens
|
|
*
|
|
* Created on 19. Dezember 2014, 18:24
|
|
*/
|
|
|
|
#ifndef _RADIO_VECTOR_HPP_
|
|
#define _RADIO_VECTOR_HPP_
|
|
|
|
#define VECTOR_USE_EIGEN
|
|
//#define VECTOR_USE_ARMADILLO
|
|
|
|
#include <complex>
|
|
#include <radio/radio_types.h>
|
|
|
|
#ifndef radio_float_t
|
|
#define radio_float_t float
|
|
#endif
|
|
|
|
#ifdef VECTOR_USE_EIGEN
|
|
#include <Eigen/Dense>
|
|
#endif
|
|
|
|
#ifdef VECTOR_USE_ARMADILLO
|
|
#include <armadillo>
|
|
#endif
|
|
|
|
namespace Radio
|
|
{
|
|
|
|
typedef radio_float_t RealScalar;
|
|
typedef std::complex<radio_float_t> ComplexScalar;
|
|
|
|
#ifdef VECTOR_USE_EIGEN
|
|
|
|
typedef Eigen::Matrix<RealScalar, Eigen::Dynamic, 1> RVec;
|
|
typedef Eigen::Matrix<ComplexScalar, Eigen::Dynamic, 1> CVec;
|
|
|
|
typedef Eigen::Matrix<RealScalar, Eigen::Dynamic, Eigen::Dynamic> RMat;
|
|
typedef Eigen::Matrix<ComplexScalar, Eigen::Dynamic, Eigen::Dynamic> CMat;
|
|
|
|
typedef Eigen::Map<RVec> RMap;
|
|
#endif
|
|
|
|
#ifdef VECTOR_USE_ARMADILLO
|
|
#if 1
|
|
template <typename T>
|
|
class Vec : public arma::Col<T>
|
|
{
|
|
public:
|
|
void setZero()
|
|
{
|
|
|
|
}
|
|
};
|
|
class RVec : public Vec<RealScalar>
|
|
{
|
|
};
|
|
|
|
class CVec : public Vec<ComplexScalar>
|
|
{
|
|
};
|
|
#endif
|
|
//typedef arma::col<RealScalar> RVec;
|
|
//typedef arma::col<ComplexScalar> CVec;
|
|
|
|
typedef arma::Mat<RealScalar> RMat;
|
|
typedef arma::Mat<ComplexScalar> CMat;
|
|
|
|
typedef arma::Map<RVec> RMap;
|
|
#endif
|
|
|
|
static ComplexScalar toComplexScalar(cpx_t v)
|
|
{
|
|
return ComplexScalar(v.real, v.imag);
|
|
}
|
|
|
|
static cpx_t toCpx(ComplexScalar v)
|
|
{
|
|
return Cpx(v.real(), v.imag());
|
|
}
|
|
|
|
static void toComplexVector(CVec &dst, cpx_t const *pSrc, uint32_t len)
|
|
{
|
|
for (uint32_t i=0; i < len; i++)
|
|
{
|
|
dst[i] = ComplexScalar(pSrc[i].real, pSrc[i].imag);
|
|
}
|
|
}
|
|
|
|
static void toCpxVector(cpx_t *pDst, CVec const &src, uint32_t len)
|
|
{
|
|
for (uint32_t i=0; i < len; i++)
|
|
{
|
|
pDst[i].real = src[i].real();
|
|
pDst[i].imag = src[i].imag();
|
|
}
|
|
}
|
|
|
|
} // ::Radio
|
|
|
|
#endif /* _RADIO_VECTOR_HPP_ */
|
|
|