Vector of variable size.
More...
#include "Imagine/LinAlg.h"
|
|
typedef Base::const_iterator | const_iterator |
| | Const iterator type.
|
| |
|
typedef Base::iterator | iterator |
| | Iterator type.
|
| |
|
typedef const T * | const_iterator |
| | Const iterator type.
|
| |
|
typedef T * | iterator |
| | Iterator type.
|
| |
template<typename T>
class Imagine::Vector< T >
Vector of variable size. Memory is reference counted, i.e.:
- a=b results in a and b sharing the same memory
- the last object using memory frees it when it dies
- use clone() when this sharing is not desired
- Parameters
-
- Examples
- LinAlg/test/test.cpp.
◆ Vector() [1/4]
Constructs an unallocated vector of variables of type T
Vector()
Empty constructor.
Definition Vector.h:36
◆ Vector() [2/4]
Constructs an allocated vector of size variables of type T
- Parameters
-
◆ Vector() [3/4]
Constructs a vector from another one (sharing memory!)
- Parameters
-
◆ Vector() [4/4]
template<typename T>
| Imagine::Vector< T >::Vector |
( |
T * | ptr, |
|
|
size_t | n, |
|
|
bool | handleDelete = false ) |
|
inline |
Constructs a vector of variables of type T stored at an already allocated memory. Does not allocate fresh memory. Does not free given memory at object destruction unless handleDelete=true. This memory must indeed stay available during object life.
- Parameters
-
| ptr | address of memory |
| n | vector size |
| handleDelete | delete memory at destruction? (default=false) |
T t[]={1,2,3};
T *t2=new T[3];
◆ ~Vector()
Reference counted desctructor: frees memory if the object is the last one to use it.
◆ clone()
Clones: creates a new vector, with fresh memory, copying values to it
- Returns
- cloned vector
- Examples
- LinAlg/test/test.cpp.
◆ fill()
Fills with constant value
- Parameters
-
| x | value to be copied to each element |
- Returns
- self reference
- Examples
- LinAlg/test/test.cpp.
◆ getSubVect()
Construct a sub vector, i.e. a new vector with fresh memory, initialized from a part of values of *this
- Parameters
-
| offset | position of first element of sub vector |
| size | size of sub vector |
- Returns
- sub vector
- Examples
- LinAlg/test/test.cpp.
◆ getSubVectRef()
Construct a sub vector without allocating new memory but pointing to some part of *this. Beware: *this (or its memory) must not be destroyed as long as the returned subvectref is used!
- Parameters
-
| offset | position of first element of sub vector |
| size | size of sub vector |
- Returns
- sub vector
- Examples
- LinAlg/test/test.cpp.
◆ normalize()
◆ operator*() [1/2]
Scalar product of Vectors
- Parameters
-
| v | Vector to be combined with myself |
- Returns
- Scalar product
◆ operator*() [2/2]
Multiplies each coordinate by a scalar
- Parameters
-
- Returns
- Result
◆ operator*=()
Multiplies each coordinate by a scalar
- Parameters
-
- Returns
- self reference
◆ operator+() [1/2]
Addition of two Vectors
- Parameters
-
- Returns
- sum
◆ operator+() [2/2]
Adds a scalar to each coordinate
- Parameters
-
| x | Scalar to be added to myself |
- Returns
- sum
◆ operator+=() [1/2]
In place Addition of Vectors
- Parameters
-
- Returns
- self reference
◆ operator+=() [2/2]
Adds a scalar to each own coordinate
- Parameters
-
| x | Scalar to be added to myself |
- Returns
- self reference
◆ operator-() [1/3]
Opposite of a Vector
- Returns
- Opposite
◆ operator-() [2/3]
Substraction of two Vectors
- Parameters
-
| v | Vector to be substracted from myself |
- Returns
- difference
◆ operator-() [3/3]
Substracts a scalar to each coordinate
- Parameters
-
| x | Scalar to be substracted from myself |
- Returns
- difference
◆ operator-=() [1/2]
In place Substraction of Vectors
- Parameters
-
| v | Vector to be substracted from myself |
- Returns
- self reference
◆ operator-=() [2/2]
Subtracts a scalar to each own coordinate
- Parameters
-
| x | Scalar to be substracted from myself |
- Returns
- self reference
◆ operator/()
Divides each coordinate by a scalar
- Parameters
-
- Returns
- Result
◆ operator/=()
Divides each coordinate by a scalar
- Parameters
-
- Returns
- self reference
◆ operator=()
Assigns from another vector (sharing its memory)
- Parameters
-
| v | vector to be assigned to |
- Returns
- self reference
◆ Zero()
Vector with constant 0 value
- Parameters
-
- Returns
- vector
static Vector Zero(size_t n)
Zero vector.
Definition Vector.h:101
◆ convolution
Convolution. Returns a vector which size if sum of sizes minus 1
- Parameters
-
| K | kernel |
| v | vector to convolution with K |
- Returns
- Result
friend Vector convolution(const Vector &K, const Vector &v)
Convolution.
Definition Vector.h:403
◆ correlation
template<typename T>
| T correlation |
( |
const Vector< T > & | V1, |
|
|
const Vector< T > & | V2 ) |
|
friend |
Correlation between 2 vectors
- Parameters
-
- Returns
- correlation
friend T correlation(const Vector &V1, const Vector &V2)
Correlation.
Definition Vector.h:439
◆ dist
template<typename T>
| double dist |
( |
const Vector< T > & | V1, |
|
|
const Vector< T > & | V2 ) |
|
friend |
Distance Correlation between 2 vectors
- Parameters
-
- Returns
- distance
friend double dist(const Vector &V1, const Vector &V2)
Distance.
Definition Vector.h:467
◆ maxNorm
template<typename T>
| T maxNorm |
( |
const Vector< T > & | v | ) |
|
|
friend |
Maximum norm
- Parameters
-
- Returns
- Maximum norm
friend T maxNorm(const Vector &v)
Maximum norm.
Definition Vector.h:364
◆ mean
template<typename T>
| T mean |
( |
const Vector< T > & | v | ) |
|
|
friend |
Mean of values
- Parameters
-
- Returns
- Result
friend T mean(const Vector &v)
Mean of values.
Definition Vector.h:392
◆ norm
template<typename T>
| T norm |
( |
const Vector< T > & | v | ) |
|
|
friend |
Euclidean norm
- Parameters
-
- Returns
- squared Euclidean norm
friend T norm2(const Vector &v)
Squared Euclidean norm.
Definition Vector.h:331
◆ norm2
template<typename T>
| T norm2 |
( |
const Vector< T > & | v | ) |
|
|
friend |
Squared Euclidean norm. NB: obtained from Euclidean norm, thus it's not faster to use norm2() instead of norm() ...
- Parameters
-
- Returns
- squared Euclidean norm
◆ normalized
Normalization using Euclidean norm
- Parameters
-
- Returns
- normalized vector
friend Vector normalized(const Vector &v)
Euclidean normalization.
Definition Vector.h:352
◆ normalizedCorrelation
template<typename T>
| T normalizedCorrelation |
( |
const Vector< T > & | V1, |
|
|
const Vector< T > & | V2 ) |
|
friend |
Normalized Correlation between 2 vectors
- Parameters
-
- Returns
- correlation
friend T normalizedCorrelation(const Vector &V1, const Vector &V2)
Normalized Correlation.
Definition Vector.h:451
◆ operator*
Multiplies each coordinate by a scalar
- Parameters
-
- Returns
- The result
◆ operator+
Adds a scalar to each coordinate
- Parameters
-
- Returns
- The result
◆ operator-
Substract each coordinate to a scalar
- Parameters
-
- Returns
- The result
◆ sum
template<typename T>
| T sum |
( |
const Vector< T > & | v | ) |
|
|
friend |
Sum of values
- Parameters
-
- Returns
- Result
friend T sum(const Vector &v)
Sum of values.
Definition Vector.h:382
◆ truncConvolution
Truncated convolution. Returns a vector of the same size than v.
- Parameters
-
| K | kernel |
| v | vector to convolution with K |
| n | shift |
- Returns
- Result
friend Vector truncConvolution(const Vector &K, const Vector &v, size_t n=0)
Truncated Convolution.
Definition Vector.h:421
The documentation for this class was generated from the following file:
- /home/pascal/Ponts/svn/ImagineQt/Imagine/LinAlg/src/Imagine/LinAlg/Vector.h