A.I.M.S


vector.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 /*
35  * AIMS vector class
36  */
37 #ifndef AIMS_VECTOR_VECTOR_H
38 #define AIMS_VECTOR_VECTOR_H
39 
40 #include <aims/def/assert.h>
41 #include <aims/def/general.h>
43 #include <cartobase/type/types.h>
44 #include <fstream>
45 #include <math.h>
47 
48 template <class T,int D> class AimsVector;
49 
50 
51 template <class T,int D>
52 bool operator == (const AimsVector<T,D>& v1,
53  const AimsVector<T,D>& v2);
54 
55 template <class T,int D>
56 bool operator == (const AimsVector<T,D>& v1,
57  const T& val);
58 
60 template <class T,int D>
62  const AimsVector<T,D>& v2)
63 {
64  return !( v1 == v2 );
65 }
66 
68 template <class T,int D>
70  const T& val)
71 {
72  return !( v1 == val );
73 }
74 
75 template <class T,int D>
77  const AimsVector<T,D>& v2);
78 
79 template <class T,int D>
81  const AimsVector<T,D>& v2);
82 
83 template <class T,int D>
85  double value );
86 
87 template <class T,int D>
88 AimsVector<T,D> operator * (double value,
89  const AimsVector<T,D>& v1);
90 
91 template <class T,int D>
93  double value);
94 
95 template <class T,int D>
97 
98 template <class T,int D>
100 
101 template <class T,int D>
103  const AimsVector<T,D>& v2);
104 
105 template <class T,int D>
106 float norm(const AimsVector<T,D>& v1);
107 
108 template <class T,int D>
109 float norm2(const AimsVector<T,D>& v1);
110 
111 template <class T,int D>
112 double dnorm(const AimsVector<T,D>& v1);
113 
114 template <class T,int D>
115 double dnorm2(const AimsVector<T,D>& v1);
116 
117 template <class T,int D>
118 std::ostream& operator << (std::ostream& out,
119  const AimsVector<T,D>& thing);
120 
121 template <class T,int D>
122 std::istream& operator >> (std::istream& in,
123  AimsVector<T,D>& thing);
124 
125 
130 template <class T,int D>
131 class AimsVector
132 {
133  public:
136  AimsVector();
139  AimsVector(const T& value);
141  explicit AimsVector(const T value[]);
143  AimsVector(const T& x,const T& y);
145  AimsVector(const T& x,const T& y,const T& z);
147  AimsVector(const T& x,const T& y,const T& z,const T& t);
149  AimsVector(const AimsVector<T,D>& other);
151  template<class U>
152  explicit AimsVector(const AimsVector<U,D>& other);
153 
155  ~AimsVector();
157 
163  AimsVector<T,D>& operator *= ( double val );
164  AimsVector<T,D>& operator /= ( double val );
166 
168  const T& item(int d) const;
170  const T& operator[](int d) const;
172  T& item(int d);
174  T& operator[](int d);
175 
176  int size() const;
178  bool isNull() const;
180  float norm() const;
182  float norm2() const;
184  double dnorm() const;
186  double dnorm2() const;
188  T dot(const AimsVector<T,D>& other) const;
189 
191 
194  typedef T * iterator;
195  typedef const T * const_iterator;
196  iterator begin() { return _value; }
197  const_iterator begin() const { return _value; }
198  iterator end() { return _value + D; }
199  const_iterator end() const { return _value + D; }
201 
202  protected:
204  T _value[D];
205 };
206 
207 
210 // Keep those for compability
217 // 2016: l now means long (64bit), i int (32bit), s short (16bit)
243 
244 
245 extern template class AimsVector<int16_t,2>;
246 extern template class AimsVector<int16_t,3>;
247 extern template class AimsVector<int16_t,4>;
248 extern template class AimsVector<int32_t,2>;
249 extern template class AimsVector<int32_t,3>;
250 extern template class AimsVector<int32_t,4>;
251 extern template class AimsVector<int64_t,2>;
252 extern template class AimsVector<int64_t,3>;
253 extern template class AimsVector<int64_t,4>;
254 extern template class AimsVector<uint16_t,2>;
255 extern template class AimsVector<uint16_t,3>;
256 extern template class AimsVector<uint16_t,4>;
257 extern template class AimsVector<uint32_t,2>;
258 extern template class AimsVector<uint32_t,3>;
259 extern template class AimsVector<uint32_t,4>;
260 extern template class AimsVector<uint64_t,2>;
261 extern template class AimsVector<uint64_t,3>;
262 extern template class AimsVector<uint64_t,4>;
263 extern template class AimsVector<float,2>;
264 extern template class AimsVector<float,3>;
265 extern template class AimsVector<float,4>;
266 extern template class AimsVector<double,2>;
267 extern template class AimsVector<double,3>;
268 extern template class AimsVector<double,4>;
269 
270 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
271 
272 namespace carto
273 {
298 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2ds> )
299 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3ds> )
300 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4ds> )
301 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2di> )
302 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3di> )
303 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4di> )
304 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2dl> )
305 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3dl> )
306 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4dl> )
307 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2dus> )
308 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3dus> )
309 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4dus> )
310 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2dui> )
311 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3dui> )
312 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4dui> )
313 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2dul> )
314 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3dul> )
315 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4dul> )
316 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2df> )
317 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3df> )
318 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4df> )
319 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point2dd> )
320 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point3dd> )
321 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Point4dd> )
322 
323  // partial specializations
324 
325  template<class T, int D> class DataTypeCode<AimsVector<T,D> >
326  {
327  public:
328  static std::string objectType()
329  { return( "Vector" ); }
330  static std::string dataType()
331  {
332  char num[10];
333  sprintf( num, "%d", (int) D );
334  return( std::string( "VECTOR_OF_" ) + num + "_" +
336  }
337  static std::string name()
338  {
339  return DataTypeCode<AimsVector<T,D> >::dataType();
340  }
341  };
342 
343  template<> inline std::string DataTypeCode<Point2df>::dataType()
344  {
345  return "POINT2DF";
346  }
347 
348  template<> inline std::string DataTypeCode<Point3df>::dataType()
349  {
350  return "POINT3DF";
351  }
352 
353 }
354 
355 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
356 
357 
358 //
359 // Members of class AimsVector<T,D>
360 //
361 template <class T,int D>
362 inline
364 {
365 }
366 
367 
368 template <class T,int D>
369 inline
371 {
372  for (int d = 0; d < D; d++)
373  _value[d] = value;
374 }
375 
376 
377 template <class T,int D>
378 inline
380 {
381  for (int d = 0; d < D; d++)
382  _value[d] = value[d];
383 }
384 
385 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
386 namespace internal
387 {
388  template <typename T, int D>
390  {
391  public:
392  inline static void doit( T _value[D], const T& x, const T& y )
393  {
394  _value[0] = x;
395  _value[1] = y;
396  }
397  };
398 
399  template <typename T, int D>
401  {
402  public:
403  inline static void doit( T _value[D], const T& x, const T& y, const T& z )
404  {
405  _value[0] = x;
406  _value[1] = y;
407  _value[2] = z;
408  }
409  };
410 
411  template <typename T, int D>
413  {
414  public:
415  inline static void doit( T _value[D], const T& x, const T& y, const T& z,
416  const T& t )
417  {
418  _value[0] = x;
419  _value[1] = y;
420  _value[2] = z;
421  _value[3] = t;
422  }
423  };
424 
425  template <typename T>
426  class fill_aimsvector2<T, 1>
427  {
428  public:
429  inline static void doit( T _value[1], const T& x, const T& )
430  {
431  _value[0] = x;
432  }
433  };
434 
435  template <typename T>
436  class fill_aimsvector3<T, 1>
437  {
438  public:
439  inline static void doit( T _value[1], const T& x, const T&, const T& )
440  {
441  _value[0] = x;
442  }
443  };
444 
445  template <typename T>
446  class fill_aimsvector4<T, 1>
447  {
448  public:
449  inline static void doit( T _value[1], const T& x, const T&, const T&,
450  const T& )
451  {
452  _value[0] = x;
453  }
454  };
455 
456  template <typename T>
457  class fill_aimsvector3<T, 2>
458  {
459  public:
460  inline static void doit( T _value[2], const T& x, const T& y, const T& )
461  {
462  _value[0] = x;
463  _value[1] = y;
464  }
465  };
466 
467  template <typename T>
468  class fill_aimsvector4<T, 2>
469  {
470  public:
471  inline static void doit( T _value[2], const T& x, const T& y, const T&,
472  const T& )
473  {
474  _value[0] = x;
475  _value[1] = y;
476  }
477  };
478 
479  template <typename T>
480  class fill_aimsvector4<T, 3>
481  {
482  public:
483  inline static void doit( T _value[3], const T& x, const T& y, const T& z,
484  const T& )
485  {
486  _value[0] = x;
487  _value[1] = y;
488  _value[2] = z;
489  }
490  };
491 
492 }
493 #endif
494 
495 template <class T,int D>
496 inline
497 AimsVector<T,D>::AimsVector(const T& x, const T& y)
498 {
500 }
501 
502 
503 template <class T,int D>
504 inline
505 AimsVector<T,D>::AimsVector(const T& x, const T& y, const T& z)
506 {
507  ::internal::fill_aimsvector3<T,D>::doit( _value, x, y, z );
508 }
509 
510 
511 template <class T,int D>
512 inline
513 AimsVector<T,D>::AimsVector(const T& x, const T& y, const T& z, const T& t)
514 {
515  ::internal::fill_aimsvector4<T,D>::doit( _value, x, y, z, t );
516 }
517 
518 
519 template <class T,int D>
520 inline
522 {
523  for (int d = 0; d < D; d++)
524  _value[d] = other._value[d];
525 }
526 
527 template <class T,int D> template<class U>
528 inline
530 {
531  for (int d = 0; d < D; d++)
532  _value[d] = other._value[d];
533 }
534 
535 
536 template <class T,int D>
537 inline
539 {
540  if (this == &other)
541  return *this;
542  for (int d = 0; d < D; d++)
543  _value[d] = other._value[d];
544  return *this;
545 }
546 
547 
548 template <class T,int D>
549 inline
551 {
552 }
553 
554 
555 template <class T,int D>
556 inline
558 {
559  for (int d = 0;d < D; d++)
560  _value[d] += other._value[d];
561  return *this;
562 }
563 
564 
565 template <class T,int D>
566 inline
568 {
569  for (int d = 0; d < D; d++)
570  _value[d] -= other._value[d];
571  return *this;
572 }
573 
574 
575 template <class T,int D>
576 inline
578 {
579  for (int d = 0; d < D; d++)
580  _value[d] = (T) ( _value[d] * val );
581  return *this;
582 }
583 
584 
585 template <class T,int D>
586 inline
588 {
589  for (int d = 0; d < D; d++)
590  _value[d] = (T) ( _value[d] / val );
591  return *this;
592 }
593 
594 
595 template <class T,int D>
596 inline
598 {
599  return operator /=( norm() );
600 }
601 
602 
603 template <class T,int D>
604 inline
605 const T& AimsVector<T,D>::item(int d) const
606 {
607  ASSERT(d < D);
608  return _value[d];
609 }
610 
611 
612 template <class T,int D>
613 inline
614 const T& AimsVector<T,D>::operator[](int d) const
615 {
616  ASSERT(d < D);
617  return _value[d];
618 }
619 
620 
621 template <class T,int D>
622 inline
624 {
625  ASSERT(d < D);
626  return _value[d];
627 }
628 
629 
630 template <class T,int D>
631 inline
633 {
634  ASSERT(d < D);
635  return _value[d];
636 }
637 
638 template <class T,int D>
639 inline
641 {
642  return D;
643 }
644 
645 template <class T,int D>
646 inline
648 {
649  for (int d = 0; d < D; ++d) {
650  if ( _value[ d ] ) return false;
651  }
652  return true;
653 }
654 
655 template <class T,int D>
656 inline
658 {
659  float result = 0;
660  for (int d = 0; d < D; ++d)
661  result += float(item(d)) * float(item(d));
662  return sqrt(result);
663 }
664 
665 template <class T,int D>
666 inline
668 {
669  float result = 0;
670  for (int d = 0; d < D; ++d)
671  result += float(item(d)) * float(item(d));
672  return result;
673 }
674 
675 template <class T,int D>
676 inline
678 {
679  double result = 0;
680  for (int d = 0; d < D; ++d)
681  result += double(item(d)) * double(item(d));
682  return sqrt(result);
683 }
684 
685 template <class T,int D>
686 inline
688 {
689  double result = 0;
690  for (int d = 0; d < D; ++d)
691  result += double(item(d)) * double(item(d));
692  return result;
693 }
694 
695 
696 template <class T,int D>
697 inline
699 {
700  T result = (T)0;
701  for (int d = 0; d < D; ++d)
702  result += item(d) * other.item(d);
703  return result;
704 }
705 
706 
707 
708 //
709 // Friend functions
710 //
711 
712 template <class T,int D>
713 inline
715  const AimsVector<T,D>& v2)
716 {
717  for (int d = 0; d < D; ++d)
718  if (v1.item(d) != v2.item(d))
719  return false;
720  return true;
721 }
722 
723 
724 template <class T,int D>
725 inline
727  const T& value)
728 {
729  for (int d = 0; d < D; ++d)
730  if (v1[d] != value)
731  return false;
732  return true;
733 }
734 
735 
736 template <class T,int D>
737 inline
739  const AimsVector<T,D> &v2)
740 {
741  AimsVector<T,D> result;
742  for (int d = 0; d < D; ++d)
743  result[d] = v1[d] + v2[d];
744  return result;
745 }
746 
747 
748 template <class T,int D>
749 inline
751  const AimsVector<T,D>& v2)
752 {
753  AimsVector<T,D> result;
754  for (int d = 0; d < D; ++d)
755  result[d] = v1[d] - v2[d];
756  return result;
757 }
758 
759 
760 template <class T,int D>
761 inline
763  double value )
764 {
765  AimsVector<T,D> result;
766  for (int d = 0; d < D; ++d)
767  result[d] = (T) ( v1[d] * value );
768  return result;
769 }
770 
771 
772 template <class T,int D>
773 inline
775  const AimsVector<T,D>& v1 )
776 {
777  AimsVector<T,D> result;
778  for (int d = 0; d < D; ++d)
779  result[d] = (T) ( v1[d] * value );
780  return result;
781 }
782 
783 
784 template <class T,int D>
785 inline
787  double value )
788 {
789  AimsVector<T,D> result;
790  for (int d = 0; d < D; ++d)
791  result[d] = (T) ( v1[d] / value );
792  return result;
793 }
794 
795 
796 template <class T,int D>
797 inline
799 {
800  return v1;
801 }
802 
803 
804 template <class T,int D>
805 inline
807 {
808  AimsVector<T,D> result;
809  for (int d = 0; d < D; ++d)
810  result[d] = -v1[d];
811  return result;
812 }
813 
814 
815 template <class T,int D>
816 inline
818  const AimsVector<T,D>& v2)
819 {
820  AimsVector<T,3> result;
821  result[0] = v1[1] * v2[2] - v1[2] * v2[1];
822  result[1] = v1[2] * v2[0] - v1[0] * v2[2];
823  result[2] = v1[0] * v2[1] - v1[1] * v2[0];
824  return result;
825 }
826 
827 
828 template <class T,int D>
829 inline
830 float norm(const AimsVector<T,D>& v1)
831 {
832  return v1.norm();
833 }
834 
835 
836 template <class T,int D>
837 inline
838 float norm2(const AimsVector<T,D>& v1)
839 {
840  return v1.norm2();
841 }
842 
843 template <class T,int D>
844 inline
845 double dnorm(const AimsVector<T,D>& v1)
846 {
847  return v1.dnorm();
848 }
849 
850 
851 template <class T,int D>
852 inline
853 double dnorm2(const AimsVector<T,D>& v1)
854 {
855  return v1.dnorm2();
856 }
857 
858 
859 template <class T,int D>
860 inline
861 std::ostream& operator << ( std::ostream& out,const AimsVector<T,D>& thing)
862 {
863  out << '(';
864  for (int d = 0; d < D-1 ; ++d)
865  out << thing.item(d) << " ,";
866  out << thing.item(D-1) << ')';
867  return(out);
868 }
869 
870 
871 template <int D>
872 inline
873 std::ostream& operator << ( std::ostream& out,const AimsVector<char,D>& thing)
874 {
875  out << '(';
876  for (int d = 0; d < D-1 ; ++d)
877  out << (int)thing.item(d) << " ,";
878  out << (int)thing.item(D-1) << ')';
879  return(out);
880 }
881 
882 
883 template <int D>
884 inline
885 std::ostream& operator << ( std::ostream& out,const AimsVector<byte,D>& thing)
886 {
887  out << '(';
888  for (int d = 0; d < D-1 ; ++d)
889  out << (int)thing.item(d) << " ,";
890  out << (int)thing.item(D-1) << ')';
891  return(out);
892 }
893 
894 
895 template <class T,int D>
896 inline
897 std::istream& operator >> (std::istream& is, AimsVector<T,D>& thing)
898 {
899  char ch = 0;
900 
901  //std::istream::sentry s( is ); // to use in the future...
902  carto::StreamUtil::skip( is );
903  if( !is )
904  return is;
905  if (is.peek() == '(')
906  {
907  is >> ch;
908  carto::StreamUtil::skip( is );
909  is >> thing.item(0);
910  for (int i = 1; i < D; ++i)
911  {
912  carto::StreamUtil::skip( is );
913  is >> ch;
914  if (ch != ',')
915  break;
916  carto::StreamUtil::skip( is );
917  is >> thing.item(i);
918  }
919  if( is )
920  {
921  carto::StreamUtil::skip( is );
922  is >> ch;
923  }
924  }
925 
926  if( ch != ')' )
927  std::cout << "vector read ends not with )\n";
928  //is.setstate (std::ios::failbit);
929 
930  return is;
931 }
932 
933 
934 template <int D>
935 inline
936 std::istream& operator >> (std::istream& is, AimsVector<char,D>& thing)
937 {
938  char ch = 0;
939  int tmp;
940 
941  //std::istream::sentry s( is ); // to use in the future...
942  carto::StreamUtil::skip( is );
943  if( !is )
944  return is;
945  if (is.peek() == '(')
946  {
947  is >> ch;
948  carto::StreamUtil::skip( is );
949  is >> tmp;
950  thing.item(0) = (char)tmp;
951  for (int i = 1; i < D; ++i)
952  {
953  carto::StreamUtil::skip( is );
954  is >> ch;
955  if (ch != ',')
956  break;
957  carto::StreamUtil::skip( is );
958  is >> tmp;
959  thing.item(i) = (char)tmp;
960  }
961  if( is )
962  {
963  carto::StreamUtil::skip( is );
964  is >> ch;
965  }
966  }
967 
968  if( ch != ')' )
969  is.setstate (std::ios::failbit);
970 
971  return is;
972 }
973 
974 
975 template <int D>
976 inline
977 std::istream& operator >> (std::istream& is, AimsVector<byte,D>& thing)
978 {
979  char ch = 0;
980  int tmp;
981 
982  //std::istream::sentry s( is ); // to use in the future...
983  carto::StreamUtil::skip( is );
984  if( !is )
985  return is;
986  if (is.peek() == '(')
987  {
988  is >> ch;
989  carto::StreamUtil::skip( is );
990  is >> tmp;
991  thing.item(0) = (byte)tmp;
992  for (int i = 1; i < D; ++i)
993  {
994  carto::StreamUtil::skip( is );
995  is >> ch;
996  if (ch != ',')
997  break;
998  carto::StreamUtil::skip( is );
999  is >> tmp;
1000  thing.item(i) = (byte)tmp;
1001  }
1002  if( is )
1003  {
1004  carto::StreamUtil::skip( is );
1005  is >> ch;
1006  }
1007  }
1008 
1009  if( ch != ')' )
1010  is.setstate (std::ios::failbit);
1011 
1012  return is;
1013 }
1014 
1015 
1016 
1017 template <typename T>
1018 inline
1020  const AimsVector<T,3> & v2 )
1021 {
1022  return AimsVector<T,3>( v1[1] * v2[2] - v1[2] * v2[1],
1023  v1[2] * v2[0] - v1[0] * v2[2],
1024  v1[0] * v2[1] - v1[1] * v2[0] );
1025 }
1026 
1027 
1028 #endif
#define DECLARE_GENERIC_OBJECT_TYPE(T)
AimsVector< uint32_t, 2 > Point2dui
Definition: vector.h:230
static void doit(T _value[D], const T &x, const T &y, const T &z, const T &t)
Definition: vector.h:415
float norm2() const
Return the square magnitude of the vector.
Definition: vector.h:667
AimsVector< double, 4 > Point4dd
Definition: vector.h:241
AimsVector< uint16_t, 2 > Point2dus
Definition: vector.h:227
const_iterator end() const
Definition: vector.h:199
AimsVector< int32_t, 2 > Point2di
Definition: vector.h:221
AimsVector< T, D > operator*(const AimsVector< T, D > &v1, double value)
Definition: vector.h:762
AimsVector< uint32_t, 3 > Point3du
Definition: vector.h:215
AimsVector< int16_t, 3 > Point3ds
Definition: vector.h:219
AimsVector< float, 4 > Point4df
Definition: vector.h:238
AimsVector< T, D > operator-(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
Definition: vector.h:750
static void doit(T _value[D], const T &x, const T &y)
Definition: vector.h:392
The template class to implement basic vectors.
Definition: vector.h:48
static void doit(T _value[2], const T &x, const T &y, const T &)
Definition: vector.h:460
AimsVector< uint32_t, 4 > Point4dui
Definition: vector.h:232
AimsVector< int64_t, 4 > Point4dl
Definition: vector.h:226
AimsVector< double, 3 > Point3dd
Definition: vector.h:240
bool operator!=(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
should be defined implicitely, but fails with some compilers (Intel)
Definition: vector.h:61
float norm2(const AimsVector< T, D > &v1)
Definition: vector.h:838
AimsVector< float, 2 > Point2df
Definition: vector.h:236
AimsVector< T, D > operator/(const AimsVector< T, D > &v1, double value)
Definition: vector.h:786
AimsVector< int16_t, 2 > Point2d
Definition: vector.h:211
AimsVector< T, D > & normalize()
Definition: vector.h:597
static void doit(T _value[1], const T &x, const T &)
Definition: vector.h:429
const_iterator begin() const
Definition: vector.h:197
AimsVector< T, 3 > crossed(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
Definition: vector.h:817
double dnorm2() const
Return the square magnitude of the vector.
Definition: vector.h:687
AimsVector< T, D > & operator/=(double val)
Definition: vector.h:587
bool operator==(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
Definition: vector.h:714
std::istream & operator>>(std::istream &in, AimsVector< T, D > &thing)
Definition: vector.h:897
AimsVector< int64_t, 2 > Point2dl
Definition: vector.h:224
double dnorm2(const AimsVector< T, D > &v1)
Definition: vector.h:853
static void doit(T _value[D], const T &x, const T &y, const T &z)
Definition: vector.h:403
T * iterator
Definition: vector.h:194
AimsVector< uint32_t, 3 > Point3dui
Definition: vector.h:231
bool isNull() const
Test if the vector is the null vector.
Definition: vector.h:647
AimsVector< int16_t, 4 > Point4d
Definition: vector.h:213
AimsVector< float, 3 > Point3df
Definition: vector.h:237
AimsVector< T, D > operator+(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
Definition: vector.h:738
const T * const_iterator
Definition: vector.h:195
AimsVector< T, D > & operator+=(const AimsVector< T, D > &other)
Definition: vector.h:557
double dnorm() const
Return the magnitude of the vector.
Definition: vector.h:677
float norm(const AimsVector< T, D > &v1)
Definition: vector.h:830
T _value[D]
Memory space allocated.
Definition: vector.h:204
static void doit(T _value[3], const T &x, const T &y, const T &z, const T &)
Definition: vector.h:483
AimsVector< T, D > & operator=(const AimsVector< T, D > &other)
Definition: vector.h:538
AimsVector()
The constructor allocates an appropriate amount of memory.
Definition: vector.h:363
static void doit(T _value[2], const T &x, const T &y, const T &, const T &)
Definition: vector.h:471
AimsVector< int16_t, 2 > Point2ds
Definition: vector.h:218
AimsVector< int32_t, 4 > Point4di
Definition: vector.h:223
AimsVector< uint64_t, 3 > Point3dul
Definition: vector.h:234
AimsVector< uint64_t, 2 > Point2dul
Definition: vector.h:233
const T & operator[](int d) const
Get a const reference to the dth item.
Definition: vector.h:614
AimsVector< int32_t, 3 > Point3di
Definition: vector.h:222
const T & item(int d) const
Get a const reference to the dth item.
Definition: vector.h:605
AimsVector< T, 3 > vectProduct(const AimsVector< T, 3 > &v1, const AimsVector< T, 3 > &v2)
Definition: vector.h:1019
AimsVector< int16_t, 3 > Point3d
Definition: vector.h:212
~AimsVector()
The destructor deletes the allocated memory space.
Definition: vector.h:550
AimsVector< uint64_t, 4 > Point4dul
Definition: vector.h:235
static void doit(T _value[1], const T &x, const T &, const T &, const T &)
Definition: vector.h:449
double dnorm(const AimsVector< T, D > &v1)
Definition: vector.h:845
AimsVector< uint32_t, 4 > Point4du
Definition: vector.h:216
iterator end()
Definition: vector.h:198
std::ostream & operator<<(std::ostream &out, const AimsVector< T, D > &thing)
Definition: vector.h:861
uint8_t byte
int size() const
Definition: vector.h:640
AimsVector< int64_t, 3 > Point3dl
Definition: vector.h:225
iterator begin()
Definition: vector.h:196
T dot(const AimsVector< T, D > &other) const
Get the dot product between 2 vectors.
Definition: vector.h:698
static void doit(T _value[1], const T &x, const T &, const T &)
Definition: vector.h:439
float norm() const
Return the magnitude of the vector.
Definition: vector.h:657
#define ASSERT(EX)
AimsVector< double, 2 > Point2dd
Definition: vector.h:239
AimsVector< int16_t, 4 > Point4ds
Definition: vector.h:220
AimsVector< T, D > & operator-=(const AimsVector< T, D > &other)
Definition: vector.h:567
AimsVector< uint16_t, 3 > Point3dus
Definition: vector.h:228
AimsVector< uint16_t, 4 > Point4dus
Definition: vector.h:229
AimsVector< uint32_t, 2 > Point2du
Definition: vector.h:214
AimsVector< T, D > & operator*=(double val)
Definition: vector.h:577