20 #ifndef _vctDynamicConstVectorBase_h
21 #define _vctDynamicConstVectorBase_h
47 template <
class _vectorOwnerType,
class __vectorOwnerType,
class _elementType,
48 class _elementOperationType>
53 template <
class _vectorOwnerType,
class _elementType,
54 class _elementOperationType>
57 const _elementType & scalar);
76 template <
class _vectorOwnerType,
typename _elementType>
132 cmnThrow(std::out_of_range(
"vctDynamicVector: Invalid index"));
176 return (
size() == 0);
190 const_reference
at(
size_type index)
const throw(std::out_of_range) {
197 return this->
at(index);
222 return Vector.Pointer(index);
228 return (index <
size());
243 const value_type &
X(
void)
const {
251 const value_type &
Y(
void)
const {
259 const value_type &
Z(
void)
const {
266 const value_type &
W(
void)
const {
347 if ((startPosition + size) > this->
size()) {
348 cmnThrow(std::out_of_range(
"vctDynamicConstVectorBase::Ref: reference is out of range"));
386 inline NormType
Norm(
void)
const {
536 inline bool All(
void)
const {
545 inline bool Any(
void)
const {
579 return (this->
stride() == 1);
591 template <
class __vectorOwnerType>
599 template <
size_type __size, str
ide_type __str
ide,
class __dataPtrType>
612 template <
class __vectorOwnerType>
617 Run(*
this, otherVector);
636 template <
class __vectorOwnerType>
641 Run(*
this, otherVector);
645 template <
class __vectorOwnerType>
647 return Equal(otherVector);
651 template <
class __vectorOwnerType>
653 value_type tolerance)
const {
654 return ((*
this - otherVector).
LinfNorm() <= tolerance);
658 template <
class __vectorOwnerType>
664 template <
class __vectorOwnerType>
669 Run(*
this, otherVector);
673 template <
class __vectorOwnerType>
679 template <
class __vectorOwnerType>
684 Run(*
this, otherVector);
688 template <
class __vectorOwnerType>
693 Run(*
this, otherVector);
697 template <
class __vectorOwnerType>
702 Run(*
this, otherVector);
706 template <
class __vectorOwnerType>
711 Run(*
this, otherVector);
731 template <
class __vectorOwnerType>
735 _vectorOwnerType, __vectorOwnerType, value_type,
741 template <
class __vectorOwnerType>
745 _vectorOwnerType, __vectorOwnerType, value_type,
750 template <
class __vectorOwnerType>
754 _vectorOwnerType, __vectorOwnerType, value_type,
759 template <
class __vectorOwnerType>
763 _vectorOwnerType, __vectorOwnerType, value_type,
768 template <
class __vectorOwnerType>
772 _vectorOwnerType, __vectorOwnerType, value_type,
777 template <
class __vectorOwnerType>
781 _vectorOwnerType, __vectorOwnerType, value_type,
802 inline bool Equal(
const value_type & scalar)
const {
811 return Equal(scalar);
815 inline bool NotEqual(
const value_type & scalar)
const {
828 inline bool Lesser(
const value_type & scalar)
const {
844 inline bool Greater(
const value_type & scalar)
const {
945 std::stringstream outputStream;
947 return outputStream.str();
955 const std::streamsize width = outputStream.width(12);
956 const std::streamsize precision = outputStream.precision(6);
957 bool showpoint = ((outputStream.flags() & std::ios_base::showpoint) != 0);
958 outputStream << std::setprecision(6) << std::showpoint;
959 for (index = 0; index < mySize; ++index) {
960 outputStream << std::setw(12) << (*this)[index];
961 if (index < (mySize-1)) {
966 outputStream << std::setprecision(precision) << std::setw(width);
968 outputStream << std::noshowpoint;
973 void ToStreamRaw(std::ostream & outputStream,
const char delimiter =
' ',
974 bool headerOnly =
false,
const std::string & headerPrefix =
"")
const
979 for (index = 0; index < mySize; ++index) {
980 outputStream << headerPrefix <<
"-v" << index;
981 if (index < (mySize-1)) {
982 outputStream << delimiter;
986 for (index = 0; index < mySize; ++index) {
987 outputStream << (*this)[index];
988 if (index < (mySize-1)) {
989 outputStream << delimiter;
1001 for (index = 0; index < mySize; ++index) {
1011 template <
class _vectorOwnerType,
class _elementType>
1019 template <
class _vectorOwnerType,
class _elementType>
1027 template <
class _vectorOwnerType,
class _elementType>
1035 template <
class _vectorOwnerType,
class _elementType>
1043 template <
class _vectorOwnerType,
class _elementType>
1051 template <
class _vectorOwnerType,
class _elementType>
1066 template <
class _vector1OwnerType,
class _vector2OwnerType,
class _elementType>
1079 template <
class _vector1OwnerType,
class _vector2OwnerType,
class _elementType>
1086 template <
class _vectorOwnerType,
typename _elementType>
1088 return vector.
All();
1092 template <
class _vectorOwnerType,
typename _elementType>
1094 return vector.
Any();
1098 template <
class _vectorOwnerType,
typename _elementType>
1106 template <vct::
size_type __size,
class _vectorOwnerType,
class __elementType>
1112 for (counter = 0; counter < numElements; ++counter) {
1114 vector[counter].ToStream(output);
1123 template <vct::
size_type _size, vct::str
ide_type _str
ide,
class _elementType,
class _dataPtrType,
class _vectorOwnerType>
1129 tempRef.
Assign(dynamicVector);
1134 #endif // _vctDynamicConstVectorBase_h
size_t index_type
Definition: vctContainerTraits.h:36
bool IsPositive(void) const
Definition: vctDynamicConstVectorBase.h:500
OwnerType Vector
Definition: vctDynamicConstVectorBase.h:126
const value_type & Y(void) const
Definition: vctDynamicConstVectorBase.h:251
Implement operation of the form for dynamic vectors.
Definition: vctDynamicVectorLoopEngines.h:667
bool ValidIndex(size_type index) const
Definition: vctDynamicConstVectorBase.h:227
vctDynamicVector< _elementType > CopyType
Definition: vctDynamicConstVectorBase.h:102
vctReturnDynamicVector< BoolType > BoolVectorReturnType
Definition: vctDynamicConstVectorBase.h:121
vctDynamicConstVectorRef< _elementType > YZW(void) const
Definition: vctDynamicConstVectorBase.h:327
bool AlmostEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector, value_type tolerance) const
Definition: vctDynamicConstVectorBase.h:652
A vector object of dynamic size.
Definition: vctDynamicVector.h:127
const_iterator end(void) const
Definition: vctDynamicConstVectorBase.h:145
cmnTypeTraits< value_type > TypeTraits
Definition: vctDynamicConstVectorBase.h:112
Assert macros definitions.
_vectorOwnerType OwnerType
Definition: vctDynamicConstVectorBase.h:87
#define CMN_ASSERT(expr)
Definition: cmnAssert.h:90
vctDynamicConstVectorRef< _elementType > YZ(void) const
Definition: vctDynamicConstVectorBase.h:296
bool IsFinite(void) const
Definition: vctDynamicConstVectorBase.h:554
VectorReturnType Ceil(void) const
Definition: vctDynamicVector.h:663
const_reverse_iterator rbegin(void) const
Definition: vctDynamicConstVectorBase.h:151
Returns the absolute value of the input as an OutputType object.
Definition: vctUnaryOperations.h:80
bool Greater(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:698
Dynamic vector referencing existing memory (const)
Definition: vctDynamicConstVectorRef.h:79
bool Equal(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:637
const_reference at(size_type index) const
Definition: vctDynamicConstVectorBase.h:190
const_reference operator()(size_type index) const
Definition: vctDynamicConstVectorBase.h:196
Portability across compilers and operating systems tools.
Test if input1 is lesser than input2.
Definition: vctBinaryOperations.h:322
OwnerType::iterator iterator
Definition: vctDynamicConstVectorBase.h:90
Declaration of cmnSerializer and functions cmnSerializeRaw.
vctDynamicConstVectorBase< _vectorOwnerType, _elementType > ThisType
Definition: vctDynamicConstVectorBase.h:84
static Type Tolerance(void)
Definition: cmnTypeTraits.h:170
BoolVectorReturnType ElementwiseGreater(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:770
bool GreaterOrEqual(const value_type &scalar) const
Definition: vctDynamicConstVectorBase.h:852
Forward declarations and #define for cisstVector.
ThisType & Assign(const vctDynamicConstVectorBase< __vectorOwnerType, value_type > &other)
Definition: vctDynamicVectorBase.h:242
Test for non equality between input1 and input2.
Definition: vctBinaryOperations.h:302
value_type MinAbsElement(void) const
Definition: vctDynamicConstVectorBase.h:479
const value_type & X(void) const
Definition: vctDynamicConstVectorBase.h:243
Dynamic vector referencing existing memory.
Definition: vctDynamicVectorRef.h:77
std::ostream & operator<<(std::ostream &output, const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &vector)
Definition: vctDynamicConstVectorBase.h:1099
vctDynamicConstVectorRef< _elementType > Ref(const size_type size, const size_type startPosition=0) const
Definition: vctDynamicConstVectorBase.h:346
void cmnSerializeSizeRaw(std::ostream &outputStream, const size_t &data)
Definition: cmnSerializer.h:93
bool GreaterOrEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:707
size_t size_type
Definition: vctContainerTraits.h:35
BoolVectorReturnType ElementwiseNotEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:743
void ThrowUnlessValidIndex(size_type index) const
Definition: vctDynamicConstVectorBase.h:130
value_type ProductOfElements(void) const
Definition: vctDynamicConstVectorBase.h:368
const_iterator begin(void) const
Definition: vctDynamicConstVectorBase.h:139
Definition: vctUnaryOperations.h:178
Test for equality between input1 and input2.
Definition: vctBinaryOperations.h:282
bool operator==(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:646
bool FastCopyCompatible(const vctFixedSizeConstVectorBase< __size, __stride, value_type, __dataPtrType > &source) const
Definition: vctDynamicConstVectorBase.h:600
bool HasNaN(void) const
Definition: vctDynamicConstVectorBase.h:563
Returns the square of the input as an OutputType object.
Definition: vctUnaryOperations.h:119
BoolVectorReturnType ElementwiseGreaterOrEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:779
BoolVectorReturnType ElementwiseLesser(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:752
_elementType operator*(const vctDynamicConstVectorBase< _vector1OwnerType, _elementType > &vector1, const vctDynamicConstVectorBase< _vector2OwnerType, _elementType > &vector2)
Definition: vctDynamicConstVectorBase.h:1080
vctDynamicVector< _elementType > VectorValueType
Definition: vctDynamicConstVectorBase.h:106
const_reverse_iterator rend(void) const
Definition: vctDynamicConstVectorBase.h:157
const value_type & Z(void) const
Definition: vctDynamicConstVectorBase.h:259
Returns the input as an OutputType object.
Definition: vctUnaryOperations.h:65
Implementation of a fixed-size vector using template metaprogramming.
Definition: vctFixedSizeVector.h:52
value_type DotProduct(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:613
vctReturnDynamicVector< bool > vctDynamicVectorElementwiseCompareScalar(const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &vector, const _elementType &scalar)
Definition: vctDynamicVector.h:696
bool IsNonPositive(void) const
Definition: vctDynamicConstVectorBase.h:518
OwnerType::const_reverse_iterator const_reverse_iterator
Definition: vctDynamicConstVectorBase.h:99
Test if input1 is greater than input2.
Definition: vctBinaryOperations.h:363
VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType)
bool LesserOrEqual(const value_type &scalar) const
Definition: vctDynamicConstVectorBase.h:836
Define unary operations on an object as classes.
Definition: vctUnaryOperations.h:55
size_type size(void) const
Definition: vctDynamicConstVectorBase.h:164
Definition: vctUnaryOperations.h:186
bool Lesser(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:680
ptrdiff_t difference_type
Definition: vctContainerTraits.h:38
void ToStreamRaw(std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
Definition: vctDynamicConstVectorBase.h:973
Declaration of vctDynamicVectorLoopEngines.
vctDynamicConstVectorRef< _elementType > YW(void) const
Definition: vctDynamicConstVectorBase.h:303
void SerializeRaw(std::ostream &outputStream) const
Definition: vctDynamicConstVectorBase.h:996
Test if input1 is greater than or equal to input2.
Definition: vctBinaryOperations.h:384
vctDynamicConstVectorRef< _elementType > XW(void) const
Definition: vctDynamicConstVectorBase.h:289
bool LesserOrEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:689
bool AlmostEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:659
bool Greater(const value_type &scalar) const
Definition: vctDynamicConstVectorBase.h:844
Definition: vctDynamicVector.h:392
std::string ToString(void) const
Definition: vctDynamicConstVectorBase.h:944
value_type LinfNorm(void) const
Definition: vctDynamicConstVectorBase.h:440
Declaration of the class cmnTypeTraits.
vctDynamicConstVectorRef< _elementType > XZ(void) const
Definition: vctDynamicConstVectorBase.h:282
value_type NormSquare(void) const
Definition: vctDynamicConstVectorBase.h:377
vctDynamicConstVectorRef< value_type > Type
Definition: vctDynamicConstVectorBase.h:913
vctDynamicConstVectorRef< _elementType > XY(void) const
Definition: vctDynamicConstVectorBase.h:275
Basic traits for the cisstVector containers.
Definition: vctUnaryOperations.h:154
bool Lesser(const value_type &scalar) const
Definition: vctDynamicConstVectorBase.h:828
VectorReturnType Negation(void) const
Definition: vctDynamicVector.h:639
_elementType vctDotProduct(const vctDynamicConstVectorBase< _vector1OwnerType, _elementType > &vector1, const vctDynamicConstVectorBase< _vector2OwnerType, _elementType > &vector2)
Definition: vctDynamicConstVectorBase.h:1067
void cmnSerializeRaw(std::ostream &outputStream, const _elementType &data)
Definition: cmnSerializer.h:78
vctDynamicConstVectorRef< _elementType > ZW(void) const
Definition: vctDynamicConstVectorBase.h:310
bool IsNegative(void) const
Definition: vctDynamicConstVectorBase.h:527
Definition: vctDynamicConstVectorBase.h:910
Implement operation of the form for dynamic vectors.
Definition: vctDynamicVectorLoopEngines.h:981
difference_type stride() const
Definition: vctDynamicConstVectorBase.h:169
bool Any(void) const
Definition: vctDynamicConstVectorBase.h:545
bool IsNormalized(void) const
Definition: vctDynamicConstVectorBase.h:394
VectorReturnType Floor(void) const
Definition: vctDynamicVector.h:651
Definition: vctUnaryOperations.h:170
vctReturnDynamicVector< bool > vctDynamicVectorElementwiseCompareVector(const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &vector1, const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &vector2)
Definition: vctDynamicVector.h:685
const value_type & W(void) const
Definition: vctDynamicConstVectorBase.h:266
Declaration of vctBinaryOperations.
vctDynamicVector< _elementType > VectorReturnType
Definition: vctDynamicConstVectorBase.h:110
bool FastCopyCompatible(const vctDynamicConstVectorBase< __vectorOwnerType, value_type > &source) const
Definition: vctDynamicConstVectorBase.h:592
#define cmnThrow(a)
Definition: MinimalCmn.h:4
value_type MaxElement(void) const
Definition: vctDynamicConstVectorBase.h:446
void vctFixedSizeVectorBaseAssignDynamicConstVectorBase(vctFixedSizeVectorBase< _size, _stride, _elementType, _dataPtrType > &fixedSizeVector, const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &dynamicVector)
Definition: vctDynamicConstVectorBase.h:1124
const_reference operator[](index_type index) const
Definition: vctDynamicConstVectorBase.h:181
BoolVectorReturnType ElementwiseLesserOrEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:761
const_pointer Pointer(index_type index=0) const
Definition: vctDynamicConstVectorBase.h:221
Definition: vctUnaryOperations.h:146
A template for a fixed length vector with fixed spacing in memory.
Definition: vctFixedSizeVectorBase.h:76
Definition: vctDynamicVectorRefOwner.h:39
VectorReturnType Normalized(void) const
Definition: vctDynamicVector.h:675
bool vctAny(const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &vector)
Definition: vctDynamicConstVectorBase.h:1093
Test if input1 is lesser than or equal to input2.
Definition: vctBinaryOperations.h:343
bool IsNormalized(_elementType tolerance) const
Definition: vctDynamicConstVectorBase.h:415
bool IsFortran(void) const
Definition: vctDynamicConstVectorBase.h:585
bool empty() const
Definition: vctDynamicConstVectorBase.h:175
value_type SumOfElements(void) const
Definition: vctDynamicConstVectorBase.h:359
vctDynamicConstVectorRef< _elementType > XYZW(void) const
Definition: vctDynamicConstVectorBase.h:337
void ToStream(std::ostream &outputStream) const
Definition: vctDynamicConstVectorBase.h:950
vctDynamicConstVectorRef< _elementType > XYZ(void) const
Definition: vctDynamicConstVectorBase.h:320
OwnerType::reverse_iterator reverse_iterator
Definition: vctDynamicConstVectorBase.h:96
Definition: vctVarStrideVectorIterator.h:222
Definition: vctDynamicConstVectorBase.h:77
A template for a fixed length vector with fixed spacing in memory.
Definition: vctFixedSizeConstVectorBase.h:107
bool IsNonNegative(void) const
Definition: vctDynamicConstVectorBase.h:509
static bool VectorCopyCompatible(const _vector1Type &vector1, const _vector2Type &vector2)
Definition: vctFastCopy.h:129
bool All(void) const
Definition: vctDynamicConstVectorBase.h:536
NormType Norm(void) const
Definition: vctDynamicConstVectorBase.h:386
Declaration of vctUnaryOperations.
const_reference Element(size_type index) const
Definition: vctDynamicConstVectorBase.h:205
bool Equal(const value_type &scalar) const
Definition: vctDynamicConstVectorBase.h:802
Declaration of the template function cmnThrow.
VectorReturnType Abs(void) const
Definition: vctDynamicVector.h:627
bool NotEqual(const value_type &scalar) const
Definition: vctDynamicConstVectorBase.h:815
bool vctAll(const vctDynamicConstVectorBase< _vectorOwnerType, _elementType > &vector)
Definition: vctDynamicConstVectorBase.h:1087
value_type L1Norm(void) const
Definition: vctDynamicConstVectorBase.h:427
A collection of useful information about the C++ basic types, represented in a generic programming wa...
Definition: cmnTypeTraits.h:155
bool operator!=(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:674
bool NotEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:665
Definition: vctUnaryOperations.h:194
Returns the product of the two InputType object.
Definition: vctBinaryOperations.h:116
bool IsCompact(void) const
Definition: vctDynamicConstVectorBase.h:578
value_type MaxAbsElement(void) const
Definition: vctDynamicConstVectorBase.h:468
OwnerType::const_iterator const_iterator
Definition: vctDynamicConstVectorBase.h:93
value_type MinElement(void) const
Definition: vctDynamicConstVectorBase.h:455
void MinAndMaxElement(value_type &minElement, value_type &maxElement) const
Definition: vctDynamicConstVectorBase.h:493
Definition: vctVarStrideVectorIterator.h:56
const OwnerType & Owner(void) const
Definition: vctDynamicConstVectorBase.h:213
BoolVectorReturnType ElementwiseEqual(const vctDynamicConstVectorBase< __vectorOwnerType, _elementType > &otherVector) const
Definition: vctDynamicConstVectorBase.h:733
Implement operation of the form for dynamic vectors.
Definition: vctDynamicVectorLoopEngines.h:732
static void Run(const _inputVectorType &inputVector, typename _inputVectorType::value_type &minValue, typename _inputVectorType::value_type &maxValue)
Definition: vctDynamicVectorLoopEngines.h:1037
bool BoolType
Definition: cmnTypeTraits.h:164
TypeTraits::BoolType BoolType
Definition: vctDynamicConstVectorBase.h:117
Definition: vctUnaryOperations.h:162