vnl_file_vector< T > Class Template Reference

#include <vnl_file_vector.h>

Inheritance diagram for vnl_file_vector< T >:

vnl_vector< T > List of all members.

Detailed Description

template<class T>
class vnl_file_vector< T >

Templated class to load a vector from a file.

Definition at line 24 of file vnl_file_vector.h.


Public Types

typedef T element_type
 Type defs for iterators.
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_file_vector (char const *filename)
 Load vector from filename.
 operator safe_bool () const
bool operator! () const
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.
void fill (T const &v)
 Set all values to v.
void copy_in (T const *ptr)
 Sets elements to ptr[i].
void copy_out (T *) const
 Copy elements to ptr[i].
void set (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)
 Add scalar value to all elements.
vnl_vector< T > & operator+= (vnl_vector< T > const &rhs)
 Add rhs to this and return *this.
vnl_vector< T > & operator-= (T value)
 Subtract scalar value from all elements.
vnl_vector< T > & operator-= (vnl_vector< T > const &rhs)
 Subtract rhs from this and return *this.
vnl_vector< T > & operator *= (T)
 Multiply all elements by scalar.
vnl_vector< T > & operator *= (vnl_matrix< T > const &m)
 *this = (*this)*M where M is a suitable matrix.
vnl_vector< T > & operator/= (T)
 Divide all elements by scalar.
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+ () const
 Unary plus operator.
vnl_vector< T > operator+ (T v) const
vnl_vector< T > operator+ (vnl_vector< T > const &v) const
vnl_vector< T > operator- () const
 Unary minus operator.
vnl_vector< T > operator- (T v) const
vnl_vector< T > operator- (vnl_vector< T > const &v) const
vnl_vector< T > operator * (T v) const
vnl_vector< T > operator * (vnl_matrix< T > const &M) const
vnl_vector< T > operator/ (T v) 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.
const_iterator begin () const
 Iterator pointing to start of data.
iterator end ()
 Iterator pointing to element beyond end 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.
mean () const
 Mean of values in vector.
sum () const
 Sum of values in a vector.
void flip ()
 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 its finite.
bool is_zero () const
 Return true iff all the entries are zero.
bool empty () const
 Return true iff the size is zero.
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

Private Attributes

 VCL_SAFE_BOOL_DEFINE
bool ok_

Friends

class vnl_matrix< T >

Related Functions

(Note that these are not member functions.)

vnl_vector< T > operator+ (T s, vnl_vector< T > const &v)
 add scalar and vector. O(n).
vnl_vector< T > operator- (T s, vnl_vector< T > const &v)
 subtract vector from scalar. O(n).
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.
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.
vnl_vector< T > operator * (T s, vnl_vector< T > const &v)
 multiply scalar and vector. O(n).
void swap (vnl_vector< T > &a, vnl_vector< T > &b)
 Interchange the two vectors.
vnl_vector< vcl_complex< T > > vnl_complexify (vnl_vector< T > const &R)
 Return complexified version of real vector R.
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.
void vnl_copy (S const *src, T *dst, unsigned n)
 Easy conversion between vectors and matrices templated over different types.
void vnl_copy (S const &, T &)
 Easy conversion between vectors and matrices templated over different types.
vnl_cross_2d (const vnl_vector< T > &v1, const vnl_vector< T > &v2)
 Compute the 2-D cross product.
vnl_vector< T > vnl_cross_3d (const vnl_vector< T > &v1, const vnl_vector< T > &v2)
 Compute the 3-D cross product.
vnl_vector< T > vnl_imag (vnl_vector< vcl_complex< T > > const &C)
 Vector of imaginary parts of vnl_vector<vcl_complex<T> >.
bool operator< (vnl_vector< T > const &lhs, vnl_vector< T > const &rhs)
 Define a complete ordering on vnl_vector.
vnl_vector< T > vnl_real (vnl_vector< vcl_complex< T > > const &C)
 Vector of real parts of vnl_vector<vcl_complex<T> >.
