ODIN
|
#include <tjvector.h>
Public Member Functions | |
tjvector (unsigned int n=0) | |
tjvector (const T *array, unsigned int n) | |
tjvector (const STD_vector< T > &v) | |
tjvector (const tjvector< T > &tv) | |
virtual | ~tjvector () |
tjvector< T > & | operator= (const T &value) |
tjvector< T > & | operator= (const STD_vector< T > &vec) |
tjvector< T > & | operator= (const tjvector< T > &tv) |
tjvector< T > | operator+ (const STD_vector< T > &w) const |
tjvector< T > | operator- (const STD_vector< T > &w) const |
tjvector< T > | operator* (const STD_vector< T > &w) const |
tjvector< T > | operator/ (const STD_vector< T > &w) const |
tjvector< T > | operator- () const |
tjvector< T > | operator+ (const T &s) const |
tjvector< T > | operator- (const T &s) const |
tjvector< T > | operator* (const T &s) const |
tjvector< T > | operator/ (const T &s) const |
tjvector< T > & | operator+= (const STD_vector< T > &v) |
tjvector< T > & | operator+= (const T &s) |
tjvector< T > & | operator-= (const STD_vector< T > &v) |
tjvector< T > & | operator-= (const T &s) |
tjvector< T > & | operator*= (const STD_vector< T > &v) |
tjvector< T > & | operator*= (const T &s) |
tjvector< T > & | operator/= (const STD_vector< T > &v) |
tjvector< T > & | operator/= (const T &s) |
virtual tjvector< T > & | resize (unsigned int newsize) |
unsigned int | length () const |
unsigned int | fill_linear (const T &min, const T &max) |
T | sum () const |
tjvector< T > | range (unsigned int startindex, unsigned int endindex) const |
T | maxvalue () const |
T | minvalue () const |
T | maxabs () const |
const T * | c_array () const |
tjvector & | set_c_array (const unsigned char *array, unsigned int n) |
T | normalize () |
tjvector & | interpolate (unsigned int newsize, float subpixel_shift=0.0) |
int | load (const STD_string &fname) |
int | write (const STD_string &fname, fopenMode mode=overwriteMode, LONGEST_INT nelements=-1) const |
STD_string | printbody () const |
Friends | |
tjvector< T > | operator+ (const T &s, const STD_vector< T > &v) |
tjvector< T > | operator- (const T &s, const STD_vector< T > &v) |
tjvector< T > | operator* (const T &s, const STD_vector< T > &v) |
tjvector< T > | operator/ (const T &s, const STD_vector< T > &v) |
STD_ostream & | operator<< (STD_ostream &s, const tjvector< T > &v) |
This class represents a basic vector which is derived from the Standard Template Library (STL) vector class. it adds some useful functionality to the STL base class, for example element-wise arithmetics and reading/writing.
Definition at line 50 of file tjvector.h.
constructs a vector and allocates memory for n values which are initialised to zero.
constructs a vector of length n and gets n values from array No bounds checking possible, so take care that the pointer array has memory allocated which is in fact n values long.
constructs a copy from std::vector
const T* tjvector< T >::c_array | ( | ) | const |
Returns an allocated C-style array of Ts with the values of this vector. The array is deleted automatically at the next call of c_array() or if this vector is destroyed.
unsigned int tjvector< T >::fill_linear | ( | const T & | min, |
const T & | max | ||
) |
fill the array linearly from value min to value max, return number of fills
tjvector& tjvector< T >::interpolate | ( | unsigned int | newsize, |
float | subpixel_shift = 0.0 |
||
) |
interpolate values to new size 'newsize'. Add extra shift 'subpixel_shift' in units of pixels on the destination grid.
unsigned int tjvector< T >::length | ( | ) | const |
returns the length
int tjvector< T >::load | ( | const STD_string & | fname | ) |
Loads the values from disk, the file is expected to contain the same data type as the array. Returns 0 on success, -1 otherwise.
T tjvector< T >::maxabs | ( | ) | const |
Maximum absolute value
T tjvector< T >::maxvalue | ( | ) | const |
Return the greatest value
T tjvector< T >::minvalue | ( | ) | const |
Return the smallest value
T tjvector< T >::normalize | ( | ) |
Normalize the vector, i.e. make its smallest/largest non-zero value become -1 or 1. Returns the maximum absolute value which was used to achieve the normalization.
returns the element-wise product of two tjvectors
Definition at line 133 of file tjvector.h.
returns the element-wise product of a tjvector with a scalar
Definition at line 210 of file tjvector.h.
Equivalent to: this = this * v
Definition at line 270 of file tjvector.h.
Equivalent to: this = this * s
Definition at line 278 of file tjvector.h.
returns the element-wise sum of two tjvectors
Definition at line 113 of file tjvector.h.
returns the element-wise sum of a tjvector with a scalar
Definition at line 173 of file tjvector.h.
Equivalent to: this = this + v
Definition at line 237 of file tjvector.h.
Equivalent to: this = this + s
Definition at line 245 of file tjvector.h.
returns the negation of a tjvector
Definition at line 153 of file tjvector.h.
returns the element-wise difference of two tjvectors
Definition at line 123 of file tjvector.h.
returns the element-wise difference of a tjvector with a scalar
Definition at line 191 of file tjvector.h.
Equivalent to: this = this - v
Definition at line 253 of file tjvector.h.
Equivalent to: this = this - s
Definition at line 261 of file tjvector.h.
returns the element-wise division of two tjvectors
Definition at line 143 of file tjvector.h.
returns the element-wise division of a tjvector with a scalar
Definition at line 229 of file tjvector.h.
Equivalent to: this = this / v
Definition at line 287 of file tjvector.h.
Equivalent to: this = this / s
Definition at line 295 of file tjvector.h.
assignment from std::vector
assign value to all elements of vector
copy assignment
STD_string tjvector< T >::printbody | ( | ) | const |
returns the elements of the vector as a formatted string
tjvector<T> tjvector< T >::range | ( | unsigned int | startindex, |
unsigned int | endindex | ||
) | const |
Returns the given range of elements starting at startindex and ending at endindex-1
Resizes the vector to 'newsize'. If the 'newsize' is smaller than the actual size, the starting values will be preserved in the smaller vector. If the 'newsize' is larger than the actual size, the vector will be zero padded.
Reimplemented in tjarray< dvector, double >, and tjarray< fvector, float >.
tjvector& tjvector< T >::set_c_array | ( | const unsigned char * | array, |
unsigned int | n | ||
) |
Gets n values from 'array' (raw memory), no resizing is done prior to assignment, this has to be manually beforehand. No bounds checking possible, so take care that the pointer array has memory allocated which is in fact n values long.
T tjvector< T >::sum | ( | ) | const |
Returns the sum of all elements
int tjvector< T >::write | ( | const STD_string & | fname, |
fopenMode | mode = overwriteMode , |
||
LONGEST_INT | nelements = -1 |
||
) | const |
Writes the first 'nelements' values to disk as raw data, the 'mode' determines whether data will be appended/overwritten if the file already exists. If 'nelements' is negative, the whole vector will we written. Returns 0 on success, -1 otherwise.
|
friend |
returns the element-wise product of a tjvector with a scalar
Definition at line 200 of file tjvector.h.
|
friend |
returns the element-wise sum of a tjvector with a scalar
Definition at line 163 of file tjvector.h.
|
friend |
returns the element-wise difference of a tjvector with a scalar
Definition at line 181 of file tjvector.h.
|
friend |
returns the element-wise division of a tjvector with a scalar
Definition at line 219 of file tjvector.h.
|
friend |
prints v to the stream s
Definition at line 423 of file tjvector.h.