ML 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 <mlTypeTraits.h>
21#include <mlUtilsSystemC.h>
22
23
24ML_START_NAMESPACE
25
26 //-------------------------------------------------------------------------
28 //-------------------------------------------------------------------------
29 typedef int VectorDimIdxType;
30
31 //-------------------------------------------------------------------------
37 //-------------------------------------------------------------------------
38 template <typename CompIntType, VectorDimIdxType NumDim>
40 {
41 public:
42
44 typedef CompIntType ComponentType;
45
47 enum { NumberOfDimensions = NumDim };
48
51 ComponentType array[NumberOfDimensions];
52
53 protected:
54
59 };
60
61 //-------------------------------------------------------------------------
65
109 //-------------------------------------------------------------------------
110 template<class TVectorBase>
111 class TVector : public TVectorBase
112 {
113 public:
114
116 typedef typename TVectorBase::ComponentType ComponentType;
117
119 typedef TVectorBase ParentClass;
120
122 enum { NumberOfDimensions = ParentClass::NumberOfDimensions };
123
124
125 //------------------------------------------------------
128 //------------------------------------------------------
131 {
132 memset(this->array, 0, static_cast<size_t>(NumberOfDimensions)*sizeof(ComponentType));
133 }
134
136 explicit TVector(const ComponentType i) : ParentClass()
137 {
138 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d)
139 {
140 this->array[d]=i;
141 }
142 }
143
144 // Even though the compiler should generate the copy constructor for us, gcc9+10 have a bug here, so implementation by hand again
146 {
147 *this = v2;
148 }
149
151 {
152 for (VectorDimIdxType d = 0; d < NumberOfDimensions; ++d)
153 {
154 this->array[d] = v2.array[d];
155 }
156 return *this;
157 }
158
161 template <typename TVectorBase2>
163 {
164 VectorDimIdxType numDims = NumberOfDimensions;
165 if (v2.NumberOfDimensions < numDims)
166 {
167 numDims = v2.NumberOfDimensions;
168 }
170 for (; d < numDims; ++d)
171 {
172 this->array[d] = static_cast<ComponentType>(v2.array[d]);
173 }
174 for (; d < NumberOfDimensions; ++d)
175 {
176 this->array[d] = 0;
177 }
178 }
179
181 explicit TVector(const ComponentType xp, const TVector &p) : ParentClass()
182 {
183 this->array[0] = xp;
184 for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d){ this->array[d] = p.array[d]; }
185 }
186
190 explicit TVector(const MLint num, const ComponentType* const arr, const ComponentType deflt);
191
196 void copy(const MLint num, ComponentType* const arr) const;
197
199 void set(const ComponentType v=0)
200 {
201 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d]=v; }
202 }
203
205 void set(const TVector &v)
206 {
207 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] = v.array[d]; }
208 }
210
211
212 //------------------------------------------------------
215 //------------------------------------------------------
216
218 TVector<TVectorBase> operator+ (const TVector &b) const
219 {
220 return TVector<TVectorBase>(*this) += b;
221 }
224 {
225 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] += b.array[d]; }
226 return *this;
227 }
230 {
231 return TVector<TVectorBase>(*this) -= b;
232 }
235 {
236 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] -= b.array[d]; }
237 return *this;
238 }
241 {
242 return TVector<TVectorBase>(*this) *= b;
243 }
246 {
247 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] *= b.array[d]; }
248 return *this;
249 }
251 TVector<TVectorBase> operator+ (const ComponentType b) const
252 {
253 TVector<TVectorBase> retVec(*this);
254 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] += b; }
255 return retVec;
256 }
258 TVector<TVectorBase> operator- (const ComponentType b) const
259 {
260 TVector<TVectorBase> retVec(*this);
261 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] -= b; }
262 return retVec;
263 }
265 TVector<TVectorBase> operator* (const ComponentType b) const
266 {
267 TVector<TVectorBase> retVec(*this);
268 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] *= b; }
269 return retVec;
270 }
273 {
274 return TVector<TVectorBase>(*this) /= b;
275 }
278 {
279 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
280 ML_CHECK_THROW(b.array[d]);
281 this->array[d] /= b.array[d];
282 }
283 return *this;
284 }
287 bool operator== (const TVector<TVectorBase> &b) const
288 {
289 bool retFlag = true;
290 for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] == b.array[d]); }
291 return retFlag;
292 }
295 bool operator!= (const TVector<TVectorBase> &b) const
296 {
297 return !(*this == b);
298 }
299
301 bool operator< (const TVector<TVectorBase> &b) const
302 {
303 bool retFlag = true;
304 for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] < b.array[d]); }
305 return retFlag;
306 }
308 bool operator<= (const TVector<TVectorBase> &b) const
309 {
310 bool retFlag = true;
311 for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] <= b.array[d]); }
312 return retFlag;
313 }
315 bool operator> (const TVector<TVectorBase> &b) const
316 {
317 bool retFlag = true;
318 for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] > b.array[d]); }
319 return retFlag;
320 }
322 bool operator>= (const TVector<TVectorBase> &b) const
323 {
324 bool retFlag = true;
325 for (VectorDimIdxType d=0; retFlag && (d < NumberOfDimensions); ++d){ retFlag = retFlag && (this->array[d] >= b.array[d]); }
326 return retFlag;
327 }
328
331 {
332 return TVector<TVectorBase>(*this) &= b;
333 }
336 {
337 return TVector<TVectorBase>(*this) |= b;
338 }
341 {
342 return TVector<TVectorBase>(*this) ^= b;
343 }
344
347 {
348 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] &= b.array[d]; }
349 return *this;
350 }
353 {
354 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] |= b.array[d]; }
355 return *this;
356 }
359 {
360 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] ^= b.array[d]; }
361 return *this;
362 }
363
365 TVector<TVectorBase> operator& (const ComponentType b) const
366 {
367 return TVector<TVectorBase>(*this) &= b;
368 }
370 TVector<TVectorBase> operator| (const ComponentType b) const
371 {
372 return TVector<TVectorBase>(*this) |= b;
373 }
375 TVector<TVectorBase> operator^ (const ComponentType b) const
376 {
377 return TVector<TVectorBase>(*this) ^= b;
378 }
379
382 {
383 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] &= b; }
384 return *this;
385 }
388 {
389 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] |= b; }
390 return *this;
391 }
394 {
395 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] ^= b; }
396 return *this;
397 }
398
400 TVector<TVectorBase> operator>> (const int b) const
401 {
402 return TVector<TVectorBase>(*this) >>= b;
403 }
405 TVector<TVectorBase> operator<< (const int b) const
406 {
407 return TVector<TVectorBase>(*this) <<= b;
408 }
409
411 TVector<TVectorBase> &operator>>= (const int b)
412 {
413 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] >>= b; }
414 return *this;
415 }
417 TVector<TVectorBase> &operator<<= (const int b)
418 {
419 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] <<= b; }
420 return *this;
421 }
422
424 TVector<TVectorBase> operator- () const
425 {
426 TVector<TVectorBase> retVec(*this);
427 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ retVec.array[d] = -retVec.array[d]; }
428 return retVec;
429 }
430
434 // Note: No tracing! No try, No catch! Do nothing here which could degrade performance!
435 ComponentType operator[](const size_t i) const { return this->array[i]; }
436
440 // Note: No tracing! No try, No catch! Do nothing here which could degrade performance!
441 ComponentType &operator[](const size_t i) { return this->array[i]; }
442
445 {
446 VectorDimIdxType idx = NumberOfDimensions-1;
447 ComponentType val = this->array[idx];
448 for (VectorDimIdxType d=NumberOfDimensions-2; d >=0; d--){
449 if (this->array[d] >= val){ idx=d; val=this->array[d]; }
450 }
451 return idx;
452 }
453
456 {
457 return this->array[getMaxIdx()];
458 }
459
462 {
463 VectorDimIdxType idx = NumberOfDimensions-1;
464 ComponentType val = this->array[idx];
465 for (VectorDimIdxType d=NumberOfDimensions-2; d >= 0; d--){
466 if (this->array[d] <= val){ idx=d; val=this->array[d]; }
467 }
468 return idx;
469 }
470
473 {
474 return this->array[getMinIdx()];
475 }
476
483
490
494
496 bool hasNegativeComp() const
497 {
498 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d]<0){ return true; } }
499 return false;
500 }
501
503 bool allBiggerZero() const
504 {
505 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d]<=0){ return false; } }
506 return true;
507 }
508
511 {
512 double product = 1.0;
513 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d)
514 {
515 product *= ((double) this->array[d]);
516 }
518 }
520
521
522 //------------------------------------------------------
525 //------------------------------------------------------
526 // Methods:
539
544
547
560
563 {
564 ComponentType retVal = a.array[0];
565 for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d)
566 {
567 retVal *= a.array[d];
568 }
569 return retVal;
570 }
573 {
574 ComponentType retVal = a.array[0];
575 for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d)
576 {
577 retVal += a.array[d];
578 }
579 return retVal;
580 }
581
582
585 {
586 ComponentType retVal = a.array[0]*b.array[0];
587 for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d)
588 {
589 retVal += a.array[d]*b.array[d];
590 }
591 return retVal;
592 }
593
595 void fillSmallerComps(const ComponentType threshold=0, const ComponentType fillVal=0)
596 {
597 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d)
598 {
599 if (this->array[d] < threshold)
600 {
601 this->array[d] = fillVal;
602 }
603 }
604 }
605
607 void fillGreaterComps(const ComponentType threshold=0, const ComponentType fillVal=0)
608 {
609 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d] > threshold){ this->array[d] = fillVal; } }
610 }
611
613 void fillEqualComps(const ComponentType threshold=0, const ComponentType fillVal=0)
614 {
615 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (this->array[d] == threshold){ this->array[d] = fillVal; } }
616 }
618
622 std::string print(const std::string &openStr="",
623 const std::string &sepStr=" ",
624 const std::string &termStr="",
625 const MLint16 numDigits=-1) const;
626
627 };
628
629ML_END_NAMESPACE
630
631
632//-----------------------------------------------------------------------------------
633// Stream output for std::ostream
634//-----------------------------------------------------------------------------------
635namespace std {
636
639 template <class TVectorBase>
640 ostream& operator<<(ostream& s, const ML_NAMESPACE::TVector<TVectorBase> &v){
641 s << "(";
642 for (ML_NAMESPACE::VectorDimIdxType d=0; d < ML_NAMESPACE::TVector<TVectorBase>::NumberOfDimensions-1; ++d){ s << v.array[d] << ","; }
643 s << v.array[ML_NAMESPACE::TVector<TVectorBase>::NumberOfDimensions-1];
644 s << ")";
645 return s;
646 }
647
648}
649
650
651
652ML_START_NAMESPACE
653
654
655 //------------------------------------------------------
656 // TVector<TVectorBase>
657 //------------------------------------------------------
658 // Constructor which initializes the vector components by copying them from
659 // arr[0] ,..., arr[num-1]. All other elements are initialized to
660 // the value deflt.
661 template <class TVectorBase>
662 TVector<TVectorBase>::TVector(const MLint num, const ComponentType* const arr, const ComponentType deflt) : ParentClass()
663 {
664 ML_CHECK_THROW(arr);
665 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ this->array[d] = (num>d ? arr[d] : deflt); }
666 }
667
668 // Copies the first num elements from internal array into arr
669 // starting with array[0] to arr[0] to array[num-1] to arr[num-1], respectively.
670 // All other components are left unchanged.
671 // arr must have at least num entries and at most NumberOfDimensions elements are copied.
672 template <class TVectorBase>
673 void TVector<TVectorBase>::copy(const MLint num, ComponentType* const arr) const
674 {
675 ML_CHECK_THROW(arr);
676 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){ if (num>d){ arr[d] = this->array[d]; } }
677 }
678
679 // Interprets vector as image extent and returns a stride vector.
680 // The smallest stride (the x stride) is set to offset, i.e. an
681 // image voxel is assumed to have size = offset.
682 // So stride.x = offset, stride.y = offset*x, stride.z = offset*x*y, ...,
683 // stride.u=offset*x*y*z*c*t.
684 template <class TVectorBase>
686 {
688 stride.array[0] = offset;
689 for (VectorDimIdxType d=1; d < NumberOfDimensions; ++d){ stride.array[d] = stride.array[d-1] * this->array[d-1]; }
690 return stride;
691 }
692
693 // Interprets the vector as a stride vector of an image and returns the offset
694 // position offsetPos from the image origin to the coordinate specified by
695 // the vector. For offsetPos, an image with extents given by *this and the return
696 // value rv then holds:
697 // \code offsetPos = rv.x*x + rv.y*y + ... + rv.u*u \endcode )
698 template <class TVectorBase>
700 {
701 TVector<TVectorBase> vectorPos;
702 for (VectorDimIdxType d=NumberOfDimensions-1; d>=1; d--){
703 ML_CHECK_THROW(this->array[d]);
704 vectorPos.array[d] = offsetPos / this->array[d];
705 offsetPos = offsetPos % this->array[d];
706 }
707 ML_CHECK_THROW(this->array[0]);
708 vectorPos.array[0] = offsetPos / this->array[0];
709
710 return vectorPos;
711 }
712
713 // Returns the highest vector component which is not 1. Useful to get the real dimension of an image.
714 template <class TVectorBase>
716 {
717 VectorDimIdxType dimen = 1;
718 for (VectorDimIdxType d=NumberOfDimensions-1; d >=1; d--){
719 if (1 != this->array[d]){
720 dimen = d+1;
721 break;
722 }
723 }
724 return dimen;
725 }
726
727 // Returns the component wise division of the vector this by vector b with rounding up.
728 // Division by zero caused by zero components of b must be avoided by caller.
729 template <class TVectorBase>
731 {
733 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
734 ML_CHECK_THROW(b.array[d]);
735 c.array[d] = static_cast<ComponentType>(ceil(static_cast<MLdouble>(a.array[d])/b.array[d]));
736 }
737 return c;
738 }
739
740
741 // Returns the component wise minimum of TVector<TVectorBase>s this and b.
742 template <class TVectorBase>
744 {
746 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
747 if (a.array[d] < c.array[d]){ c.array[d] = a.array[d]; }
748 }
749 return c;
750 }
751
752 // Returns the component wise maximum of vectors this and b.
753 template <class TVectorBase>
755 {
757 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
758 if (a.array[d] > c.array[d]){ c.array[d] = a.array[d]; }
759 }
760 return c;
761 }
762
763 // Returns the rest dividing vector this a by b component wise.
764 // Division by zero caused by zero components of b must be avoided by caller and will
765 // be handled as fatal error exception otherwise.
766 template <class TVectorBase>
768 {
770 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
771 ML_CHECK_THROW(b.array[d]);
772 c.array[d] = a.array[d] % b.array[d];
773 }
774 return c;
775 }
776
777 // Returns a vector with all components of a replaced by their absolute values.
778 template <class TVectorBase>
780 {
782 for (VectorDimIdxType d=0; d < NumberOfDimensions; ++d){
783 if (c.array[d]<0){ c.array[d] = -c.array[d]; }
784 }
785 return c;
786 }
787
788 // Returns the string openStr + v.x + sepStr + ... + v.t + sepStr + v.u + termStr.
789 // numDigits is the number of digits to be used as print parameter.
790 // If numDigits is <=0 then no space specification is used.
791 template <class TVectorBase>
792 std::string TVector<TVectorBase>::print(const std::string &openStr,
793 const std::string &sepStr,
794 const std::string &termStr,
795 const MLint16 numDigits) const
796 {
797 std::string result = openStr;
798 // 512 chars are sufficient, because MLint64 or even in future MLint
799 // as 128 bit version does not use more than 2^128 digits which are
800 // about 10^43.
801 char buf [512]="";
802 char frmt[100]="";
803
804 // Create a format string with or without space specifications
805 // dependent on numDigits.
806 if (numDigits>=0){
807 snprintf(frmt, 99, "%%%dlld", numDigits);
808 }
809 else{
810 snprintf(frmt, 99, "%%lld");
811 }
812
813 for (VectorDimIdxType d=0; d < NumberOfDimensions-1; ++d){
814 snprintf(buf, 511, frmt, this->array[d]);
815 result += buf + sepStr;
816 }
817 snprintf(buf, 511, frmt, this->array[NumberOfDimensions-1]);
818 result += buf + termStr;
819 return result;
820 }
821
822ML_END_NAMESPACE
823
824#endif //of __mlIntegerVector_H
825
826
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.
TVector< TVectorBase > compMin(const TVector< TVectorBase > &b) const
Returns the component wise minimum of components of this and b.
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.
TVector< TVectorBase > compMax(const TVector< TVectorBase > &b) const
Returns the component wise maximum of components of this and b.
void set(const TVector &v)
Like assignment operator.
bool hasNegativeComp() const
Returns whether any component is negative.
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 > & operator=(const TVector< TVectorBase > &v2)
TVector< TVectorBase > getStrides(const ComponentType offset=1) const
Interprets the vector as image extension and returns a stride vector.
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 > compAbs() const
Returns a vector with all components of this replaced by their absolute values.
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.
bool sanityCheckNumberOfVoxels() const
Returns whether product of all components is in range of integer type.
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 + ... + v.array[NumberOfDimensions-2] + sepStr + v....
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.
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.
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.
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 > compMod(const TVector< TVectorBase > &b) const
Returns the rest of the division of this by b component wise.
ComponentType compMul() const
Returns the product of all components. There is no check for integer overflow.
ComponentType & operator[](const size_t i)
Indexing operator permits read and write access to array[0], ..., array[NumberOfDimensions-1] via ind...
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)
double MLdouble
Definition mlTypeDefs.h:217
signed short MLint16
Definition mlTypeDefs.h:125
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490
int VectorDimIdxType
Signed integer type used as count and index type to traverse the array of the TVector.
STL namespace.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
Define a template to get the min and max values for each basic integer type.