ODIN
Public Member Functions | Friends | List of all members

#include <tjvector.h>

Inheritance diagram for tjvector< T >:
Inheritance graph
[legend]

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)
 
sum () const
 
tjvector< T > range (unsigned int startindex, unsigned int endindex) const
 
maxvalue () const
 
minvalue () const
 
maxabs () const
 
const T * c_array () const
 
tjvectorset_c_array (const unsigned char *array, unsigned int n)
 
normalize ()
 
tjvectorinterpolate (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)
 

Detailed Description

template<class T>
class tjvector< T >

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.

Constructor & Destructor Documentation

◆ tjvector() [1/4]

template<class T >
tjvector< T >::tjvector ( unsigned int  n = 0)

constructs a vector and allocates memory for n values which are initialised to zero.

◆ tjvector() [2/4]

template<class T >
tjvector< T >::tjvector ( const T *  array,
unsigned int  n 
)

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.

◆ tjvector() [3/4]

template<class T >
tjvector< T >::tjvector ( const STD_vector< T > &  v)

constructs a copy from std::vector

◆ tjvector() [4/4]

template<class T >
tjvector< T >::tjvector ( const tjvector< T > &  tv)

Copy constructor

◆ ~tjvector()

template<class T >
virtual tjvector< T >::~tjvector ( )
virtual

destructor

Member Function Documentation

◆ c_array()

template<class T >
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.

◆ fill_linear()

template<class T >
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

◆ interpolate()

template<class T >
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.

◆ length()

template<class T >
unsigned int tjvector< T >::length ( ) const

returns the length

◆ load()

template<class T >
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.

◆ maxabs()

template<class T >
T tjvector< T >::maxabs ( ) const

Maximum absolute value

◆ maxvalue()

template<class T >
T tjvector< T >::maxvalue ( ) const

Return the greatest value

◆ minvalue()

template<class T >
T tjvector< T >::minvalue ( ) const

Return the smallest value

◆ normalize()

template<class T >
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.

◆ operator*() [1/2]

template<class T >
tjvector<T> tjvector< T >::operator* ( const STD_vector< T > &  w) const
inline

returns the element-wise product of two tjvectors

Definition at line 133 of file tjvector.h.

◆ operator*() [2/2]

template<class T >
tjvector<T> tjvector< T >::operator* ( const T &  s) const
inline

returns the element-wise product of a tjvector with a scalar

Definition at line 210 of file tjvector.h.

◆ operator*=() [1/2]

template<class T >
tjvector<T>& tjvector< T >::operator*= ( const STD_vector< T > &  v)
inline

Equivalent to: this = this * v

Definition at line 270 of file tjvector.h.

◆ operator*=() [2/2]

template<class T >
tjvector<T>& tjvector< T >::operator*= ( const T &  s)
inline

Equivalent to: this = this * s

Definition at line 278 of file tjvector.h.

◆ operator+() [1/2]

template<class T >
tjvector<T> tjvector< T >::operator+ ( const STD_vector< T > &  w) const
inline

returns the element-wise sum of two tjvectors

Definition at line 113 of file tjvector.h.

◆ operator+() [2/2]

template<class T >
tjvector<T> tjvector< T >::operator+ ( const T &  s) const
inline

returns the element-wise sum of a tjvector with a scalar

Definition at line 173 of file tjvector.h.

◆ operator+=() [1/2]

template<class T >
tjvector<T>& tjvector< T >::operator+= ( const STD_vector< T > &  v)
inline

Equivalent to: this = this + v

Definition at line 237 of file tjvector.h.

◆ operator+=() [2/2]

template<class T >
tjvector<T>& tjvector< T >::operator+= ( const T &  s)
inline

Equivalent to: this = this + s

Definition at line 245 of file tjvector.h.

◆ operator-() [1/3]

template<class T >
tjvector<T> tjvector< T >::operator- ( ) const
inline

returns the negation of a tjvector

Definition at line 153 of file tjvector.h.

