Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | Related Functions
vnl_vector< T > Class Template Reference

Mathematical vector class, templated by type of element. More...

#include <vnl_vector.h>

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

List of all members.

Public Types

typedef T element_type
 Type defs for iterators.
typedef unsigned size_type
typedef T * iterator
 Type defs for iterators.
typedef T const * const_iterator
 Const iterator type.
typedef vnl_c_vector< T >::abs_t abs_t

Public Member Functions

 vnl_vector ()
 Creates an empty vector. O(1).
 vnl_vector (unsigned len)
 Creates vector containing n elements.
 vnl_vector (unsigned len, T const &v0)
 Creates vector of len elements, all set to v0.
 vnl_vector (unsigned len, int n, T const values[])
 Creates a vector of specified length and initialize first n elements with values. O(n).
 vnl_vector (T const *data_block, unsigned int n)
 Create n element vector and copy data from data_block.
 vnl_vector (vnl_vector< T > const &)
 Copy constructor.
 vnl_vector (vnl_vector< T > const &, vnl_vector< T > const &, vnl_tag_add)
 vnl_vector (vnl_vector< T > const &, vnl_vector< T > const &, vnl_tag_sub)
 vnl_vector (vnl_vector< T > const &, T, vnl_tag_mul)
 vnl_vector (vnl_vector< T > const &, T, vnl_tag_div)
 vnl_vector (vnl_vector< T > const &, T, vnl_tag_add)
 vnl_vector (vnl_vector< T > const &, T, vnl_tag_sub)
 vnl_vector (vnl_matrix< T > const &, vnl_vector< T > const &, vnl_tag_mul)
 vnl_vector (vnl_vector< T > const &, vnl_matrix< T > const &, vnl_tag_mul)
 vnl_vector (vnl_vector< T > &that, vnl_tag_grab)
 ~vnl_vector ()
 Destructor.
unsigned size () const
 Return the length, number of elements, dimension of this vector.
void put (unsigned int i, T const &)
 Put value at given position in vector.
get (unsigned int i) const
 Get value at element i.
vnl_vectorfill (T const &v)
 Set all values to v.
vnl_vectorcopy_in (T const *ptr)
 Sets elements to ptr[i].
void copy_out (T *) const
 Copy elements to ptr[i].
vnl_vectorset (T const *ptr)
 Sets elements to ptr[i].
T & operator() (unsigned int i)
 Return reference to the element at specified index.
T const & operator() (unsigned int i) const
 Return reference to the element at specified index. No range checking.
T & operator[] (unsigned int i)
 Return reference to the element at specified index. No range checking.
T const & operator[] (unsigned int i) const
 Return reference to the element at specified index. No range checking.
vnl_vector< T > & operator= (T const &v)
 Set all elements to value v.
vnl_vector< T > & operator= (vnl_vector< T > const &rhs)
 Copy operator.
vnl_vector< T > & operator+= (T)
 Add scalar value to all elements.
vnl_vector< T > & operator-= (T value)
 Subtract scalar value from all elements.
vnl_vector< T > & operator*= (T)
 Multiply all elements by scalar.
vnl_vector< T > & operator/= (T)
 Divide all elements by scalar.
vnl_vector< T > & operator+= (vnl_vector< T > const &rhs)
 Add rhs to this and return *this.
vnl_vector< T > & operator-= (vnl_vector< T > const &rhs)
 Subtract rhs from this and return *this.
vnl_vector< T > & pre_multiply (vnl_matrix< T > const &M)
 *this = M*(*this) where M is a suitable matrix.
vnl_vector< T > & post_multiply (vnl_matrix< T > const &M)
 *this = (*this)*M where M is a suitable matrix.
vnl_vector< T > & operator*= (vnl_matrix< T > const &m)
 *this = (*this)*M where M is a suitable matrix.
vnl_vector< T > operator+ () const
 Unary plus operator.
vnl_vector< T > operator- () const
 Unary minus operator.
vnl_vector< T > operator+ (T v) const
vnl_vector< T > operator- (T v) const
vnl_vector< T > operator* (T v) const
vnl_vector< T > operator/ (T v) const
vnl_vector< T > operator+ (vnl_vector< T > const &v) const
vnl_vector< T > operator- (vnl_vector< T > const &v) const
vnl_vector< T > operator* (vnl_matrix< T > const &M) const
T const * data_block () const
 Access the contiguous block storing the elements in the vector. O(1).
T * data_block ()
 Access the contiguous block storing the elements in the vector. O(1).
