22#define MappingAppll_D 0
23#define MappingAppl_D 0
25#define MappingConstructorHack 1
30 template<
typename F,
typename G>
32 for (
size_t i = 0; i < n; ++i) *
dest++ = *
src++;
45 template<
class F, u
int dim>
51 Point() { F* d = data_;
for(
uint i = dim; i--;) *d++ = 0; }
61 F* d = data_+
dim2;
for(
uint i = dim-
dim2; i--;) *d++ = 0;
68 Point(F x) { F* d = data_;
for(
uint i = dim; i--;) *d++ = x; }
70 Point(
const F
e0,
const F e1,
const F e2 = 0) {
99 operator F*() {
return data_; }
101 operator const F*()
const {
return data_; }
105 F* d = data_;
const F* dp = p.data_;
106 for(
uint i = dim; i--;) *d++ += *dp++;
116 F* d = data_;
const F* dp = p.data_;
117 for(
uint i = dim; i--;) *d++ -= *dp++;
136 for(
uint i = dim; i--;) *d++ *= n;
143 F* d = data_;
for(
uint i = dim; i--;) *d++ /= n;
171 F* d = data_;
const F* e = n.data_;
172 for(
uint i = dim; i--;) *d++ *= *e++;
190 const F ca = 1.0,
const F cb = 1.0);
207 std::ostream& info(std::ostream&
os)
const;
212 template<
class F, u
int dim>
218 template<
typename F, u
int dim>
224 template<
typename F, u
int dim>
230 template <
class F, u
int dim>
233 const F* d = (
const F*)x;
const F* e = (
const F*)y;
234 for (
uint i = dim; i--;)
235 if (*d++ != *e++)
return false;
239 template <
class F, u
int dim>
245 template <
class F, u
int dim>
255 for(
uint i = 2; i--;)
256 res += (*d++) * (*
db++);
264 for(
uint i = dim; i--;)
265 res += (*d++) * (*
db++);
294 len_ = this->
l2(); *
this *= (1.0 / len_);
300 len_ = this->
l2(); *
this *= (1.0 / len_);
312 template<
class F, u
int DimY, u
int DimX=DimY>
334 data_[lin_(i,j)] = m(i,j);
342#if MappingConstructorHack
357#if MappingConstructorHack
362 Mapping(std::enable_if<std::is_floating_point<FieldTs>::value,
FieldTs>::type... data) : data_{data...} {
363 static_assert(
sizeof...(FieldTs)==
DimX*
DimY,
"Wrong number of arguments.");
440 DEBUGL(MappingAppll_D,
'(' << i <<
", " << j <<
") is " << data_[i*
DimY+j]
441 <<
" at " << &(data_[i*
DimX+j]));
442 return data_[i*
DimX+j];
449 DEBUGL(MappingAppll_D,
'(' << i <<
", " << j <<
") is " << data_[i*
DimY+j]
450 <<
" at " << &(data_[i*
DimX+j]));
451 return data_[i*
DimX+j];
464 template<
class G, u
int DimZ>
514 template<
class H,
class J, u
int dimy, u
int dimx>
517 std::ostream& info(std::ostream&
os)
const;
529 template<
class F, u
int DimY, u
int DimX>
534 this->operator()(p,
res);
538 template<
class F, u
int DimY, u
int DimX>
545 const H* dp = (
const H*)y;
546 const F*
dm = data_ + i;
549 *
dr += (*dm) * (*dp);
555 template<
class F, u
int DimY, u
int DimX>
556 template<
class H,
class J, u
int dimy, u
int dimx>
559 DEBUGL(MappingAppl_D, *
this <<
" * " << y <<
" -> " << x);
560 if (
dimx ==
dimy && (
void*)&x == (
void*)&y) {
563 const F* d = this->data_;
564 const H*
yp = (
const H*)y;
572 *dx += d[j] * (*dy++);
585 DEBUGL(MappingAppl_D,
"x != y");
587 const F* d = this->data_;
588 const H* dy = (
const H*)y;
593 *dx += d[j] * (*dy++);
595 DEBUGL(MappingAppl_D,
"x = " << x);
608 template<
class F, u
int DimY, u
int DimX>
614 template<
typename F, u
int DimX, u
int DimY>
620 template<
typename F, u
int DimX, u
int DimY>
622 typedef typename Datatype<F>::type type;
641 template<
class F, u
int dim>
654 template<
class F, u
int dim>
656 static inline std::string name() {
661 template<
class F, u
int dim>
663 static inline std::string name() {
681 template<
class F, u
int CoordDim>
684 concepts::Point<F,CoordDim>> {};
687 template<u
int CoordDim>
691 template<
int CoordDim>
693 const typename Coordinate<1>::type,
694 const typename Coordinate<CoordDim>::type &> {};
708 template<
class F, u
int dim>
711 F* d = (F*)res;
const F* e = (
const F*)v;
712 for(uint i = dim; i--;) *d++ += conj(*e++);
721 template<
class F, u
int dim>
Mapping< F, DimX, DimY > inverse() const
Returns the inverse of the matrix.
Mapping< F, DimX, DimY > transpose() const
Returns the transpose of the matrix.
const F & operator()(uint i, uint j) const
Returns an entry of the matrix.
Mapping< F, DimY, DimY > prodTranspose() const
Returns the product with the transpose of the matrix.
Mapping(const Point< F, DimY > first, const Point< F, DimY > second)
void zeros()
Fills the matrix with zeros.
void rank1Product(const Point< F, DimX > x, const Point< F, DimY > y)
Computes x yT and adds the result to the matrix.
Mapping< F, DimY, DimX > & operator*=(const Mapping< F, DimY, DimX > &m)
Multiplication operator ( *this = operator()(*this, m); )
Mapping< typename Combtype< G, F >::type, DimY, DimZ > operator*(const Mapping< G, DimX, DimZ > &m) const
Multiplication operator.
Mapping< F, DimY, DimX > & operator*=(const F n)
Scaling operator.
Mapping< typename Combtype< G, F >::type, DimY, DimX > operator*(const G n) const
Scaling operator.
Mapping< F, DimY, DimX > & scaleRows(const Point< F, DimY > &s)
Scales the rows with the respective entries in s.
Mapping< F, DimY, DimX > & scaleCols(const Point< F, DimX > &s)
Scales the columns with the respective entries in s.
void mapTranspose(const Point< H, DimY > &y, Point< H, DimX > &x) const
Mapping(const Point< F, DimY > first)
F determinant() const
Returns the determinant of the matrix (only valid for square matrices)
Mapping< F, DimY, DimX > & operator+=(const Mapping< F, DimY, DimX > &M)
Addition operator.
Mapping< F, DimY-1, DimX-1 > subMatrix(uint i, uint j) const
Mapping(const UnitNd< DimY > &n)
Mapping(const Mapping< H, DimY, DimX > &m)
void operator()(const Point< H, dimy > &y, Point< J, dimx > &x) const
F & operator()(uint i, uint j)
Returns an entry of the matrix (for read / write access)
Point< typename Combtype< F, H >::type, DimY > operator*(const Point< H, DimX > &p) const
Returns a mapped Point.
Mapping(const Mapping< F, DimY, DimX > &m)
Copy constructor.
Mapping< F, DimY, DimX > adjugate() const
F trace() const
Returns the trace (only valid for square matrices)
Point< F, DimY > column(const uint i) const
Returns a column of the matrix.
Mapping(const Point< F, DimY > first, const Point< F, DimY > second, const Point< F, DimY > third)
Point< F, dim > operator-(const Point< F, dim > &p) const
Subtraction operator.
Point< F, dim > & operator=(const Point< F, dim2 > &b)
Assignment operator.
void max(const Point< F, dim > &a, const Point< F, dim > &b)
Sets the vector to the elementwise maximum of a and b.
Point< F, dim > operator/(const Real n) const
Unscaling operator with a real number.
Point< Cmplx, dim > operator/(const Cmplx n) const
Unscaling operator with a complex number.
Point< F, dim > & ortho(const Point< F, dim > &a)
Real l2_2() const
Returns the square of the Euclidian norm of the vector.
Point< F, dim > operator*(const Real n) const
Scaling operator with a real number.
F operator^(const Point< F, 2 > &b) const
Outer product (for 2D)
Point< F, dim > & operator*=(const G n)
Scaling operator.
Point< F, dim > & scale(const Point< F, dim > &n)
Scaling.
Point< F, dim > & operator-=(const Point< F, dim > &p)
Subtraction operator.
Point< F, dim > ortho() const
Returns a by 90 degrees (clockwise) rotated vector (only 2D)
F operator*(const Point< F, dim > &b) const
Inner product.
Point< F, dim > & operator+=(const Point< F, dim > &p)
Addition operator.
Point(const uchar *pgm, const Real x, const Real y, const Real z=0.0)
Constructor with a processed map.
void lincomb(const Point< F, dim > &a, const Point< F, dim > &b, const F ca=1.0, const F cb=1.0)
Assign the vector the linear combination of a and b.
Real linfty() const
Returns the Maximum norm of the vector.
Point(const Point< G, dim > &p)
Copy constructor.
const F & operator[](const uint i) const
Index operator.
Point< F, dim > operator+(const Point< F, dim > &p) const
Addition operator.
F & operator[](const uint i)
Index operator.
Point(const F e0, const F e1, const F e2=0)
Constructor for a 2D or a 3D Point.
F dot(const Point< F, dim > &b) const
Inner product, i.e. for complex arguments: this * conjugate(b)
void min(const Point< F, dim > &a, const Point< F, dim > &b)
Sets the vector to the elementwise minimum of a and b.
Point< Cmplx, dim > operator*(const Cmplx n) const
Scaling operator with a complex number.
Point< F, dim > & operator/=(const G n)
Unscaling operator.
Real l2() const
Returns the Euclidian norm of the vector.
Point< F, 3 > operator^(const Point< F, 3 > &b) const
Outer product (for 3D)
Point< F, dim > & ortho()
Rotates the vector by 90 degrees (clockwise) (only 2D)
Point(const Point< F, dim2 > &p)
Copy constructor.
UnitNd()
Constructor. Initializes all elements to 0.
UnitNd(Real x, Real y, Real z)
Constructor for at most 3D.
UnitNd(const Point< Real, dim > &u)
Constructor for a point.
Real length() const
Length of the initially given vector.
#define conceptsAssert(cond, exc)
#define DEBUGL(doit, msg)
void memorycpy(F *dest, const G *src, size_t n)
Copies n entries from src to dest (faster than std::memcpy)
Set< F > makeSet(uint n, const F &first,...)
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
unsigned char uchar
Abbreviation for unsigned char.
const concepts::Real norm(const concepts::Real &v)
concepts::Real arg(const concepts::Point< concepts::Real, 2 > &p)