- deleted
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/radio@8 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
-1027
File diff suppressed because it is too large
Load Diff
@@ -1,550 +0,0 @@
|
||||
#ifndef _COMPLEX_HPP_
|
||||
#define _COMPLEX_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <memory.h>
|
||||
#include <radio/radio_types.h>
|
||||
#include <radio/cpx.h>
|
||||
|
||||
void ComplexDebug(char *fmtstr, ...);
|
||||
|
||||
class ComplexException
|
||||
{
|
||||
public:
|
||||
ComplexException (std::string s)
|
||||
{
|
||||
m_what = s;
|
||||
}
|
||||
~ComplexException()
|
||||
{
|
||||
}
|
||||
std::string& what()
|
||||
{
|
||||
return m_what;
|
||||
}
|
||||
private:
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
class ComplexVector
|
||||
{
|
||||
public:
|
||||
struct Negate
|
||||
{
|
||||
Negate(const ComplexVector &src)
|
||||
: src(src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &src;
|
||||
|
||||
private:
|
||||
Negate& operator=(const Negate&);
|
||||
};
|
||||
|
||||
struct ConjugateNegate;
|
||||
struct Conjugate
|
||||
{
|
||||
Conjugate(const ComplexVector &src)
|
||||
: src(src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &src;
|
||||
const ConjugateNegate operator-()
|
||||
{
|
||||
const ConjugateNegate neg(src);
|
||||
return neg;
|
||||
}
|
||||
|
||||
private:
|
||||
Conjugate& operator=(const Conjugate&);
|
||||
};
|
||||
|
||||
struct ConjugateNegate
|
||||
{
|
||||
ConjugateNegate(const Conjugate &src)
|
||||
: src(src.src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &src;
|
||||
|
||||
private:
|
||||
ConjugateNegate& operator=(const ConjugateNegate&);
|
||||
};
|
||||
|
||||
struct NegMul_A_B;
|
||||
struct Mul_A_B
|
||||
{
|
||||
Mul_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
const NegMul_A_B operator-()
|
||||
{
|
||||
const NegMul_A_B neg(a, b);
|
||||
return neg;
|
||||
}
|
||||
private:
|
||||
Mul_A_B& operator=(const Mul_A_B&);
|
||||
};
|
||||
|
||||
struct NegMul_A_B
|
||||
{
|
||||
NegMul_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
NegMul_A_B& operator=(const NegMul_A_B&);
|
||||
};
|
||||
|
||||
struct ConjNegMul_A_B
|
||||
{
|
||||
ConjNegMul_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
ConjNegMul_A_B& operator=(const ConjNegMul_A_B&);
|
||||
};
|
||||
|
||||
struct ConjMul_A_B
|
||||
{
|
||||
ConjMul_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ConjNegMul_A_B operator-()
|
||||
{
|
||||
const ConjNegMul_A_B neg(a, b);
|
||||
return neg;
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
ConjMul_A_B& operator=(const ConjMul_A_B&);
|
||||
};
|
||||
|
||||
struct NegMul_A_ConjB;
|
||||
struct Mul_A_ConjB
|
||||
{
|
||||
Mul_A_ConjB(const ComplexVector &a, const Conjugate &b)
|
||||
: a(a)
|
||||
, b(b.src)
|
||||
{
|
||||
}
|
||||
const NegMul_A_ConjB operator-()
|
||||
{
|
||||
const NegMul_A_ConjB neg(a, b);
|
||||
return neg;
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
Mul_A_ConjB& operator=(const Mul_A_ConjB&);
|
||||
};
|
||||
|
||||
struct NegMul_A_ConjB
|
||||
{
|
||||
NegMul_A_ConjB(const ComplexVector &a, const Conjugate &b)
|
||||
: a(a)
|
||||
, b(b.src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
NegMul_A_ConjB& operator=(const NegMul_A_ConjB&);
|
||||
};
|
||||
|
||||
struct NegAdd_A_B;
|
||||
struct Add_A_B
|
||||
{
|
||||
Add_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
const NegAdd_A_B operator-()
|
||||
{
|
||||
const NegAdd_A_B neg(a, b);
|
||||
return neg;
|
||||
}
|
||||
|
||||
private:
|
||||
Add_A_B& operator=(const Add_A_B&);
|
||||
};
|
||||
|
||||
struct NegAdd_A_B
|
||||
{
|
||||
NegAdd_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
NegAdd_A_B& operator=(const NegAdd_A_B&);
|
||||
};
|
||||
|
||||
struct ConjNegAdd_A_B;
|
||||
struct ConjAdd_A_B
|
||||
{
|
||||
ConjAdd_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
const ConjNegAdd_A_B operator-()
|
||||
{
|
||||
const ConjNegAdd_A_B neg(a, b);
|
||||
return neg;
|
||||
}
|
||||
|
||||
private:
|
||||
ConjAdd_A_B& operator=(const ConjAdd_A_B&);
|
||||
};
|
||||
|
||||
struct ConjNegAdd_A_B
|
||||
{
|
||||
ConjNegAdd_A_B(const ComplexVector &a, const ComplexVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
ConjNegAdd_A_B& operator=(const ConjNegAdd_A_B&);
|
||||
};
|
||||
|
||||
struct Add_A_NegB
|
||||
{
|
||||
Add_A_NegB(const ComplexVector &a, const Negate &b)
|
||||
: a(a)
|
||||
, b(b.src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
Add_A_NegB& operator=(const Add_A_NegB&);
|
||||
};
|
||||
|
||||
struct Add_A_ConjB
|
||||
{
|
||||
Add_A_ConjB(const ComplexVector &a, const Conjugate &b)
|
||||
: a(a)
|
||||
, b(b.src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
Add_A_ConjB& operator=(const Add_A_ConjB&);
|
||||
};
|
||||
|
||||
struct NegAdd_A_ConjB
|
||||
{
|
||||
NegAdd_A_ConjB(const ComplexVector &a, const Conjugate &b)
|
||||
: a(a)
|
||||
, b(b.src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
NegAdd_A_ConjB& operator=(const NegAdd_A_ConjB&);
|
||||
};
|
||||
|
||||
struct Add_A_ConjNegB
|
||||
{
|
||||
Add_A_ConjNegB(const ComplexVector &a, const ConjugateNegate &b)
|
||||
: a(a)
|
||||
, b(b.src)
|
||||
{
|
||||
}
|
||||
const ComplexVector &a;
|
||||
const ComplexVector &b;
|
||||
|
||||
private:
|
||||
Add_A_ConjNegB& operator=(const Add_A_ConjNegB&);
|
||||
};
|
||||
|
||||
ComplexVector(uint32_t size, radio_float_t *real=0, radio_float_t *imag=0)
|
||||
: m_size(size)
|
||||
, m_real(0)
|
||||
, m_imag(0)
|
||||
, m_pBufReal(0)
|
||||
, m_pBufImag(0)
|
||||
, m_pPtrReal(real)
|
||||
, m_pPtrImag(imag)
|
||||
{
|
||||
if (!real)
|
||||
{
|
||||
m_pBufReal = new radio_float_t[m_size];
|
||||
memset(m_pBufReal, 0, m_size*sizeof(radio_float_t));
|
||||
m_pPtrReal = m_pBufReal;
|
||||
}
|
||||
if (!imag)
|
||||
{
|
||||
m_pBufImag = new radio_float_t[m_size];
|
||||
memset(m_pBufImag, 0, m_size*sizeof(radio_float_t));
|
||||
m_pPtrImag = m_pBufImag;
|
||||
}
|
||||
}
|
||||
|
||||
ComplexVector(radio_float_t real, radio_float_t imag)
|
||||
: m_size(1)
|
||||
, m_real(real)
|
||||
, m_imag(imag)
|
||||
, m_pBufReal(0)
|
||||
, m_pBufImag(0)
|
||||
, m_pPtrReal(&m_real)
|
||||
, m_pPtrImag(&m_imag)
|
||||
{
|
||||
}
|
||||
|
||||
~ComplexVector(void)
|
||||
{
|
||||
if (m_pBufReal)
|
||||
delete(m_pBufReal);
|
||||
|
||||
if (m_pBufImag)
|
||||
delete(m_pBufImag);
|
||||
|
||||
m_pBufReal = nullptr;
|
||||
m_pBufImag = nullptr;
|
||||
}
|
||||
|
||||
radio_float_t* getReal()
|
||||
{
|
||||
return m_pPtrReal;
|
||||
}
|
||||
|
||||
radio_float_t* getImag()
|
||||
{
|
||||
return m_pPtrImag;
|
||||
}
|
||||
|
||||
uint32_t getSize()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
ComplexVector at(uint32_t const &i)
|
||||
{
|
||||
return ComplexVector(*this, i);
|
||||
}
|
||||
|
||||
Conjugate conj()
|
||||
{
|
||||
const ComplexVector::Conjugate src_conj(*this);
|
||||
|
||||
return src_conj;
|
||||
}
|
||||
|
||||
void print(char *pPrefix)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
ComplexDebug("%s:\n", pPrefix);
|
||||
for (i=0; i < m_size; i++)
|
||||
{
|
||||
if (m_pPtrImag[i] < 0)
|
||||
{
|
||||
ComplexDebug("%d: %.6f - j%.6f\n", i, m_pPtrReal[i], -m_pPtrImag[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ComplexDebug("%d: %.6f + j%.6f\n", i, m_pPtrReal[i], m_pPtrImag[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Operators
|
||||
const Negate operator-()
|
||||
{
|
||||
const Negate neg(*this);
|
||||
return neg;
|
||||
}
|
||||
|
||||
ComplexVector& operator=(const radio_float_t &b);
|
||||
ComplexVector& operator*=(const radio_float_t &b);
|
||||
ComplexVector& operator+=(const radio_float_t &b);
|
||||
ComplexVector& operator-=(const radio_float_t &b);
|
||||
|
||||
ComplexVector& operator=(const ComplexVector &src);
|
||||
ComplexVector& operator*=(const ComplexVector &src);
|
||||
ComplexVector& operator+=(const ComplexVector &src);
|
||||
ComplexVector& operator-=(const ComplexVector &src);
|
||||
|
||||
ComplexVector& operator=(const Negate &src);
|
||||
ComplexVector& operator*=(const Negate &src);
|
||||
ComplexVector& operator+=(const Negate &src);
|
||||
ComplexVector& operator-=(const Negate &src);
|
||||
|
||||
ComplexVector& operator=(const Conjugate &src);
|
||||
ComplexVector& operator*=(const Conjugate &src);
|
||||
ComplexVector& operator+=(const Conjugate &src);
|
||||
ComplexVector& operator-=(const Conjugate &src);
|
||||
|
||||
ComplexVector& operator=(const ConjugateNegate &src);
|
||||
ComplexVector& operator*=(const ConjugateNegate &src);
|
||||
ComplexVector& operator+=(const ConjugateNegate &src);
|
||||
ComplexVector& operator-=(const ConjugateNegate &src);
|
||||
|
||||
ComplexVector& operator=(const Mul_A_B &src);
|
||||
ComplexVector& operator+=(const Mul_A_B &src);
|
||||
ComplexVector& operator-=(const Mul_A_B &src);
|
||||
|
||||
ComplexVector& operator=(const NegMul_A_B &src);
|
||||
ComplexVector& operator+=(const NegMul_A_B &src);
|
||||
ComplexVector& operator-=(const NegMul_A_B &src);
|
||||
|
||||
ComplexVector& operator=(const Mul_A_ConjB &src);
|
||||
ComplexVector& operator+=(const Mul_A_ConjB &src);
|
||||
ComplexVector& operator-=(const Mul_A_ConjB &src);
|
||||
|
||||
ComplexVector& operator=(const ConjMul_A_B &src);
|
||||
ComplexVector& operator+=(const ConjMul_A_B &src);
|
||||
ComplexVector& operator-=(const ConjMul_A_B &src);
|
||||
|
||||
ComplexVector& operator=(const ConjNegMul_A_B &src);
|
||||
ComplexVector& operator+=(const ConjNegMul_A_B &src);
|
||||
ComplexVector& operator-=(const ConjNegMul_A_B &src);
|
||||
|
||||
ComplexVector& operator=(const NegMul_A_ConjB &src);
|
||||
ComplexVector& operator+=(const NegMul_A_ConjB &src);
|
||||
ComplexVector& operator-=(const NegMul_A_ConjB &src);
|
||||
|
||||
ComplexVector& operator=(const Add_A_B &src);
|
||||
ComplexVector& operator=(const NegAdd_A_B &src);
|
||||
ComplexVector& operator=(const ConjAdd_A_B &src);
|
||||
ComplexVector& operator=(const ConjNegAdd_A_B &src);
|
||||
ComplexVector& operator=(const Add_A_NegB &src);
|
||||
ComplexVector& operator=(const Add_A_ConjB &src);
|
||||
ComplexVector& operator=(const NegAdd_A_ConjB &src);
|
||||
ComplexVector& operator=(const Add_A_ConjNegB &src);
|
||||
|
||||
private:
|
||||
uint32_t m_size;
|
||||
radio_float_t m_real;
|
||||
radio_float_t m_imag;
|
||||
radio_float_t *m_pBufReal;
|
||||
radio_float_t *m_pBufImag;
|
||||
radio_float_t *m_pPtrReal;
|
||||
radio_float_t *m_pPtrImag;
|
||||
|
||||
ComplexVector(ComplexVector &src, uint32_t index)
|
||||
: m_size(1)
|
||||
, m_pBufReal(0)
|
||||
, m_pBufImag(0)
|
||||
, m_pPtrReal(&src.m_pPtrReal[index])
|
||||
, m_pPtrImag(&src.m_pPtrImag[index])
|
||||
{
|
||||
}
|
||||
|
||||
_inline void checkSize(uint32_t size1, uint32_t size2)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((size1 != size2) && (size2 != 1))
|
||||
{
|
||||
throw(ComplexException("Size mismatch"));
|
||||
}
|
||||
}
|
||||
catch(ComplexException &exc)
|
||||
{
|
||||
ComplexDebug("Problem: %s\n", exc.what().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ComplexVector::Mul_A_B operator*(const ComplexVector &a, radio_float_t b);
|
||||
ComplexVector::Mul_A_B operator*(const ComplexVector &a, const ComplexVector &b);
|
||||
|
||||
ComplexVector::Mul_A_B operator*(const ComplexVector::Negate &a, const ComplexVector::Negate &b);
|
||||
ComplexVector::NegMul_A_B operator*(const ComplexVector::Negate &a, const ComplexVector &b);
|
||||
ComplexVector::NegMul_A_B operator*(const ComplexVector &a, const ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::ConjMul_A_B operator*(const ComplexVector::Conjugate &a, const ComplexVector::Conjugate &b);
|
||||
ComplexVector::Mul_A_ConjB operator*(const ComplexVector::Conjugate &a, const ComplexVector &b);
|
||||
ComplexVector::Mul_A_ConjB operator*(const ComplexVector &a, const ComplexVector::Conjugate &b);
|
||||
|
||||
ComplexVector::ConjMul_A_B operator*(const ComplexVector::ConjugateNegate &a, const ComplexVector::ConjugateNegate &b);
|
||||
ComplexVector::NegMul_A_ConjB operator*(const ComplexVector &a, const ComplexVector::ConjugateNegate &b);
|
||||
ComplexVector::NegMul_A_ConjB operator*(const ComplexVector::ConjugateNegate &a, const ComplexVector &b);
|
||||
|
||||
ComplexVector::Mul_A_ConjB operator*(const ComplexVector::Negate &a, const ComplexVector::ConjugateNegate &b);
|
||||
ComplexVector::Mul_A_ConjB operator*(const ComplexVector::ConjugateNegate &a, const ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::NegMul_A_ConjB operator*(const ComplexVector::Negate &a, const ComplexVector::Conjugate &b);
|
||||
ComplexVector::NegMul_A_ConjB operator*(const ComplexVector::Conjugate &a, const ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::Add_A_B operator+(const ComplexVector &a, radio_float_t b);
|
||||
ComplexVector::Add_A_B operator+(const ComplexVector &a, const ComplexVector &b);
|
||||
ComplexVector::NegAdd_A_B operator+(ComplexVector::Negate &a, ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::Add_A_NegB operator+(const ComplexVector::Negate &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_NegB operator+(const ComplexVector &a, const ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::Add_A_ConjB operator+(const ComplexVector::Conjugate &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_ConjB operator+(const ComplexVector &a, const ComplexVector::Conjugate &b);
|
||||
ComplexVector::ConjAdd_A_B operator+(const ComplexVector::Conjugate &a, const ComplexVector::Conjugate &b);
|
||||
|
||||
|
||||
ComplexVector::Add_A_ConjNegB operator+(const ComplexVector::ConjugateNegate &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_ConjNegB operator+(const ComplexVector &a, const ComplexVector::ConjugateNegate &b);
|
||||
|
||||
ComplexVector::Add_A_ConjB operator+(const ComplexVector::Conjugate &a, const ComplexVector::Negate &b);
|
||||
ComplexVector::Add_A_ConjB operator+(const ComplexVector::Negate &a, const ComplexVector::Conjugate &b);
|
||||
|
||||
ComplexVector::Add_A_ConjB operator+(const ComplexVector::ConjugateNegate &a, const ComplexVector::Negate &b);
|
||||
ComplexVector::Add_A_ConjB operator+(const ComplexVector::Negate &a, const ComplexVector::ConjugateNegate &b);
|
||||
|
||||
ComplexVector::Add_A_B operator-(const ComplexVector &a, radio_float_t b);
|
||||
ComplexVector::Add_A_NegB operator-(const ComplexVector &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_NegB operator-(const ComplexVector::Negate &a, const ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::NegAdd_A_B operator-(const ComplexVector::Negate &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_B operator-(const ComplexVector &a, const ComplexVector::Negate &b);
|
||||
|
||||
ComplexVector::Add_A_ConjNegB operator-(const ComplexVector::Conjugate &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_ConjNegB operator-(const ComplexVector &a, const ComplexVector::Conjugate &b);
|
||||
|
||||
ComplexVector::NegAdd_A_ConjB operator-(const ComplexVector::ConjugateNegate &a, const ComplexVector &b);
|
||||
ComplexVector::Add_A_ConjB operator-(const ComplexVector &a, const ComplexVector::ConjugateNegate &b);
|
||||
|
||||
ComplexVector::Add_A_ConjB operator-(const ComplexVector::Conjugate &a, const ComplexVector::Negate &b);
|
||||
ComplexVector::Add_A_ConjB operator-(const ComplexVector::Negate &a, const ComplexVector::Conjugate &b);
|
||||
|
||||
ComplexVector::Add_A_ConjB operator-(const ComplexVector::ConjugateNegate &a, const ComplexVector::Negate &b);
|
||||
ComplexVector::Add_A_ConjB operator-(const ComplexVector::Negate &a, const ComplexVector::ConjugateNegate &b);
|
||||
|
||||
#endif // _COMPLEX_HPP_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,403 +0,0 @@
|
||||
#ifndef _REAL_HPP_
|
||||
#define _REAL_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <memory.h>
|
||||
#include <radio/radio_types.h>
|
||||
|
||||
void RealDebug(char *fmtstr, ...);
|
||||
|
||||
class RealException
|
||||
{
|
||||
public:
|
||||
RealException (std::string s)
|
||||
{
|
||||
m_what = s;
|
||||
}
|
||||
~RealException()
|
||||
{
|
||||
}
|
||||
std::string& what()
|
||||
{
|
||||
return m_what;
|
||||
}
|
||||
private:
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
class RealVectorNegative;
|
||||
|
||||
class RealVector
|
||||
{
|
||||
public:
|
||||
|
||||
struct OpBinaryAdd
|
||||
{
|
||||
struct Negative
|
||||
{
|
||||
Negative(const OpBinaryAdd src)
|
||||
: a(src.a)
|
||||
, b(src.b)
|
||||
{
|
||||
}
|
||||
|
||||
OpBinaryAdd operator-() const
|
||||
{
|
||||
return OpBinaryAdd(a, b);
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
Negative& operator=(const Negative&);
|
||||
};
|
||||
|
||||
OpBinaryAdd(const RealVector &a, const RealVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
|
||||
Negative operator-() const
|
||||
{
|
||||
return Negative(*this);
|
||||
}
|
||||
|
||||
const OpBinaryAdd& operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
~OpBinaryAdd()
|
||||
{
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
OpBinaryAdd& operator=(const OpBinaryAdd&);
|
||||
};
|
||||
|
||||
struct OpBinarySub
|
||||
{
|
||||
struct Negative
|
||||
{
|
||||
Negative(const OpBinarySub src)
|
||||
: a(src.a)
|
||||
, b(src.b)
|
||||
{
|
||||
}
|
||||
|
||||
OpBinarySub operator-() const
|
||||
{
|
||||
return OpBinarySub(a, b);
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
Negative& operator=(const Negative&);
|
||||
};
|
||||
|
||||
OpBinarySub(const RealVector &a, const RealVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
|
||||
~OpBinarySub()
|
||||
{
|
||||
}
|
||||
|
||||
Negative operator-() const
|
||||
{
|
||||
return Negative(*this);
|
||||
}
|
||||
|
||||
const OpBinarySub& operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
OpBinarySub& operator=(const OpBinarySub&);
|
||||
};
|
||||
|
||||
struct OpBinaryMul
|
||||
{
|
||||
struct Negative
|
||||
{
|
||||
Negative(const OpBinaryMul src)
|
||||
: a(src.a)
|
||||
, b(src.b)
|
||||
{
|
||||
}
|
||||
|
||||
OpBinaryMul operator-() const
|
||||
{
|
||||
return OpBinaryMul(a, b);
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
Negative& operator=(const Negative&);
|
||||
};
|
||||
|
||||
OpBinaryMul(const RealVector &a, const RealVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
|
||||
Negative operator-() const
|
||||
{
|
||||
return Negative(*this);
|
||||
}
|
||||
|
||||
const OpBinaryMul& operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
~OpBinaryMul()
|
||||
{
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
OpBinaryMul& operator=(const OpBinaryMul&);
|
||||
};
|
||||
|
||||
struct OpBinaryDiv
|
||||
{
|
||||
struct Negative
|
||||
{
|
||||
Negative(const OpBinaryDiv src)
|
||||
: a(src.a)
|
||||
, b(src.b)
|
||||
{
|
||||
}
|
||||
|
||||
OpBinaryDiv operator-() const
|
||||
{
|
||||
return OpBinaryDiv(a, b);
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
Negative& operator=(const Negative&);
|
||||
};
|
||||
|
||||
OpBinaryDiv(const RealVector &a, const RealVector &b)
|
||||
: a(a)
|
||||
, b(b)
|
||||
{
|
||||
}
|
||||
|
||||
Negative operator-() const
|
||||
{
|
||||
return Negative(*this);
|
||||
}
|
||||
|
||||
const OpBinaryDiv& operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
~OpBinaryDiv()
|
||||
{
|
||||
}
|
||||
const RealVector &a;
|
||||
const RealVector &b;
|
||||
|
||||
private:
|
||||
OpBinaryDiv& operator=(const OpBinaryDiv&);
|
||||
};
|
||||
|
||||
~RealVector(void);
|
||||
|
||||
// Standard constructor
|
||||
RealVector(uint32_t size, radio_float_t *real=0);
|
||||
|
||||
// Copy constructor
|
||||
RealVector(const RealVector &src);
|
||||
|
||||
// Slicing constructor
|
||||
RealVector(RealVector &src, uint32_t from, uint32_t step, uint32_t to);
|
||||
|
||||
// Negative resolver copy constructor
|
||||
RealVector(const RealVectorNegative &src);
|
||||
|
||||
// OpBinaryAdd resolver copy constructor
|
||||
RealVector(const OpBinaryAdd &src);
|
||||
|
||||
// OpBinaryAdd::Negative resolver copy constructor
|
||||
RealVector(const OpBinaryAdd::Negative &src);
|
||||
|
||||
// OpBinarySub resolver copy constructor
|
||||
RealVector(const OpBinarySub &src);
|
||||
|
||||
// OpBinaryMul resolver copy constructor
|
||||
RealVector(const OpBinaryMul &src);
|
||||
|
||||
// OpBinaryMul::Negative resolver copy constructor
|
||||
RealVector(const OpBinaryMul::Negative &src);
|
||||
|
||||
// OpBinaryDiv resolver copy constructor
|
||||
RealVector(const OpBinaryDiv &src);
|
||||
|
||||
// OpBinaryDiv::Negative resolver copy constructor
|
||||
RealVector(const OpBinaryDiv::Negative &src);
|
||||
|
||||
// Scalar constructor
|
||||
RealVector(radio_float_t real);
|
||||
|
||||
uint32_t getSize() const;
|
||||
|
||||
radio_float_t getValue() const;
|
||||
|
||||
RealVector at(uint32_t const &i);
|
||||
void print(char *pPrefix) const;
|
||||
|
||||
RealVectorNegative operator-() const;
|
||||
const RealVector& operator+() const;
|
||||
|
||||
// Assignments
|
||||
RealVector& operator=(const RealVector &src);
|
||||
RealVector& operator+=(const RealVector &src);
|
||||
RealVector& operator-=(const RealVector &src);
|
||||
RealVector& operator*=(const RealVector &src);
|
||||
RealVector& operator/=(const RealVector &src);
|
||||
|
||||
RealVector& operator=(const RealVectorNegative &src);
|
||||
RealVector& operator+=(const RealVectorNegative &src);
|
||||
RealVector& operator-=(const RealVectorNegative &src);
|
||||
RealVector& operator*=(const RealVectorNegative &src);
|
||||
RealVector& operator/=(const RealVectorNegative &src);
|
||||
|
||||
RealVector& operator=(const OpBinaryAdd &src);
|
||||
RealVector& operator+=(const OpBinaryAdd &src);
|
||||
RealVector& operator-=(const OpBinaryAdd &src);
|
||||
RealVector& operator*=(const OpBinaryAdd &src);
|
||||
RealVector& operator/=(const OpBinaryAdd &src);
|
||||
|
||||
RealVector& operator=(const OpBinaryAdd::Negative &src);
|
||||
RealVector& operator+=(const OpBinaryAdd::Negative &src);
|
||||
RealVector& operator-=(const OpBinaryAdd::Negative &src);
|
||||
RealVector& operator*=(const OpBinaryAdd::Negative &src);
|
||||
RealVector& operator/=(const OpBinaryAdd::Negative &src);
|
||||
|
||||
RealVector& operator=(const OpBinarySub &src);
|
||||
RealVector& operator+=(const OpBinarySub &src);
|
||||
RealVector& operator-=(const OpBinarySub &src);
|
||||
RealVector& operator*=(const OpBinarySub &src);
|
||||
RealVector& operator/=(const OpBinarySub &src);
|
||||
|
||||
RealVector& operator=(const OpBinaryMul &src);
|
||||
RealVector& operator+=(const OpBinaryMul &src);
|
||||
RealVector& operator-=(const OpBinaryMul &src);
|
||||
RealVector& operator*=(const OpBinaryMul &src);
|
||||
RealVector& operator/=(const OpBinaryMul &src);
|
||||
|
||||
RealVector& operator=(const OpBinaryMul::Negative &src);
|
||||
RealVector& operator+=(const OpBinaryMul::Negative &src);
|
||||
RealVector& operator-=(const OpBinaryMul::Negative &src);
|
||||
RealVector& operator*=(const OpBinaryMul::Negative &src);
|
||||
RealVector& operator/=(const OpBinaryMul::Negative &src);
|
||||
|
||||
RealVector& operator=(const OpBinaryDiv &src);
|
||||
RealVector& operator+=(const OpBinaryDiv &src);
|
||||
RealVector& operator-=(const OpBinaryDiv &src);
|
||||
RealVector& operator*=(const OpBinaryDiv &src);
|
||||
RealVector& operator/=(const OpBinaryDiv &src);
|
||||
|
||||
RealVector& operator=(const OpBinaryDiv::Negative &src);
|
||||
RealVector& operator+=(const OpBinaryDiv::Negative &src);
|
||||
RealVector& operator-=(const OpBinaryDiv::Negative &src);
|
||||
RealVector& operator*=(const OpBinaryDiv::Negative &src);
|
||||
RealVector& operator/=(const OpBinaryDiv::Negative &src);
|
||||
|
||||
private:
|
||||
uint32_t m_size;
|
||||
radio_float_t m_real;
|
||||
radio_float_t *m_pBufReal;
|
||||
radio_float_t *m_pPtrReal;
|
||||
|
||||
_inline void checkSize(uint32_t size1, uint32_t size2)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((size1 != size2) && (size2 != 1))
|
||||
{
|
||||
throw(RealException("Size mismatch"));
|
||||
}
|
||||
}
|
||||
catch(RealException &exc)
|
||||
{
|
||||
RealDebug("Problem: %s\n", exc.what().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class RealVectorNegative : public RealVector
|
||||
{
|
||||
public:
|
||||
RealVectorNegative(const RealVector &src)
|
||||
: RealVector(src)
|
||||
, m_iamNegative(true)
|
||||
{
|
||||
}
|
||||
|
||||
const RealVector& operator-() const
|
||||
{
|
||||
return (RealVector&)*this;
|
||||
}
|
||||
|
||||
const RealVectorNegative& operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_iamNegative;
|
||||
RealVectorNegative& operator=(const RealVectorNegative&);
|
||||
};
|
||||
|
||||
|
||||
// Non-Member
|
||||
// Binary Operators
|
||||
// Returning RealVector::OpBinary
|
||||
RealVector::OpBinaryAdd operator+(const RealVector &a, const RealVector &b);
|
||||
#if 0
|
||||
RealVector::OpBinarySub operator+(const RealVectorNegative &a, const RealVector &b);
|
||||
RealVector::OpBinarySub operator+(const RealVector &a, const RealVectorNegative &b);
|
||||
RealVector::OpBinaryAdd::Negative operator+(const RealVectorNegative &a, const RealVectorNegative &b);
|
||||
#endif
|
||||
|
||||
RealVector::OpBinarySub operator-(const RealVector &a, const RealVector &b);
|
||||
#if 0
|
||||
RealVector::OpBinaryAdd::Negative operator-(const RealVectorNegative &a, const RealVector &b);
|
||||
RealVector::OpBinaryAdd operator-(const RealVector &a, const RealVectorNegative &b);
|
||||
RealVector::OpBinarySub operator-(const RealVectorNegative &a, const RealVectorNegative &b);
|
||||
#endif
|
||||
|
||||
RealVector::OpBinaryMul operator*(const RealVector &a, const RealVector &b);
|
||||
#if 0
|
||||
RealVector::OpBinaryMul::Negative operator*(const RealVectorNegative &a, const RealVector &b);
|
||||
RealVector::OpBinaryMul::Negative operator*(const RealVector &a, const RealVectorNegative &b);
|
||||
RealVector::OpBinaryMul operator*(const RealVectorNegative &a, const RealVectorNegative &b);
|
||||
#endif
|
||||
|
||||
RealVector::OpBinaryDiv operator/(const RealVector &a, const RealVector &b);
|
||||
RealVector::OpBinaryDiv::Negative operator/(const RealVectorNegative &a, const RealVector &b);
|
||||
RealVector::OpBinaryDiv::Negative operator/(const RealVector &a, const RealVectorNegative &b);
|
||||
RealVector::OpBinaryDiv operator/(const RealVectorNegative &a, const RealVectorNegative &b);
|
||||
|
||||
#endif // _REAL_HPP_
|
||||
Reference in New Issue
Block a user