iterator begin ()
 Iterator pointing to start of data.
iterator end ()
 Iterator pointing to element beyond end of data.
const_iterator begin () const
 Iterator pointing to start of data.
const_iterator end () const
 Iterator pointing to element beyond end of data.
vnl_vector< T > const & as_ref () const
 Return a reference to this.
vnl_vector< T > & as_ref ()
 Return a reference to this.
vnl_vector< T > apply (T(*f)(T)) const
 Applies function to elements.
vnl_vector< T > apply (T(*f)(T const &)) const
 Applies function to elements.
vnl_vector< T > extract (unsigned int len, unsigned int start=0) const
 Returns a subvector specified by the start index and length. O(n).
vnl_vector< T > & update (vnl_vector< T > const &, unsigned int start=0)
 Replaces elements with index beginning at start, by values of v. O(n).
abs_t squared_magnitude () const
 Return sum of squares of elements.
abs_t magnitude () const
 Return magnitude (length) of vector.
abs_t one_norm () const
 Return sum of absolute values of the elements.
abs_t two_norm () const
 Return sqrt of sum of squares of values of elements.
abs_t inf_norm () const
 Return largest absolute element value.
vnl_vector< T > & normalize ()
 Normalise by dividing through by the magnitude.
abs_t rms () const
 Root Mean Squares of values.
min_value () const
 Smallest value.
max_value () const
 Largest value.
unsigned arg_min () const
 Location of smallest value.
unsigned arg_max () const
 Location of largest value.
mean () const
 Mean of values in vector.
sum () const
 Sum of values in a vector.
vnl_vectorflip ()
 Reverse the order of the elements.
void swap (vnl_vector< T > &that)
 Set this to that and that to this.
void assert_size (unsigned sz) const
 Check that size()==sz if not, abort();.
void assert_finite () const
 Check that this is finite if not, abort();.
bool is_finite () const
 Return true if it's finite.
bool is_zero () const
 Return true iff all the entries are zero.
bool empty () const
 Return true iff the size is zero.
bool is_equal (vnl_vector< T > const &rhs, double tol) const
 Return true if all elements of vectors are equal, within given tolerance.
bool operator_eq (vnl_vector< T > const &v) const
 Return true if *this == v.
bool operator== (vnl_vector< T > const &that) const
 Equality test.
bool operator!= (vnl_vector< T > const &that) const
 Inequality test.
bool set_size (unsigned n)
 Resize to n elements.
void clear ()
 Make the vector as if it had been default-constructed.
bool read_ascii (vcl_istream &s)
 Read from text stream.

Static Public Member Functions

static vnl_vector< T > read (vcl_istream &s)
 Read from text stream.

Protected Member Functions

void assert_size_internal (unsigned sz) const
void assert_finite_internal () const
void destroy ()
 Frees up the array inside vector. O(1).

Static Protected Member Functions

static void inline_function_tickler ()

Protected Attributes

unsigned num_elmts
T * data

Friends

class vnl_matrix< T >

Related Functions

(Note that these are not member functions.)

template<class T >
vnl_vector< T > vnl_convolve (vnl_vector< T > const &v1, vnl_vector< T > const &v2, int use_fft=0)
 Convolve two vnl_vector<T>'s, with the same base type T.
template<class T1 , class T2 , class U >
vnl_vector< U > vnl_convolve_cyclic (vnl_vector< T1 > const &v1, vnl_vector< T2 > const &v2, U *, bool use_fft=false)
 Cyclically convolve two vnl_vector<T>'s of the same length.
template<class T >
void vsl_b_write (vsl_b_ostream &os, const vnl_vector< T > &v)
 Binary save vnl_vector to stream.
template<class T >
void vsl_b_read (vsl_b_istream &is, vnl_vector< T > &v)
 Binary load vnl_vector from stream.
template<class T >
void vsl_print_summary (vcl_ostream &os, const vnl_vector< T > &b)
 Print human readable summary of object to a stream.
template<class T >
vnl_vector< vcl_complex< T > > vnl_complexify (vnl_vector< T > const &R)
 Return complexified version of real vector R.
template<class T >
vnl_vector< vcl_complex< T > > vnl_complexify (vnl_vector< T > const &R, vnl_vector< T > const &I)
 Return complex vector R+j*I from two real vectors R and I.
template<class S , class T >
void vnl_copy (S const *src, T *dst, unsigned n)
 Easy conversion between vectors and matrices templated over different types.