vnl_vector_ssd (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Euclidean Distance between two vectors.
export vcl_ostream & operator<< (vcl_ostream &, vnl_vector< T > const &)
 Write vector to a vcl_ostream.
export vcl_istream & operator>> (vcl_istream &, vnl_vector< T > &)
 Read vector from a vcl_istream.

Member Typedef Documentation

template<class T>
typedef T vnl_vector< T >::element_type [inherited]

Type defs for iterators.

Definition at line 251 of file vnl_vector.h.

template<class T>
typedef T* vnl_vector< T >::iterator [inherited]

Type defs for iterators.

Definition at line 253 of file vnl_vector.h.

template<class T>
typedef T const* vnl_vector< T >::const_iterator [inherited]

Const iterator type.

Definition at line 261 of file vnl_vector.h.

template<class T>
typedef vnl_c_vector<T>::abs_t vnl_vector< T >::abs_t [inherited]

Definition at line 288 of file vnl_vector.h.


Constructor & Destructor Documentation

template<class T>
vnl_file_vector< T >::vnl_file_vector ( char const *  filename  ) 

Load vector from filename.

Definition at line 14 of file vnl_file_vector.txx.


Member Function Documentation

template<class T>
vnl_file_vector< T >::operator safe_bool (  )  const [inline]

Definition at line 30 of file vnl_file_vector.h.

template<class T>
bool vnl_file_vector< T >::operator! (  )  const [inline]

Definition at line 32 of file vnl_file_vector.h.

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

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

Definition at line 139 of file vnl_vector.h.

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

Put value at given position in vector.

Range check is performed.

Definition at line 470 of file vnl_vector.h.

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

Get value at element i.

Range check is performed.

Definition at line 457 of file vnl_vector.h.

template<class T>
void vnl_vector< T >::fill ( T const &  v  )  [inherited]

Set all values to v.

Definition at line 354 of file vnl_vector.txx.

template<class T>
void vnl_vector< T >::copy_in ( T const *  ptr  )  [inherited]

Sets elements to ptr[i].

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

Definition at line 363 of file vnl_vector.txx.

template<class T>
void vnl_vector< T >::copy_out ( T *   )  const [inherited]

Copy elements to ptr[i].

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

Definition at line 372 of file vnl_vector.txx.

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

Sets elements to ptr[i].

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

Definition at line 161 of file vnl_vector.h.

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

Return reference to the element at specified index.

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

Definition at line 165 of file vnl_vector.h.

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

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 174 of file vnl_vector.h.

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

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

Definition at line 183 of file vnl_vector.h.

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

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

Definition at line 185 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator+= (  )  [inherited]

Add scalar value to all elements.

Definition at line 402 of file vnl_vector.txx.

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

Add rhs to this and return *this.

Definition at line 433 of file vnl_vector.txx.

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

Subtract scalar value from all elements.

Definition at line 197 of file vnl_vector.h.

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

Subtract rhs from this and return *this.

Definition at line 448 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator *= (  )  [inherited]

Multiply all elements by scalar.

Definition at line 412 of file vnl_vector.txx.

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

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

this is treated as a row vector

Definition at line 221 of file vnl_vector.h.

template<class T>
vnl_vector< T > & vnl_vector< T >::operator/= (  )  [inherited]

Divide all elements by scalar.

Definition at line 422 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::pre_multiply ( vnl_matrix< T > const &  M  )  [inherited]

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

this is treated as a column vector

Definition at line 463 of file vnl_vector.txx.

template<class T>
vnl_vector< T > & vnl_vector< T >::post_multiply ( vnl_matrix< T > const &  M  )  [inherited]

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

this is treated as a row vector

Definition at line 486 of file vnl_vector.txx.

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

Unary plus operator.

Return new vector = (*this)

Definition at line 225 of file vnl_vector.h.

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

Definition at line 231 of file vnl_vector.h.

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

Definition at line 236 of file vnl_vector.h.

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

Unary minus operator.

Return new vector = -1*(*this)

Definition at line 509 of file vnl_vector.txx.

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

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, inherited]

