1 #ifndef SELDON_FILE_TINY_VECTOR_HXX
3 #include "TinyVectorExpression.hxx"
16 template<
class T,
int m>
20 template <
class T,
int m_>
40 TinyVector_Base(
const T& a,
const T& b,
const T& c,
const T& d,
const T& e);
42 void Init(
const T & a);
43 void Init(
const T & a,
const T& b);
44 void Init(
const T & a,
const T& b,
const T& c);
45 void Init(
const T & a,
const T& b,
const T& c,
const T& d);
46 void Init(
const T & a,
const T& b,
const T& c,
const T& d,
const T& e);
63 void Print(ostream&)
const;
68 void Fill(
const T0& x);
80 template <
class T,
int m_>
84 static typename ClassComplexType<T>::Treal threshold;
90 TinyVector(
const T& a,
const T& b,
const T& c);
91 TinyVector(
const T& a,
const T& b,
const T& c,
const T& d);
92 TinyVector(
const T& a,
const T& b,
const T& c,
const T& d,
const T& e);
98 template<
class T1,
class E>
102 template<
class T1,
class E>
106 template<
class T1,
class E>
131 explicit TinyVector(
const int& a,
const int& b);
132 TinyVector(
const int& a,
const int& b,
const int& c);
133 TinyVector(
const int& a,
const int& b,
const int& c,
const int& d);
134 TinyVector(
const int& a,
const int& b,
const int& c,
const int& d,
const int& e);
163 template<
class T,
int m,
class E1,
class E2>
167 template<
class T,
int m,
class E1,
class E2>
171 template<
class T,
int m,
class E1,
class E2>
175 template<
class T,
int m,
class E1,
class E2>
179 template<
class T,
int m,
class E1,
class E2>
183 template<
class T,
int m,
class E1,
class E2>
187 template <
class T,
int m>
190 template <
class T,
int m>
194 #ifdef MONTJOIE_WITH_MPFR
195 template<
class T,
int m>
198 template<
class T,
int m>
213 template<
int m,
class T0>
216 template<
int m,
class T0>
219 template<
int m,
class T0>
222 template<
int m,
class T0,
class T1>
225 template<
int m,
class T0>
228 template<
int m,
class T0>
231 template<
int m,
class T0,
class E0>
234 template<
int m,
class T1,
class E,
class T0>
237 template<
int m,
class T1,
class E,
class T0>
240 template<
int m,
class T1,
class E,
class T0>
243 template<
int m,
class T0,
class T1>
247 template<
int m,
class T0,
class T1>
251 template<
int m,
class T0,
class T1>
254 template<
int m,
class T>
257 template<
int m,
class T0,
class T1>
260 template<
int m,
class T0,
class T1>
263 template<
int m,
class T0,
class T1>
266 template<
int m,
class T0,
class T1>
269 template<
int m,
class T0,
class T1>
272 template<
int m,
class T0,
class T1>
276 template<
int m,
class T0,
class T1>
280 template<
int p,
int m,
class T0,
class T1>
284 template<
int m,
class T0,
class T1>
288 template<
int m,
class T0,
class T1>
292 template<
class T0,
class T1>
296 template<
int m,
class T0,
class T1>
300 template<
int m,
class T0,
class T1>
304 template<
int m,
class T0,
class T1>
308 template<
int m,
class T0,
class T1>
312 template<
int m,
class T0,
class T1>
315 template<
int m,
class T0,
class T1,
class E0,
class E1>
319 template<
int m,
class T0,
class T1,
class E0,
class E1>
323 template<
int m,
class T0,
class T1,
class E0,
class E1>
327 template<
int m,
class T0,
class T1>
330 template<
int m,
class T0,
class T1>
334 template<
int m,
class T0,
class T1>
337 template<
int m,
class T0,
class T1>
340 template<
int m,
class T0,
class T1,
class T2,
class E0,
class E1>
344 template<
int m,
class T0,
class T1,
class T2,
class E0,
class E1>
348 template<
int m,
class T0,
class T1,
class E0>
351 template<
int m,
class T0,
class T1,
class E0>
354 template<
int m,
class T0,
class T1,
class E0>
357 template<
int m,
class T>
360 template<
int m,
class T>
363 template<
int m,
class T>
366 template<
class T,
int m>
369 template<
class T,
int m>
379 template<
int m,
class T0>
382 template<
int m,
class T0,
class E0>
385 template<
int m,
class T0>
388 template<
int m,
class T0>
391 template<
int m,
class T0,
class T1>
394 template<
int m,
class T0>
397 template<
int m,
class T0>
400 template<
int m,
class T1,
class E,
class T0>
403 template<
int m,
class T1,
class E,
class T0>
406 template<
int m,
class T1,
class E,
class T0>
409 template<
int m,
class T0,
class T1>
413 template<
int m,
class T0,
class T1>
417 template<
int m,
class T0,
class T1>
420 template<
int m,
class T>
424 template<
int m,
class T0,
class T1>
427 template<
int m,
class T0,
class T1>
430 template<
int m,
class T0,
class T1>
433 template<
int m,
class T0,
class T1>
436 template<
int m,
class T0,
class T1>
439 template<
int m,
class T0,
class T1>
443 template<
int m,
class T0,
class T1>
447 template<
int m,
class T0,
class T1>
451 template<
int p,
int m,
class T0,
class T1>
455 template<
int m,
class T0,
class T1>
459 template<
class T0,
class T1>
463 template<
int m,
class T0,
class T1>
467 template<
int m,
class T0,
class T1>
471 template<
int m,
class T0,
class T1>
475 template<
int m,
class T0,
class T1>
479 template<
int m,
class T0,
class T1>
482 template<
int m,
class T0,
class T1,
class E0,
class E1>
489 template<
int m,
class T0,
class T1,
class E0,
class E1>
496 template<
int m,
class T0,
class T1,
class E0,
class E1>
503 template<
int m,
class T0,
class T1>
509 template<
int m,
class T0,
class T1>
515 template<
int m,
class T0,
class T1>
521 template<
int m,
class T0,
class T1>
524 template<
int m,
class T0,
class T1,
class T2,
class E0,
class E1>
528 template<
int m,
class T0,
class T1,
class E0,
class E1,
class T2>
532 template<
int m,
class T0,
class T1,
class E0>
535 template<
int m,
class T0,
class T1,
class E0>
538 template<
int m,
class T0,
class T1,
class E0>
541 template<
int m,
class T>
544 template<
int m,
class T>
547 template<
int m,
class T>
550 template<
class T,
int m>
553 template<
class T,
int m>
564 template<
class T,
int m,
class E1,
class E2>
569 template<
class T,
int m,
class E1,
class E2>
573 template<
class T,
int m,
class E1,
class E2>
578 template<
class T,
int m,
class E1,
class E2>
583 template<
class T,
int m,
class E>
587 template<
class T,
int m,
class E>
591 template<
class T,
int m,
class E>
594 template <
class T,
int m>
598 template<
class T,
int m,
class E>
601 template<
class T0,
class T1,
class T2,
int m>
604 template<
class T0,
class T1,
class T2,
int m>
607 template<
class T0,
class T,
int m>
616 template<
int p,
int m,
class T0,
class T1>
620 template<
int m,
class T0,
class T1>
624 template<
int m,
class T0,
class T1>
628 template<
int m,
class T0,
class T1>
632 template<
int m,
class T0,
class T1>
636 template<
int m,
class T0,
class T1>
640 template<
int m,
class T0,
class T1>
644 template<
int m,
class T0,
class T1>
648 template<
int m,
class T0,
class T1>
653 template<
int m,
class T0,
class T1>
657 template<
int m,
class T0,
class T1>
661 template<
int m,
class T0,
class T1>
664 template<
int m,
class T0,
class T1>
667 template<
int m,
class T>
670 template<
int m,
class T0,
class T1>
673 template<
int m,
class T0,
class T1>
676 template<
int m,
class T0,
class T1>
679 template<
int m,
class T0,
class T1>
688 template<
class T0,
int m>
692 template<
class T,
int m>
695 template<
class T,
int m>
698 template<
int m,
class T0,
class T1>
711 template<
class T,
int p>
714 template<
class T,
class Prop,
class Storage,
int p>
718 template<
class T,
class Prop,
class Storage,
int p>
728 template<
class T1,
class T2,
class T3>
744 template<
class T0,
class T1,
class T2,
class T3>
757 void FillZero(
double& X);
758 void FillZero(complex<double>& X);
759 void FillZero(
int& X);
760 void FillZero(
float& X);
761 void FillZero(complex<float>& X);
762 void FillZero(
bool& X);
764 template<
class T,
class Storage,
class Allocator>
767 template<
class T,
class Prop,
class Storage,
class Allocator>
770 template<
class T,
class Prop,
class Allocator>
773 template<
class T,
int m>
780 void FillZero(complex<T>& x);
782 template<
class T,
int p>
786 bool IsComplexZero(
const T& x);
789 bool IsComplexZero(
const complex<T>& x);
793 #define SELDON_FILE_TINY_VECTOR_HXX
void GenerateSymPts(const TinyVector< T0, 3 > &u, TinyVector< T1, 3 > &v, TinyVector< T2, 3 > &w, TinyVector< T3, 3 > &t)
generates four points respecting the symmetry of the reference pyramid with one point
bool operator==(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this == u
void TimesProd(const TinyVector< T1, 3 > &u, const TinyVector< T2, 3 > &v, TinyVector< T3, 3 > &res)
cross product res = u^v where u,v and res are vectors
static void ExtractVectorConj(const Vector< T0 > &Vh, const IVect &row_num, int j, TinyVector< T1, m > &tmp)
tmp = conj(Vh(row_num(nb+:)))
static void ExtractVector(const Vector< T0 > &Vh, int j, TinyVector< T1, m > &tmp)
tmp(:) = Vh(offset + :)
static void DiffCopy(const TinyVectorExpression< T1, m, E > &x, TinyVector< T0, m > &y)
y -= x
static void FillRand(TinyVector< T0, m > &x)
sets randomly the components with function rand()
Class storing a tiny vector whose size is known at compilation time.
ClassComplexType< T >::Treal Norm2(const VectorExpression< T, E > &X)
returns 2-norm of an expression with vectors
Expression between vectors.
ClassComplexType< T >::Treal Norm1(const VectorExpression< T, E > &X)
returns 1-norm of an expression with vectors
TinyVector()
Sets all components to 0.
static void Zero(TinyVector< T0, m > &x)
Sets all components to 0.
static ostream & WriteText(const TinyVector< T, m > &V, ostream &out)
displays V
static void Copy(const TinyVectorExpression< T1, m, E > &x, TinyVector< T0, m > &y)
y = x
static void AddCopy(const TinyVectorExpression< T1, m, E > &x, TinyVector< T0, m > &y)
y += x
void FillRand()
sets randomly the components with function rand()
static void UpdateMaximum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = max(v, u)
class used for unrolling loops for operators/functions of TinyVector
static void CopyVector(const TinyVector< Vector< T0 >, m > &uvec, int j, TinyVector< T1, m > &u)
u(:) = uvec(:)(j)
ClassComplexType< T >::Treal DistanceSquare(const TinyVector< T, m_ > &p) const
returns |u-v|^2 (usual euclidian norm)
vector with real/complex components
static void Mlt(const T1 &alpha, TinyVector< T0, m > &x)
Multiplies x by alpha.
Row-major sparse-matrix class.
static void Abs(const TinyVectorExpression< T0, m, E0 > &u, T1 &scal)
computes scal = \sum |u_i|^2
void AddVectorConj(const T0 &alpha, const TinyVector< T1, m > &tmp, const IVect &row_num, int nb, Vector< T0 > &Vh)
Vh(row_num(nb+:)) += alpha * conj(tmp)
static bool IsZero(const TinyVectorExpression< T0, m, E0 > &x)
returns true if all components are 0
ClassComplexType< T >::Treal Distance(const TinyVector< T, m_ > &p) const
returns |u-v| (usual euclidian norm)
bool operator<=(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns true if u <= v, false otherwise
void Init(const T &a)
sets first component to a
void ExtractVector(const Vector< Vector< TinyVector< T0, p > > > &u, int j, int k, int offset, TinyVector< T1, m > &v)
v(:) = u(offset+:)(j)(k)
int GetSize() const
Returns the number of stored elements.
static bool Less(const TinyVectorExpression< T0, m, E0 > &x, const TinyVectorExpression< T1, m, E1 > &y)
returns x < y
void ForceZeroVdotN(const TinyVector< T, 2 > &normale, TinyVector< T, 2 > &v0)
modifies v0 such that v0 \cdot normale = 0
TinyVector_Base()
all components are set to 0
void UpdateMinimum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = min(v, u) elementwise
void UpdateMaximum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = max(v, u) elementwise
static void NormInf(const TinyVectorExpression< T0, m, E0 > &u, T1 &scal)
computes scal = max |u_i|^2
void CopyVector(const Vector< T1, Storage1, Allocator1 > &X, Vector< T2, Storage2, Allocator2 > &Y)
Y = X.
bool PointInsideBoundingBox(const TinyVector< T, 2 > &, const TinyVector< TinyVector< T, 2 >, 2 > &)
returns true if x is inside the bounding box s
istream & operator>>(istream &out, TinyVector< T, m > &V)
reads V
static void Print(const TinyVector< T, m > &V, ostream &out)
displays V without brackets
void Print() const
displays the vector without brackets
int GetLength() const
Returns the number of stored elements.
static bool LessInt(const TinyVector< T0, m > &x, const TinyVector< T1, m > &y)
returns x < y
bool IsZero() const
returns true if all components are 0
void Zero()
Sets all components to 0.
static bool LessOrEqualInt(const TinyVector< T0, m > &x, const TinyVector< T1, m > &y)
returns x <= y
void Fill()
Sets the vector to [0, 1, 2, 3, ..., n-1].
TinyVector< T, m_ > & operator+=(const TinyVectorExpression< T1, m_, E > &u)
Operator *this += expression with vectors.
bool operator>=(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns true if u >= v, false otherwise
static void Fill(TinyVector< T0, m > &x, const T1 &a)
Sets all components to a given value.
ClassComplexType< T >::Treal NormInf(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the infinity-norm of a matrix.
TinyVector< T, m_ > & operator=(const TinyVectorExpression< T1, m_, E > &u)
Operator *this = expression with vectors.
TinyVector< T, m_ > & GetLeafClass()
returns leaf class
static void DotProd(const TinyVectorExpression< T0, m, E0 > &u, const TinyVectorExpression< T1, m, E1 > &v, T2 &scal)
scal = u.v
bool operator!=(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this != u
static void FillGreater(TinyVector< T0, m > &x, const T0 &a)
Fills with a in ascendant order (instead of descendant order for Fill)
static void AddVectorConj(const T0 &alpha, const TinyVector< T1, m > &tmp, const IVect &row_num, int j, Vector< T0 > &Vh)
Vh(row_num(nb+:)) += alpha * conj(tmp)
static void AddVector(const Vector< T0 > &Vh, int j, TinyVector< T1, m > &tmp)
tmp(:) += Vh(offset + :)
static void UpdateMinimum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = min(v, u)
TinyVector< T, m_ > & operator-=(const TinyVectorExpression< T1, m_, E > &u)
Operator *this -= expression with vectors.
ClassComplexType< T >::Treal AbsSquare(const TinyVectorExpression< T, m, E > &u)
returns || u ||^2
T Distance(const TinyVector< T, m > &u, const TinyVector< T, m > &v)
returns || u-v ||
void SymmetrizePointPlane(const TinyVector< T0, m > &u, const TinyVector< T0, m > &normale, const T0 &d, TinyVector< T0, m > &v)
Applies the symmetry with respect to the hyperplane a x + b y + c z + .. + d = 0 v = S(u) where S is ...
static void InitValue(TinyVector< T0, m > &x, const T0 &a)
initializes a single value
void ExtractVectorConj(const Vector< T0 > &Vh, const IVect &row_num, int nb, TinyVector< T1, m > &tmp)
tmp = conj(Vh(row_num(nb+:)))
size_t GetMemorySize() const
returns the size used by the object in bytes
T Determinant(const TinyVector< T, 3 > &u, const TinyVector< T, 3 > &v, const TinyVector< T, 3 > &w)
res = (u^v) . w = det(u,v,w) where u,v and w are vectors
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
static void AbsSquare(const TinyVectorExpression< T0, m, E0 > &u, T1 &scal)
computes scal = \sum |u_i|^2
const T & operator()(int i) const
returns x(i)
static void MltVector(const T1 &alpha, int j, TinyVector< Vector< T0 >, m > &uvec)
u(:)(j) *= alpha
static istream & ReadText(TinyVector< T, m > &V, istream &in)
reads V
static void DotProdConj(const TinyVectorExpression< T0, m, E0 > &u, const TinyVectorExpression< T1, m, E1 > &v, T2 &scal)
returns (conj(u), v)
bool operator>(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns true if u > v, false otherwise
bool operator<(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns *this < u
int GetM() const
Returns the number of stored elements.
void AddVector(const T0 &alpha, const Vector< T1, Storage1, Allocator1 > &X, Vector< T2, Storage2, Allocator2 > &Y)
Adds two vectors Y = Y + alpha X.
static bool LessOrEqual(const TinyVectorExpression< T0, m, E0 > &x, const TinyVectorExpression< T1, m, E1 > &y)
returns x <= y
static bool Equal(const TinyVectorExpression< T0, m, E0 > &x, const TinyVectorExpression< T1, m, E1 > &y)
returns x == y
static bool EqualInt(const TinyVector< T0, m > &x, const TinyVector< T1, m > &y)
returns x == y