template<class S , class T >
void vnl_copy (S const &, T &)
 Easy conversion between vectors and matrices templated over different types.
template<class T >
vnl_cross_2d (const vnl_vector< T > &v1, const vnl_vector< T > &v2)
 Compute the 2-D cross product.
template<class T >
vnl_vector< T > vnl_cross_3d (const vnl_vector< T > &v1, const vnl_vector< T > &v2)
 Compute the 3-D cross product.
template<class T >
vnl_vector< T > operator* (vnl_diag_matrix< T > const &D, vnl_vector< T > const &A)
 Multiply a vnl_diag_matrix by a vnl_vector. n flops.
template<class T >
vnl_vector< T > operator* (vnl_vector< T > const &A, vnl_diag_matrix< T > const &D)
 Multiply a vnl_vector by a vnl_diag_matrix. n flops.
template<class T >
vnl_vector< T > vnl_imag (vnl_vector< vcl_complex< T > > const &C)
 Vector of imaginary parts of vnl_vector<vcl_complex<T> >.
template<class T >
vcl_ostream & vnl_matlab_print (vcl_ostream &, vnl_vector< T > const &, char const *variable_name=0, vnl_matlab_print_format=vnl_matlab_print_format_default)
 print a vnl_vector<T>.
template<class T >
bool operator< (vnl_vector< T > const &lhs, vnl_vector< T > const &rhs)
 Define a complete ordering on vnl_vector.
template<class T >
vnl_vector< T > vnl_real (vnl_vector< vcl_complex< T > > const &C)
 Vector of real parts of vnl_vector<vcl_complex<T> >.
template<class T >
vnl_vector< T > operator+ (T s, vnl_vector< T > const &v)
 add scalar and vector. O(n).
template<class T >
vnl_vector< T > operator- (T s, vnl_vector< T > const &v)
 subtract vector from scalar. O(n).
template<class T >
vnl_vector< T > operator* (T s, vnl_vector< T > const &v)
 multiply scalar and vector. O(n).
template<class T >
void swap (vnl_vector< T > &a, vnl_vector< T > &b)
 Interchange the two vectors.
template<class T >
vnl_vector_ssd (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Euclidean Distance between two vectors.
template<class T >
export vcl_ostream & operator<< (vcl_ostream &, vnl_vector< T > const &)
 Write vector to a vcl_ostream.
template<class T >
export vcl_istream & operator>> (vcl_istream &, vnl_vector< T > &)
 Read vector from a vcl_istream.
template<class T >
void x_write (vcl_ostream &os, vnl_vector< T > const &v, vcl_string name="vnl_vector")
 XML save vnl_vector to stream.
template<class T >
void x_write_tree (vcl_ostream &os, vnl_vector< T > const &v, vcl_string name="vnl_vector")
 XML save vnl_vector as a 2-level tree to stream.

Detailed Description

template<class T>
class vnl_vector< T >

Mathematical vector class, templated by type of element.

The vnl_vector<T> class implements one-dimensional arithmetic vectors to be used with the vnl_matrix<T> class. vnl_vector<T> has size fixed by constructor time or changed by assignment operator. For faster, non-mallocing vectors with size known at compile time, use vnl_vector_fixed* or vnl_T_n (e.g. vnl_double_3).

NOTE: Vectors are indexed from zero! Thus valid elements are [0,size()-1].

Definition at line 75 of file vnl_vector.h.


Member Typedef Documentation

template<class T>
typedef vnl_c_vector<T>::abs_t vnl_vector< T >::abs_t

Definition at line 291 of file vnl_vector.h.

template<class T>
typedef T const* vnl_vector< T >::const_iterator

Const iterator type.

Definition at line 264 of file vnl_vector.h.

template<class T>
typedef T vnl_vector< T >::element_type

Type defs for iterators.

Definition at line 252 of file vnl_vector.h.

template<class T>
typedef T* vnl_vector< T >::iterator

Type defs for iterators.

Definition at line 256 of file vnl_vector.h.

template<class T>
typedef unsigned vnl_vector< T >::size_type

Definition at line 253 of file vnl_vector.h.


Constructor & Destructor Documentation

template<class T>
vnl_vector< T >::vnl_vector ( ) [inline]

Creates an empty vector. O(1).

Definition at line 81 of file vnl_vector.h.

template<class T >
vnl_vector< T >::vnl_vector ( unsigned  len) [explicit]

Creates vector containing n elements.

Creates a vector with specified length. O(n).

Elements are not initialized.

Definition at line 82 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( unsigned  len,
T const &  v0 
)

Creates vector of len elements, all set to v0.

Creates a vector of specified length, and initialize all elements with value. O(n).

Definition at line 92 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( unsigned  len,
int  n,
T const  values[] 
)

Creates a vector of specified length and initialize first n elements with values. O(n).

Definition at line 103 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( T const *  data_block,
unsigned int  n 
)

Create n element vector and copy data from data_block.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  v)

