SLIMMER
Public Member Functions | Static Public Attributes | Friends
SimpleBaseTVec< T, TS > Class Template Reference

Templated Base Class for Vectors. More...

#include <SimpleBaseTVec.h>

Inheritance diagram for SimpleBaseTVec< T, TS >:
SimpleTVec< T, STVEC_LEN, TS > SimpleVTVec< T, TS > SimpleVTVec< float, unsigned long int > SimpleVTVec< LinTransParam< T > > SimpleVTVec< SimpleTField< T, TS >, TS > SimpleVTVec< T2, unsigned long int > SimpleTField< T, TS > SimpleTField< float > SimpleTField< T2 > LinTransList< T > SimpleTFieldList< T, TD, TS >

List of all members.

Public Member Functions

 SimpleBaseTVec ()
 Default Constructor.
 SimpleBaseTVec (const SimpleBaseTVec< T, TS > &tmp)
 Copy Constructor.
virtual ~SimpleBaseTVec ()
 Destructor.
virtual void ReSize (const TS s)
 Change Size/Dimension of vector (only works for variable length vectors)
virtual void IncreaseSize (const TS s)
 Increase Size/Dimension of vector and Preserve Current Values (only works for variable length vectors)
virtual TS Size () const
 Return Size/Dimension of vector.
virtual T & operator[] (const TS &i)
 Return reference to given element (allows modification)
virtual T & operator[] (const int &i)
 Return reference to given element (allows modification)
virtual T operator() (const int &) const
 Return copy of a given element (class constant)
virtual T operator() (const TS &) const
 Return copy of a given element (class constant)
virtual T operator[] (const TS &) const
void Set (const char *s)
 Set Element values to string of numbers.
void SetAll (const T &v0)
 Set All Elements to a given Value.
void Null ()
 Set All Elements to Zero.
bool HasNAN ()
 Check for presence of NAN in elements.
void Unit ()
 Set All Elements to One.
void Random (const T &max=T(1.0), const T &min=T(0), long int seed=1234551662)
 Set Elements to Random Value with even distribution over given range.
void RandomNormal (const T &mean=T(1.0), const T &stddev=T(0), long int seed=1234551662)
 Set Elements to Random Value with Normal/Gaussian distribution.
bool operator== (const SimpleBaseTVec< T, TS > &v2) const
bool operator!= (const SimpleBaseTVec< T, TS > &v2) const
bool lessAny (SimpleBaseTVec< T, TS > &v2)
 Returns true if any element is less than the counterpart of v2.
template<typename T2 >
void lessThan (T val, SimpleBaseTVec< T2, TS > &v2)
 Sets v2 1 if the corresponding element is less than val, 0 if not.
template<typename T2 >
void greaterThan (T val, SimpleBaseTVec< T2, TS > &v2)
 Sets v2 1 if the corresponding element is greater than val, 0 if not.
void Convolve (SimpleBaseTVec< T, TS > &v2)
 VECTOR Convolve.
void Correlation (SimpleBaseTVec< T, TS > &v2)
 VECTOR Correlation.
template<typename T2 >
dot (const SimpleBaseTVec< T2, TS > &v2) const
 DOT PRODUCT-----------------------------.
template<typename TIN1 , typename TIN2 >
void cross (const SimpleBaseTVec< TIN1, TS > &v1, const SimpleBaseTVec< TIN2, TS > &v2)
 generalized cross product
virtual T Sum () const
 Return Sum.
template<typename T2 >
T2 Sum (T2 &tot) const
 Return Sum.
Avg () const
 Return Average.
template<typename T2 >
SumElemValMask (TS &cnt, const SimpleBaseTVec< T2, TS > &mask, const T2 maskThresh) const
 Return Sum of Element Values in Mask.
template<typename T2 >
AvgElemValMask (const SimpleBaseTVec< T2, TS > &mask, const T2 maskThresh) const
 Return Average Element Values in Mask.
Median () const
 Return Median. For even number of elements retained for backwards compatibility.
MedianElemVal () const
 Return Median. For even number of elements, returns the n/2-th element, not the average.
Var () const
 Return Variance.
StDev () const
 Return Standard Deviation.
Length () const
 Length Of Vector.
SqLength () const
 Squared Length.
void UpperThreshold (T const val)
 Force Upper Threshold on Element Values.
