MeVisLab Toolbox Reference
mlIntegerVector.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_INTEGER_VECTOR_H
14 #define ML_INTEGER_VECTOR_H
15 
17 
18 // ML-includes
19 #include "mlLinearAlgebra.h"
20 #include <mlUtilsSystemC.h>
21 
22 
23 ML_START_NAMESPACE
24 
25  //-------------------------------------------------------------------------
27  //-------------------------------------------------------------------------
28  typedef int VectorDimIdxType;
29 
30  //-------------------------------------------------------------------------
36  //-------------------------------------------------------------------------
37  template <typename CompIntType, VectorDimIdxType NumDim>
39  {
40  public:
41 
43  typedef CompIntType ComponentType;
44 
46  enum { NumberOfDimensions = NumDim };
47 
50  ComponentType array[NumberOfDimensions];
51 
52  protected:
53 
58  };
59 
60  //-------------------------------------------------------------------------
64 
108  //-------------------------------------------------------------------------
109  template<class TVectorBase>
110  class TVector : public TVectorBase
111  {
112  public:
113 
115  typedef typename TVectorBase::ComponentType ComponentType;
116 
118  typedef TVectorBase ParentClass;
119 
121  enum { NumberOfDimensions = ParentClass::NumberOfDimensions };
122 
123 
124  //------------------------------------------------------
127  //------------------------------------------------------
130  {
131  memset(this->array, 0, static_cast<size_t>(NumberOfDimensions)*sizeof(ComponentType));
132  }
133 
135  explicit TVector(const ComponentType i) : ParentClass()
136  {
137  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d)
138  {
139  this->array[d]=i;
140  }
141  }
142 
143  // Even though the compiler should generate the copy constructor for us, gcc9+10 have a bug here, so implementation by hand again
145  {
146  *this = v2;
147  }
148 
150  {
151  for (VectorDimIdxType d = 0; d < NumberOfDimensions; ++d)
152  {
153  this->array[d] = v2.array[d];
154  }
155  return *this;
156  }
157 
160  template <typename TVectorBase2>
161  explicit TVector(const TVector<TVectorBase2> &v2) : ParentClass()
162  {
163  VectorDimIdxType numDims = NumberOfDimensions;
164  if (v2.NumberOfDimensions < numDims)
165  {
166  numDims = v2.NumberOfDimensions;
167  }
168  VectorDimIdxType d=0;
169  for (; d < numDims; ++d)
170  {
171  this->array[d] = static_cast<ComponentType>(v2.array[d]);
172  }
173  for (; d < NumberOfDimensions; ++d)
174  {
175  this->array[d] = 0;
176  }
177  }
178 
180  explicit TVector(const ComponentType xp, const TVector &p) : ParentClass()
181  {
182  this->array[0] = xp;
183  for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d){ this->array[d] = p.array[d]; }
184  }
185 
189  explicit TVector(const MLint num, const ComponentType* const arr, const ComponentType deflt);
190 
195  void copy(const MLint num, ComponentType* const arr) const;
196 
198  void set(const ComponentType v=0)
199  {
200  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d]=v; }
201  }
202 
204  void set(const TVector &v)
205  {
206  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] = v.array[d]; }
207  }
209 
210 
211  //------------------------------------------------------
214  //------------------------------------------------------
215 
218  {
219  return TVector<TVectorBase>(*this) += b;
220  }
223  {
224  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] += b.array[d]; }
225  return *this;
226  }
229  {
230  return TVector<TVectorBase>(*this) -= b;
231  }
234  {
235  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] -= b.array[d]; }
236  return *this;
237  }
240  {
241  return TVector<TVectorBase>(*this) *= b;
242  }
245  {
246  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] *= b.array[d]; }
247  return *this;
248  }
251  {
252  TVector<TVectorBase> retVec(*this);
253  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] += b; }
254  return retVec;
255  }
258  {
259  TVector<TVectorBase> retVec(*this);
260  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] -= b; }
261  return retVec;
262  }
265  {
266  TVector<TVectorBase> retVec(*this);
267  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] *= b; }
268  return retVec;
269  }
272  {
273  return TVector<TVectorBase>(*this) /= b;
274  }
277  {
278  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
279  ML_CHECK_THROW(b.array[d]);
280  this->array[d] /= b.array[d];
281  }
282  return *this;
283  }
286  bool operator== (const TVector<TVectorBase> &b) const
287  {
288  bool retFlag = true;
289  for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] == b.array[d]); }
290  return retFlag;
291  }
294  bool operator!= (const TVector<TVectorBase> &b) const
295  {
296  return !(*this == b);
297  }
298 
300  bool operator< (const TVector<TVectorBase> &b) const
301  {
302  bool retFlag = true;
303  for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] < b.array[d]); }
304  return retFlag;
305  }
307  bool operator<= (const TVector<TVectorBase> &b) const
308  {
309  bool retFlag = true;
310  for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] <= b.array[d]); }
311  return retFlag;
312  }
314  bool operator> (const TVector<TVectorBase> &b) const
315  {
316  bool retFlag = true;
317  for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] > b.array[d]); }
318  return retFlag;
319  }
321  bool operator>= (const TVector<TVectorBase> &b) const
322  {
323  bool retFlag = true;
324  for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] >= b.array[d]); }
325  return retFlag;
326  }
327 
330  {
331  return TVector<TVectorBase>(*this) &= b;
332  }
334  TVector<TVectorBase> operator| (const TVector<TVectorBase> &b) const
335  {
336  return TVector<TVectorBase>(*this) |= b;
337  }
340  {
341  return TVector<TVectorBase>(*this) ^= b;
342  }
343 
346  {
347  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] &= b.array[d]; }
348  return *this;
349  }
352  {
353  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] |= b.array[d]; }
354  return *this;
355  }
358  {
359  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] ^= b.array[d]; }
360  return *this;
361  }
362 
365  {
366  return TVector<TVectorBase>(*this) &= b;
367  }
369  TVector<TVectorBase> operator| (const ComponentType b) const
370  {
371  return TVector<TVectorBase>(*this) |= b;
372  }
375  {
376  return TVector<TVectorBase>(*this) ^= b;
377  }
378 
380  TVector<TVectorBase> &operator&= (const ComponentType b)
381  {
382  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] &= b; }
383  return *this;
384  }
386  TVector<TVectorBase> &operator|= (const ComponentType b)
387  {
388  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] |= b; }
389  return *this;
390  }
392  TVector<TVectorBase> &operator^= (const ComponentType b)
393  {
394  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] ^= b; }
395  return *this;
396  }
397 
400  {
401  return TVector<TVectorBase>(*this) >>= b;
402  }
404  TVector<TVectorBase> operator<< (const int b) const
405  {
406  return TVector<TVectorBase>(*this) <<= b;
407  }
408 
410  TVector<TVectorBase> &operator>>= (const int b)
411  {
412  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] >>= b; }
413  return *this;
414  }
416  TVector<TVectorBase> &operator<<= (const int b)
417  {
418  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] <<= b; }
419  return *this;
420  }
421 
424  {
425  TVector<TVectorBase> retVec(*this);
426  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] = -retVec.array[d]; }
427  return retVec;
428  }
429 
433  // Note: No tracing! No try, No catch! Do nothing here which could degrade performance!
434  ComponentType operator[](const size_t i) const { return this->array[i]; }
435 
439  // Note: No tracing! No try, No catch! Do nothing here which could degrade performance!
440  ComponentType &operator[](const size_t i) { return this->array[i]; }
441 
443  MLint getMaxIdx() const
444  {
445  VectorDimIdxType idx = NumberOfDimensions-1;
446  ComponentType val = this->array[idx];
447  for (VectorDimIdxType d=NumberOfDimensions-2; d >=0; d--){
448  if (this->array[d] >= val){ idx=d; val=this->array[d]; }
449  }
450  return idx;
451  }
452 
455  {
456  return this->array[getMaxIdx()];
457  }
458 
460  MLint getMinIdx() const
461  {
462  VectorDimIdxType idx = NumberOfDimensions-1;
463  ComponentType val = this->array[idx];
464  for (VectorDimIdxType d=NumberOfDimensions-2; d >= 0; d--){
465  if (this->array[d] <= val){ idx=d; val=this->array[d]; }
466  }
467  return idx;
468  }
469 
472  {
473  return this->array[getMinIdx()];
474  }
475 
482 
489 
493 
495  bool hasNegativeComp() const
496  {
497  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d]<0){ return true; } }
498  return false;
499  }
500 
502  bool allBiggerZero() const
503  {
504  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d]<=0){ return false; } }
505  return true;
506  }
508 
509 
510  //------------------------------------------------------
513  //------------------------------------------------------
514  // Methods:
527 
532 
534  ComponentType dot(const TVector<TVectorBase> &b) const { return TVector<TVectorBase>::dot(*this, b); }
535 
548 
551  {
552  ComponentType retVal = a.array[0];
553  for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d)
554  {
555  retVal *= a.array[d];
556  }
557  return retVal;
558  }
561  {
562  ComponentType retVal = a.array[0];
563  for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d)
564  {
565  retVal += a.array[d];
566  }
567  return retVal;
568  }
569 
570 
573  {
574  ComponentType retVal = a.array[0]*b.array[0];
575  for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d)
576  {
577  retVal += a.array[d]*b.array[d];
578  }
579  return retVal;
580  }
581 
583  void fillSmallerComps(const ComponentType threshold=0, const ComponentType fillVal=0)
584  {
585  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d)
586  {
587  if (this->array[d] < threshold)
588  {
589  this->array[d] = fillVal;
590  }
591  }
592  }
593 
595  void fillGreaterComps(const ComponentType threshold=0, const ComponentType fillVal=0)
596  {
597  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d] > threshold){ this->array[d] = fillVal; } }
598  }
599 
601  void fillEqualComps(const ComponentType threshold=0, const ComponentType fillVal=0)
602  {
603  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d] == threshold){ this->array[d] = fillVal; } }
604  }
606 
610  std::string print(const std::string &openStr="",
611  const std::string &sepStr=" ",
612  const std::string &termStr="",
613  const MLint16 numDigits=-1) const;
614 
615  };
616 
617 ML_END_NAMESPACE
618 
619 
620 //-----------------------------------------------------------------------------------
621 // Stream output for std::ostream
622 //-----------------------------------------------------------------------------------
623 namespace std {
624 
627  template <class TVectorBase>
628  ostream& operator<<(ostream& s, const ML_NAMESPACE::TVector<TVectorBase> &v){
629  s << "(";
630  for (ML_NAMESPACE::VectorDimIdxType d=0; d < ML_NAMESPACE::TVector<TVectorBase>::NumberOfDimensions-1; ++d){ s << v.array[d] << ","; }
631  s << v.array[ML_NAMESPACE::TVector<TVectorBase>::NumberOfDimensions-1];
632  s << ")";
633  return s;
634  }
635 
636 }
637 
638 
639 
640 ML_START_NAMESPACE
641 
642 
643  //------------------------------------------------------
644  // TVector<TVectorBase>
645  //------------------------------------------------------
646  // Constructor which initializes the vector components by copying them from
647  // arr[0] ,..., arr[num-1]. All other elements are initialized to
648  // the value deflt.
649  template <class TVectorBase>
650  TVector<TVectorBase>::TVector(const MLint num, const ComponentType* const arr, const ComponentType deflt) : ParentClass()
651  {
652  ML_CHECK_THROW(arr);
653  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] = (num>d ? arr[d] : deflt); }
654  }
655 
656  // Copies the first num elements from internal array into arr
657  // starting with array[0] to arr[0] to array[num-1] to arr[num-1], respectively.
658  // All other components are left unchanged.
659  // arr must have at least num entries and at most NumberOfDimensions elements are copied.
660  template <class TVectorBase>
661  void TVector<TVectorBase>::copy(const MLint num, ComponentType* const arr) const
662  {
663  ML_CHECK_THROW(arr);
664  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (num>d){ arr[d] = this->array[d]; } }
665  }
666 
667  // Interprets vector as image extent and returns a stride vector.
668  // The smallest stride (the x stride) is set to offset, i.e. an
669  // image voxel is assumed to have size = offset.
670  // So stride.x = offset, stride.y = offset*x, stride.z = offset*x*y, ...,
671  // stride.u=offset*x*y*z*c*t.
672  template <class TVectorBase>
674  {
675  TVector<TVectorBase> stride;
676  stride.array[0] = offset;
677  for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d){ stride.array[d] = stride.array[d-1] * this->array[d-1]; }
678  return stride;
679  }
680 
681  // Interprets the vector as a stride vector of an image and returns the offset
682  // position offsetPos from the image origin to the coordinate specified by
683  // the vector. For offsetPos, an image with extents given by *this and the return
684  // value rv then holds:
685  // \code offsetPos = rv.x*x + rv.y*y + ... + rv.u*u \endcode )
686  template <class TVectorBase>
688  {
689  TVector<TVectorBase> vectorPos;
690  for (VectorDimIdxType d=NumberOfDimensions-1; d>=1; d--){
691  ML_CHECK_THROW(this->array[d]);
692  vectorPos.array[d] = offsetPos / this->array[d];
693  offsetPos = offsetPos % this->array[d];
694  }
695  ML_CHECK_THROW(this->array[0]);
696  vectorPos.array[0] = offsetPos / this->array[0];
697 
698  return vectorPos;
699  }
700 
701  // Returns the highest vector component which is not 1. Useful to get the real dimension of an image.
702  template <class TVectorBase>
704  {
705  VectorDimIdxType dimen = 1;
706  for (VectorDimIdxType d=NumberOfDimensions-1; d >=1; d--){
707  if (1 != this->array[d]){
708  dimen = d+1;
709  break;
710  }
711  }
712  return dimen;
713  }
714 
715  // Returns the component wise division of the vector this by vector b with rounding up.
716  // Division by zero caused by zero components of b must be avoided by caller.
717  template <class TVectorBase>
719  {
721  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
722  ML_CHECK_THROW(b.array[d]);
723  c.array[d] = static_cast<ComponentType>(ceil(static_cast<MLdouble>(a.array[d])/b.array[d]));
724  }
725  return c;
726  }
727 
728 
729  // Returns the component wise minimum of TVector<TVectorBase>s this and b.
730  template <class TVectorBase>
732  {
734  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
735  if (a.array[d] < c.array[d]){ c.array[d] = a.array[d]; }
736  }
737  return c;
738  }
739 
740  // Returns the component wise maximum of vectors this and b.
741  template <class TVectorBase>
743  {
745  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
746  if (a.array[d] > c.array[d]){ c.array[d] = a.array[d]; }
747  }
748  return c;
749  }
750 
751  // Returns the rest dividing vector this a by b component wise.
752  // Division by zero caused by zero components of b must be avoided by caller and will
753  // be handled as fatal error exception otherwise.
754  template <class TVectorBase>
756  {
758  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
759  ML_CHECK_THROW(b.array[d]);
760  c.array[d] = a.array[d] % b.array[d];
761  }
762  return c;
763  }
764 
765  // Returns a vector with all components of a replaced by their absolute values.
766  template <class TVectorBase>
768  {
770  for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
771  if (c.array[d]<0){ c.array[d] = -c.array[d]; }
772  }
773  return c;
774  }
775 
776  // Returns the string openStr + v.x + sepStr + ... + v.t + sepStr + v.u + termStr.
777  // numDigits is the number of digits to be used as print parameter.
778  // If numDigits is <=0 then no space specification is used.
779  template <class TVectorBase>
780  std::string TVector<TVectorBase>::print(const std::string &openStr,
781  const std::string &sepStr,
782  const std::string &termStr,
783  const MLint16 numDigits) const
784  {
785  std::string result = openStr;
786  // 512 chars are sufficient, because MLint64 or even in future MLint
787  // as 128 bit version does not use more than 2^128 digits which are
788  // about 10^43.
789  char buf [512]="";
790  char frmt[100]="";
791 
792  // Create a format string with or without space specifications
793  // dependent on numDigits.
794  if (numDigits>=0){
795  snprintf(frmt, 99, "%%%dlld", numDigits);
796  }
797  else{
798  snprintf(frmt, 99, "%%lld");
799  }
800 
801  // Print all vector components with platform independent MLsnprintf,
802  // because MLint64 prints are needed and 64 bit integer print is
803  // platform dependent.
804  for (VectorDimIdxType d=0; d < NumberOfDimensions-1; ++d){
805  snprintf(buf, 511, frmt, this->array[d]);
806  result += buf + sepStr;
807  }
808  snprintf(buf, 511, frmt, this->array[NumberOfDimensions-1]);
809  result += buf + termStr;
810  return result;
811  }
812 
813 ML_END_NAMESPACE
814 
815 #endif //of __mlIntegerVector_H
816 
817 
CompIntType ComponentType
Integer type used by this vector.
Definition: mlImageVector.h:44
Declaration of integer vector type traits:
TVectorNDBase()
Do not allow a direct creation of this class as object, because this container does not initialize it...
CompIntType ComponentType
Integer type used by this vector.
ML integer image vector class to be specialized for different purposes.
ComponentType getMax() const
Returns the maximum component value.
void set(const ComponentType v=0)
Sets all components to v or - if v is not specified - to 0.
static TVector< TVectorBase > compAbs(const TVector< TVectorBase > &a)
Static version: Returns a vector with all components of a replaced by their absolute values.
static ComponentType compMul(const TVector< TVectorBase > &a)
Static version: Returns the product of all components without check for integer overflow.
static TVector< TVectorBase > divCeil(const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
Static version: Returns the component wise division of the vector a by vector b with rounding up.
bool allBiggerZero() const
Returns whether all components > 0.
MLint getMaxIdx() const
Searches the maximum component and returns the index of its first occurrence.
void fillGreaterComps(const ComponentType threshold=0, const ComponentType fillVal=0)
Sets the components which are greater than threshold to fillVal.
static TVector< TVectorBase > compMax(const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
Static version: Returns the component wise maximum of vectors a and b.
void set(const TVector &v)
Like assignment operator.
bool hasNegativeComp() const
Returns whether any component is negative.
TVector< TVectorBase > compMax(const TVector< TVectorBase > &b) const
Returns the component wise maximum of components of this and b.
void fillEqualComps(const ComponentType threshold=0, const ComponentType fillVal=0)
Sets the components which are equal to threshold to fillVal.
void fillSmallerComps(const ComponentType threshold=0, const ComponentType fillVal=0)
Sets the components which are smaller than threshold to fillVal.
TVector< TVectorBase > getStrides(const ComponentType offset=1) const
Interprets the vector as image extension and returns a stride vector.
TVector< TVectorBase > divCeil(const TVector< TVectorBase > &b) const
Returns the component wise division of the vector this by vector b with rounding up.
TVector< TVectorBase > compMin(const TVector< TVectorBase > &b) const
Returns the component wise minimum of components of this and b.
ComponentType dot(const TVector< TVectorBase > &b) const
Returns the scalar product of vectors this and b. There is no check for integer overflow.
TVector(const MLint num, const ComponentType *const arr, const ComponentType deflt)
Constructor which initializes the vector components by copying them from arr[0] ,....
static ComponentType dot(const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
Static version: Returns the scalar product of vectors a and b without check for integer overflow.
TVector< TVectorBase > & operator=(const TVector< TVectorBase > &v2)
MLint getExtDimension() const
Returns the index to the highest vector component which is not 1 which is useful to get the real dime...
TVectorBase ParentClass
Parent class of this class.
TVector(const TVector< TVectorBase > &v2)
std::string print(const std::string &openStr="", const std::string &sepStr=" ", const std::string &termStr="", const MLint16 numDigits=-1) const
Returns the string openStr + v.array[0] + sepStr + ...
TVector(const ComponentType i)
Constructor which initializes all components to i.
void copy(const MLint num, ComponentType *const arr) const
Copy the first num elements from internal array into arr starting with array[0] to arr[0] to array[nu...
MLint getMinIdx() const
Searches the minimum component and returns the index of its first occurrence.
TVector(const ComponentType xp, const TVector &p)
Constructor which assigns X to x and copies other elements from p.
ComponentType & operator[](const size_t i)
Indexing operator permits read and write access to array[0], ..., array[NumberOfDimensions-1] via ind...
static TVector< TVectorBase > compMod(const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
Static version: Returns the rest dividing vector a by b component wise.
ComponentType operator[](const size_t i) const
Constant indexing operator permits read access to array[0], ..., array[NumberOfDimensions-1] via inde...
TVector(const TVector< TVectorBase2 > &v2)
Copy constructor from another TVector of same or other integer type, values are cast.
TVectorBase::ComponentType ComponentType
Integer type used by this vector.
ComponentType compSum() const
Returns the sum of all components. There is no check for integer overflow.
TVector< TVectorBase > compAbs() const
Returns a vector with all components of this replaced by their absolute values.
ComponentType getMin() const
Returns the minimum component value.
static ComponentType compSum(const TVector< TVectorBase > &a)
Static version: Returns the sum of all components without check for integer overflow.
static TVector< TVectorBase > compMin(const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
Static version: Returns the component wise minimum of vectors a and b.
ComponentType compMul() const
Returns the product of all components. There is no check for integer overflow.
TVector< TVectorBase > compMod(const TVector< TVectorBase > &b) const
Returns the rest of the division of this by b component wise.
TVector()
Constructor. All components are initialized to 0.
TVector< TVectorBase > getVectorPosition(ComponentType offsetPos) const
Interprets the vector as a stride vector of an image and returns the offset position offsetPos from t...
#define ML_CHECK_THROW(x)
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
double MLdouble
Definition: mlTypeDefs.h:223
signed short MLint16
Definition: mlTypeDefs.h:131
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
std::istream & operator>>(std::istream &in, ml::Variant &variant)
Definition: mlVariant.h:215
ScopeGuard< Functor > operator+(ScopeGuardOnExit, Functor &&fn)
Definition: mlScopeGuard.h:82
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component wise division of lhs by specialized rhs of type MLdouble.
FloatingPointVector< T, size, DataContainer > compMax(FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2)
Component wise maximum of buffer1 and buffer2.
WEMBoundingBox MLWEM_EXPORT operator&(WEMBoundingBox x, const WEMBoundingBox &y)
Returns the united bounding box of x and y.
FloatingPointVector< T, size, DataContainer > & operator/=(FloatingPointVector< T, size, DataContainer > &op1, MLdouble value)
Arithmetic assignment: Component wise division of *this by scalar value.
FloatingPointVector< T, size, DataContainer > & operator-=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component wise subtraction of buffer from *this.
int VectorDimIdxType
Signed integer type used as count and index type to traverse the array of the TVector.
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Return true if yes.
Definition: mlMatrix2.h:425
T compMul(const FloatingPointVector< T, size, DataContainer > &vec)
Returns the product of all components.
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Return true if yes.
Definition: mlMatrix2.h:433
Tvec3< DT > operator^(const Tvec3< DT > &a, const Tvec3< DT2 > &b)
Returns a vector orthogonal to a and b.
Definition: mlVector3.h:282
FloatingPointVector< T, size, DataContainer > compMin(FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2)
Component wise minimum of buffer1 and buffer2.
FloatingPointVector< T, size, DataContainer > & operator+=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component wise addition.
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component wise subtraction of rhs from lhs.
FloatingPointVector< T, size, DataContainer > compAbs(FloatingPointVector< T, size, DataContainer > vec)
Returns a vector with all components from vec without negative sign.
FloatingPointVector< T, size, DataContainer > & operator*=(FloatingPointVector< T, size, DataContainer > &op1, MLdouble value)
Arithmetic assignment: Component wise multiplication *this with specialized MLdouble scalar value.