Copy constructor.

Creates a new copy of vector v. O(n).

Definition at line 155 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  u,
vnl_vector< T > const &  v,
vnl_tag_add   
)

Definition at line 178 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  u,
vnl_vector< T > const &  v,
vnl_tag_sub   
)

Definition at line 191 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  u,
s,
vnl_tag_mul   
)

Definition at line 204 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  u,
s,
vnl_tag_div   
)

Definition at line 213 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  u,
s,
vnl_tag_add   
)

Definition at line 222 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  u,
s,
vnl_tag_sub   
)

Definition at line 231 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_matrix< T > const &  M,
vnl_vector< T > const &  v,
vnl_tag_mul   
)

Definition at line 240 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > const &  v,
vnl_matrix< T > const &  M,
vnl_tag_mul   
)

Definition at line 253 of file vnl_vector.txx.

template<class T>
vnl_vector< T >::vnl_vector ( vnl_vector< T > &  that,
vnl_tag_grab   
) [inline]

Definition at line 131 of file vnl_vector.h.

template<class T >
vnl_vector< T >::~vnl_vector ( )

Destructor.

Definition at line 265 of file vnl_vector.txx.


Member Function Documentation

template<class T>
vnl_vector< T > vnl_vector< T >::apply ( T(*)(T)  f) const

Applies function to elements.

Return the vector made by applying "f" to each element.

Definition at line 643 of file vnl_vector.txx.

template<class T>
vnl_vector< T > vnl_vector< T >::apply ( T(*)(T const &)  f) const

Applies function to elements.

Definition at line 634 of file vnl_vector.txx.

template<class T>
unsigned vnl_vector< T >::arg_max ( ) const [inline]

Location of largest value.

Definition at line 327 of file vnl_vector.h.

template<class T>
unsigned vnl_vector< T >::arg_min ( ) const [inline]

Location of smallest value.

Definition at line 324 of file vnl_vector.h.

template<class T>
vnl_vector<T> const& vnl_vector< T >::as_ref ( ) const [inline]

Return a reference to this.

Useful in code which would prefer not to know if its argument is a vector, vector_ref or a vector_fixed. Note that it doesn't return a vector_ref, so it's only useful in templates or macros.

Definition at line 274 of file vnl_vector.h.

template<class T>
vnl_vector<T>& vnl_vector< T >::as_ref ( ) [inline]

Return a reference to this.

Definition at line 277 of file vnl_vector.h.

template<class T>
void vnl_vector< T >::assert_finite ( ) const [inline]

Check that this is finite if not, abort();.

This function does or tests nothing if NDEBUG is defined

Definition at line 379 of file vnl_vector.h.

template<class T >
void vnl_vector< T >::assert_finite_internal ( ) const [protected]

Definition at line 794 of file vnl_vector.txx.

template<class T>
void vnl_vector< T >::assert_size ( unsigned  sz) const [inline]

Check that size()==sz if not, abort();.

This function does or tests nothing if NDEBUG is defined

Definition at line 371 of file vnl_vector.h.

template<class T >
void vnl_vector< T >::assert_size_internal ( unsigned  sz) const [protected]

Definition at line 804 of file vnl_vector.txx.

template<class T>
iterator vnl_vector< T >::begin ( ) [inline]

Iterator pointing to start of data.

Definition at line 258 of file vnl_vector.h.

template<class T>
const_iterator vnl_vector< T >::begin ( ) const [inline]

Iterator pointing to start of data.

Definition at line 266 of file vnl_vector.h.

template<class T >
void vnl_vector< T >::clear ( )

Make the vector as if it had been default-constructed.

Definition at line 283 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::copy_in ( T const *  ptr)

Sets elements to ptr[i].

Sets elements of a vector to those in an array. O(n).

Note: ptr[i] must be valid for i=0..size()-1

Definition at line 368 of file vnl_vector.txx.

template<class T>
void vnl_vector< T >::copy_out ( T *  ptr) const

Copy elements to ptr[i].

Sets elements of an array to those in vector. O(n).

