#include <vctDynamicVector.h>
Inheritance diagram for vctDynamicVector< _elementType >:


This class defines a vector object of dynamic size with memory allocation. Note that unlike the STL vector class (std::vector), this class is not meant to be used as a dynamic container, but in vector algebra.
The algebraic operations are mostly inherited from the base classes vctDynamicVectorBase and vctDynamicConstVectorBase. Here, we will briefly describe the specific properties of vctDynamicVector, with a few usage examples.
// define a typical element type typedef double ElementType; // the vectorSize variable can be set to any value at any time // before creating the vector. size_t vectorSize = 12; // constructor allocation vctDynamicVector<ElementType> v1(vectorSize); // Create an empty vector and later allocate memory. vctDynamicVector<ElementType> v2; v2.SetSize(vectorSize); // Create a dynamic vector of some size and then change it. // This operation does not preserve any elements in the resized // vector vctDynamicVector<Elements> v3(3 * vectorSize); v3.SetSize(2 * vectorSize); // resize a vector and keep as many elements as possible. v3.resize(vectorSize); // Store an algebraic result to a new vector. In this case, // memory is allocated by the algebraic operation, and then // attached to the vector object. vctDynamicVector<double> v4 = v3 - v2;
// Initialize all elements to the same value vctDynamicVector<ElementType> v5(vectorSize, 2.0); // Initialize the elements by specific value. NOTE: All the // arguments MUST be of type ElementType vctDynamicVector<ElementType> sequence(7, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); // Assign one vector to another. This operation reallocates // space for the target vector. Note that the right-hand-side // object can be any ``dynamic'' vector of any element type, // not just a vctDynamicVector<ElementType> vctDynamicMatrix<int> someNumbers(numRows, numCols); v1 = someNumbers.Column(2);
A few more notes.
| _elementType | the type of an element in the vector |
Definition at line 128 of file vctDynamicVector.h.
| typedef vctDynamicVector<_elementType> vctDynamicVector< _elementType >::ThisType |
Type of the vector itself.
Reimplemented from vctDynamicVectorBase< vctDynamicVectorOwner< _elementType >, _elementType >.
Reimplemented in mtsHistory< _elementType >, and mtsVector< _elementType >.
Definition at line 135 of file vctDynamicVector.h.
| typedef vctDynamicVectorBase<vctDynamicVectorOwner<_elementType>, _elementType> vctDynamicVector< _elementType >::BaseType |
Type of the base class.
Reimplemented from vctDynamicVectorBase< vctDynamicVectorOwner< _elementType >, _elementType >.
Reimplemented in vctReturnDynamicVector< _elementType >.
Definition at line 136 of file vctDynamicVector.h.
| typedef BaseType::CopyType vctDynamicVector< _elementType >::CopyType |
The type used to create a copy.
Reimplemented from vctDynamicVectorBase< vctDynamicVectorOwner< _elementType >, _elementType >.
Definition at line 137 of file vctDynamicVector.h.
| typedef BaseType::TypeTraits vctDynamicVector< _elementType >::TypeTraits |
Type traits for the elements of the vector.
Reimplemented from vctDynamicVectorBase< vctDynamicVectorOwner< _elementType >, _elementType >.
Definition at line 138 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | ) | [inline] |
Default constructor. Initialize an empty vector.
Definition at line 142 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | size_type | size | ) | [inline, explicit] |
Constructor: Create a vector of the specified size. Elements initialized with default constructor.
Definition at line 149 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | size_type | size, | |
| value_type | value | |||
| ) | [inline] |
Constructor: Create a vector of the specified size and assign all elements a specific value.
Definition at line 155 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | size_type | size, | |
| value_type | element0, | |||
| value_type | element1, | |||
| ... | ||||
| ) | throw (std::runtime_error) [inline] |
Constructor for any size greater than or equal to 2, using stdarg macros and variable number of arguments. This operation assumes that all the arguments are of type value_type, and that their number is equal to the size of the vector. The user may need to explicitly cast the parameters to value_type to avoid runtime bugs and errors. We have not checked if stdarg macros can use reference types (probably not), so unlike the other constructors, this constructor takes all arguments by value.
Definition at line 172 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | size_type | size, | |
| const value_type * | values | |||
| ) | [inline] |
Constructor: Create a vector of the specified size and assign the elements values from the memory block pointed to
Definition at line 189 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | const vctReturnDynamicVector< value_type > & | otherVector | ) |
Special copy constructor: Take ownership of the data of a temporary vector object of type vctReturnDynamicVector. Disown the other vector.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | const ThisType & | otherVector | ) | [inline] |
Copy constructor: Allocate memory to store a copy of the other vector, and copy the elements of the other vector to this vector.
Definition at line 205 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | const vctDynamicConstVectorBase< _otherVectorOwnerType, value_type > & | otherVector | ) | [inline] |
Copy constructor: Allocate memory and copy all the elements from the other vector.
Definition at line 217 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | const vctDynamicConstVectorBase< _otherVectorOwnerType, _otherVectorElementType > & | otherVector | ) | [inline, explicit] |
Copy constructor: Allocate memory and copy all the elements from the other vector. This constructor can also be used for type conversions.
Definition at line 228 of file vctDynamicVector.h.
| vctDynamicVector< _elementType >::vctDynamicVector | ( | const vctFixedSizeConstVectorBase< __size, __stride, __elementType, __dataPtrType > & | fixedVector | ) | [inline, explicit] |
Constructor from a fixed-size vector
Definition at line 235 of file vctDynamicVector.h.
| ThisType& vctDynamicVector< _elementType >::operator= | ( | const vctDynamicConstVectorBase< __vectorOwnerType, __elementType > & | otherVector | ) | [inline] |
Assignment from a dynamic vector to a vector. The operation discards the old memory allocated for this vector, and allocates new memory the size of the input vector. Then the elements of the input vector are copied into this vector.
Reimplemented from vctDynamicVectorBase< vctDynamicVectorOwner< _elementType >, _elementType >.
Definition at line 246 of file vctDynamicVector.h.
| ThisType& vctDynamicVector< _elementType >::operator= | ( | const ThisType & | other | ) | [inline] |
Assignment from a dynamic vector to this vector. The operation discards the old memory allocated for this vector, and allocates new memory the size of the input vector. Then the elements of the input vector are copied into this vector.
Definition at line 258 of file vctDynamicVector.h.
| ThisType& vctDynamicVector< _elementType >::operator= | ( | const vctReturnDynamicVector< value_type > & | other | ) |
Assignement from a transitional vctReturnDynamicVector to a vctDynamicVector variable. This specialized operation does not perform any element copy. Instead it transfers ownership of the data from the other vector to this vector, and disowns the other vector. The right hand side operand must be a temporary object returned, e.g., from a function or overloaded operator.
| ThisType& vctDynamicVector< _elementType >::operator= | ( | const value_type & | value | ) | [inline] |
Assignement of a scalar to all elements. See also SetAll.
Definition at line 274 of file vctDynamicVector.h.
| void vctDynamicVector< _elementType >::resize | ( | size_type | size | ) | [inline] |
Non-destructive size change. Change the size to the specified size, and copy as many elements as possible from the former vector.
Definition at line 300 of file vctDynamicVector.h.
| void vctDynamicVector< _elementType >::SetSize | ( | size_type | size | ) | [inline] |
DESTRUCTIVE size change. Change the size to the specified size. Discard of all the old values.
Definition at line 316 of file vctDynamicVector.h.
Referenced by nmrFnSolver::Allocate(), nmrLUSolver::Allocate(), nmrLSNonLinJacobianSolver::Allocate(), nmrFnJacobianSolver::Allocate(), nmrLSNonLinSolver::Allocate(), nmrLSqLinSolutionDynamic::AllocateIWorkspace(), nmrLUDynamicData::AllocateOutput(), nmrSVDEconomyDynamicData::AllocateOutputWorkspace(), nmrPInverseEconomyDynamicData::AllocateOutputWorkspace(), nmrPInverseDynamicData::AllocateOutputWorkspace(), nmrSVDDynamicData::AllocateOutputWorkspace(), nmrNNLSDynamicData::AllocateOutputWorkspaces(), nmrInverseDynamicData::AllocatePivotIndicesWorkspace(), nmrLSqLinSolutionDynamic::AllocateWorkspace(), vctDynamicVector< svlSample * >::DeSerializeRaw(), vctDynamicVector< svlSample * >::ForceAssign(), mtsVector< _elementType >::operator=(), vctDynamicVector< svlSample * >::operator=(), mtsHistory< _elementType >::SetHistorySize(), nmrFminSolver::Solve(), and vctDynamicVector< svlSample * >::vctDynamicVector().
| bool vctDynamicVector< _elementType >::FromStreamRaw | ( | std::istream & | inputStream, | |
| const char | delimiter = ' ' | |||
| ) | [inline] |
Read from an unformatted text input (e.g., one created by ToStreamRaw). Returns true if successful. This particular implementation assumes that the correct vector size is already set.
Definition at line 323 of file vctDynamicVector.h.
| void vctDynamicVector< _elementType >::DeSerializeRaw | ( | std::istream & | inputStream | ) | [inline] |
Binary deserialization
Reimplemented in mtsVector< _elementType >.
Definition at line 358 of file vctDynamicVector.h.
Referenced by mtsVector< _elementType >::DeSerializeRaw().