DGtal  1.1.0
PointVector.h
1 
17 #pragma once
18 
34 #if defined(PointVector_RECURSES)
35 #error Recursive header files inclusion detected in PointVector.h
36 #else // defined(PointVector_RECURSES)
37 
38 #define PointVector_RECURSES
39 
40 #if !defined PointVector_h
41 
42 #define PointVector_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <string>
48 #include <bitset>
49 #include <algorithm>
50 #include <array>
51 #include <vector>
52 #include <type_traits>
53 #include <utility>
54 #include <functional>
55 
56 #include "DGtal/base/Common.h"
57 #include "DGtal/base/CBidirectionalRange.h"
58 #include "DGtal/kernel/NumberTraits.h"
59 #include "DGtal/kernel/CEuclideanRing.h"
60 #include "DGtal/kernel/ArithmeticConversionTraits.h"
61 
63 
64 namespace DGtal
65 {
67  template<Dimension dim, typename Container>
68  std::bitset<dim> setDimensionsIn( const Container &dimensions );
69 
71  template<Dimension dim, typename Container>
72  std::bitset<dim> setDimensionsNotIn( const Container &dimensions );
73 
75  // class PointVector pre-declaration
162  template < DGtal::Dimension dim,
163  typename TEuclideanRing,
164  typename TContainer=std::array<TEuclideanRing,dim> >
165  class PointVector;
166 
168  // Type traits
169 
174  template <typename T>
175  struct IsAPointVector : std::false_type {};
176 
181  template <DGtal::Dimension dim, typename TEuclideanRing, typename TContainer>
182  struct IsAPointVector<PointVector<dim, TEuclideanRing, TContainer>> : std::true_type {};
183 
188  template < DGtal::Dimension dim,
189  typename LeftEuclideanRing, typename LeftContainer,
190  typename RightEuclideanRing, typename RightContainer >
191  struct ArithmeticConversionTraits< PointVector<dim, LeftEuclideanRing, LeftContainer>, PointVector<dim, RightEuclideanRing, RightContainer>,
192  typename std::enable_if< IsArithmeticConversionValid<LeftEuclideanRing, RightEuclideanRing>::value >::type >
193  {
194  using type = typename std::conditional<
195  std::is_same< LeftEuclideanRing, ArithmeticConversionType<LeftEuclideanRing, RightEuclideanRing> >::value,
198  };
199 
204  template < DGtal::Dimension dim,
205  typename LeftEuclideanRing, typename LeftContainer,
206  typename RightEuclideanRing >
207  struct ArithmeticConversionTraits< PointVector<dim, LeftEuclideanRing, LeftContainer>, RightEuclideanRing,
208  typename std::enable_if<
209  IsArithmeticConversionValid<LeftEuclideanRing, RightEuclideanRing>::value
210  && ! IsAPointVector<RightEuclideanRing>::value >::type >
211  {
212  using type = typename std::conditional<
213  std::is_same< LeftEuclideanRing, ArithmeticConversionType<LeftEuclideanRing, RightEuclideanRing> >::value,
216  };
217 
222  template < DGtal::Dimension dim,
223  typename LeftEuclideanRing,
224  typename RightEuclideanRing, typename RightContainer >
225  struct ArithmeticConversionTraits< LeftEuclideanRing, PointVector<dim, RightEuclideanRing, RightContainer>,
226  typename std::enable_if<
227  IsArithmeticConversionValid<LeftEuclideanRing, RightEuclideanRing>::value
228  && ! IsAPointVector<LeftEuclideanRing>::value >::type >
229  {
230  using type = typename std::conditional<
231  std::is_same< LeftEuclideanRing, ArithmeticConversionType<LeftEuclideanRing, RightEuclideanRing> >::value,
234  };
235 
236 
238  // PointVector comparison operators
239 
244  template < Dimension ptDim,
245  typename LeftEuclideanRing, typename LeftContainer,
246  typename RightEuclideanRing, typename RightContainer >
247  inline bool
250 
255  template < Dimension ptDim,
256  typename LeftEuclideanRing, typename LeftContainer,
257  typename RightEuclideanRing, typename RightContainer >
258  inline bool
261 
268  template < Dimension ptDim,
269  typename LeftEuclideanRing, typename LeftContainer,
270  typename RightEuclideanRing, typename RightContainer >
271  inline bool
274 
281  template < Dimension ptDim,
282  typename LeftEuclideanRing, typename LeftContainer,
283  typename RightEuclideanRing, typename RightContainer >
284  inline bool
287 
294  template < Dimension ptDim,
295  typename LeftEuclideanRing, typename LeftContainer,
296  typename RightEuclideanRing, typename RightContainer >
297  inline bool
300 
307  template < Dimension ptDim,
308  typename LeftEuclideanRing, typename LeftContainer,
309  typename RightEuclideanRing, typename RightContainer >
310  inline bool
313 
315  // Binary arithmetics operators between two PointVectors
316 
322  template < Dimension ptDim,
323  typename LeftEuclideanRing, typename LeftContainer,
324  typename RightEuclideanRing, typename RightContainer >
325  inline auto
328  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
329 
335  template < Dimension ptDim,
336  typename LeftEuclideanRing, typename LeftContainer,
337  typename RightEuclideanRing, typename RightContainer >
338  inline auto
341  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
342 
348  template < Dimension ptDim,
349  typename LeftEuclideanRing, typename LeftContainer,
350  typename RightEuclideanRing, typename RightContainer >
351  inline auto
354  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
355 
361  template < Dimension ptDim,
362  typename LeftEuclideanRing, typename LeftContainer,
363  typename RightEuclideanRing, typename RightContainer >
364  inline auto
367  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
368 
370  // Binary arithmetics operators between a PointVector and a scalar
371 
377  template < Dimension ptDim,
378  typename LeftEuclideanRing, typename LeftContainer,
379  typename RightScalar >
380  inline auto
382  RightScalar const& rhs )
383  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
384 
390  template < Dimension ptDim,
391  typename LeftScalar,
392  typename RightEuclideanRing, typename RightContainer >
393  inline auto
394  operator+ ( LeftScalar const& lhs,
396  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
397 
403  template < Dimension ptDim,
404  typename LeftEuclideanRing, typename LeftContainer,
405  typename RightScalar >
406  inline auto
408  RightScalar const& rhs )
409  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
410 
416  template < Dimension ptDim,
417  typename LeftScalar,
418  typename RightEuclideanRing, typename RightContainer >
419  inline auto
420  operator- ( LeftScalar const& lhs,
422  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
423 
429  template < Dimension ptDim,
430  typename LeftEuclideanRing, typename LeftContainer,
431  typename RightScalar >
432  inline auto
434  RightScalar const& rhs )
435  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
436 
442  template < Dimension ptDim,
443  typename LeftScalar,
444  typename RightEuclideanRing, typename RightContainer >
445  inline auto
446  operator* ( LeftScalar const& lhs,
448  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
449 
455  template < Dimension ptDim,
456  typename LeftEuclideanRing, typename LeftContainer,
457  typename RightScalar >
458  inline auto
460  RightScalar const& rhs )
461  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
462 
468  template < Dimension ptDim,
469  typename LeftScalar,
470  typename RightEuclideanRing, typename RightContainer >
471  inline auto
472  operator/ ( LeftScalar const& lhs,
474  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
475 
477  // Operations between Points/Vectors
478 
484  template < Dimension ptDim,
485  typename LeftEuclideanRing, typename LeftContainer,
486  typename RightEuclideanRing, typename RightContainer >
487  inline
491 
497  template <
498  typename LeftEuclideanRing, typename LeftContainer,
499  typename RightEuclideanRing, typename RightContainer >
500  inline auto
503  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
504 
510  template <
511  typename LeftEuclideanRing, typename LeftContainer,
512  typename RightEuclideanRing, typename RightContainer >
513  inline
517 
522  template < Dimension ptDim,
523  typename LeftEuclideanRing, typename LeftContainer,
524  typename RightEuclideanRing, typename RightContainer >
525  inline double
528 
538  template < Dimension ptDim,
539  typename LeftEuclideanRing, typename LeftContainer,
540  typename RightEuclideanRing, typename RightContainer >
541  inline auto
544  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
545 
555  template < Dimension ptDim,
556  typename LeftEuclideanRing, typename LeftContainer,
557  typename RightEuclideanRing, typename RightContainer >
558  inline auto
561  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
562 
568  template < Dimension ptDim,
569  typename LeftEuclideanRing, typename LeftContainer,
570  typename RightEuclideanRing, typename RightContainer >
571  inline bool
574 
580  template < Dimension ptDim,
581  typename LeftEuclideanRing, typename LeftContainer,
582  typename RightEuclideanRing, typename RightContainer >
583  inline bool
586 
588  // class PointVector full declaration
589  template < DGtal::Dimension dim,
590  typename TEuclideanRing,
591  typename TContainer >
593  {
594 
595  // Friend with all PointVectors
596  template <
597  DGtal::Dimension otherDim,
598  typename TOtherEuclideanRing,
599  typename TOtherContainer >
600  friend class PointVector;
601 
602  // ----------------------- Standard services ------------------------------
603  public:
604 
606 
609 
612 
614  typedef TEuclideanRing Component;
615 
618 
621 
624 
626  static const Dimension dimension = dim;
627 
629  typedef Component Scalar;
630  typedef Dimension Index;
631 
633  typedef TContainer Container;
634 
635 
640  typedef typename Container::iterator Iterator;
641  typedef typename Container::const_iterator ConstIterator;
642  typedef typename Container::reverse_iterator ReverseIterator;
643  typedef typename Container::const_reverse_iterator ConstReverseIterator;
644 
649 
656  explicit PointVector( const Component* ptrValues );
657 
665  PointVector( const Component & x, const Component & y );
666 
675  PointVector( const Component & x, const Component & y, const Component & z );
676 
686  PointVector( const Component & x, const Component & y,
687  const Component & z, const Component & t );
688 
693  PointVector( std::initializer_list<Component> init );
694 
700  template <
701  typename LeftComponent, typename LeftStorage,
702  typename RightComponent, typename RightStorage,
703  typename BinaryFunctor >
706  const BinaryFunctor& f );
707 
713  template <
714  typename OtherComponent, typename OtherStorage,
715  typename UnaryFunctor >
717  const UnaryFunctor & f );
718 
723 
724  // ----------------------- Standard services ------------------------------
725 
726  public:
731  PointVector( const Self & other );
732 
742  template <
743  typename OtherComponent, typename OtherCont,
744  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
746 
756  template <
757  typename OtherComponent, typename OtherCont,
758  typename std::enable_if< ! std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
759  explicit
761 
767  Self & operator= ( const Self & pv );
768 
780  template <
781  typename OtherComponent,
782  typename OtherContainer,
783  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
785 
803  template <
804  typename OtherComponent,
805  typename OtherContainer,
806  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
808  const std::vector<Dimension> &dimensions);
809 
827  template <
828  typename OtherComponent,
829  typename OtherContainer,
830  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
832  const std::vector<Dimension> &dimensions);
833 
849  template <
850  typename OtherComponent,
851  typename OtherContainer,
852  typename UnaryFunctor >
854  const std::vector<Dimension> & dimensions,
855  const UnaryFunctor & f);
856 
872  template <
873  typename OtherComponent,
874  typename OtherContainer,
875  typename UnaryFunctor >
877  const std::vector<Dimension> & dimensions,
878  const UnaryFunctor & f);
879 
892  template <
893  typename OtherComponent,
894  typename OtherContainer >
896  const std::vector<Dimension> &dimensions ) const;
897 
910  template <
911  typename OtherComponent,
912  typename OtherContainer >
914  const std::vector<Dimension> &dimensions ) const;
915 
916  // ----------------------- Iterator services ------------------------------
917  public:
924 
931 
938 
945 
952 
959 
966 
973 
979  inline const Component* data() const noexcept;
980  inline Component* data() noexcept;
981 
982  // ----------------------- Array services ------------------------------
983  public:
988  static Dimension size();
989  inline Dimension rows() const { return dim; }
990 
998  const Component& operator[]( Dimension i ) const;
999  inline const Component& operator()( Dimension i ) const { return (*this)[i]; }
1000 
1010  Component& operator()(Dimension i ) { return (*this)[i]; }
1011 
1012  // ----------------------- Comparison operations --------------------------
1013  // Friend declarations in order to have them documented on the same page
1014  // as PointVector.
1015  public:
1016 
1017  template < Dimension ptDim,
1018  typename LeftEuclideanRing, typename LeftContainer,
1019  typename RightEuclideanRing, typename RightContainer >
1020  friend inline bool
1023 
1024  template < Dimension ptDim,
1025  typename LeftEuclideanRing, typename LeftContainer,
1026  typename RightEuclideanRing, typename RightContainer >
1027  friend inline bool
1030 
1031  template < Dimension ptDim,
1032  typename LeftEuclideanRing, typename LeftContainer,
1033  typename RightEuclideanRing, typename RightContainer >
1034  friend inline bool
1037 
1038  template < Dimension ptDim,
1039  typename LeftEuclideanRing, typename LeftContainer,
1040  typename RightEuclideanRing, typename RightContainer >
1041  friend inline bool
1044 
1045  template < Dimension ptDim,
1046  typename LeftEuclideanRing, typename LeftContainer,
1047  typename RightEuclideanRing, typename RightContainer >
1048  friend inline bool
1051 
1052  // ------------- Binary arithmetic operations between points --------------
1053  // Friend declarations in order to have them documented on the same page
1054  // as PointVector.
1055  public:
1056 
1057  template < Dimension ptDim,
1058  typename LeftEuclideanRing, typename LeftContainer,
1059  typename RightEuclideanRing, typename RightContainer >
1060  friend inline auto
1063  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1064 
1065  template < Dimension ptDim,
1066  typename LeftEuclideanRing, typename LeftContainer,
1067  typename RightEuclideanRing, typename RightContainer >
1068  friend inline auto
1071  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1072 
1073  template < Dimension ptDim,
1074  typename LeftEuclideanRing, typename LeftContainer,
1075  typename RightEuclideanRing, typename RightContainer >
1076  friend inline auto
1079  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1080 
1081  template < Dimension ptDim,
1082  typename LeftEuclideanRing, typename LeftContainer,
1083  typename RightEuclideanRing, typename RightContainer >
1084  friend inline auto
1087  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1088 
1089  // ------ Binary arithmetic operations between a point and a vector -------
1090  // Friend declarations in order to have them documented on the same page
1091  // as PointVector.
1092  public:
1093 
1094  template < DGtal::Dimension ptDim,
1095  typename LeftEuclideanRing, typename LeftContainer,
1096  typename RightScalar >
1097  friend inline auto
1099  RightScalar const& rhs )
1100  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1101 
1102  template < Dimension ptDim,
1103  typename LeftScalar,
1104  typename RightEuclideanRing, typename RightContainer >
1105  friend inline auto
1106  operator+ ( LeftScalar const& lhs,
1108  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1109 
1110  template < DGtal::Dimension ptDim,
1111  typename LeftEuclideanRing, typename LeftContainer,
1112  typename RightScalar >
1113  friend inline auto
1115  RightScalar const& rhs )
1116  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1117 
1118  template < Dimension ptDim,
1119  typename LeftScalar,
1120  typename RightEuclideanRing, typename RightContainer >
1121  friend inline auto
1122  operator- ( LeftScalar const& lhs,
1124  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1125 
1126  template < DGtal::Dimension ptDim,
1127  typename LeftEuclideanRing, typename LeftContainer,
1128  typename RightScalar >
1129  friend inline auto
1131  RightScalar const& rhs )
1132  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1133 
1134  template < Dimension ptDim,
1135  typename LeftScalar,
1136  typename RightEuclideanRing, typename RightContainer >
1137  friend inline auto
1138  operator* ( LeftScalar const& lhs,
1140  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1141 
1142  template < DGtal::Dimension ptDim,
1143  typename LeftEuclideanRing, typename LeftContainer,
1144  typename RightScalar >
1145  friend inline auto
1147  RightScalar const& rhs )
1148  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1149 
1150  template < Dimension ptDim,
1151  typename LeftScalar,
1152  typename RightEuclideanRing, typename RightContainer >
1153  friend inline auto
1154  operator/ ( LeftScalar const& lhs,
1156  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1157 
1158  // -------- Unary arithmetic operations on a point or a vector ------------
1159  public:
1160 
1171  template <
1172  typename OtherComponent,
1173  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1174  inline
1175  PointVector & operator+= ( OtherComponent coeff );
1176 
1187  template <
1188  typename OtherComponent, typename OtherStorage,
1189  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1190  inline
1192 
1203  template <
1204  typename OtherComponent,
1205  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1206  inline
1207  PointVector & operator-= ( OtherComponent coeff );
1208 
1219  template <
1220  typename OtherComponent, typename OtherStorage,
1221  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1222  inline
1224 
1235  template <
1236  typename OtherComponent,
1237  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1238  inline
1239  PointVector & operator*= ( OtherComponent coeff );
1240 
1251  template <
1252  typename OtherComponent, typename OtherStorage,
1253  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1254  inline
1256 
1267  template <
1268  typename OtherComponent,
1269  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1270  inline
1271  PointVector & operator/= ( OtherComponent coeff );
1272 
1283  template <
1284  typename OtherComponent, typename OtherStorage,
1285  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1286  inline
1288 
1295  inline
1296  Self operator-() const;
1297 
1298 
1299  // ------------------ Other operators between vectors ---------------------
1300  public:
1309  template < typename OtherComponent, typename OtherStorage >
1310  inline auto
1312  -> decltype( DGtal::dotProduct(*this, v) );
1313 
1314  template < Dimension ptDim,
1315  typename LeftEuclideanRing, typename LeftContainer,
1316  typename RightEuclideanRing, typename RightContainer >
1317  friend inline
1321 
1333  template < typename OtherComponent, typename OtherStorage >
1334  inline auto
1336  -> decltype( DGtal::crossProduct(*this, v) );
1337 
1338  template <
1339  typename LeftEuclideanRing, typename LeftContainer,
1340  typename RightEuclideanRing, typename RightContainer >
1341  friend inline auto
1344  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1345 
1346  template <
1347  typename LeftEuclideanRing, typename LeftContainer,
1348  typename RightEuclideanRing, typename RightContainer >
1349  friend inline
1353 
1360  template < typename OtherComponent, typename OtherStorage >
1361  inline double
1363 
1364  template < Dimension ptDim,
1365  typename LeftEuclideanRing, typename LeftContainer,
1366  typename RightEuclideanRing, typename RightContainer >
1367  friend inline double
1370 
1381  template < typename OtherComponent, typename OtherStorage >
1382  inline auto
1384  -> decltype( DGtal::inf(*this, aPoint) );
1385 
1386  template < Dimension ptDim,
1387  typename LeftEuclideanRing, typename LeftContainer,
1388  typename RightEuclideanRing, typename RightContainer >
1389  friend inline auto
1392  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1393 
1404  template < typename OtherComponent, typename OtherStorage >
1405  inline auto
1407  -> decltype( DGtal::sup(*this, aPoint) );
1408 
1409  template < Dimension ptDim,
1410  typename LeftEuclideanRing, typename LeftContainer,
1411  typename RightEuclideanRing, typename RightContainer >
1412  friend inline auto
1415  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1416 
1423  template < typename OtherComponent, typename OtherStorage >
1425 
1426  template < Dimension ptDim,
1427  typename LeftEuclideanRing, typename LeftContainer,
1428  typename RightEuclideanRing, typename RightContainer >
1429  friend inline bool
1432 
1439  template < typename OtherComponent, typename OtherStorage >
1441 
1442  template < Dimension ptDim,
1443  typename LeftEuclideanRing, typename LeftContainer,
1444  typename RightEuclideanRing, typename RightContainer >
1445  friend inline bool
1448 
1454  Component max() const;
1455 
1461  Component min() const;
1462 
1470 
1478 
1482  void negate();
1483 
1488  enum NormType { L_2, L_1, L_infty };
1489 
1501  double norm( const NormType type = L_2 ) const;
1502 
1511  double squaredNorm( ) const;
1512 
1513 
1520 
1527 
1528 
1537 
1540  void reset();
1541 
1546  inline void clear() { reset(); }
1547 
1548 
1549 
1550  // ------------------------- Standard vectors ------------------------------
1551  public:
1552 
1557  static Self diagonal( Component val = 1 );
1558 
1564  static Self base( Dimension k, Component val = 1 );
1565 
1566  // --------------- CDrawableWithBoard2D realization -------------------
1567  public:
1568 
1572  std::string className() const;
1573 
1574  // ----------------------- Interface --------------------------------------
1575  public:
1576 
1581  void selfDisplay( std::ostream & out ) const;
1582 
1587  bool isValid() const;
1588 
1590  static Self zero;
1591 
1592  // ------------------------- Hidden services ------------------------------
1593  protected:
1594 
1597 
1598  }; // end of class PointVector
1599 
1601  template<Dimension dim, typename Component, typename TC>
1602  std::ostream&
1603  operator<<( std::ostream & out, const PointVector<dim, Component, TC> & object );
1604 
1606  template< Dimension dim, typename Component, typename TC>
1608 
1609 } // namespace DGtal
1610 
1612 // Includes inline functions
1613 #include "DGtal/kernel/PointVector.ih"
1614 
1615 // //
1617 
1618 #endif // !defined PointVector_h
1619 
1620 #undef PointVector_RECURSES
1621 #endif // else defined(PointVector_RECURSES)
DGtal::PointVector::sup
auto sup(const PointVector< dim, OtherComponent, OtherStorage > &aPoint) const -> decltype(DGtal::sup(*this, aPoint))
Implements the supremum (or least upper bound).
DGtal::PointVector::data
const Component * data() const noexcept
DGtal::PointVector::ConstReverseIterator
Container::const_reverse_iterator ConstReverseIterator
Constant reverse iterator type.
Definition: PointVector.h:643
DGtal::PointVector::Index
Dimension Index
Definition: PointVector.h:630
DGtal::PointVector::maxElement
Iterator maxElement()
DGtal::PointVector::zero
static Self zero
Static const for zero PointVector.
Definition: PointVector.h:1590
DGtal::PointVector::isUpper
bool isUpper(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is upper a given point.
DGtal::PointVector::Dimension
DGtal::Dimension Dimension
Copy of the dimension type.
Definition: PointVector.h:623
DGtal::PointVector::partialCopyInv
Self & partialCopyInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
DGtal::operator-
KForm< Calculus, order, duality > operator-(const KForm< Calculus, order, duality > &form_a, const KForm< Calculus, order, duality > &form_b)
DGtal::PointVector::operator/
friend auto operator/(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Division operator between two Points/Vectors.
DGtal::operator/
auto operator/(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Division operator between two Points/Vectors.
DGtal::PointVector::Self
PointVector< dim, TEuclideanRing, TContainer > Self
Self type.
Definition: PointVector.h:611
DGtal::PointVector::L_infty
@ L_infty
Definition: PointVector.h:1488
DGtal::PointVector::partialCopy
Self & partialCopy(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions, const UnaryFunctor &f)
Partial copy of a given PointVector using a functor.
DGtal::PointVector::Coordinate
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
DGtal::PointVector::PointVector
PointVector(const Component &x, const Component &y, const Component &z, const Component &t)
Constructor from four values (the Dimension of the vector should be at least 4). Other components are...
DGtal::cosineSimilarity
double cosineSimilarity(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Positive angle between two vectors, deduced from their scalar product.
DGtal::PointVector::PointVector
PointVector(const PointVector< dim, OtherComponent, OtherCont > &other)
Copy constructor from another component PointVector.
DGtal::PointVector::cosineSimilarity
friend double cosineSimilarity(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Positive angle between two vectors, deduced from their scalar product.
DGtal::dotProduct
DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > dotProduct(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Dot product between two points/vectors.
DGtal::IsAPointVector
Type trait to check if a given type is a PointVector.
Definition: PointVector.h:175
DGtal::PointVector::isUpper
friend bool isUpper(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Return true if the first point is upper the second point.
DGtal::PointVector::rows
Dimension rows() const
Definition: PointVector.h:989
aPoint
const Point aPoint(3, 4)
DGtal::ArithmeticConversionTraits< LeftEuclideanRing, PointVector< dim, RightEuclideanRing, RightContainer >, typename std::enable_if< IsArithmeticConversionValid< LeftEuclideanRing, RightEuclideanRing >::value &&! IsAPointVector< LeftEuclideanRing >::value >::type >::type
typename std::conditional< std::is_same< LeftEuclideanRing, ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > >::value, PointVector< dim, LeftEuclideanRing >, PointVector< dim, RightEuclideanRing, RightContainer > >::type type
Definition: PointVector.h:233
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:133
DGtal::PointVector::inf
auto inf(const PointVector< dim, OtherComponent, OtherStorage > &aPoint) const -> decltype(DGtal::inf(*this, aPoint))
Implements the infimum (or greatest lower bound).
DGtal::PointVector::operator*=
PointVector & operator*=(OtherComponent coeff)
Multiplies *this by the coeff scalar number.
DGtal::operator<=
bool operator<=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserOrEqualThan).
DGtal::PointVector::L_2
@ L_2
Definition: PointVector.h:1488
DGtal::PointVector::end
ConstIterator end() const
DGtal::PointVector::cosineSimilarity
double cosineSimilarity(const PointVector< dim, OtherComponent, OtherStorage > &v) const
Positive angle between two vectors, deduced from their scalar product.
DGtal::operator!=
bool operator!=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Difference operator on Points/Vectors.
DGtal::PointVector::normInfinity
UnsignedComponent normInfinity() const
dim
unsigned int dim(const Vector &z)
Definition: viewDualSurface.cpp:174
DGtal::PointVector::diagonal
static Self diagonal(Component val=1)
DGtal::operator>
bool operator>(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterThan).
DGtal::PointVector::partialCopy
Self & partialCopy(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
DGtal::inf
auto inf(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Implements the infimum (or greatest lower bound).
DGtal::PointVector::rbegin
ConstReverseIterator rbegin() const
DGtal::PointVector::L_1
@ L_1
Definition: PointVector.h:1488
DGtal::ArithmeticConversionType
typename ArithmeticConversionTraits< T, U >::type ArithmeticConversionType
Result type of arithmetic binary operators between two given types.
Definition: ArithmeticConversionTraits.h:135
DGtal::PointVector::norm1
UnsignedComponent norm1() const
DGtal::PointVector::Component
TEuclideanRing Component
Type for Vector elements.
Definition: PointVector.h:614
DGtal::PointVector::operator+
friend auto operator+(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Addition operator between two Points/Vectors.
DGtal::PointVector::base
static Self base(Dimension k, Component val=1)
DGtal::PointVector::rend
ConstReverseIterator rend() const
DGtal::PointVector::Container
TContainer Container
Copy of the container type.
Definition: PointVector.h:633
DGtal::PointVector::crossProduct
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
DGtal::PointVector::className
std::string className() const
DGtal::PointVector::operator[]
Component & operator[](Dimension i)
DGtal::PointVector::min
Component min() const
DGtal::ArithmeticConversionTraits< PointVector< dim, LeftEuclideanRing, LeftContainer >, RightEuclideanRing, typename std::enable_if< IsArithmeticConversionValid< LeftEuclideanRing, RightEuclideanRing >::value &&! IsAPointVector< RightEuclideanRing >::value >::type >::type
typename std::conditional< std::is_same< LeftEuclideanRing, ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > >::value, PointVector< dim, LeftEuclideanRing, LeftContainer >, PointVector< dim, RightEuclideanRing > >::type type
Definition: PointVector.h:215
DGtal::PointVector::PointVector
PointVector(std::initializer_list< Component > init)
Constructor from initializer list.
DGtal::PointVector::operator<=
friend bool operator<=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserOrEqualThan).
DGtal::PointVector::isValid
bool isValid() const
DGtal::PointVector::negate
void negate()
DGtal::PointVector::partialEqualInv
bool partialEqualInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) const
Partial inverse equality.
DGtal::setDimensionsNotIn
std::bitset< dim > setDimensionsNotIn(const Container &dimensions)
DGtal::operator+
Circulator< TIterator > operator+(typename IteratorCirculatorTraits< TIterator >::Difference d, Circulator< TIterator > &object)
Definition: Circulator.h:453
DGtal::PointVector::dotProduct
friend DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > dotProduct(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Dot product between two points/vectors.
DGtal::PointVector::crossProduct
friend PointVector< 3, DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > > crossProduct(PointVector< 2, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< 2, RightEuclideanRing, RightContainer > const &rhs)
Cross product of two 2D Points/Vectors.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::PointVector::operator=
Self & operator=(const Self &pv)
Assignement Operator.
DGtal::PointVector::PointVector
PointVector()
Constructor.
DGtal::PointVector::getNormalized
PointVector< dim, double, std::array< double, dim > > getNormalized() const
DGtal::operator>=
bool operator>=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterOrEqualThan).
DGtal::PointVector::operator[]
const Component & operator[](Dimension i) const
DGtal::PointVector::Scalar
Component Scalar
Types needed by CLinearAlgebraContainer.
Definition: PointVector.h:629
DGtal::ArithmeticConversionTraits< PointVector< dim, LeftEuclideanRing, LeftContainer >, PointVector< dim, RightEuclideanRing, RightContainer >, typename std::enable_if< IsArithmeticConversionValid< LeftEuclideanRing, RightEuclideanRing >::value >::type >::type
typename std::conditional< std::is_same< LeftEuclideanRing, ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > >::value, PointVector< dim, LeftEuclideanRing, LeftContainer >, PointVector< dim, RightEuclideanRing, RightContainer > >::type type
Definition: PointVector.h:197
DGtal::sup
auto sup(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Implements the supremum (or least upper bound).
DGtal::PointVector::operator()
Component & operator()(Dimension i)
Definition: PointVector.h:1010
DGtal::PointVector::max
Component max() const
DGtal::PointVector::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CEuclideanRing< TEuclideanRing >))
DGtal::concepts::CEuclideanRing
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...
Definition: CEuclideanRing.h:88
DGtal::PointVector::ConstIterator
Container::const_iterator ConstIterator
Constant iterator type.
Definition: PointVector.h:641
DGtal::PointVector::sup
friend auto sup(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Implements the supremum (or least upper bound).
DGtal::PointVector::end
Iterator end()
DGtal::PointVector::rend
ReverseIterator rend()
DGtal::isLower
bool isLower(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Return true if the first point is below the second point.
DGtal::PointVector::operator!=
friend bool operator!=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Difference operator on Points/Vectors.
DGtal::NumberTraitsImpl< std::decay< T >::type >::UnsignedVersion
std::decay< T >::type UnsignedVersion
Alias to the unsigned version of the number type.
Definition: NumberTraits.h:90
DGtal::PointVector::operator-
Self operator-() const
Unary minus operator.
DGtal::PointVector::operator==
friend bool operator==(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Equality operator between two Points/Vectors.
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::PointVector::begin
Iterator begin()
DGtal::isUpper
bool isUpper(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Return true if the first point is upper the second point.
DGtal::PointVector::PointVector
PointVector(const Component *ptrValues)
Constructor from array of values.
DGtal::PointVector::begin
ConstIterator begin() const
DGtal::PointVector::dimension
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Definition: PointVector.h:626
DGtal::PointVector::crossProduct
friend auto crossProduct(PointVector< 3, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< 3, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Cross product of two 3D Points/Vectors.
DGtal::PointVector::Iterator
Container::iterator Iterator
Mutable iterator type.
Definition: PointVector.h:640
DGtal::constructFromArithmeticConversion
ArithmeticConversionType< LHS, RHS > constructFromArithmeticConversion(LHS const &lhs, RHS const &rhs, Args &&... args)
Call constructor for the result type of an arithmetic operation.
Definition: ArithmeticConversionTraits.h:182
DGtal::PointVector::~PointVector
~PointVector()
Destructor.
DGtal::PointVector::squaredNorm
double squaredNorm() const
DGtal::PointVector::operator>=
friend bool operator>=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterOrEqualThan).
DGtal::PointVector::PointVector
PointVector(const PointVector< dim, OtherComponent, OtherStorage > &apoint1, const UnaryFunctor &f)
Constructor taking a point and a unary functor as parameters.
DGtal::PointVector::norm
double norm(const NormType type=L_2) const
DGtal::crossProduct
auto crossProduct(PointVector< 3, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< 3, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Cross product of two 3D Points/Vectors.
DGtal::PointVector::rbegin
ReverseIterator rbegin()
DGtal::PointVector::operator()
const Component & operator()(Dimension i) const
Definition: PointVector.h:999
DGtal::PointVector::ReverseIterator
Container::reverse_iterator ReverseIterator
Mutable reverse iterator type.
Definition: PointVector.h:642
DGtal::PointVector::operator<
friend bool operator<(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserThan).
DGtal::PointVector::dot
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal::PointVector< dim, Integer >::NormType
NormType
Definition: PointVector.h:1488
DGtal::setDimensionsIn
std::bitset< dim > setDimensionsIn(const Container &dimensions)
DGtal::PointVector::partialEqual
bool partialEqual(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) const
Partial equality.
DGtal::PointVector::clear
void clear()
Resets all the values to zero.
Definition: PointVector.h:1546
DGtal::PointVector::operator/=
PointVector & operator/=(OtherComponent coeff)
Divides *this by the coeff scalar number.
DGtal::operator*
KForm< Calculus, order, duality > operator*(const typename Calculus::Scalar &scalar, const KForm< Calculus, order, duality > &form)
DGtal::PointVector::minElement
Iterator minElement()
DGtal::operator==
bool operator==(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Equality operator between two Points/Vectors.
DGtal::PointVector::operator-=
PointVector & operator-=(OtherComponent coeff)
Subtracts the coeff scalar number to *this.
DGtal::PointVector::operator*
friend auto operator*(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Multiplication operator between two Points/Vectors.
DGtal::PointVector::operator+=
PointVector & operator+=(OtherComponent coeff)
Adds the coeff scalar number to *this.
DGtal::operator<
bool operator<(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserThan).
DGtal::PointVector::partialCopyInv
Self & partialCopyInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions, const UnaryFunctor &f)
Partial copy of a given PointVector using a functor.
DGtal::PointVector::myArray
Container myArray
Internal data-structure: std::array with constant size.
Definition: PointVector.h:1596
DGtal::PointVector::isLower
bool isLower(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is below a given point.
DGtal::PointVector::reset
void reset()
Resets all the values to zero.
DGtal::PointVector::UnsignedComponent
NumberTraits< Component >::UnsignedVersion UnsignedComponent
Unsigned version of the components.
Definition: PointVector.h:620
DGtal::PointVector::isLower
friend bool isLower(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Return true if the first point is below the second point.
DGtal::PointVector::PointVector
PointVector(const PointVector< dim, LeftComponent, LeftStorage > &apoint1, const PointVector< dim, RightComponent, RightStorage > &apoint2, const BinaryFunctor &f)
Constructor taking two points and a functor as parameters.
init
K init(Point(0, 0, 0), Point(512, 512, 512), true)
DGtal::ArithmeticConversionTraits
Aim: Trait class to get result type of arithmetic binary operators between two given types.
Definition: ArithmeticConversionTraits.h:93
DGtal::PointVector::PointVector
PointVector(const Self &other)
Copy constructor.
DGtal::PointVector::inf
friend auto inf(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Implements the infimum (or greatest lower bound).
DGtal::PointVector::PointVector
PointVector(const Component &x, const Component &y, const Component &z)
Constructor from three values (the Dimension of the vector should be at least 3). Other components ar...
DGtal::PointVector::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::PointVector::PointVector
PointVector(const Component &x, const Component &y)
Constructor from two values (the Dimension of the vector should be at least 2). Other components are ...