Note: ptr[i] must be valid for i=0..size()-1

Definition at line 378 of file vnl_vector.txx.

template<class T>
T const* vnl_vector< T >::data_block ( ) const [inline]

Access the contiguous block storing the elements in the vector. O(1).

data_block()[0] is the first element of the vector

Definition at line 245 of file vnl_vector.h.

template<class T>
T* vnl_vector< T >::data_block ( ) [inline]

Access the contiguous block storing the elements in the vector. O(1).

data_block()[0] is the first element of the vector

Definition at line 249 of file vnl_vector.h.

template<class T >
void vnl_vector< T >::destroy ( ) [protected]

Frees up the array inside vector. O(1).

Definition at line 277 of file vnl_vector.txx.

template<class T>
bool vnl_vector< T >::empty ( ) const [inline]

Return true iff the size is zero.

Definition at line 392 of file vnl_vector.h.

template<class T>
iterator vnl_vector< T >::end ( ) [inline]

Iterator pointing to element beyond end of data.

Definition at line 261 of file vnl_vector.h.

template<class T>
const_iterator vnl_vector< T >::end ( ) const [inline]

Iterator pointing to element beyond end of data.

Definition at line 268 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::extract ( unsigned int  len,
unsigned int  start = 0 
) const

Returns a subvector specified by the start index and length. O(n).

template<class T>
vnl_vector< T > & vnl_vector< T >::fill ( T const &  v)

Set all values to v.

Sets all elements of a vector to a specified fill value. O(n).

Definition at line 357 of file vnl_vector.txx.

template<class T >
vnl_vector< T > & vnl_vector< T >::flip ( )

Reverse the order of the elements.

Element i swaps with element size()-1-i

Definition at line 713 of file vnl_vector.txx.

template<class T >
T vnl_vector< T >::get ( unsigned int  index) const [inline]

Get value at element i.

Gets the element at specified index and return its value. O(1).

Range check is performed.

Definition at line 468 of file vnl_vector.h.

template<class T>
abs_t vnl_vector< T >::inf_norm ( ) const [inline]

Return largest absolute element value.

Definition at line 306 of file vnl_vector.h.

template<class T >
void vnl_vector< T >::inline_function_tickler ( ) [static, protected]

Definition at line 866 of file vnl_vector.txx.

template<class T>
bool vnl_vector< T >::is_equal ( vnl_vector< T > const &  rhs,
double  tol 
) const

Return true if all elements of vectors are equal, within given tolerance.

Definition at line 813 of file vnl_vector.txx.

template<class T >
bool vnl_vector< T >::is_finite ( ) const

Return true if it's finite.

Definition at line 773 of file vnl_vector.txx.

template<class T >
bool vnl_vector< T >::is_zero ( ) const

Return true iff all the entries are zero.

Definition at line 783 of file vnl_vector.txx.

template<class T>
abs_t vnl_vector< T >::magnitude ( ) const [inline]

Return magnitude (length) of vector.

Definition at line 297 of file vnl_vector.h.

template<class T>
T vnl_vector< T >::max_value ( ) const [inline]

Largest value.

Definition at line 321 of file vnl_vector.h.

template<class T>
T vnl_vector< T >::mean ( ) const [inline]

Mean of values in vector.

Definition at line 330 of file vnl_vector.h.

template<class T>
T vnl_vector< T >::min_value ( ) const [inline]

Smallest value.

Definition at line 318 of file vnl_vector.h.

template<class T>
vnl_vector<T>& vnl_vector< T >::normalize ( ) [inline]

Normalise by dividing through by the magnitude.

Definition at line 309 of file vnl_vector.h.

template<class T>
abs_t vnl_vector< T >::one_norm ( ) const [inline]

Return sum of absolute values of the elements.

Definition at line 300 of file vnl_vector.h.

template<class T>
bool vnl_vector< T >::operator!= ( vnl_vector< T > const &  that) const [inline]

Inequality test.

Definition at line 404 of file vnl_vector.h.

template<class T>
T& vnl_vector< T >::operator() ( unsigned int  i) [inline]

Return reference to the element at specified index.

There are assert style boundary checks - #define NDEBUG to turn them off.

Definition at line 166 of file vnl_vector.h.

template<class T>
T const& vnl_vector< T >::operator() ( unsigned int  i) const [inline]

Return reference to the element at specified index. No range checking.

There are assert style boundary checks - #define NDEBUG to turn them off.