◆ operator-() [2/3]

template<class T >
tjvector<T> tjvector< T >::operator- ( const STD_vector< T > &  w) const
inline

returns the element-wise difference of two tjvectors

Definition at line 123 of file tjvector.h.

◆ operator-() [3/3]

template<class T >
tjvector<T> tjvector< T >::operator- ( const T &  s) const
inline

returns the element-wise difference of a tjvector with a scalar

Definition at line 191 of file tjvector.h.

◆ operator-=() [1/2]

template<class T >
tjvector<T>& tjvector< T >::operator-= ( const STD_vector< T > &  v)
inline

Equivalent to: this = this - v

Definition at line 253 of file tjvector.h.

◆ operator-=() [2/2]

template<class T >
tjvector<T>& tjvector< T >::operator-= ( const T &  s)
inline

Equivalent to: this = this - s

Definition at line 261 of file tjvector.h.

◆ operator/() [1/2]

template<class T >
tjvector<T> tjvector< T >::operator/ ( const STD_vector< T > &  w) const
inline

returns the element-wise division of two tjvectors

Definition at line 143 of file tjvector.h.

◆ operator/() [2/2]

template<class T >
tjvector<T> tjvector< T >::operator/ ( const T &  s) const
inline

returns the element-wise division of a tjvector with a scalar

Definition at line 229 of file tjvector.h.

◆ operator/=() [1/2]

template<class T >
tjvector<T>& tjvector< T >::operator/= ( const STD_vector< T > &  v)
inline

Equivalent to: this = this / v

Definition at line 287 of file tjvector.h.

◆ operator/=() [2/2]

template<class T >
tjvector<T>& tjvector< T >::operator/= ( const T &  s)
inline

Equivalent to: this = this / s

Definition at line 295 of file tjvector.h.

◆ operator=() [1/3]

template<class T >
tjvector<T>& tjvector< T >::operator= ( const STD_vector< T > &  vec)

assignment from std::vector

◆ operator=() [2/3]

template<class T >
tjvector<T>& tjvector< T >::operator= ( const T &  value)

assign value to all elements of vector

◆ operator=() [3/3]

template<class T >
tjvector<T>& tjvector< T >::operator= ( const tjvector< T > &  tv)

copy assignment

◆ printbody()

template<class T >
STD_string tjvector< T >::printbody ( ) const

returns the elements of the vector as a formatted string

◆ range()

template<class T >
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

◆ resize()

template<class T >
virtual tjvector<T>& tjvector< T >::resize ( unsigned int  newsize)
virtual

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 >.

◆ set_c_array()

template<class T >
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.

◆ sum()

template<class T >
T tjvector< T >::sum ( ) const

Returns the sum of all elements

◆ write()

template<class T >
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.

Friends And Related Function Documentation

◆ operator*

template<class T >
tjvector<T> operator* ( const T &  s,
const STD_vector< T > &  v 
)
friend

returns the element-wise product of a tjvector with a scalar

Definition at line 200 of file tjvector.h.

◆ operator+

template<class T >
tjvector<T> operator+ ( const T &  s,
const STD_vector< T > &  v 
)
friend

returns the element-wise sum of a tjvector with a scalar

Definition at line 163 of file tjvector.h.

◆ operator-

template<class T >
tjvector<T> operator- ( const T &  s,
const STD_vector< T > &  v 
)
friend

returns the element-wise difference of a tjvector with a scalar

Definition at line 181 of file tjvector.h.

◆ operator/

template<class T >
tjvector<T> operator/ ( const T &  s,
const STD_vector< T > &  v 
)
friend

returns the element-wise division of a tjvector with a scalar

Definition at line 219 of file tjvector.h.

◆ operator<<

template<class T >
STD_ostream& operator<< ( STD_ostream &  s,
const tjvector< T > &  v 
)
friend

prints v to the stream s

Definition at line 423 of file tjvector.h.


The documentation for this class was generated from the following file: