Defines | Functions
core/vnl/vnl_vector.txx File Reference

new lite version adapted from Matrix.h More...

#include "vnl_vector.h"
#include <vcl_cstdlib.h>
#include <vcl_cassert.h>
#include <vcl_vector.h>
#include <vcl_iostream.h>
#include <vcl_algorithm.h>
#include <vnl/vnl_math.h>
#include <vnl/vnl_matrix.h>
#include <vnl/vnl_numeric_traits.h>
#include <vnl/vnl_c_vector.h>
#include <vnl/vnl_sse.h>

Go to the source code of this file.

Defines

#define vnl_vector_txx_
#define vnl_vector_construct_hack()
#define vnl_vector_alloc_blah(size)
#define vnl_vector_free_blah
#define VNL_VECTOR_INSTANTIATE_COMMON(T)
#define VNL_VECTOR_INSTANTIATE(T)
#define VNL_VECTOR_INSTANTIATE_COMPLEX(T)

Functions

template<class T >
vnl_vector< T > element_product (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Returns new vector whose elements are the products v1[i]*v2[i]. O(n).
template<class T >
vnl_vector< T > element_quotient (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Returns new vector whose elements are the quotients v1[i]/v2[i]. O(n).
template<class T >
dot_product (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Returns the dot product of two nd-vectors, or [v1]*[v2]^T. O(n).
template<class T >
inner_product (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Hermitian inner product. O(n).
template<class T >
bracket (vnl_vector< T > const &u, vnl_matrix< T > const &A, vnl_vector< T > const &v)
 Returns the 'matrix element' <u|A|v> = u^t * A * v. O(mn).
template<class T >
vnl_matrix< T > outer_product (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Returns the nxn outer product of two nd-vectors, or [v1]^T*[v2]. O(n).
template<class T >
cos_angle (vnl_vector< T > const &a, vnl_vector< T > const &b)
template<class T >
double angle (vnl_vector< T > const &a, vnl_vector< T > const &b)
 Returns smallest angle between two non-zero n-dimensional vectors. O(n).
template<class T >
vcl_ostream & operator<< (vcl_ostream &s, vnl_vector< T > const &v)
 Overloads the output operator to print a vector. O(n).
template<class T >
vcl_istream & operator>> (vcl_istream &s, vnl_vector< T > &M)
 Read a vnl_vector from an ascii vcl_istream.

Detailed Description

new lite version adapted from Matrix.h

Author:
VDN
Date:
Feb 21, 1992 The parameterized vnl_vector<T> class implements 1D arithmetic vectors of a user specified type. The only constraint placed on the type is that it must overload the following operators: +, -, *, and /. Thus, it will be possible to have a vnl_vector over vcl_complex<T>. The vnl_vector<T> class is static in size, that is once a vnl_vector<T> of a particular size has been declared, elements cannot be added or removed. Using the set_size() method causes the vector to resize, but the contents will be lost.

Each vector contains a protected data section that has a T* slot that points to the physical memory allocated for the one dimensional array. In addition, an integer specifies the number of elements for the vector. These values are provided in the constructors.

Several constructors are provided. See .h file for descriptions.

Methods are provided for destructive scalar and vector addition, multiplication, check for equality and inequality, fill, reduce, and access and set individual elements. Finally, both the input and output operators are overloaded to allow for formatted input and output of vector elements.

vnl_vector is a special type of matrix, and is implemented for space and time efficiency. When vnl_vector is pre_multiplied by/with matrix, m*v, vnl_vector is implicitly a column matrix. When vnl_vector is post_multiplied by/with matrix v*m, vnl_vector is implicitly a row matrix.

Definition in file vnl_vector.txx.


Define Documentation

#define vnl_vector_alloc_blah (   size)
Value:
do { \
  this->num_elmts = (size); \
  this->data = size ? vnl_c_vector<T>::allocate_T(size) : 0; \
} while (false)

Definition at line 64 of file vnl_vector.txx.

#define vnl_vector_construct_hack ( )

Definition at line 59 of file vnl_vector.txx.

#define vnl_vector_free_blah
Value:
do { \
  if (this->data) \
    vnl_c_vector<T>::deallocate(this->data, this->num_elmts); \
} while (false)

Definition at line 71 of file vnl_vector.txx.

#define VNL_VECTOR_INSTANTIATE (   T)
Value:
VNL_VECTOR_INSTANTIATE_COMMON(T); \
template T cos_angle(vnl_vector<T > const & , vnl_vector<T > const &); \
template double angle(vnl_vector<T > const & , vnl_vector<T > const &)

Definition at line 899 of file vnl_vector.txx.

#define VNL_VECTOR_INSTANTIATE_COMMON (   T)
Value:
template class vnl_vector<T >; \
/* arithmetic, comparison etc */ \
VCL_INSTANTIATE_INLINE(vnl_vector<T > operator+(T const, vnl_vector<T > const &)); \
VCL_INSTANTIATE_INLINE(vnl_vector<T > operator-(T const, vnl_vector<T > const &)); \
VCL_INSTANTIATE_INLINE(vnl_vector<T > operator*(T const, vnl_vector<T > const &)); \
template vnl_vector<T > operator*(vnl_matrix<T > const &, vnl_vector<T > const &); \
/* element-wise */ \
template vnl_vector<T > element_product(vnl_vector<T > const &, vnl_vector<T > const &); \
template vnl_vector<T > element_quotient(vnl_vector<T > const &, vnl_vector<T > const &); \
/* dot products, angles etc */ \
template T inner_product(vnl_vector<T > const &, vnl_vector<T > const &); \
template T dot_product(vnl_vector<T > const &, vnl_vector<T > const &); \
template T bracket(vnl_vector<T > const &, vnl_matrix<T > const &, vnl_vector<T > const &); \
template vnl_matrix<T > outer_product(vnl_vector<T > const &,vnl_vector<T > const &); \
/* I/O */ \
template vcl_ostream & operator<<(vcl_ostream &, vnl_vector<T > const &); \
template vcl_istream & operator>>(vcl_istream &, vnl_vector<T >       &)

Definition at line 880 of file vnl_vector.txx.

#define VNL_VECTOR_INSTANTIATE_COMPLEX (   T)
Value:

Definition at line 904 of file vnl_vector.txx.

#define vnl_vector_txx_

Definition at line 3 of file vnl_vector.txx.


Function Documentation

template<class T >
double angle ( vnl_vector< T > const &  a,
vnl_vector< T > const &  b 
)

Returns smallest angle between two non-zero n-dimensional vectors. O(n).

Definition at line 761 of file vnl_vector.txx.

template<class T >
T bracket ( vnl_vector< T > const &  u,
vnl_matrix< T > const &  A,
vnl_vector< T > const &  v 
)

Returns the 'matrix element' <u|A|v> = u^t * A * v. O(mn).

Definition at line 681 of file vnl_vector.txx.

template<class T >
T cos_angle ( vnl_vector< T > const &  a,
vnl_vector< T > const &  b 
)

Definition at line 742 of file vnl_vector.txx.

template<class T >
T dot_product ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2 
)

Returns the dot product of two nd-vectors, or [v1]*[v2]^T. O(n).

Definition at line 653 of file vnl_vector.txx.

template<class T >
vnl_vector<T> element_product ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2 
)

Returns new vector whose elements are the products v1[i]*v2[i]. O(n).

Definition at line 603 of file vnl_vector.txx.

template<class T >
vnl_vector<T> element_quotient ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2 
)

Returns new vector whose elements are the quotients v1[i]/v2[i]. O(n).

Definition at line 620 of file vnl_vector.txx.

template<class T >
T inner_product ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2 
)

Hermitian inner product. O(n).

Definition at line 667 of file vnl_vector.txx.

template<class T >
vcl_ostream& operator<< ( vcl_ostream &  s,
vnl_vector< T > const &  v 
)

Overloads the output operator to print a vector. O(n).

Write vector to a vcl_ostream.

Definition at line 847 of file vnl_vector.txx.

template<class T >
vcl_istream& operator>> ( vcl_istream &  s,
vnl_vector< T > &  M 
)

Read a vnl_vector from an ascii vcl_istream.

Read vector from a vcl_istream.

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

Definition at line 859 of file vnl_vector.txx.

template<class T >
vnl_matrix<T> outer_product ( vnl_vector< T > const &  v1,
vnl_vector< T > const &  v2 
)

Returns the nxn outer product of two nd-vectors, or [v1]^T*[v2]. O(n).

Definition at line 699 of file vnl_vector.txx.