Definition at line 175 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::operator* ( v) const [inline]

Definition at line 234 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::operator* ( vnl_matrix< T > const &  M) const [inline]

Definition at line 239 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator*= ( value)

Multiply all elements by scalar.

Multiplies all elements of vector with value. O(n).

Definition at line 418 of file vnl_vector.txx.

template<class T>
vnl_vector<T>& vnl_vector< T >::operator*= ( vnl_matrix< T > const &  m) [inline]

*this = (*this)*M where M is a suitable matrix.

this is treated as a row vector

Definition at line 222 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::operator+ ( ) const [inline]

Unary plus operator.

Return new vector = (*this)

Definition at line 226 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::operator+ ( v) const [inline]

Definition at line 232 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::operator+ ( vnl_vector< T > const &  v) const [inline]

Definition at line 237 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator+= ( value)

Add scalar value to all elements.

Increments all elements of vector with value. O(n).

Definition at line 408 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator+= ( vnl_vector< T > const &  rhs)

Add rhs to this and return *this.

Mutates lhs vector with its addition with rhs vector. O(n).

Definition at line 439 of file vnl_vector.txx.

template<class T >
vnl_vector< T > vnl_vector< T >::operator- ( ) const

Unary minus operator.

Creates new vector containing the negation of THIS vector. O(n).

Return new vector = -1*(*this)

Definition at line 513 of file vnl_vector.txx.

template<class T>
vnl_vector<T> vnl_vector< T >::operator- ( v) const [inline]

Definition at line 233 of file vnl_vector.h.

template<class T>
vnl_vector<T> vnl_vector< T >::operator- ( vnl_vector< T > const &  v) const [inline]

Definition at line 238 of file vnl_vector.h.

template<class T>
vnl_vector<T>& vnl_vector< T >::operator-= ( value) [inline]

Subtract scalar value from all elements.

Definition at line 198 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator-= ( vnl_vector< T > const &  rhs)

Subtract rhs from this and return *this.

Mutates lhs vector with its subtraction with rhs vector. O(n).

Definition at line 454 of file vnl_vector.txx.

template<class T>
vnl_vector<T> vnl_vector< T >::operator/ ( v) const [inline]

Definition at line 235 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator/= ( value)

Divide all elements by scalar.

Divides all elements of vector by value. O(n).

Definition at line 428 of file vnl_vector.txx.

template<class T>
vnl_vector<T>& vnl_vector< T >::operator= ( T const &  v) [inline]

Set all elements to value v.

Definition at line 189 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator= ( vnl_vector< T > const &  rhs)

Copy operator.

Copies rhs vector into lhs vector. O(n).

Changes the dimension of lhs vector if necessary.

Definition at line 388 of file vnl_vector.txx.

template<class T>
bool vnl_vector< T >::operator== ( vnl_vector< T > const &  that) const [inline]

Equality test.

Definition at line 401 of file vnl_vector.h.

template<class T>
T& vnl_vector< T >::operator[] ( unsigned int  i) [inline]

Return reference to the element at specified index. No range checking.

Definition at line 184 of file vnl_vector.h.

template<class T>
T const& vnl_vector< T >::operator[] ( unsigned int  i) const [inline]

Return reference to the element at specified index. No range checking.

Definition at line 186 of file vnl_vector.h.

template<class T>
bool vnl_vector< T >::operator_eq ( vnl_vector< T > const &  v) const

Return true if *this == v.

Definition at line 829 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::post_multiply ( vnl_matrix< T > const &  m)

*this = (*this)*M where M is a suitable matrix.

Post-multiplies vector with matrix and stores result back in vector.

this is treated as a row vector

v = v * m. O(m*n). Vector is assumed a row matrix.

Definition at line 491 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::pre_multiply ( vnl_matrix< T > const &  m)

*this = M*(*this) where M is a suitable matrix.

Pre-multiplies vector with matrix and stores result back in vector.

this is treated as a column vector

v = m * v. O(m*n). Vector is assumed a column matrix.

Definition at line 469 of file vnl_vector.txx.

template<class T>
void vnl_vector< T >::put ( unsigned int  index,
T const &  value 
) [inline]

Put value at given position in vector.

Puts the value at specified index. O(1).

Range check is performed.

Definition at line 481 of file vnl_vector.h.

template<class T >
vnl_vector< T > vnl_vector< T >::read ( vcl_istream &  s) [static]

Read from text stream.

Definition at line 346 of file vnl_vector.txx.

