#include <array1D.h>
Inheritance diagram for dlr::numeric::Array1D< Type >:


Public Types | |
| typedef Type | value_type |
| Typedef for value_type describes the contents of the array. | |
| typedef Type * | iterator |
| Typedef for iterator type helps with standard library interface. | |
| typedef const Type * | const_iterator |
| Typedef for const_iterator type helps with standard library interface. | |
Public Member Functions | |
| Array1D () | |
| Default constructor initializes to zero size. | |
| Array1D (size_t size) | |
| Constructs a "size" element array. | |
| Array1D (const std::string &inputString) | |
| Constructs an Array1D by parsing an input string. | |
| Array1D (const Array1D< Type > &source) | |
| The copy constructor does a shallow copy. | |
| Array1D (size_t size, Type *const dataPtr) | |
| Construct an array around external data. | |
| Array1D (size_t size, Type *const dataPtr, size_t *const refCountPtr) | |
| Construct an array around external data which was allocated by an Array?D instance. | |
| ~Array1D () | |
| Destroys the Array1D instance and deletes the internal data store if no remaining arrays point to it. | |
| iterator | begin () |
| Return begin() iterator for Standard Library algorithms. | |
| const_iterator | begin () const |
| Return begin() const_iterator for Standard Library algorithms. | |
| void | checkDimension (size_t size) const |
| Optionally throw an exception if the shape of *this is different than specified. | |
| void | clear () |
| Reset the array to zero size, abandoning all contents. | |
| Array1D< Type > | copy () const |
| Allocate a new array and deep copy the contents of *this. | |
| template<class Type2> | |
| void | copy (const Array1D< Type2 > &source) |
| Deep copies the contents of source. | |
| template<class Type2> | |
| void | copy (const Type2 *dataPtr) |
| Copies elements from dataPtr. | |
| Type * | data () |
| Returns a pointer to the internal data store. | |
| const Type * | data () const |
| This version of data(void) is appropriate for const Array1D, and returns a pointer-to-const. | |
| Type * | data (size_t index) |
| Just like data(void), which is documented above, but returns a pointer to the (index)th element instead of the first element. | |
| const Type * | data (size_t index) const |
| This version of data(size_t) is appropriate for const Array1D, and returns a pointer-to-const. | |
| bool | empty () const |
| This member function returns true if the array instance contains no elements. | |
| iterator | end () |
| Return end() iterator for Standard Library algorithms. | |
| const_iterator | end () const |
| Return end() const_iterator for Standard Library algorithms. | |
| bool | isAllocated () const |
| Indicates whether the internal data array is being managed (and reference counted) by *this. | |
| size_t | length () const |
| Returns the number of elements in the array. | |
| std::istream & | readFromStream (std::istream &inputStream) |
| This member function sets the value of the array from an input stream. | |
| size_t * | refCountPtr () const |
| Temporary function to ease porting of code from early versions of dlr_libs. | |
| void | reinit (size_t size) |
| Changes the shape of the array and reallocates storage. | |
| size_t | size () const |
| Returns the number of elements in the array. | |
| Array1D< Type > & | operator= (const Array1D< Type > &source) |
| Assignment operator shallow copies the contents of source. | |
| Array1D< Type > & | operator= (Type value) |
| Assign value to every element in the array. | |
| Type & | operator() (size_t index) |
| Returns the (index)th element of the array by reference. | |
| Type | operator() (size_t index) const |
| Returns the (index)th element of the array by value. | |
| Type & | operator[] (size_t index) |
| Returns the (index)th element of the array by reference. | |
| Type | operator[] (size_t index) const |
| Returns the (index)th element of the array by value. | |
| template<class Type2> | |
| Array1D< Type > & | operator+= (const Array1D< Type2 > &arg) |
| Increments each element of *this by the value of the corresponding element of arg. | |
| Array1D< Type > & | operator+= (const Type arg) |
| Increments each element of *this by a constant. | |
| template<class Type2> | |
| Array1D< Type > & | operator-= (const Array1D< Type2 > &arg) |
| Decrements each element of *this by the value of the corresponding element of arg. | |
| Array1D< Type > & | operator-= (const Type arg) |
| Decrements each element of *this by a constant. | |
| template<class Type2> | |
| Array1D< Type > & | operator *= (const Array1D< Type2 > &arg) |
| Multiplies each element of *this by the value of the corresponding element of arg. | |
| Array1D< Type > & | operator *= (const Type arg) |
| Multiplies each element of *this by a constant. | |
| template<class Type2> | |
| Array1D< Type > & | operator/= (const Array1D< Type2 > &arg) |
| Divides each element of *this by the value of the corresponding element of arg. | |
| Array1D< Type > & | operator/= (const Type arg) |
| Divides each element of *this by a constant. | |
This class has internal reference counting.
IMPORTANT: This class does _shallow_ copies by default. If you type:
array1 = array2;
then array1 and array2 point to the same data. To do a deep copy, type
array1.copy(array2);
or
array1 = array2.copy();
The advantage of the first form is that it doesn't involve allocating memory. The advantage of the second form is that there's no error if array1 and array2 have different shapes.
Definition at line 55 of file array1D.h.
| typedef Type dlr::numeric::Array1D< Type >::value_type |
| typedef Type* dlr::numeric::Array1D< Type >::iterator |
| typedef const Type* dlr::numeric::Array1D< Type >::const_iterator |
| dlr::numeric::Array1D< Type >::Array1D | ( | ) | [inline] |
| dlr::numeric::Array1D< Type >::Array1D | ( | size_t | size | ) | [inline, explicit] |
| dlr::numeric::Array1D< Type >::Array1D | ( | const std::string & | inputString | ) | [inline, explicit] |
Constructs an Array1D by parsing an input string.
For example, the code line
Array1D<double> testArray("[1.0, 2.0, 3.0]");
would construct a 3 element array.
| inputString | A formatted string which could be reasonably expected to parse into the desired array values. |
Definition at line 990 of file array1D.h.
References DLR_THROW3.
| dlr::numeric::Array1D< Type >::Array1D | ( | const Array1D< Type > & | source | ) | [inline] |
| dlr::numeric::Array1D< Type >::Array1D | ( | size_t | size, | |
| Type *const | dataPtr | |||
| ) | [inline] |
Construct an array around external data.
Arrays constructed in this way will not implement reference counting, and will not delete dataPtr when done.
| size | Number of elements in the array after construction. | |
| dataPtr | A C-style array of Type into which the newly constructed Array1D should index. |
| dlr::numeric::Array1D< Type >::Array1D | ( | size_t | size, | |
| Type *const | dataPtr, | |||
| size_t *const | refCountPtr | |||
| ) | [inline] |
Construct an array around external data which was allocated by an Array?D instance.
Arrays constructed in this way _do_ implement reference counting, and will delete dataPtr when done. This constructor is provided primarily so that higher dimensionality array classes can return Array1D instances which reference their data without being friend classes. Caveat emptor.
| size | Number of elements in the array after construction. | |
| dataPtr | A C-style array of Type into which the newly constructed Array1D should index. | |
| refCountPtr | Pointer to size_t indicating the number of Array classes currently using dataPtr. |
| dlr::numeric::Array1D< Type >::~Array1D | ( | ) | [inline] |
| iterator dlr::numeric::Array1D< Type >::begin | ( | ) | [inline] |
Return begin() iterator for Standard Library algorithms.
Definition at line 156 of file array1D.h.
Referenced by dlr::numeric::abs(), dlr::numeric::allFalse(), dlr::numeric::allTrue(), dlr::numeric::argmax(), dlr::numeric::argmin(), dlr::numeric::columnIndices(), dlr::numeric::compress(), dlr::numeric::convolve(), dlr::numeric::convolve1D(), dlr::numeric::count(), dlr::numeric::dot(), dlr::numeric::BSpline< Type >::getSpanNumber(), dlr::numeric::magnitudeSquared(), dlr::numeric::maximum(), dlr::numeric::minimum(), dlr::numeric::operator *(), dlr::numeric::operator+(), dlr::numeric::operator-(), dlr::numeric::operator/(), dlr::numeric::operator==(), dlr::numeric::operator>(), dlr::numeric::operator>=(), dlr::numeric::outerProduct(), dlr::numeric::Array1D< Type >::readFromStream(), dlr::numeric::BSpline< Type >::setKnotMultiplicities(), dlr::numeric::BSpline< Type >::setNodePositions(), and dlr::numeric::sum().
| const_iterator dlr::numeric::Array1D< Type >::begin | ( | ) | const [inline] |
Return begin() const_iterator for Standard Library algorithms.
| void dlr::numeric::Array1D< Type >::checkDimension | ( | size_t | size | ) | const [inline] |
Optionally throw an exception if the shape of *this is different than specified.
| size | The required array size. |
Definition at line 1064 of file array1D.h.
References DLR_THROW, and dlr::numeric::Array1D< Type >::size().
Referenced by dlr::numeric::operator==().
| void dlr::numeric::Array1D< Type >::clear | ( | ) | [inline] |
Reset the array to zero size, abandoning all contents.
This is equivalent to this->reinit(0);
Definition at line 183 of file array1D.h.
Referenced by dlr::numeric::Array2D< Type >::readFromStream().
| Array1D< Type > dlr::numeric::Array1D< Type >::copy | ( | ) | const [inline] |
Allocate a new array and deep copy the contents of *this.
Definition at line 1080 of file array1D.h.
References dlr::numeric::Array1D< Type >::copy().
Referenced by dlr::numeric::Array1D< Type >::copy(), dlr::numeric::BSpline< Type >::getCoefficientMatrices(), and dlr::numeric::BSpline< Type >::operator=().
| void dlr::numeric::Array1D< Type >::copy | ( | const Array1D< Type2 > & | source | ) | [inline] |
Deep copies the contents of source.
It is an error if source does not have the same size as *this.
| source | The array to be copied. |
| ValueException | on incompatible array sizes |
Definition at line 1090 of file array1D.h.
References dlr::numeric::Array1D< Type >::copy(), dlr::numeric::Array1D< Type >::data(), DLR_THROW3, and dlr::numeric::Array1D< Type >::size().
| void dlr::numeric::Array1D< Type >::copy | ( | const Type2 * | dataPtr | ) | [inline] |
| Type* dlr::numeric::Array1D< Type >::data | ( | void | ) | [inline] |
Returns a pointer to the internal data store.
This is ugly but often necessary for interfacing with external libraries. Data is stored contiguously.
Definition at line 223 of file array1D.h.
Referenced by dlr::numeric::Array1D< Type >::copy(), dlr::numeric::Array1D< Type >::operator *=(), dlr::numeric::Array1D< Type >::operator+=(), dlr::numeric::Array1D< Type >::operator-=(), and dlr::numeric::Array1D< Type >::operator/=().
| const Type* dlr::numeric::Array1D< Type >::data | ( | void | ) | const [inline] |
This version of data(void) is appropriate for const Array1D, and returns a pointer-to-const.
| Type* dlr::numeric::Array1D< Type >::data | ( | size_t | index | ) | [inline] |
Just like data(void), which is documented above, but returns a pointer to the (index)th element instead of the first element.
Note that "data(index)" is synonymous with "data() + index" .
| index | Indicates to which element of the array the return value should point. |
| const Type* dlr::numeric::Array1D< Type >::data | ( | size_t | index | ) | const [inline] |
This version of data(size_t) is appropriate for const Array1D, and returns a pointer-to-const.
| index | Indicates to which element of the array the return value should point. |
| bool dlr::numeric::Array1D< Type >::empty | ( | ) | const [inline] |
| iterator dlr::numeric::Array1D< Type >::end | ( | ) | [inline] |
Return end() iterator for Standard Library algorithms.
Definition at line 284 of file array1D.h.
Referenced by dlr::numeric::abs(), dlr::numeric::allFalse(), dlr::numeric::allTrue(), dlr::numeric::argmax(), dlr::numeric::argmin(), dlr::numeric::columnIndices(), dlr::numeric::compress(), dlr::numeric::convolve(), dlr::numeric::convolve1D(), dlr::numeric::count(), dlr::numeric::dot(), dlr::numeric::BSpline< Type >::getSpanNumber(), dlr::numeric::magnitudeSquared(), dlr::numeric::maximum(), dlr::numeric::minimum(), dlr::numeric::operator *(), dlr::numeric::operator+(), dlr::numeric::operator-(), dlr::numeric::operator/(), dlr::numeric::operator==(), dlr::numeric::operator>(), dlr::numeric::operator>=(), dlr::numeric::outerProduct(), and dlr::numeric::sum().
| const_iterator dlr::numeric::Array1D< Type >::end | ( | ) | const [inline] |
Return end() const_iterator for Standard Library algorithms.
| bool dlr::numeric::Array1D< Type >::isAllocated | ( | ) | const [inline] |
Indicates whether the internal data array is being managed (and reference counted) by *this.
This member function is only needed in very unusual circumstances.
| size_t dlr::numeric::Array1D< Type >::length | ( | ) | const [inline] |
Returns the number of elements in the array.
This is a synonym for size().
Definition at line 313 of file array1D.h.
Referenced by dlr::numeric::equivalentMatrix().
| std::istream & dlr::numeric::Array1D< Type >::readFromStream | ( | std::istream & | inputStream | ) | [inline] |
This member function sets the value of the array from an input stream.
The array is modified only if the read was successful, otherwise the array is not modified, and failbit is set in the stream state. Because of this nice behavior, readFromStream is quite slow.
| inputStream | This is the stream from which to read the array. |
Definition at line 1129 of file array1D.h.
References dlr::numeric::Array1D< Type >::begin(), and dlr::numeric::Array1D< Type >::reinit().
Referenced by dlr::numeric::operator>>().
| size_t* dlr::numeric::Array1D< Type >::refCountPtr | ( | ) | const [inline] |
| void dlr::numeric::Array1D< Type >::reinit | ( | size_t | size | ) | [inline] |
Changes the shape of the array and reallocates storage.
The current array contents are lost.
| size | Number of elements in the array after reallocation. |
Definition at line 1207 of file array1D.h.
Referenced by dlr::numeric::axisMaximum(), dlr::numeric::axisMinimum(), dlr::numeric::axisSum(), dlr::numeric::Array1D< size_t >::clear(), dlr::numeric::getMeanAndCovariance(), dlr::numeric::Array1D< Type >::readFromStream(), dlr::numeric::BSpline< Type >::setKnotMultiplicities(), and dlr::numeric::BSpline< Type >::setNodePositions().
| size_t dlr::numeric::Array1D< Type >::size | ( | ) | const [inline] |
Returns the number of elements in the array.
This is a synonym for length().
Definition at line 356 of file array1D.h.
Referenced by dlr::numeric::abs(), dlr::numeric::argsort(), dlr::numeric::Array1D< Type >::checkDimension(), dlr::numeric::compress(), dlr::numeric::BSpline< Type >::computeBasisFunction(), dlr::numeric::convolve(), dlr::numeric::convolve1D(), dlr::numeric::Array1D< Type >::copy(), dlr::numeric::correlate1D(), dlr::numeric::dot(), dlr::numeric::Array1D< size_t >::empty(), dlr::numeric::equivalentMatrix(), dlr::numeric::BSpline< Type >::getKnotPosition(), dlr::numeric::BSpline< Type >::getMaximumSValue(), dlr::numeric::BSpline< Type >::getMinimumSValue(), dlr::numeric::Array1D< size_t >::length(), dlr::numeric::ln(), dlr::numeric::matrixMultiply(), dlr::numeric::maximum(), dlr::numeric::mean(), dlr::numeric::minimum(), dlr::numeric::normalizedCorrelation(), dlr::numeric::operator *(), dlr::numeric::Array1D< Type >::operator *=(), dlr::numeric::BSpline< Type >::operator()(), dlr::numeric::operator+(), dlr::numeric::Array1D< Type >::operator+=(), dlr::numeric::operator-(), dlr::numeric::Array1D< Type >::operator-=(), dlr::numeric::operator/(), dlr::numeric::Array1D< Type >::operator/=(), dlr::numeric::operator==(), dlr::numeric::operator>(), dlr::numeric::operator>=(), dlr::numeric::outerProduct(), dlr::numeric::rms(), dlr::numeric::BSpline< Type >::setControlPoints(), dlr::numeric::BSpline< Type >::setKnotMultiplicities(), dlr::numeric::BSpline< Type >::setNodePositions(), dlr::numeric::shapeMatch(), dlr::numeric::skewSymmetric(), dlr::numeric::SubArray1D< Type >::SubArray1D(), and dlr::numeric::variance().
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator= | ( | const Array1D< Type > & | source | ) | [inline] |
Assignment operator shallow copies the contents of source.
After the copy, both arrays reference the same data.
| source | The Array1D instance to be copied. |
Definition at line 1217 of file array1D.h.
References dlr::numeric::Array1D< Type >::m_dataPtr, dlr::numeric::Array1D< Type >::m_isAllocated, dlr::numeric::Array1D< Type >::m_refCountPtr, and dlr::numeric::Array1D< Type >::m_size.
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator= | ( | Type | value | ) | [inline] |
| Type& dlr::numeric::Array1D< Type >::operator() | ( | size_t | index | ) | [inline] |
Returns the (index)th element of the array by reference.
| index | Indicates the selected element. |
Definition at line 387 of file array1D.h.
Referenced by dlr::numeric::Array1D< size_t >::operator[]().
| Type dlr::numeric::Array1D< Type >::operator() | ( | size_t | index | ) | const [inline] |
| Type& dlr::numeric::Array1D< Type >::operator[] | ( | size_t | index | ) | [inline] |
Returns the (index)th element of the array by reference.
Synonymous with operator()().
| index | Indicates the selected element. |
| Type dlr::numeric::Array1D< Type >::operator[] | ( | size_t | index | ) | const [inline] |
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator+= | ( | const Array1D< Type2 > & | arg | ) | [inline] |
Increments each element of *this by the value of the corresponding element of arg.
| arg | Array1D of values to be added to the elements of *this. |
| ValueException | on incompatible array sizes |
Definition at line 1238 of file array1D.h.
References dlr::numeric::Array1D< Type >::data(), DLR_THROW3, and dlr::numeric::Array1D< Type >::size().
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator+= | ( | const Type | arg | ) | [inline] |
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator-= | ( | const Array1D< Type2 > & | arg | ) | [inline] |
Decrements each element of *this by the value of the corresponding element of arg.
| arg | Array1D of values to be subtracted from the elements of *this. |
| ValueException | on incompatible array sizes |
Definition at line 1268 of file array1D.h.
References dlr::numeric::Array1D< Type >::data(), DLR_THROW3, and dlr::numeric::Array1D< Type >::size().
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator-= | ( | const Type | arg | ) | [inline] |
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator *= | ( | const Array1D< Type2 > & | arg | ) | [inline] |
Multiplies each element of *this by the value of the corresponding element of arg.
| arg | Array1D of values by which the elements of *this should be multiplied. |
| ValueException | on incompatible array sizes |
Definition at line 1298 of file array1D.h.
References dlr::numeric::Array1D< Type >::data(), DLR_THROW3, and dlr::numeric::Array1D< Type >::size().
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator *= | ( | const Type | arg | ) | [inline] |
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator/= | ( | const Array1D< Type2 > & | arg | ) | [inline] |
Divides each element of *this by the value of the corresponding element of arg.
| arg | Array1D of values by which the elements of *this should be divided. |
| ValueException | on incompatible array sizes |
Definition at line 1328 of file array1D.h.
References dlr::numeric::Array1D< Type >::data(), DLR_THROW3, and dlr::numeric::Array1D< Type >::size().
| Array1D< Type > & dlr::numeric::Array1D< Type >::operator/= | ( | const Type | arg | ) | [inline] |
1.5.2