TinyVectorInline.cxx
1 #ifndef SELDON_FILE_TINY_VECTOR_INLINE_CXX
2 
3 #include "TinyVectorExpressionInline.cxx"
4 
5 namespace Seldon
6 {
7 
8  /*******************
9  * TinyVector_Base *
10  *******************/
11 
12 
14  template <class T, int m>
16  {
17  this->Zero();
18  }
19 
20 
22  template <class T, int m>
24  {
25  this->Fill(a);
26  }
27 
28 
30  template <class T, int m>
31  inline TinyVector_Base<T, m>::TinyVector_Base(const T& a, const T& b)
32  {
33  this->data_[0] = a;
34  TinyVectorLoop<(m>1)>::InitValue(this->GetLeafClass(), b);
35  TinyVectorLoop<2*(m>2)>::FillGreater(this->GetLeafClass(), T(0));
36  }
37 
38 
40  template <class T, int m>
41  inline TinyVector_Base<T, m>::TinyVector_Base(const T& a, const T& b ,const T& c)
42  {
43  this->data_[0] = a;
44  TinyVectorLoop<(m>1)>::InitValue(this->GetLeafClass(), b);
45  TinyVectorLoop<2*(m>2)>::InitValue(this->GetLeafClass(), c);
46  TinyVectorLoop<3*(m>3)>::FillGreater(this->GetLeafClass(), T(0));
47  }
48 
49 
51  template <class T, int m>
52  inline TinyVector_Base<T, m>::TinyVector_Base(const T& a, const T& b ,const T& c, const T& d)
53  {
54  this->data_[0] = a;
55  TinyVectorLoop<(m>1)>::InitValue(this->GetLeafClass(), b);
56  TinyVectorLoop<2*(m>2)>::InitValue(this->GetLeafClass(), c);
57  TinyVectorLoop<3*(m>3)>::InitValue(this->GetLeafClass(), d);
58  TinyVectorLoop<4*(m>4)>::FillGreater(this->GetLeafClass(), T(0));
59  }
60 
61 
63  template <class T, int m>
64  inline TinyVector_Base<T, m>::TinyVector_Base(const T& a, const T& b ,const T& c, const T& d, const T& e)
65  {
66  this->data_[0] = a;
67  TinyVectorLoop<(m>1)>::InitValue(this->GetLeafClass(), b);
68  TinyVectorLoop<2*(m>2)>::InitValue(this->GetLeafClass(), c);
69  TinyVectorLoop<3*(m>3)>::InitValue(this->GetLeafClass(), d);
70  TinyVectorLoop<4*(m>4)>::InitValue(this->GetLeafClass(), e);
71  TinyVectorLoop<5*(m>5)>::FillGreater(this->GetLeafClass(), T(0));
72  }
73 
74 
76  template <class T, int m>
77  inline void TinyVector_Base<T, m>::Init(const T& a)
78  {
79 #ifdef SELDON_CHECK_BOUNDS
80  if (m < 1)
81  throw WrongIndex("TinyVector::TinyVector",
82  string("size should be greater than 1,")+
83  "but is equal to" + to_str(m) + ".");
84 #endif
85 
86  this->data_[0] = a;
87  }
88 
89 
91  template <class T, int m>
92  inline void TinyVector_Base<T, m>::Init(const T& a, const T& b)
93  {
94 #ifdef SELDON_CHECK_BOUNDS
95  if (m < 2)
96  throw WrongIndex("TinyVector::TinyVector",
97  string("size should be greater than 2,")+
98  "but is equal to" + to_str(m) + ".");
99 #endif
100 
101  this->data_[0] = a;
102  this->data_[1] = b;
103  }
104 
105 
107  template <class T, int m>
108  inline void TinyVector_Base<T, m>::Init(const T& a, const T& b, const T& c)
109  {
110 #ifdef SELDON_CHECK_BOUNDS
111  if (m < 3)
112  throw WrongIndex("TinyVector::TinyVector",
113  string("size should be greater than 3,")+
114  "but is equal to" + to_str(m) + ".");
115 #endif
116 
117  this->data_[0] = a;
118  this->data_[1] = b;
119  this->data_[2] = c;
120  }
121 
122 
124  template <class T, int m>
125  inline void TinyVector_Base<T, m>::Init(const T& a, const T& b, const T& c, const T& d)
126  {
127 #ifdef SELDON_CHECK_BOUNDS
128  if (m < 4)
129  throw WrongIndex("TinyVector::TinyVector",
130  string("size should be greater than 4,")
131  +"but is equal to" + to_str(m) + ".");
132 #endif
133 
134  this->data_[0] = a;
135  this->data_[1] = b;
136  this->data_[2] = c;
137  this->data_[3] = d;
138  }
139 
140 
142  template <class T, int m>
143  inline void TinyVector_Base<T, m>::Init(const T& a, const T& b,
144  const T& c, const T& d, const T& e)
145  {
146 #ifdef SELDON_CHECK_BOUNDS
147  if (m < 5)
148  throw WrongIndex("TinyVector::TinyVector",
149  string("size should be greater than 5,")+
150  "but is equal to" + to_str(m) + ".");
151 #endif
152 
153  this->data_[0] = a;
154  this->data_[1] = b;
155  this->data_[2] = c;
156  this->data_[3] = d;
157  this->data_[4] = e;
158  }
159 
160 
162  template<class T, int m_>
163  inline int TinyVector_Base<T, m_>::GetM() const
164  {
165  return m_;
166  }
167 
168 
170  template<class T, int m_>
172  {
173  return m_;
174  }
175 
176 
178  template<class T, int m_>
180  {
181  return m_;
182  }
183 
184 
186  template<class T, int m_>
188  {
189  return m_*sizeof(T);
190  }
191 
192 
194  template<class T, int m_>
196  {
197  return static_cast<TinyVector<T, m_>& >(*this);
198  }
199 
200 
202  template<class T, int m_>
204  {
205  return static_cast<const TinyVector<T, m_>& >(*this);
206  }
207 
208 
210  template <class T, int m_>
211  inline const T& TinyVector_Base<T, m_>::operator()(int i) const
212  {
213 #ifdef SELDON_CHECK_BOUNDS
214  CheckBounds(i, m_, "TinVector");
215 #endif
216 
217  return this->data_[i];
218  }
219 
220 
222  template <class T, int m_>
224  {
225 #ifdef SELDON_CHECK_BOUNDS
226  CheckBounds(i, m_, "TinVector");
227 #endif
228 
229  return this->data_[i];
230  }
231 
232 
234  template <class T, int m>
235  inline void TinyVector_Base<T, m>::Print() const
236  {
237  Print(cout);
238  }
239 
240 
242  template <class T, int m>
243  inline void TinyVector_Base<T, m>::Print(ostream& out) const
244  {
245  TinyVectorLoop<m>::Print(this->GetLeafClass(), out);
246  }
247 
248 
250  template <class T, int m>
252  {
253  TinyVectorLoop<m>::Zero(this->GetLeafClass());
254  }
255 
256 
258  template <class T, int m>
260  {
261  TinyVectorLoop<m>::Fill(this->GetLeafClass());
262  }
263 
264 
266  template<class T, int m> template<class T0>
267  inline void TinyVector_Base<T, m>::Fill(const T0& x)
268  {
269  TinyVectorLoop<m>::Fill(this->GetLeafClass(), x);
270  }
271 
272 
274  template <class T, int m>
276  {
277  TinyVectorLoop<m>::FillRand(this->GetLeafClass());
278  }
279 
280 
282  template <class T, int m>
283  inline bool TinyVector_Base<T, m>::IsZero() const
284  {
285  return TinyVectorLoop<m>::IsZero(*this);
286  }
287 
288 
290  template <class T, int m>
291  inline typename ClassComplexType<T>::Treal TinyVector_Base<T, m>::DistanceSquare(const TinyVector<T, m> & p) const
292  {
293  return AbsSquare(*this - p);
294  }
295 
296 
298  template <class T, int m>
299  inline typename ClassComplexType<T>::Treal TinyVector_Base<T, m>::Distance(const TinyVector<T, m> & p) const
300  {
301  return sqrt(DistanceSquare(p));
302  }
303 
304 
305  /*******************
306  * TinyVector<T> *
307  *******************/
308 
309 
311  template <class T, int m_>
313  {
314  }
315 
316 
318  template <class T, int m_>
319  inline TinyVector<T, m_>::TinyVector(const T& a) : TinyVector_Base<T, m_>(a)
320  {
321  }
322 
323 
325  template <class T, int m_>
326  inline TinyVector<T, m_>::TinyVector(const T& a, const T& b) : TinyVector_Base<T, m_>(a, b)
327  {
328  }
329 
330 
332  template <class T, int m_>
333  inline TinyVector<T, m_>::TinyVector(const T& a, const T& b, const T& c) : TinyVector_Base<T, m_>(a, b, c)
334  {
335  }
336 
337 
339  template <class T, int m_>
340  inline TinyVector<T, m_>::TinyVector(const T& a, const T& b, const T& c, const T& d)
341  : TinyVector_Base<T, m_>(a, b, c, d)
342  {
343  }
344 
345 
347  template <class T, int m_>
348  inline TinyVector<T, m_>::TinyVector(const T& a, const T& b, const T& c, const T& d, const T& e)
349  : TinyVector_Base<T, m_>(a, b, c, d, e)
350  {
351  }
352 
353 
355  template<class T, int m_> template<class E>
357  {
358  TinyVectorLoop<m_>::Copy(u, *this);
359  }
360 
361 
363  template<class T, int m_> template<class T1, class E>
365  {
366  TinyVectorLoop<m_>::Copy(u, *this);
367 
368  return *this;
369  }
370 
371 
373  template<class T, int m_> template<class T1, class E>
375  {
376  TinyVectorLoop<m_>::AddCopy(u, *this);
377 
378  return *this;
379  }
380 
381 
383  template<class T, int m_> template<class T1, class E>
385  {
387 
388  return *this;
389  }
390 
391 
393  template<class T, int m_>
395  {
396  this->Fill(x);
397  return *this;
398  }
399 
400 
402  template <class T, int m> template<class T1>
404  {
405  TinyVectorLoop<m>::Mlt(a, *this);
406  return *this;
407  }
408 
409 
411  template <class T, int m> template<class T1>
413  {
414  T one; SetComplexOne(one);
415  T a_; SetComplexReal(a, a_);
416  TinyVectorLoop<m>::Mlt(one/a_, *this);
417  return *this;
418  }
419 
420 
421  /*******************
422  * TinyVector<int> *
423  *******************/
424 
425 
427  template<int m_>
429  {
430  }
431 
432 
434  template<int m_>
435  inline TinyVector<int, m_>::TinyVector(const int& a) : TinyVector_Base<int, m_>(a)
436  {
437  }
438 
439 
441  template<int m_>
442  inline TinyVector<int, m_>::TinyVector(const int& a, const int& b) : TinyVector_Base<int, m_>(a, b)
443  {
444  }
445 
446 
448  template<int m_>
449  inline TinyVector<int, m_>::TinyVector(const int& a, const int& b, const int& c)
450  : TinyVector_Base<int, m_>(a, b, c)
451  {
452  }
453 
454 
456  template<int m_>
457  inline TinyVector<int, m_>::TinyVector(const int& a, const int& b, const int& c, const int& d)
458  : TinyVector_Base<int, m_>(a, b, c, d)
459  {
460  }
461 
462 
464  template<int m_>
465  inline TinyVector<int, m_>::TinyVector(const int& a, const int& b, const int& c, const int& d, const int& e)
466  : TinyVector_Base<int, m_>(a, b, c, d, e)
467  {
468  }
469 
470 
471  /*************
472  * Operators *
473  *************/
474 
475 
477  template<int m>
478  inline bool operator==(const TinyVector<int, m>& u, const TinyVector<int, m>& v)
479  {
480  return TinyVectorLoop<m>::EqualInt(u, v);
481  }
482 
483 
485  template<int m>
486  inline bool operator!=(const TinyVector<int, m> & u, const TinyVector<int, m>& v)
487  {
488  return !TinyVectorLoop<m>::EqualInt(u, v);
489  }
490 
491 
493  template<int m>
494  inline bool operator<=(const TinyVector<int, m> & u, const TinyVector<int, m>& v)
495  {
497  }
498 
500  template<int m>
501  inline bool operator<(const TinyVector<int, m> & u, const TinyVector<int, m>& v)
502  {
503  return TinyVectorLoop<m>::LessInt(u, v);
504  }
505 
506 
508  template<int m>
509  inline bool operator>=(const TinyVector<int, m> & u, const TinyVector<int, m>& v)
510  {
511  return !TinyVectorLoop<m>::LessInt(u, v);
512  }
513 
514 
516  template<int m>
517  inline bool operator>(const TinyVector<int, m> & u, const TinyVector<int, m>& v)
518  {
519  return !TinyVectorLoop<m>::LessOrEqualInt(u, v);
520  }
521 
522 
524  template<class T, int m, class E1, class E2>
527  {
528  return TinyVectorLoop<m>::Equal(u, v);
529  }
530 
531 
533  template<class T, int m, class E1, class E2>
536  {
537  return !TinyVectorLoop<m>::Equal(u, v);
538  }
539 
540 
542  template<class T, int m, class E1, class E2>
545  {
546  return TinyVectorLoop<m>::LessOrEqual(u, v);
547  }
548 
550  template<class T, int m, class E1, class E2>
553  {
554  return TinyVectorLoop<m>::Less(u, v);
555  }
556 
557 
559  template<class T, int m, class E1, class E2>
562  {
563  return !TinyVectorLoop<m>::Less(u, v);
564  }
565 
566 
568  template<class T, int m, class E1, class E2>
571  {
572  return !TinyVectorLoop<m>::LessOrEqual(u, v);
573  }
574 
575 
577  template <class T, int m>
578  inline ostream& operator <<(ostream& out, const TinyVector<T,m>& V)
579  {
580  out<<"(";
581  return TinyVectorLoop<m>::WriteText(V, out);
582  }
583 
584 
586  template <class T, int m>
587  inline istream& operator >>(istream& in, TinyVector<T,m>& V)
588  {
589  return TinyVectorLoop<m>::ReadText(V, in);
590  }
591 
592 
593  /******************
594  * TinyVectorLoop *
595  ******************/
596 
597 
599  template<int n> template<int m, class T0>
601  {
602  FillZero(x(n-1));
604  }
605 
606 
608  template <int n> template<int m, class T0>
610  {
611  x.data_[n] = a;
612  TinyVectorLoop<(n+1)*(m>n+1)>::FillGreater(x, a);
613  }
614 
615 
617  template <int n> template<int m, class T0>
618  inline void TinyVectorLoop<n>::InitValue(TinyVector<T0, m>& x, const T0& a)
619  {
620  x.data_[n] = a;
621  }
622 
623 
625  template <int n> template<int m, class T0, class T1>
626  inline void TinyVectorLoop<n>::Fill(TinyVector<T0, m>& x, const T1& a)
627  {
628  SetComplexReal(a, x.data_[n-1]);
630  }
631 
632 
634  template <int n> template<int m, class T0>
636  {
637  SetComplexReal(n-1, x.data_[n-1]);
639  }
640 
641 
643  template <int n> template<int m, class T0>
645  {
646  SetComplexReal(rand(), x.data_[n-1]);
648  }
649 
650 
652  template<int n> template<int m, class T0, class E0>
654  {
655  if (abs(x(n-1)) > TinyVector<T0, m>::threshold)
656  return false;
657 
658  return TinyVectorLoop<n-1>::IsZero(x);
659  }
660 
661 
663  template<int n> template<int m, class T1, class E, class T0>
665  {
666  y(n-1) = x(n-1);
668  }
669 
670 
672  template<int n> template<int m, class T1, class E, class T0>
674  {
675  y(n-1) += x(n-1);
677  }
678 
679 
681  template<int n> template<int m, class T1, class E, class T0>
683  {
684  y(n-1) -= x(n-1);
686  }
687 
688 
690  template<int n> template<int m, class T0, class T1>
691  inline void TinyVectorLoop<n>::
693  {
694  u(n-1) = uvec(n-1)(j);
696  }
697 
698 
700  template<int n> template<int m, class T0, class T1>
701  inline void TinyVectorLoop<n>::
703  {
704  uvec(n-1)(j) = u(n-1);
706  }
707 
708 
710  template<int n> template<int m, class T0, class T1>
711  inline void TinyVectorLoop<n>::
712  CopyVector(const Vector<T0>& Vh, int j, TinyVector<T1, m>& tmp)
713  {
714  tmp(n-1) = Vh(m*j + n-1);
716  }
717 
718 
720  template<int n> template<int m, class T>
721  inline void TinyVectorLoop<n>::
722  CopyVector(const Vector<complex<T> >& Vh, int j, TinyVector<T, m>& vr, TinyVector<T, m>& vi)
723  {
724  vr(n-1) = realpart(Vh(m*j + n-1));
725  vi(n-1) = imagpart(Vh(m*j + n-1));
726  TinyVectorLoop<n-1>::CopyVector(Vh, j, vr, vi);
727  }
728 
729 
731  template<int n> template<int m, class T0, class T1>
732  inline void TinyVectorLoop<n>::
733  CopyVector(const TinyVector<T1, m>& tmp, int j, Vector<T0>& Vh)
734  {
735  Vh(m*j + n-1) = tmp(n-1);
737  }
738 
739 
741  template<int n> template<int m, class T0, class T1>
742  inline void TinyVectorLoop<n>::
743  AddVector(const Vector<T0>& Vh, int offset, TinyVector<T1, m>& tmp)
744  {
745  tmp(n-1) += Vh(offset + n-1);
746  TinyVectorLoop<n-1>::AddVector(Vh, offset, tmp);
747  }
748 
749 
751  template<int n> template<int m, class T0, class T1>
752  inline void TinyVectorLoop<n>::
753  AddVector(const TinyVector<T1, m>& tmp, int offset, Vector<T0>& Vh)
754  {
755  Vh(offset + n-1) += tmp(n-1);
756  TinyVectorLoop<n-1>::AddVector(tmp, offset, Vh);
757  }
758 
759 
761  template<int n> template<int m, class T0, class T1>
762  inline void TinyVectorLoop<n>::
763  ExtractVector(const Vector<T0>& Vh, int offset, TinyVector<T1, m>& tmp)
764  {
765  tmp(n-1) = Vh(offset + n-1);
766  TinyVectorLoop<n-1>::ExtractVector(Vh, offset, tmp);
767  }
768 
769 
771  template<int n> template<int m, class T0, class T1>
772  inline void TinyVectorLoop<n>::
773  ExtractVector(const TinyVector<T1, m>& tmp, int offset, Vector<T0>& Vh)
774  {
775  Vh(offset + n-1) = tmp(n-1);
776  TinyVectorLoop<n-1>::ExtractVector(tmp, offset, Vh);
777  }
778 
779 
781  template<int n> template<int m, class T0, class T1>
782  inline void TinyVectorLoop<n>
784  int j, int offset, TinyVector<T1, m>& v)
785  {
786  v(n-1) = u(offset+n-1)(j);
787  TinyVectorLoop<n-1>::ExtractVector(u, j, offset, v);
788  }
789 
790 
792  template<int n> template<int m, class T0, class T1>
793  inline void TinyVectorLoop<n>
795  int j, int offset, Vector<Vector<T0> >& u)
796  {
797  u(offset+n-1)(j) = v(n-1);
798  TinyVectorLoop<n-1>::CopyVector(v, j, offset, u);
799  }
800 
801 
803  template<int n> template<int p, int m, class T0, class T1>
804  inline void TinyVectorLoop<n>
806  int j, int k, int offset, TinyVector<T1, m>& v)
807  {
808  v(n-1) = u(offset+n-1)(j)(k);
809  TinyVectorLoop<n-1>::ExtractVector(u, j, k, offset, v);
810  }
811 
812 
814  template<int n> template<int m, class T0, class T1>
815  inline void TinyVectorLoop<n>
816  ::ExtractVector(const Vector<T0>& Vh, const IVect& row_num,
817  int nb, TinyVector<T1, m>& tmp)
818  {
819  tmp(n-1) = Vh(row_num(nb + n-1));
820  TinyVectorLoop<n-1>::ExtractVector(Vh, row_num, nb, tmp);
821  }
822 
823 
825  template<int n> template<int m, class T0, class T1>
826  inline void TinyVectorLoop<n>
828  const IVect& row_num, int nb, Vector<T0>& Vh)
829  {
830  Vh(row_num(nb + n-1)) = tmp(n-1);
831  TinyVectorLoop<n-1>::ExtractVector(tmp, row_num, nb, Vh);
832  }
833 
834 
836  template<int n> template<class T0, class T1>
837  inline void TinyVectorLoop<n>
838  ::ExtractVector(const Vector<T0>& x_src, int offset_source,
839  Vector<T1>& x_dest, int offset_dest)
840  {
841  x_dest(offset_dest + n-1) = x_src(offset_source + n-1);
842  TinyVectorLoop<n-1>::ExtractVector(x_src, offset_source, x_dest, offset_dest);
843  }
844 
845 
847  template<int n> template<int m, class T0, class T1>
848  inline void TinyVectorLoop<n>
849  ::AddVector(const T0& alpha, const TinyVector<T1, m>& tmp,
850  const IVect& row_num, int nb, Vector<T0>& Vh)
851  {
852  Vh(row_num(nb + n-1)) += alpha*tmp(n-1);
853  TinyVectorLoop<n-1>::AddVector(alpha, tmp, row_num, nb, Vh);
854  }
855 
856 
858  template<int n> template<int m, class T0, class T1>
859  inline void TinyVectorLoop<n>
860  ::ExtractVectorConj(const Vector<T0>& Vh, const IVect& row_num,
861  int nb, TinyVector<T1, m>& tmp)
862  {
863  tmp(n-1) = conjugate(Vh(row_num(nb + n-1)));
864  TinyVectorLoop<n-1>::ExtractVectorConj(Vh, row_num, nb, tmp);
865  }
866 
867 
869  template<int n> template<int m, class T0, class T1>
870  inline void TinyVectorLoop<n>
872  const IVect& row_num, int nb, Vector<T0>& Vh)
873  {
874  Vh(row_num(nb + n-1)) = conjugate(tmp(n-1));
875  TinyVectorLoop<n-1>::ExtractVectorConj(tmp, row_num, nb, Vh);
876  }
877 
878 
880  template<int n> template<int m, class T0, class T1>
881  inline void TinyVectorLoop<n>
882  ::AddVectorConj(const T0& alpha, const TinyVector<T1, m>& tmp,
883  const IVect& row_num, int nb, Vector<T0>& Vh)
884  {
885  Vh(row_num(nb + n-1)) += alpha*conjugate(tmp(n-1));
886  TinyVectorLoop<n-1>::AddVectorConj(alpha, tmp, row_num, nb, Vh);
887  }
888 
889 
891  template<int n> template<int m, class T0, class T1>
892  inline void TinyVectorLoop<n>::
893  MltVector(const T1& alpha, int j, TinyVector<Vector<T0>, m>& uvec)
894  {
895  uvec(n-1)(j) *= alpha;
896  TinyVectorLoop<n-1>::MltVector(alpha, j, uvec);
897  }
898 
899 
901  template <int n> template<int m, class T0, class T1, class E0, class E1>
902  inline bool TinyVectorLoop<n>::
905  {
906  if (abs(x(m-n)-y(m-n)) > TinyVector<T0, m>::threshold)
907  return false;
908 
909  return TinyVectorLoop<n-1>::Equal(x, y);
910  }
911 
912 
914  template <int n> template<int m, class T0, class T1, class E0, class E1>
917  {
918  if (x(m-n) < (y(m-n)-TinyVector<T0, m>::threshold) )
919  return true;
920  else if ( x(m-n) > (y(m-n) + TinyVector<T0, m>::threshold))
921  return false;
922 
924  }
925 
926 
928  template <int n> template<int m, class T0, class T1, class E0, class E1>
931  {
932  if (x(m-n) < (y(m-n)-TinyVector<T0, m>::threshold) )
933  return true;
934  else if (x(m-n) > (y(m-n) + TinyVector<T0, m>::threshold))
935  return false;
936 
937  return TinyVectorLoop<n-1>::Less(x, y);
938  }
939 
940 
942  template <int n> template<int m, class T0, class T1>
943  inline bool TinyVectorLoop<n>::
945  {
946  if (x.data_[m-n] != y.data_[m-n])
947  return false;
948 
949  return TinyVectorLoop<n-1>::EqualInt(x, y);
950  }
951 
952 
954  template <int n> template<int m, class T0, class T1>
956  const TinyVector<T1, m>& y)
957  {
958  if (x.data_[m-n] < y.data_[m-n] )
959  return true;
960  else if ( x.data_[m-n] > y.data_[m-n])
961  return false;
962 
964  }
965 
966 
968  template <int n> template<int m, class T0, class T1>
970  {
971  if (x.data_[m-n] < y.data_[m-n])
972  return true;
973  else if (x.data_[m-n] > y.data_[m-n])
974  return false;
975 
976  return TinyVectorLoop<n-1>::LessInt(x, y);
977  }
978 
979 
981  template <int n> template<int m, class T0, class T1>
982  inline void TinyVectorLoop<n>::Mlt(const T1& alpha, TinyVector<T0, m>& x)
983  {
984  x(n-1) *= alpha;
985  TinyVectorLoop<n-1>::Mlt(alpha, x);
986  }
987 
988 
990  template <int n> template<int m, class T0, class T1, class T2, class E0, class E1>
991  inline void TinyVectorLoop<n>::
993  const TinyVectorExpression<T1, m, E1>& v, T2& scal)
994  {
995  scal += u(n)*v(n);
996  TinyVectorLoop<n-1>::DotProd(u, v, scal);
997  }
998 
999 
1001  template <int n> template<int m, class T0, class T1, class T2, class E0, class E1>
1002  inline void TinyVectorLoop<n>::
1004  const TinyVectorExpression<T1, m, E1>& v, T2& scal)
1005  {
1006  scal += conjugate(u(n))*v(n);
1008  }
1009 
1010 
1012  template <int n> template<int m, class T0, class T1, class E0>
1014  {
1015  scal += abs(u(n));
1016  TinyVectorLoop<n-1>::Abs(u, scal);
1017  }
1018 
1019 
1021  template <int n> template<int m, class T0, class T1, class E0>
1023  {
1024  scal = max(scal, abs(u(n)));
1026  }
1027 
1028 
1030  template <int n> template<int m, class T0, class T1, class E0>
1032  {
1033  scal += absSquare(u(n));
1035  }
1036 
1037 
1039  template<int n> template<int m, class T>
1040  inline void TinyVectorLoop<n>::Print(const TinyVector<T, m>& V, ostream& out)
1041  {
1042  if (n==1)
1043  out << V(m-n);
1044  else
1045  out<<V(m-n)<<" ";
1046 
1047  return TinyVectorLoop<n-1>::Print(V, out);
1048  }
1049 
1050 
1052  template<int n> template<int m, class T>
1053  inline ostream& TinyVectorLoop<n>::WriteText(const TinyVector<T, m>& V, ostream& out)
1054  {
1055  if (n==1)
1056  out<<V(m-n)<<')';
1057  else
1058  out<<V(m-n)<<", ";
1059 
1060  return TinyVectorLoop<n-1>::WriteText(V, out);
1061  }
1062 
1063 
1065  template<int n> template<int m, class T>
1066  inline istream& TinyVectorLoop<n>::ReadText(TinyVector<T, m>& V, istream& in)
1067  {
1068  in>>V(m-n);
1069  return TinyVectorLoop<n-1>::ReadText(V, in);
1070  }
1071 
1072 
1074  template<int n> template<class T, int m>
1076  {
1077  v.data_[n-1] = min(v.data_[n-1], u.data_[n-1]);
1079  }
1080 
1081 
1083  template<int n> template<class T, int m>
1085  {
1086  v.data_[n-1] = max(v.data_[n-1], u.data_[n-1]);
1088  }
1089 
1090 
1091  /******************
1092  * Blas Functions *
1093  ******************/
1094 
1095 
1097  template<class T, int m, class E1, class E2>
1098  inline T DotProd(const TinyVectorExpression<T, m, E1> & u,
1100  {
1101  T scal = u(0)*v(0);
1102  TinyVectorLoop<m-1>::DotProd(u, v, scal);
1103 
1104  return scal;
1105  }
1106 
1107 
1109  template<class T, int m, class E1, class E2>
1110  inline complex<T> DotProd(const TinyVectorExpression<T, m, E1> & u,
1111  const TinyVectorExpression<complex<T>, m, E2> & v)
1112  {
1113  complex<T> scal = u(0)*v(0);
1114  TinyVectorLoop<m-1>::DotProd(u, v, scal);
1115 
1116  return scal;
1117  }
1118 
1119 
1121  template<class T, int m, class E1, class E2>
1122  inline complex<T> DotProd(const TinyVectorExpression<complex<T>, m, E1> & u,
1124  {
1125  complex<T> scal = u(0)*v(0);
1126  TinyVectorLoop<m-1>::DotProd(u, v, scal);
1127 
1128  return scal;
1129  }
1130 
1131 
1133  template<class T, int m, class E1, class E2>
1134  inline complex<T> DotProdConj(const TinyVectorExpression<complex<T>, m, E1> & u,
1135  const TinyVectorExpression<complex<T>, m, E2> & v)
1136  {
1137  complex<T> scal = conjugate(u(0))*v(0);
1139 
1140  return scal;
1141  }
1142 
1143 
1145  template<class T, int m, class E>
1146  inline typename ClassComplexType<T>::Treal AbsSquare(const TinyVectorExpression<T, m, E> & u)
1147  {
1148  typename ClassComplexType<T>::Treal scal = absSquare(u(0));
1150 
1151  return scal;
1152  }
1153 
1154 
1156  template<class T, int m, class E>
1157  inline typename ClassComplexType<T>::Treal Norm1(const TinyVectorExpression<T, m, E> & u)
1158  {
1159  typename ClassComplexType<T>::Treal scal = abs(u(0));
1160  TinyVectorLoop<m-1>::Abs(u, scal);
1161 
1162  return scal;
1163  }
1164 
1165 
1167  template<class T, int m, class E>
1168  inline typename ClassComplexType<T>::Treal NormInf(const TinyVectorExpression<T, m, E> & u)
1169  {
1170  typename ClassComplexType<T>::Treal scal = abs(u(0));
1172 
1173  return scal;
1174  }
1175 
1176 
1178  template <class T, int m>
1179  inline T Distance(const TinyVector<T, m>& u, const TinyVector<T, m> & v)
1180  {
1181  return u.Distance(v);
1182  }
1183 
1184 
1186  template<class T, int m, class E>
1187  inline typename ClassComplexType<T>::Treal Norm2(const TinyVectorExpression<T, m, E> & p)
1188  {
1189  return sqrt(AbsSquare(p));
1190  }
1191 
1192 
1194  template<class T0, class T1, class T2, int m>
1195  void Add(const TinyVector<T0, m>& x, const TinyVector<T1, m>& y, TinyVector<T2, m>& z)
1196  {
1197  z = x + y;
1198  }
1199 
1200 
1202  template<class T0, class T1, class T2, int m>
1203  inline void Add(const T0& alpha, const TinyVector<T1, m>& y, TinyVector<T2, m>& x)
1204  {
1205  x += alpha*y;
1206  }
1207 
1208 
1210  template<class T0, class T, int m>
1211  inline void Mlt(const T0& alpha, TinyVector<T, m>& p)
1212  {
1213  p *= alpha;
1214  }
1215 
1216 
1217  /************************
1218  * Extraction Functions *
1219  ************************/
1220 
1221 
1223  template<int p, int m, class T0, class T1>
1224  inline void ExtractVector(const Vector<Vector<TinyVector<T0, p> > >& u,
1225  int j, int k, int offset, TinyVector<T1, m>& v)
1226  {
1227  TinyVectorLoop<m>::ExtractVector(u, j, k, offset, v);
1228  }
1229 
1230 
1232  template<int m, class T0, class T1>
1233  inline void ExtractVector(const Vector<Vector<T0> >& u,
1234  int j, int offset, TinyVector<T1, m>& v)
1235  {
1236  TinyVectorLoop<m>::ExtractVector(u, j, offset, v);
1237  }
1238 
1239 
1241  template<int m, class T0, class T1>
1242  inline void CopyVector(const TinyVector<T1, m>& v,
1243  int j, int offset, Vector<Vector<T0> >& u)
1244  {
1245  TinyVectorLoop<m>::CopyVector(v, j, offset, u);
1246  }
1247 
1248 
1250  template<int m, class T0, class T1>
1251  inline void ExtractVector(const Vector<T0>& Vh, const IVect& row_num,
1252  int nb, TinyVector<T1, m>& tmp)
1253  {
1254  TinyVectorLoop<m>::ExtractVector(Vh, row_num, nb, tmp);
1255  }
1256 
1257 
1259  template<int m, class T0, class T1>
1260  inline void ExtractVector(const TinyVector<T1, m>& tmp,
1261  const IVect& row_num, int nb, Vector<T0>& Vh)
1262  {
1263  TinyVectorLoop<m>::ExtractVector(tmp, row_num, nb, Vh);
1264  }
1265 
1266 
1268  template<int m, class T0, class T1>
1269  inline void AddVector(const T0& alpha, const TinyVector<T1, m>& tmp,
1270  const IVect& row_num, int nb, Vector<T0>& Vh)
1271  {
1272  TinyVectorLoop<m>::AddVector(alpha, tmp, row_num, nb, Vh);
1273  }
1274 
1275 
1277  template<int m, class T0, class T1>
1278  inline void ExtractVectorConj(const Vector<T0>& Vh, const IVect& row_num,
1279  int nb, TinyVector<T1, m>& tmp)
1280  {
1281  TinyVectorLoop<m>::ExtractVectorConj(Vh, row_num, nb, tmp);
1282  }
1283 
1284 
1286  template<int m, class T0, class T1>
1287  inline void ExtractVectorConj(const TinyVector<T1, m>& tmp,
1288  const IVect& row_num, int nb, Vector<T0>& Vh)
1289  {
1290  TinyVectorLoop<m>::ExtractVectorConj(tmp, row_num, nb, Vh);
1291  }
1292 
1293 
1295  template<int m, class T0, class T1>
1296  inline void AddVectorConj(const T0& alpha, const TinyVector<T1, m>& tmp,
1297  const IVect& row_num, int nb, Vector<T0>& Vh)
1298  {
1299  TinyVectorLoop<m>::AddVectorConj(alpha, tmp, row_num, nb, Vh);
1300  }
1301 
1302 
1304  template<int m, class T0, class T1>
1305  inline void CopyVector(const TinyVector<Vector<T0>, m>& uvec,
1306  int j, TinyVector<T1, m>& u)
1307  {
1308  TinyVectorLoop<m>::CopyVector(uvec, j, u);
1309  }
1310 
1311 
1313  template<int m, class T0, class T1>
1314  inline void CopyVector(const TinyVector<T1, m>& u,
1315  int j, TinyVector<Vector<T0>, m>& uvec)
1316  {
1317  TinyVectorLoop<m>::CopyVector(u, j, uvec);
1318  }
1319 
1320 
1322  template<int m, class T0, class T1>
1323  inline void CopyVector(const TinyVector<T1, m>& u, int j, Vector<T0>& uvec)
1324  {
1325  TinyVectorLoop<m>::ExtractVector(u, m*j, uvec);
1326  }
1327 
1328 
1330  template<int m, class T0, class T1>
1331  inline void CopyVector(const Vector<T0>& uvec, int j, TinyVector<T1, m>& u)
1332  {
1333  TinyVectorLoop<m>::ExtractVector(uvec, m*j, u);
1334  }
1335 
1336 
1338  template<int m, class T>
1339  inline void CopyVector(const Vector<complex<T> >& Vh, int j,
1341  {
1342  TinyVectorLoop<m>::CopyVector(Vh, j, vr, vi);
1343  }
1344 
1345 
1347  template<int m, class T0, class T1>
1348  inline void AddVector(const TinyVector<T1, m>& u, int offset, Vector<T0>& uvec)
1349  {
1350  TinyVectorLoop<m>::AddVector(u, offset, uvec);
1351  }
1352 
1353 
1355  template<int m, class T0, class T1>
1356  inline void AddVector(const Vector<T0>& uvec, int offset, TinyVector<T1, m>& u)
1357  {
1358  TinyVectorLoop<m>::AddVector(uvec, offset, u);
1359  }
1360 
1361 
1363  template<int m, class T0, class T1>
1364  inline void ExtractVector(const TinyVector<T1, m>& u, int offset, Vector<T0>& uvec)
1365  {
1366  TinyVectorLoop<m>::ExtractVector(u, offset, uvec);
1367  }
1368 
1369 
1371  template<int m, class T0, class T1>
1372  inline void ExtractVector(const Vector<T0>& uvec, int offset, TinyVector<T1, m>& u)
1373  {
1374  TinyVectorLoop<m>::ExtractVector(uvec, offset, u);
1375  }
1376 
1377 
1378  /*******************
1379  * Other Functions *
1380  *******************/
1381 
1382 
1385  template<class T0, int m>
1386  inline void SymmetrizePointPlane(const TinyVector<T0, m>& u, const TinyVector<T0, m>& normale,
1387  const T0& d, TinyVector<T0, m>& v)
1388  {
1389  T0 scal = 2*(-d - DotProd(u, normale));
1390  v = u;
1391  Add(scal, normale, v);
1392  }
1393 
1394 
1396  template<class T, int m>
1398  {
1400  }
1401 
1402 
1404  template<class T, int m>
1406  {
1408  }
1409 
1410 
1412  template<int m, class T0, class T1>
1413  inline void MltVector(const T1& alpha, int j, TinyVector<Vector<T0>, m>& uvec)
1414  {
1415  TinyVectorLoop<m>::MltVector(alpha, j, uvec);
1416  }
1417 
1418 
1419  template<class T, int p>
1420  inline void Mlt(const T& alpha, Vector<TinyVector<T, p> >& X)
1421  {
1422  Vector<T> Xvec;
1423  Xvec.SetData(X.GetM()*p, reinterpret_cast<T*>(X.GetData()));
1424  Mlt(alpha, Xvec);
1425  Xvec.Nullify();
1426  }
1427 
1428 
1429  template<class T, class Prop, class Storage, int p>
1430  inline void Mlt(const SeldonTranspose& trans, const Matrix<T, Prop, Storage>& A,
1431  const Vector<TinyVector<T, p> >& x, Vector<TinyVector<T, p> >& y)
1432  {
1433  if (trans.NoTrans())
1434  MltVector(SeldonNoTrans, A, x, y);
1435  else
1436  MltVector(SeldonTrans, A, x, y);
1437  }
1438 
1439 
1440  template<class T, class Prop, class Storage, int p>
1441  inline void Mlt(const Matrix<T, Prop, Storage>& A,
1442  const Vector<TinyVector<T, p> >& x, Vector<TinyVector<T, p> >& y)
1443  {
1444  MltVector(A, x, y);
1445  }
1446 
1447 
1448  /*****************************
1449  * Functions for 3-D vectors *
1450  *****************************/
1451 
1452 
1454  template<class T1, class T2, class T3>
1455  inline void TimesProd(const TinyVector<T1, 3> & u,
1456  const TinyVector<T2, 3> & v, TinyVector<T3, 3>& res )
1457  {
1458  res(0) = u(1)*v(2) - u(2)*v(1);
1459  res(1) = u(2)*v(0) - u(0)*v(2);
1460  res(2) = u(0)*v(1) - u(1)*v(0);
1461  }
1462 
1463 
1465  template<class T1, class T2>
1466  inline T1 TimesProd(const TinyVector<T1, 2> & u, const TinyVector<T2, 2> & v)
1467  {
1468  return u(0)*v(1) - u(1)*v(0);
1469  }
1470 
1471 
1473  template<class T>
1474  inline void ForceZeroVdotN(const TinyVector<T, 2>& normale, TinyVector<T, 2>& v0)
1475  {
1476  if (abs(normale(0)) > abs(normale(1)))
1477  v0.Init(-normale(1)*v0(1)/normale(0), v0(1));
1478  else
1479  v0.Init(v0(0), -normale(0)*v0(0)/normale(1));
1480  }
1481 
1482 
1484  template<class T>
1485  inline void ForceZeroVdotN(const TinyVector<T, 3>& normale, TinyVector<T, 3>& v0)
1486  {
1487  if (abs(normale(0)) > max(abs(normale(1)), abs(normale(2))))
1488  v0.Init(-(normale(2)*v0(2)+normale(1)*v0(1))/normale(0), v0(1), v0(2));
1489  else if (abs(normale(1)) > max(abs(normale(0)), abs(normale(2))))
1490  v0.Init(v0(0), -(normale(0)*v0(0)+normale(2)*v0(2))/normale(1), v0(2));
1491  else
1492  v0.Init(v0(0), v0(1), -(normale(0)*v0(0)+normale(1)*v0(1))/normale(2));
1493  }
1494 
1495 
1497  template<class T>
1499  {
1500  //DISP(x); DISP(s); DISP((TinyVector<T, 2>::threshold));
1501  if ((x(0) >= s(0)(0)-TinyVector<T, 2>::threshold) && (x(0) <= s(1)(0)+TinyVector<T, 2>::threshold)
1502  && (x(1) >= s(0)(1)-TinyVector<T, 2>::threshold) && (x(1) <= s(1)(1)+TinyVector<T, 2>::threshold))
1503  return true;
1504 
1505  return false;
1506  }
1507 
1508 
1510  template<class T>
1512  {
1513  if ((x(0) >= s(0)(0)-TinyVector<T, 3>::threshold) && (x(0) <= s(1)(0)+TinyVector<T, 3>::threshold)
1514  && (x(1) >= s(0)(1)-TinyVector<T, 3>::threshold) && (x(1) <= s(1)(1)+TinyVector<T, 3>::threshold)
1515  && (x(2) >= s(0)(2)-TinyVector<T, 3>::threshold) && (x(2) <= s(1)(2)+TinyVector<T, 3>::threshold) )
1516  return true;
1517 
1518  return false;
1519  }
1520 
1521 
1523  template<class T0, class T1, class T2, class T3>
1526  {
1527  v(0) = -u(1); v(1) = u(0); v(2) = u(2);
1528  w(0) = -v(1); w(1) = v(0); w(2) = v(2);
1529  t(0) = -w(1); t(1) = w(0); t(2) = w(2);
1530  }
1531 
1532 
1534  template<class T>
1535  inline T Determinant(const TinyVector<T, 3> & u,
1536  const TinyVector<T, 3> & v, const TinyVector<T,3>& w )
1537  {
1538  T res = u(0)*(v(1)*w(2)-v(2)*w(1)) - u(1)*(v(0)*w(2)-v(2)*w(0)) + u(2)*(v(0)*w(1)-v(1)*w(0));
1539  return res;
1540  }
1541 
1542 
1543  /************
1544  * FillZero *
1545  ************/
1546 
1548  inline void FillZero(double& X)
1549  {
1550  X = 0;
1551  }
1552 
1554  inline void FillZero(complex<double>& X)
1555  {
1556  X = 0;
1557  }
1558 
1560  inline void FillZero(int& X)
1561  {
1562  X = 0;
1563  }
1564 
1566  inline void FillZero(float& X)
1567  {
1568  X = 0;
1569  }
1570 
1572  inline void FillZero(complex<float>& X)
1573  {
1574  X = 0;
1575  }
1576 
1578  inline void FillZero(bool& X)
1579  {
1580  X = false;
1581  }
1582 
1584  template<class T, class Storage, class Allocator>
1585  inline void FillZero(Vector<T, Storage, Allocator>& X)
1586  {
1587  for (int i = 0; i < X.GetM(); i++)
1588  FillZero(X(i));
1589  }
1590 
1592  template<class T, class Prop, class Storage, class Allocator>
1593  inline void FillZero(Matrix<T, Prop, Storage, Allocator>& X)
1594  {
1595  for (int i = 0; i < X.GetM(); i++)
1596  for (int j = 0; j < X.GetN(); j++)
1597  FillZero(X(i, j));
1598  }
1599 
1601  template<class T, class Prop, class Allocator>
1602  inline void FillZero(Matrix<T, Prop, RowSparse, Allocator>& X)
1603  {
1604  }
1605 
1607  template<class T, class Prop, class Allocator>
1609  {
1610  }
1611 
1613  template<class T, int m>
1614  inline void FillZero(TinyVector<T, m>& X)
1615  {
1616  X.Zero();
1617  }
1618 
1620  template<class T>
1621  inline void FillZero(T& x)
1622  {
1623  x = T(0);
1624  }
1625 
1627  template<class T>
1628  inline void FillZero(complex<T>& x)
1629  {
1630  x = complex<T>(0, 0);
1631  }
1632 
1633  template<class T, int p>
1634  inline void SetComplexZero(TinyVector<T, p>& x)
1635  {
1636  T zero; SetComplexZero(zero);
1637  x.Fill(zero);
1638  }
1639 
1640  template<class T>
1641  inline bool IsComplexZero(const T& x)
1642  {
1643  if (x == T(0))
1644  return true;
1645 
1646  return false;
1647  }
1648 
1649  template<class T>
1650  inline bool IsComplexZero(const complex<T>& x)
1651  {
1652  if (x == complex<T>(0, 0))
1653  return true;
1654 
1655  return false;
1656  }
1657 
1658 } // end namespace
1659 
1660 #define SELDON_FILE_TINY_VECTOR_INLINE_CXX
1661 #endif
Seldon::GenerateSymPts
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
Definition: TinyVectorInline.cxx:1524
Seldon::operator==
bool operator==(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this == u
Definition: TinyMatrixInline.cxx:1245
Seldon::TimesProd
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
Definition: TinyVectorInline.cxx:1455
Seldon::TinyVectorLoop::ExtractVectorConj
static void ExtractVectorConj(const Vector< T0 > &Vh, const IVect &row_num, int j, TinyVector< T1, m > &tmp)
tmp = conj(Vh(row_num(nb+:)))
Definition: TinyVectorInline.cxx:860
Seldon::TinyVectorLoop::ExtractVector
static void ExtractVector(const Vector< T0 > &Vh, int j, TinyVector< T1, m > &tmp)
tmp(:) = Vh(offset + :)
Definition: TinyVectorInline.cxx:763
Seldon::TinyVectorLoop::DiffCopy
static void DiffCopy(const TinyVectorExpression< T1, m, E > &x, TinyVector< T0, m > &y)
y -= x
Definition: TinyVectorInline.cxx:682
Seldon::TinyVectorLoop::FillRand
static void FillRand(TinyVector< T0, m > &x)
sets randomly the components with function rand()
Definition: TinyVectorInline.cxx:644
Seldon::TinyVector_Base
Class storing a tiny vector whose size is known at compilation time.
Definition: TinyVector.hxx:21
Seldon::Norm2
ClassComplexType< T >::Treal Norm2(const VectorExpression< T, E > &X)
returns 2-norm of an expression with vectors
Definition: Functions_BaseInline.cxx:153
Seldon::TinyVectorExpression
Expression between vectors.
Definition: TinyVectorExpression.hxx:8
Seldon::to_str
std::string to_str(const T &input)
Converts most types to string.
Definition: CommonInline.cxx:137
Seldon::Norm1
ClassComplexType< T >::Treal Norm1(const VectorExpression< T, E > &X)
returns 1-norm of an expression with vectors
Definition: Functions_BaseInline.cxx:140
Seldon::TinyVector::TinyVector
TinyVector()
Sets all components to 0.
Definition: TinyVectorInline.cxx:312
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::TinyVectorLoop::Zero
static void Zero(TinyVector< T0, m > &x)
Sets all components to 0.
Definition: TinyVectorInline.cxx:600
Seldon::TinyVectorLoop::WriteText
static ostream & WriteText(const TinyVector< T, m > &V, ostream &out)
displays V
Definition: TinyVectorInline.cxx:1053
Seldon::TinyVectorLoop::Copy
static void Copy(const TinyVectorExpression< T1, m, E > &x, TinyVector< T0, m > &y)
y = x
Definition: TinyVectorInline.cxx:664
Seldon::WrongIndex
Definition: Errors.hxx:114
Seldon::TinyVectorLoop::AddCopy
static void AddCopy(const TinyVectorExpression< T1, m, E > &x, TinyVector< T0, m > &y)
y += x
Definition: TinyVectorInline.cxx:673
Seldon::TinyVector_Base::FillRand
void FillRand()
sets randomly the components with function rand()
Definition: TinyVectorInline.cxx:275
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::TinyVectorLoop::UpdateMaximum
static void UpdateMaximum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = max(v, u)
Definition: TinyVectorInline.cxx:1084
Seldon::TinyVectorLoop
class used for unrolling loops for operators/functions of TinyVector
Definition: TinyVector.hxx:14
Seldon::TinyVectorLoop::CopyVector
static void CopyVector(const TinyVector< Vector< T0 >, m > &uvec, int j, TinyVector< T1, m > &u)
u(:) = uvec(:)(j)
Definition: TinyVectorInline.cxx:692
Seldon::TinyVector_Base::DistanceSquare
ClassComplexType< T >::Treal DistanceSquare(const TinyVector< T, m_ > &p) const
returns |u-v|^2 (usual euclidian norm)
Definition: TinyVectorInline.cxx:291
Seldon::TinyVector
vector with real/complex components
Definition: TinyVector.hxx:17
Seldon::TinyVectorLoop::Mlt
static void Mlt(const T1 &alpha, TinyVector< T0, m > &x)
Multiplies x by alpha.
Definition: TinyVectorInline.cxx:982
Seldon::Matrix< T, Prop, RowSparse, Allocator >
Row-major sparse-matrix class.
Definition: Matrix_Sparse.hxx:223
Seldon::TinyVectorLoop::Abs
static void Abs(const TinyVectorExpression< T0, m, E0 > &u, T1 &scal)
computes scal = \sum |u_i|^2
Definition: TinyVectorInline.cxx:1013
Seldon::AddVectorConj
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)
Definition: TinyVectorInline.cxx:1296
Seldon::TinyVectorLoop::IsZero
static bool IsZero(const TinyVectorExpression< T0, m, E0 > &x)
returns true if all components are 0
Definition: TinyVectorInline.cxx:653
Seldon::TinyVector_Base::Distance
ClassComplexType< T >::Treal Distance(const TinyVector< T, m_ > &p) const
returns |u-v| (usual euclidian norm)
Definition: TinyVectorInline.cxx:299
Seldon::operator<=
bool operator<=(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns true if u <= v, false otherwise
Definition: TinyVectorInline.cxx:494
Seldon::TinyVector_Base::Init
void Init(const T &a)
sets first component to a
Definition: TinyVectorInline.cxx:77
Seldon::ExtractVector
void ExtractVector(const Vector< Vector< TinyVector< T0, p > > > &u, int j, int k, int offset, TinyVector< T1, m > &v)
v(:) = u(offset+:)(j)(k)
Definition: TinyVectorInline.cxx:1224
Seldon::TinyVector_Base::GetSize
int GetSize() const
Returns the number of stored elements.
Definition: TinyVectorInline.cxx:179
Seldon::TinyVectorLoop::Less
static bool Less(const TinyVectorExpression< T0, m, E0 > &x, const TinyVectorExpression< T1, m, E1 > &y)
returns x < y
Definition: TinyVectorInline.cxx:929
Seldon::ForceZeroVdotN
void ForceZeroVdotN(const TinyVector< T, 2 > &normale, TinyVector< T, 2 > &v0)
modifies v0 such that v0 \cdot normale = 0
Definition: TinyVectorInline.cxx:1474
Seldon::TinyVector_Base::TinyVector_Base
TinyVector_Base()
all components are set to 0
Definition: TinyVectorInline.cxx:15
Seldon::UpdateMinimum
void UpdateMinimum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = min(v, u) elementwise
Definition: TinyVectorInline.cxx:1397
Seldon::UpdateMaximum
void UpdateMaximum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = max(v, u) elementwise
Definition: TinyVectorInline.cxx:1405
Seldon::TinyVectorLoop::NormInf
static void NormInf(const TinyVectorExpression< T0, m, E0 > &u, T1 &scal)
computes scal = max |u_i|^2
Definition: TinyVectorInline.cxx:1022
Seldon::CopyVector
void CopyVector(const Vector< T1, Storage1, Allocator1 > &X, Vector< T2, Storage2, Allocator2 > &Y)
Y = X.
Definition: Functions_Vector.cxx:293
Seldon::PointInsideBoundingBox
bool PointInsideBoundingBox(const TinyVector< T, 2 > &, const TinyVector< TinyVector< T, 2 >, 2 > &)
returns true if x is inside the bounding box s
Definition: TinyVectorInline.cxx:1498
Seldon::operator>>
istream & operator>>(istream &out, TinyVector< T, m > &V)
reads V
Definition: TinyVectorInline.cxx:587
Seldon::TinyVectorLoop::Print
static void Print(const TinyVector< T, m > &V, ostream &out)
displays V without brackets
Definition: TinyVectorInline.cxx:1040
Seldon::TinyVector_Base::Print
void Print() const
displays the vector without brackets
Definition: TinyVectorInline.cxx:235
Seldon::TinyVector_Base::GetLength
int GetLength() const
Returns the number of stored elements.
Definition: TinyVectorInline.cxx:171
Seldon::TinyVectorLoop::LessInt
static bool LessInt(const TinyVector< T0, m > &x, const TinyVector< T1, m > &y)
returns x < y
Definition: TinyVectorInline.cxx:969
Seldon::TinyVector_Base::IsZero
bool IsZero() const
returns true if all components are 0
Definition: TinyVectorInline.cxx:283
Seldon::Matrix< T, Prop, ArrayRowSparse, Allocator >
Row-major sparse-matrix class.
Definition: Matrix_ArraySparse.hxx:214
Seldon::TinyVector_Base::Zero
void Zero()
Sets all components to 0.
Definition: TinyVectorInline.cxx:251
Seldon::TinyVectorLoop::LessOrEqualInt
static bool LessOrEqualInt(const TinyVector< T0, m > &x, const TinyVector< T1, m > &y)
returns x <= y
Definition: TinyVectorInline.cxx:955
Seldon::TinyVector_Base::Fill
void Fill()
Sets the vector to [0, 1, 2, 3, ..., n-1].
Definition: TinyVectorInline.cxx:259
Seldon::TinyVector::operator+=
TinyVector< T, m_ > & operator+=(const TinyVectorExpression< T1, m_, E > &u)
Operator *this += expression with vectors.
Definition: TinyVectorInline.cxx:374
Seldon::operator>=
bool operator>=(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns true if u >= v, false otherwise
Definition: TinyVectorInline.cxx:509
Seldon::TinyVectorLoop::Fill
static void Fill(TinyVector< T0, m > &x, const T1 &a)
Sets all components to a given value.
Definition: TinyVectorInline.cxx:626
Seldon::NormInf
ClassComplexType< T >::Treal NormInf(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the infinity-norm of a matrix.
Definition: Functions_Matrix.cxx:2435
Seldon::absSquare
T absSquare(const T &x)
returns the square modulus of z
Definition: CommonInline.cxx:340
Seldon::TinyVector::operator=
TinyVector< T, m_ > & operator=(const TinyVectorExpression< T1, m_, E > &u)
Operator *this = expression with vectors.
Definition: TinyVectorInline.cxx:364
Seldon::TinyVector_Base::GetLeafClass
TinyVector< T, m_ > & GetLeafClass()
returns leaf class
Definition: TinyVectorInline.cxx:195
Seldon::TinyVectorLoop::DotProd
static void DotProd(const TinyVectorExpression< T0, m, E0 > &u, const TinyVectorExpression< T1, m, E1 > &v, T2 &scal)
scal = u.v
Definition: TinyVectorInline.cxx:992
Seldon::operator!=
bool operator!=(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this != u
Definition: TinyMatrixInline.cxx:1254
Seldon::TinyVectorLoop::FillGreater
static void FillGreater(TinyVector< T0, m > &x, const T0 &a)
Fills with a in ascendant order (instead of descendant order for Fill)
Definition: TinyVectorInline.cxx:609
Seldon::TinyVectorLoop::AddVectorConj
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)
Definition: TinyVectorInline.cxx:882
Seldon::TinyVectorLoop::AddVector
static void AddVector(const Vector< T0 > &Vh, int j, TinyVector< T1, m > &tmp)
tmp(:) += Vh(offset + :)
Definition: TinyVectorInline.cxx:743
Seldon::TinyVectorLoop::UpdateMinimum
static void UpdateMinimum(const TinyVector< T, m > &u, TinyVector< T, m > &v)
sets v = min(v, u)
Definition: TinyVectorInline.cxx:1075
Seldon::TinyVector::operator-=
TinyVector< T, m_ > & operator-=(const TinyVectorExpression< T1, m_, E > &u)
Operator *this -= expression with vectors.
Definition: TinyVectorInline.cxx:384
Seldon::AbsSquare
ClassComplexType< T >::Treal AbsSquare(const TinyVectorExpression< T, m, E > &u)
returns || u ||^2
Definition: TinyVectorInline.cxx:1146
Seldon::Distance
T Distance(const TinyVector< T, m > &u, const TinyVector< T, m > &v)
returns || u-v ||
Definition: TinyVectorInline.cxx:1179
Seldon::SymmetrizePointPlane
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 ...
Definition: TinyVectorInline.cxx:1386
Seldon::TinyVectorLoop::InitValue
static void InitValue(TinyVector< T0, m > &x, const T0 &a)
initializes a single value
Definition: TinyVectorInline.cxx:618
Seldon::ExtractVectorConj
void ExtractVectorConj(const Vector< T0 > &Vh, const IVect &row_num, int nb, TinyVector< T1, m > &tmp)
tmp = conj(Vh(row_num(nb+:)))
Definition: TinyVectorInline.cxx:1278
Seldon::TinyVector_Base::GetMemorySize
size_t GetMemorySize() const
returns the size used by the object in bytes
Definition: TinyVectorInline.cxx:187
Seldon::Determinant
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
Definition: TinyVectorInline.cxx:1535
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::operator<<
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
Definition: Array.cxx:1617
Seldon::TinyVectorLoop::AbsSquare
static void AbsSquare(const TinyVectorExpression< T0, m, E0 > &u, T1 &scal)
computes scal = \sum |u_i|^2
Definition: TinyVectorInline.cxx:1031
Seldon::TinyVector_Base::operator()
const T & operator()(int i) const
returns x(i)
Definition: TinyVectorInline.cxx:211
Seldon::TinyVectorLoop::MltVector
static void MltVector(const T1 &alpha, int j, TinyVector< Vector< T0 >, m > &uvec)
u(:)(j) *= alpha
Definition: TinyVectorInline.cxx:893
Seldon::TinyVectorLoop::ReadText
static istream & ReadText(TinyVector< T, m > &V, istream &in)
reads V
Definition: TinyVectorInline.cxx:1066
Seldon::TinyVectorLoop::DotProdConj
static void DotProdConj(const TinyVectorExpression< T0, m, E0 > &u, const TinyVectorExpression< T1, m, E1 > &v, T2 &scal)
returns (conj(u), v)
Definition: TinyVectorInline.cxx:1003
Seldon::operator>
bool operator>(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns true if u > v, false otherwise
Definition: TinyVectorInline.cxx:517
Seldon::operator<
bool operator<(const TinyVector< int, m > &u, const TinyVector< int, m > &v)
returns *this < u
Definition: TinyVectorInline.cxx:501
Seldon::SetComplexReal
void SetComplexReal(int n, std::complex< T > &number)
Sets a complex number to (n, 0).
Definition: CommonInline.cxx:234
Seldon::TinyVector_Base::GetM
int GetM() const
Returns the number of stored elements.
Definition: TinyVectorInline.cxx:163
Seldon::AddVector
void AddVector(const T0 &alpha, const Vector< T1, Storage1, Allocator1 > &X, Vector< T2, Storage2, Allocator2 > &Y)
Adds two vectors Y = Y + alpha X.
Definition: Functions_Vector.cxx:94
Seldon::TinyVectorLoop::LessOrEqual
static bool LessOrEqual(const TinyVectorExpression< T0, m, E0 > &x, const TinyVectorExpression< T1, m, E1 > &y)
returns x <= y
Definition: TinyVectorInline.cxx:915
Seldon::TinyVectorLoop::Equal
static bool Equal(const TinyVectorExpression< T0, m, E0 > &x, const TinyVectorExpression< T1, m, E1 > &y)
returns x == y
Definition: TinyVectorInline.cxx:903
Seldon::TinyVectorLoop::EqualInt
static bool EqualInt(const TinyVector< T0, m > &x, const TinyVector< T1, m > &y)
returns x == y
Definition: TinyVectorInline.cxx:944