template<class T >
bool vnl_vector< T >::read_ascii ( vcl_istream &  s)

Read from text stream.

Read a vnl_vector from an ascii vcl_istream.

If the vector has nonzero size on input, read that many values. Otherwise, read to EOF.

Definition at line 319 of file vnl_vector.txx.

template<class T>
abs_t vnl_vector< T >::rms ( ) const [inline]

Root Mean Squares of values.

Definition at line 315 of file vnl_vector.h.

template<class T>
vnl_vector& vnl_vector< T >::set ( T const *  ptr) [inline]

Sets elements to ptr[i].

Note: ptr[i] must be valid for i=0..size()-1

Definition at line 162 of file vnl_vector.h.

template<class T >
bool vnl_vector< T >::set_size ( unsigned  n)

Resize to n elements.

This is a destructive resize, in that the old data is lost if size() != n before the call. If size() is already n, this is a null operation.

Definition at line 293 of file vnl_vector.txx.

template<class T>
unsigned vnl_vector< T >::size ( ) const [inline]

Return the length, number of elements, dimension of this vector.

Definition at line 141 of file vnl_vector.h.

template<class T>
abs_t vnl_vector< T >::squared_magnitude ( ) const [inline]

Return sum of squares of elements.

Definition at line 294 of file vnl_vector.h.

template<class T>
T vnl_vector< T >::sum ( ) const [inline]

Sum of values in a vector.

Definition at line 333 of file vnl_vector.h.

template<class T>
void vnl_vector< T >::swap ( vnl_vector< T > &  that)

Set this to that and that to this.

Definition at line 724 of file vnl_vector.txx.

template<class T>
abs_t vnl_vector< T >::two_norm ( ) const [inline]

Return sqrt of sum of squares of values of elements.

Definition at line 303 of file vnl_vector.h.

template<class T>
vnl_vector<T>& vnl_vector< T >::update ( vnl_vector< T > const &  ,
unsigned int  start = 0 
)

Replaces elements with index beginning at start, by values of v. O(n).


Friends And Related Function Documentation

template<class T >
vnl_vector< T > operator* ( vnl_diag_matrix< T > const &  D,
vnl_vector< T > const &  A 
) [related]

Multiply a vnl_diag_matrix by a vnl_vector. n flops.

Definition at line 332 of file vnl_diag_matrix.h.

template<class T >
vnl_vector< T > operator* ( vnl_vector< T > const &  A,
vnl_diag_matrix< T > const &  D 
) [related]

Multiply a vnl_vector by a vnl_diag_matrix. n flops.

Definition at line 342 of file vnl_diag_matrix.h.

template<class T >
vnl_vector< T > operator* ( s,
vnl_vector< T > const &  v 
) [related]

multiply scalar and vector. O(n).

Definition at line 518 of file vnl_vector.h.

template<class T >
vnl_vector< T > operator+ ( s,
vnl_vector< T > const &  v 
) [related]

add scalar and vector. O(n).

Definition at line 502 of file vnl_vector.h.

template<class T >
vnl_vector< T > operator- ( s,
vnl_vector< T > const &  v 
) [related]

subtract vector from scalar. O(n).

Definition at line 510 of file vnl_vector.h.

template<class T >
bool operator< ( vnl_vector< T > const &  lhs,
vnl_vector< T > const &  rhs 
) [related]

Define a complete ordering on vnl_vector.

This is useful to create a set, or map of vectors.

The ordering itself is implementation defined - so don't rely on the meaning of less here.

Definition at line 23 of file vnl_operators.h.

template<class T >
export vcl_ostream & operator<< ( vcl_ostream &  ,
vnl_vector< T > const &   
) [related]

Write vector to a vcl_ostream.

template<class T >
export vcl_istream & operator>> ( vcl_istream &  ,
vnl_vector< T > &   
) [related]

Read vector from a vcl_istream.

template<class T >
void swap ( vnl_vector< T > &  a,
vnl_vector< T > &  b 
) [related]

Interchange the two vectors.

Definition at line 526 of file vnl_vector.h.

template<class T >
vnl_vector< vcl_complex< T > > vnl_complexify ( vnl_vector< T > const &  R) [related]

Return complexified version of real vector R.

Definition at line 33 of file vnl_complex_ops.txx.

template<class T >
vnl_vector< vcl_complex< T > > vnl_complexify ( vnl_vector< T > const &  R,
vnl_vector< T > const &  I 
) [related]

Return complex vector R+j*I from two real vectors R and I.