Definition at line 237 of file vnl_vector.h.

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

Definition at line 233 of file vnl_vector.h.

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

Definition at line 238 of file vnl_vector.h.

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

Definition at line 234 of file vnl_vector.h.

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

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 244 of file vnl_vector.h.

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

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 248 of file vnl_vector.h.

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

Iterator pointing to start of data.

Definition at line 255 of file vnl_vector.h.

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

Iterator pointing to start of data.

Definition at line 263 of file vnl_vector.h.

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

Iterator pointing to element beyond end of data.

Definition at line 258 of file vnl_vector.h.

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

Iterator pointing to element beyond end of data.

Definition at line 265 of file vnl_vector.h.

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

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 271 of file vnl_vector.h.

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

Return a reference to this.

Definition at line 274 of file vnl_vector.h.

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

Applies function to elements.

Definition at line 641 of file vnl_vector.txx.

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

Applies function to elements.

Definition at line 632 of file vnl_vector.txx.

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

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

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

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

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

Return sum of squares of elements.

Definition at line 291 of file vnl_vector.h.

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

Return magnitude (length) of vector.

Definition at line 294 of file vnl_vector.h.

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

Return sum of absolute values of the elements.

Definition at line 297 of file vnl_vector.h.

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

Return sqrt of sum of squares of values of elements.

Definition at line 300 of file vnl_vector.h.

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

Return largest absolute element value.

Definition at line 303 of file vnl_vector.h.

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

Normalise by dividing through by the magnitude.

Definition at line 306 of file vnl_vector.h.

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

Root Mean Squares of values.

Definition at line 312 of file vnl_vector.h.

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

Smallest value.

Definition at line 315 of file vnl_vector.h.

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

Largest value.

Definition at line 318 of file vnl_vector.h.

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

Mean of values in vector.

Definition at line 321 of file vnl_vector.h.

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

Sum of values in a vector.

Definition at line 324 of file vnl_vector.h.

template<class T>
void vnl_vector< T >::flip (  )  [inherited]

Reverse the order of the elements.

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

Definition at line 710 of file vnl_vector.txx.

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

Set this to that and that to this.

Definition at line 720 of file vnl_vector.txx.

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

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

This function does or tests nothing if NDEBUG is defined

Definition at line 362 of file vnl_vector.h.

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

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

This function does or tests nothing if NDEBUG is defined

Definition at line 370 of file vnl_vector.h.

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

Return true if its finite.

Definition at line 769 of file vnl_vector.txx.

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

Return true iff all the entries are zero.

Definition at line 779 of file vnl_vector.txx.

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

Return true iff the size is zero.

Definition at line 383 of file vnl_vector.h.

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

Return true if *this == v.

Definition at line 809 of file vnl_vector.txx.

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

Equality test.

Definition at line 389 of file vnl_vector.h.

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

Inequality test.

Definition at line 392 of file vnl_vector.h.

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

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 291 of file vnl_vector.txx.

template<class T>
void vnl_vector< T >::clear (  )  [inherited]

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

Definition at line 281 of file vnl_vector.txx.

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

Read from text stream.

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

Definition at line 317 of file vnl_vector.txx.

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

Read from text stream.

Definition at line 344 of file vnl_vector.txx.

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

Definition at line 800 of file vnl_vector.txx.

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

Definition at line 790 of file vnl_vector.txx.

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

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

Definition at line 275 of file vnl_vector.txx.

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

Definition at line 846 of file vnl_vector.txx.


Friends And Related Function Documentation

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

Definition at line 76 of file vnl_vector.h.

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

add scalar and vector. O(n).

Definition at line 491 of file vnl_vector.h.

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

subtract vector from scalar. O(n).

Definition at line 499 of file vnl_vector.h.

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

Multiply a vnl_diag_matrix by a vnl_vector. n flops.

Definition at line 323 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, inherited]

Multiply a vnl_vector by a vnl_diag_matrix. n flops.

Definition at line 333 of file vnl_diag_matrix.h.

template<class T>