operators.h
Go to the documentation of this file.
#ifndef OPERATORS_H
#define OPERATORS_H
#include <itpp/base/vec.h>
#include <itpp/base/mat.h>
#include <itpp/base/converters.h>
#include <itpp/itexports.h>
namespace itpp
{
//---------------------- between scalars and complex<double> -----------------
inline std::complex<double> operator+(const int &x, const std::complex<double> &y) {return std::complex<double>(x + y.real(), y.imag());}
inline std::complex<double> operator+(const float &x, const std::complex<double> &y) {return std::complex<double>(x + y.real(), y.imag());}
inline std::complex<double> operator+(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real() + y, x.imag());}
inline std::complex<double> operator+(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real() + y, x.imag());}
inline std::complex<double> operator-(const int &x, const std::complex<double> &y) {return std::complex<double>(x - y.real(), -y.imag());}
inline std::complex<double> operator-(const float &x, const std::complex<double> &y) {return std::complex<double>(x - y.real(), -y.imag());}
inline std::complex<double> operator-(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real() - y, x.imag());}
inline std::complex<double> operator-(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real() - y, x.imag());}
inline std::complex<double> operator*(const int &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
inline std::complex<double> operator*(const float &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
inline std::complex<double> operator*(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
inline std::complex<double> operator*(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
inline std::complex<double> operator/(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real() / y, x.imag() / y);}
inline std::complex<double> operator/(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real() / y, x.imag() / y);}
//---------------------- between vec and scalar --------------------
inline vec operator+(const float &s, const vec &v) {return static_cast<double>(s) + v;}
inline vec operator+(const short &s, const vec &v) {return static_cast<double>(s) + v;}
inline vec operator+(const int &s, const vec &v) {return static_cast<double>(s) + v;}
inline vec operator+(const vec &v, const float &s) {return static_cast<double>(s) + v;}
inline vec operator+(const vec &v, const short &s) {return static_cast<double>(s) + v;}
inline vec operator+(const vec &v, const int &s) {return static_cast<double>(s) + v;}
inline vec operator-(const float &s, const vec &v) {return static_cast<double>(s) - v;}
inline vec operator-(const short &s, const vec &v) {return static_cast<double>(s) - v;}
inline vec operator-(const int &s, const vec &v) {return static_cast<double>(s) - v;}
inline vec operator-(const vec &v, const float &s) {return v -static_cast<double>(s);}
inline vec operator-(const vec &v, const short &s) {return v -static_cast<double>(s);}
inline vec operator-(const vec &v, const int &s) {return v -static_cast<double>(s);}
inline vec operator*(const float &s, const vec &v) {return static_cast<double>(s)*v;}
inline vec operator*(const short &s, const vec &v) {return static_cast<double>(s)*v;}
inline vec operator*(const int &s, const vec &v) {return static_cast<double>(s)*v;}
cvec operator*(const std::complex<double> &s, const vec &v);
inline vec operator*(const vec &v, const float &s) {return static_cast<double>(s)*v;}
inline vec operator*(const vec &v, const short &s) {return static_cast<double>(s)*v;}
inline vec operator*(const vec &v, const int &s) {return static_cast<double>(s)*v;}
cvec operator*(const vec &v, const std::complex<double> &s);
inline vec operator/(const vec &v, const float &s) {return v / static_cast<double>(s);}
inline vec operator/(const vec &v, const short &s) {return v / static_cast<double>(s);}
inline vec operator/(const vec &v, const int &s) {return v / static_cast<double>(s);}
//---------------------- between ivec and scalar --------------------
ITPP_EXPORT vec operator+(const double &s, const ivec &v);
inline vec operator+(const ivec &v, const double &s) { return s + v;}
ITPP_EXPORT vec operator-(const double &s, const ivec &v);
inline vec operator-(const ivec &v, const double &s) { return v + (-s); }
ITPP_EXPORT vec operator*(const double &s, const ivec &v);
inline vec operator*(const ivec &v, const double &s) { return s*v; }
ITPP_EXPORT vec operator/(const double &s, const ivec &v);
ITPP_EXPORT vec operator/(const ivec &v, const double &s);
ITPP_EXPORT cvec operator+(const std::complex<double> &s, const ivec &v);
inline cvec operator+(const ivec &v, const std::complex<double> &s) { return s + v;}
ITPP_EXPORT cvec operator-(const std::complex<double> &s, const ivec &v);
inline cvec operator-(const ivec &v, const std::complex<double> &s) { return v + (-s); }
ITPP_EXPORT cvec operator*(const std::complex<double> &s, const ivec &v);
inline cvec operator*(const ivec &v, const std::complex<double> &s) { return s*v; }
ITPP_EXPORT cvec operator/(const std::complex<double> &s, const ivec &v);
ITPP_EXPORT cvec operator/(const ivec &v, const std::complex<double> &s);
//---------------------- between cvec and scalar --------------------
ITPP_EXPORT cvec operator+(const double &s, const cvec &v);
inline cvec operator+(const float &s, const cvec &v) {return static_cast<double>(s) + v;}
inline cvec operator+(const short &s, const cvec &v) {return static_cast<double>(s) + v;}
inline cvec operator+(const int &s, const cvec &v) {return static_cast<double>(s) + v;}
inline cvec operator+(const cvec &v, const float &s) {return s + v;}
inline cvec operator+(const cvec &v, const double &s) {return s + v;}
inline cvec operator+(const cvec &v, const short &s) {return s + v;}
inline cvec operator+(const cvec &v, const int &s) {return s + v;}
ITPP_EXPORT cvec operator-(const double &s, const cvec &v);
inline cvec operator-(const float &s, const cvec &v) {return static_cast<double>(s) - v;}
inline cvec operator-(const short &s, const cvec &v) {return static_cast<double>(s) - v;}
inline cvec operator-(const int &s, const cvec &v) {return static_cast<double>(s) - v;}
inline cvec operator-(const cvec &v, const float &s) {return v + (-s);}
inline cvec operator-(const cvec &v, const double &s) {return v + (-s);}
inline cvec operator-(const cvec &v, const short &s) {return v + (-s);}
inline cvec operator-(const cvec &v, const int &s) {return v + (-s);}
ITPP_EXPORT cvec operator*(const double &s, const cvec &v);
inline cvec operator*(const float &s, const cvec &v) {return static_cast<double>(s)*v;}
inline cvec operator*(const short &s, const cvec &v) {return static_cast<double>(s)*v;}
inline cvec operator*(const int &s, const cvec &v) {return static_cast<double>(s)*v;}
inline cvec operator*(const cvec &v, const float &s) {return s*v;}
inline cvec operator*(const cvec &v, const double &s) {return s*v;}
inline cvec operator*(const cvec &v, const short &s) {return s*v;}
inline cvec operator*(const cvec &v, const int &s) {return s*v;}
ITPP_EXPORT cvec operator/(const cvec &v, const double &s);
ITPP_EXPORT cvec operator/(const double &s, const cvec &v);
inline cvec operator/(const cvec &v, const float &s) {return v / static_cast<double>(s);}
inline cvec operator/(const cvec &v, const short &s) {return v / static_cast<double>(s);}
inline cvec operator/(const cvec &v, const int &s) {return v / static_cast<double>(s);}
//---------------------- between mat and scalar --------------------
inline mat operator+(const float &s, const mat &m) {return static_cast<double>(s) + m;}
inline mat operator+(const short &s, const mat &m) {return static_cast<double>(s) + m;}
inline mat operator+(const int &s, const mat &m) {return static_cast<double>(s) + m;}
inline mat operator+(const mat &m, const float &s) {return static_cast<double>(s) + m;}
inline mat operator+(const mat &m, const short &s) {return static_cast<double>(s) + m;}
inline mat operator+(const mat &m, const int &s) {return static_cast<double>(s) + m;}
inline mat operator-(const float &s, const mat &m) {return static_cast<double>(s) - m;}
inline mat operator-(const short &s, const mat &m) {return static_cast<double>(s) - m;}
inline mat operator-(const int &s, const mat &m) {return static_cast<double>(s) - m;}
inline mat operator-(const mat &m, const float &s) {return m -static_cast<double>(s);}
inline mat operator-(const mat &m, const short &s) {return m -static_cast<double>(s);}
inline mat operator-(const mat &m, const int &s) {return m -static_cast<double>(s);}
inline mat operator*(const float &s, const mat &m) {return static_cast<double>(s)*m;}
inline mat operator*(const short &s, const mat &m) {return static_cast<double>(s)*m;}
inline mat operator*(const int &s, const mat &m) {return static_cast<double>(s)*m;}
inline mat operator*(const mat &m, const float &s) {return static_cast<double>(s)*m;}
inline mat operator*(const mat &m, const short &s) {return static_cast<double>(s)*m;}
inline mat operator*(const mat &m, const int &s) {return static_cast<double>(s)*m;}
inline mat operator/(const mat &m, const float &s) {return m / static_cast<double>(s);}
inline mat operator/(const mat &m, const short &s) {return m / static_cast<double>(s);}
inline mat operator/(const mat &m, const int &s) {return m / static_cast<double>(s);}
//---------------------- between cmat and scalar --------------------
ITPP_EXPORT cmat operator+(const double &s, const cmat &m);
ITPP_EXPORT cmat operator-(const double &s, const cmat &m);
ITPP_EXPORT cmat operator*(const double &s, const cmat &m);
ITPP_EXPORT cmat operator*(const std::complex<double> &s, const mat &m);
inline cmat operator*(const mat &m, const std::complex<double> &s) {return s*m;}
ITPP_EXPORT cmat operator/(const cmat &m, const double &s);
//---------------------- between vec and vectors --------------------
ITPP_EXPORT vec operator+(const bvec &a, const vec &b);
ITPP_EXPORT vec operator+(const svec &a, const vec &b);
ITPP_EXPORT vec operator+(const ivec &a, const vec &b);
inline vec operator+(const vec &a, const bvec &b) {return b + a;}
inline vec operator+(const vec &a, const svec &b) {return b + a;}
inline vec operator+(const vec &a, const ivec &b) {return b + a;}
inline vec operator-(const bvec &a, const vec &b) {return a + (-b);}
inline vec operator-(const svec &a, const vec &b) {return a + (-b);}
inline vec operator-(const ivec &a, const vec &b) {return a + (-b);}
inline vec operator-(const vec &a, const bvec &b) {return a + (-b);}
inline vec operator-(const vec &a, const svec &b) {return a + (-b);}
inline vec operator-(const vec &a, const ivec &b) {return a + (-b);}
ITPP_EXPORT double operator*(const bvec &a, const vec &b);
ITPP_EXPORT double operator*(const svec &a, const vec &b);
ITPP_EXPORT double operator*(const ivec &a, const vec &b);
inline double operator*(const vec &a, const bvec &b) {return b*a;}
inline double operator*(const vec &a, const svec &b) {return b*a;}
inline double operator*(const vec &a, const ivec &b) {return b*a;}
//---------------------- between cvec and vectors --------------------
ITPP_EXPORT cvec operator+(const bvec &a, const cvec &b);
ITPP_EXPORT cvec operator+(const svec &a, const cvec &b);
ITPP_EXPORT cvec operator+(const ivec &a, const cvec &b);
inline cvec operator+(const cvec &a, const bvec &b) {return b + a;}
inline cvec operator+(const cvec &a, const svec &b) {return b + a;}
inline cvec operator+(const cvec &a, const ivec &b) {return b + a;}
inline cvec operator-(const bvec &a, const cvec &b) {return a + (-b);}
inline cvec operator-(const svec &a, const cvec &b) {return a + (-b);}
inline cvec operator-(const ivec &a, const cvec &b) {return a + (-b);}
inline cvec operator-(const cvec &a, const bvec &b) {return a + (-b);}
inline cvec operator-(const cvec &a, const svec &b) {return a + (-b);}
inline cvec operator-(const cvec &a, const ivec &b) {return a + (-b);}
ITPP_EXPORT std::complex<double> operator*(const bvec &a, const cvec &b);
ITPP_EXPORT std::complex<double> operator*(const svec &a, const cvec &b);
ITPP_EXPORT std::complex<double> operator*(const ivec &a, const cvec &b);
inline std::complex<double> operator*(const cvec &a, const bvec &b) {return b*a;}
inline std::complex<double> operator*(const cvec &a, const svec &b) {return b*a;}
inline std::complex<double> operator*(const cvec &a, const ivec &b) {return b*a;}
//---------------------- between mat and matricies --------------------
ITPP_EXPORT mat operator+(const bmat &a, const mat &b);
ITPP_EXPORT mat operator+(const smat &a, const mat &b);
ITPP_EXPORT mat operator+(const imat &a, const mat &b);
inline mat operator+(const mat &a, const bmat &b) {return b + a;}
inline mat operator+(const mat &a, const smat &b) {return b + a;}
inline mat operator+(const mat &a, const imat &b) {return b + a;}
inline mat operator-(const bmat &a, const mat &b) {return a + (-b);}
inline mat operator-(const smat &a, const mat &b) {return a + (-b);}
inline mat operator-(const imat &a, const mat &b) {return a + (-b);}
inline mat operator-(const mat &a, const bmat &b) {return a + (-b);}
inline mat operator-(const mat &a, const smat &b) {return a + (-b);}
inline mat operator-(const mat &a, const imat &b) {return a + (-b);}
//---------------------- between cmat and matricies --------------------
ITPP_EXPORT cmat operator+(const bmat &a, const cmat &b);
ITPP_EXPORT cmat operator+(const smat &a, const cmat &b);
ITPP_EXPORT cmat operator+(const imat &a, const cmat &b);
ITPP_EXPORT cmat operator+(const mat &a, const cmat &b);
inline cmat operator+(const cmat &a, const bmat &b) {return b + a;}
inline cmat operator+(const cmat &a, const smat &b) {return b + a;}
inline cmat operator+(const cmat &a, const imat &b) {return b + a;}
inline cmat operator+(const cmat &a, const mat &b) {return b + a;}
inline cmat operator-(const bmat &a, const cmat &b) {return a + (-b);}
inline cmat operator-(const smat &a, const cmat &b) {return a + (-b);}
inline cmat operator-(const imat &a, const cmat &b) {return a + (-b);}
inline cmat operator-(const mat &a, const cmat &b) {return a + (-b);}
inline cmat operator-(const cmat &a, const bmat &b) {return a + (-b);}
inline cmat operator-(const cmat &a, const smat &b) {return a + (-b);}
inline cmat operator-(const cmat &a, const imat &b) {return a + (-b);}
inline cmat operator-(const cmat &a, const mat &b) {return a + (-b);}
inline cmat operator*(const mat &a, const cmat &b) {return to_cmat(a)*b;}
inline cmat operator*(const bmat &a, const cmat &b) {return to_cmat(a)*b;}
inline cmat operator*(const smat &a, const cmat &b) {return to_cmat(a)*b;}
inline cmat operator*(const imat &a, const cmat &b) {return to_cmat(a)*b;}
inline cmat operator*(const cmat &a, const mat &b) {return a*to_cmat(b);}
inline cmat operator*(const cmat &a, const bmat &b) {return a*to_cmat(b);}
inline cmat operator*(const cmat &a, const smat &b) {return a*to_cmat(b);}
inline cmat operator*(const cmat &a, const imat &b) {return a*to_cmat(b);}
} // namespace itpp
#endif // #ifndef OPERATORS_H
itpp::operator/
Mat< Num_T > operator/(const Mat< Num_T > &m, Num_T t)
Element-wise division by a scalar.
Definition: mat.h:1670
itpp::to_cmat
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
Definition: converters.h:232
converters.h
Definitions of converters between different vector and matrix types.
itpp::operator-
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
Definition: mat.h:1382
mat.h
Matrix Class Definitions.
itpp::operator+
GF2mat operator+(const GF2mat &X, const GF2mat &Y)
GF(2) matrix addition.
Definition: gf2mat.cpp:948
itpp
itpp namespace
Definition: itmex.h:36
itpp::operator*
GF2mat operator*(const GF2mat &X, const GF2mat &Y)
GF(2) matrix multiplication.
Definition: gf2mat.cpp:847
bmat
Mat< bin > bmat
bin matrix
Definition: mat.h:508
vec.h
Templated Vector Class Definitions.

Generated on Sat Sep 30 2017 07:04:09 for IT++ by Doxygen 1.8.13