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 > | |
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 > | |
T | inner_product (vnl_vector< T > const &v1, vnl_vector< T > const &v2) |
Hermitian inner product. O(n). | |
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). | |
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 > | |
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. |
new lite version adapted from Matrix.h
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 vnl_vector_alloc_blah | ( | size | ) |
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 |
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 | ) |
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 900 of file vnl_vector.txx.
#define VNL_VECTOR_INSTANTIATE_COMMON | ( | T | ) |
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 881 of file vnl_vector.txx.
#define VNL_VECTOR_INSTANTIATE_COMPLEX | ( | T | ) |
VNL_VECTOR_INSTANTIATE_COMMON(T); \ template T cos_angle(vnl_vector<T > const & , vnl_vector<T > const &)
Definition at line 905 of file vnl_vector.txx.
#define vnl_vector_txx_ |
Definition at line 3 of file vnl_vector.txx.
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.
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.
T cos_angle | ( | vnl_vector< T > const & | a, |
vnl_vector< T > const & | b | ||
) |
Definition at line 742 of file vnl_vector.txx.
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.
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.
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.
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.
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 848 of file vnl_vector.txx.
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 860 of file vnl_vector.txx.
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.