void LowerThreshold (T const val)
 Force Lower Threshold on Element Values.
void Threshold (T const val)
 Threshold elements to a Given Value.
void ThresholdBIN (T const val, T const valA, T const valB)
 Threshold and Binarize elements to one of two values.
void Norm ()
 Normalise Length of Vector to 1.0.
void NormP ()
 Normalize Sum of Vector to 1.0 (probability normalization)
void abs ()
 Set All Elements to Be Positive.
void intFloor ()
MaxElemVal () const
 Return Max Element Value.
MinElemVal () const
 Return Min Element Value.
TS MaxElement () const
 Return Element Index to Largest Element.
TS MinElement () const
 Return Element Index to Smallest Element.
TS MaxAbsElement () const
TS MinAbsElement () const
void MaxNorm ()
bool Contains (const T &it) const
 Test If vector Contains a Given value.
TS ReplaceValue (const T &origval, const T &newval)
 Replace All Voxel Values with New Values.
TS ReplaceValueRange (const T &origvalMin, const T &origvalMax, const T &newval)
 Replace All Voxel Values over a Range with New Values.
TS Count (const T &it) const
 Count number of elements with Given Value.
void ReflectInPlace ()
 Reflect in Place.
void Sort (SimpleBaseTVec< int, TS > &IDX, int order=0)
 Simple sorting: return order index into vector elements using bubble sort.
void Print (FILE *fp=stderr, char *name=NULL) const
 Print Elements to File.
void Print (const int w, const int p=0, FILE *fp=stderr) const
 Print Elements in with given precision to File.
int ElementDataType ()
template<>
void Null ()
template<>
void Null ()
template<>
short Avg () const
template<>
short Avg () const
template<>
const char _versionID []
template<>
const char _versionID []
template<>
const char _versionID []

Static Public Attributes

static const char _versionID []

Friends

ostream & operator<< (ostream &out, const SimpleBaseTVec< T, TS > &v)

Detailed Description

template<typename T, typename TS = unsigned int>
class SimpleBaseTVec< T, TS >

Templated Base Class for Vectors.

Contains functions for use in Fixed and Variable Sized Vectors

Author:
Colin Studholme 2008-
Id:
SimpleBaseTVec.h,v 1.55 2011/11/21 20:48:11 bicg Exp

Member Function Documentation

template<typename T, typename TS = unsigned int>
template<typename T2 >
T SimpleBaseTVec< T, TS >::dot ( const SimpleBaseTVec< T2, TS > &  v2) const [inline]

DOT PRODUCT-----------------------------.

Dot Product Note: Allows two different types Depends on * being defined between element types

template<typename T, typename TS = unsigned int>
TS SimpleBaseTVec< T, TS >::MaxAbsElement ( ) const [inline]

Return Element Index to Largest Absolute Element Note: Assumes fabs is defined for element type or cast to float exists

template<typename T, typename TS = unsigned int>
void SimpleBaseTVec< T, TS >::MaxNorm ( ) [inline]

Normalize so Max element has size 1.0 Note: Assumes fabs is defined for type T

template<typename T, typename TS = unsigned int>
TS SimpleBaseTVec< T, TS >::MinAbsElement ( ) const [inline]

Return Element Index to Smallest Absolute Element Note: Assumes fabs is defined for element type or cast to float exists

template<typename T, typename TS = unsigned int>
void SimpleBaseTVec< T, TS >::Random ( const T &  max = T(1.0),
const T &  min = T(0),
long int  seed = 1234551662 
) [inline]

Set Elements to Random Value with even distribution over given range.

Note: for integer data there is a rounding problem: cast always rounds down

template<typename T, typename TS = unsigned int>
void SimpleBaseTVec< T, TS >::RandomNormal ( const T &  mean = T(1.0),
const T &  stddev = T(0),
long int  seed = 1234551662 
) [inline]

Set Elements to Random Value with Normal/Gaussian distribution.

Note: for integer data there is a rounding problem: cast always rounds down

template<typename T, typename TS = unsigned int>
void SimpleBaseTVec< T, TS >::Set ( const char *  s) [inline]

Set Element values to string of numbers.

======= Set elements to values in a string
assumes double/int/float values separated by space
eg:
Set("10 20 30");

no test for unterminated string in char array!!
only works for elements types that can be made from doubles.

 All Classes Functions Variables Typedefs