Definition at line 41 of file vnl_complex_ops.txx.

template<class T >
vnl_vector< T > vnl_convolve ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2,
int  use_fft = 0 
) [related]

Convolve two vnl_vector<T>'s, with the same base type T.

The returned vnl_vector has the same base type T, and is identical to the return value of the previous function when T1 = T2 = U.

template<class T1 , class T2 , class U >
vnl_vector< U > vnl_convolve_cyclic ( vnl_vector< T1 > const &  v1,
vnl_vector< T2 > const &  v2,
U *  ,
bool  use_fft = false 
) [related]

Cyclically convolve two vnl_vector<T>'s of the same length.

$res[k] := \displaystyle\sum_{i=0}^{n-1} v1[k-i] \cdot v2[i]$.

A cyclic convolution requires that the lengths of the input vectors are identical. If this is not the case, an assert failure occurs. The length of the returned vector equals the length of the inputs.

Since the convolution theorem states that a cyclic convolution followed by an FFT is the same as an FFT followed by a multiplication, a cyclic convolution can also be implemented using 3 FFTs on n points and n complex multiplications. By default, vnl_convolve_cyclic does not use FFTs. By specifying "true" as the fourth argument, calculation of the convolution is done using FFTs. This will generally be faster for large n, especially if the vectors are not sparse, and/or if n is a power of 2.

template<class S , class T >
void vnl_copy ( S const *  src,
T *  dst,
unsigned  n 
) [related]

Easy conversion between vectors and matrices templated over different types.

Definition at line 19 of file vnl_copy.cxx.

template<class S , class T >
void vnl_copy ( S const &  ,
T &   
) [related]

Easy conversion between vectors and matrices templated over different types.

Definition at line 26 of file vnl_copy.cxx.

template<class T >
T vnl_cross_2d ( const vnl_vector< T > &  v1,
const vnl_vector< T > &  v2 
) [related]

Compute the 2-D cross product.

Definition at line 20 of file vnl_cross.h.

template<class T >
vnl_vector< T > vnl_cross_3d ( const vnl_vector< T > &  v1,
const vnl_vector< T > &  v2 
) [related]

Compute the 3-D cross product.

Definition at line 61 of file vnl_cross.h.

template<class T >
vnl_vector< T > vnl_imag ( vnl_vector< vcl_complex< T > > const &  C) [related]

Vector of imaginary parts of vnl_vector<vcl_complex<T> >.

Definition at line 110 of file vnl_complex_ops.txx.

template<class T >
vcl_ostream & vnl_matlab_print ( vcl_ostream &  ,
vnl_vector< T > const &  ,
char const *  variable_name = 0,
vnl_matlab_print_format  = vnl_matlab_print_format_default 
) [related]

print a vnl_vector<T>.

template<class T>
friend class vnl_matrix< T > [friend]

Definition at line 78 of file vnl_vector.h.

template<class T >
vnl_vector< T > vnl_real ( vnl_vector< vcl_complex< T > > const &  C) [related]

Vector of real parts of vnl_vector<vcl_complex<T> >.

Definition at line 79 of file vnl_complex_ops.txx.

template<class T >
T vnl_vector_ssd ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2 
) [related]

Euclidean Distance between two vectors.

Sum of Differences squared.

Definition at line 532 of file vnl_vector.h.

template<class T >
void vsl_b_read ( vsl_b_istream &  is,
vnl_vector< T > &  v 
) [related]

Binary load vnl_vector from stream.

template<class T >
void vsl_b_write ( vsl_b_ostream &  os,
const vnl_vector< T > &  v 
) [related]

Binary save vnl_vector to stream.

template<class T >
void vsl_print_summary ( vcl_ostream &  os,
const vnl_vector< T > &  b 
) [related]

Print human readable summary of object to a stream.

template<class T >
void x_write ( vcl_ostream &  os,
vnl_vector< T > const &  v,
vcl_string  name = "vnl_vector< T >" 
) [related]

XML save vnl_vector to stream.

template<class T >
void x_write_tree ( vcl_ostream &  os,
vnl_vector< T > const &  v,
vcl_string  name = "vnl_vector< T >" 
) [related]

XML save vnl_vector as a 2-level tree to stream.


Member Data Documentation

template<class T>
T* vnl_vector< T >::data [protected]

Definition at line 422 of file vnl_vector.h.

template<class T>
unsigned vnl_vector< T >::num_elmts [protected]

Definition at line 421 of file vnl_vector.h.


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