Macros | Functions
vnl_vector.hxx File Reference

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

#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
#include "vnl_vector.h"
#include <cassert>
#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.

Macros

#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). More...
 
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). More...
 
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). More...
 
template<class T >
inner_product (vnl_vector< T > const &v1, vnl_vector< T > const &v2)
 Hermitian inner product. O(n). More...
 
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). More...
 
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). More...
 
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). More...
 
template<class T >
std::ostream & operator<< (std::ostream &s, vnl_vector< T > const &v)
 Overloads the output operator to print a vector. O(n). More...
 
template<class T >
std::istream & operator>> (std::istream &s, vnl_vector< T > &M)
 Read a vnl_vector from an ascii std::istream. More...
 

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 std::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.hxx.

Macro Definition Documentation

◆ vnl_vector_alloc_blah

#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)
vnl_c_vector interfaces to lowlevel memory-block operations.
Definition: vnl_c_vector.h:39

Definition at line 62 of file vnl_vector.hxx.

◆ vnl_vector_construct_hack

#define vnl_vector_construct_hack ( )

Definition at line 58 of file vnl_vector.hxx.

◆ vnl_vector_free_blah

#define vnl_vector_free_blah
Value:
do { \
if (this->data) \
vnl_c_vector<T>::deallocate(this->data, this->num_elmts); \
} while (false)
static void deallocate(T **, const std::size_t n_when_allocated)

Definition at line 69 of file vnl_vector.hxx.

◆ VNL_VECTOR_INSTANTIATE

#define VNL_VECTOR_INSTANTIATE (   T)
Value:
template VNL_EXPORT T cos_angle(vnl_vector<T > const & , vnl_vector<T > const &); \
template VNL_EXPORT double angle(vnl_vector<T > const & , vnl_vector<T > const &)
T cos_angle(vnl_vector< T > const &a, vnl_vector< T > const &b)
Definition: vnl_vector.hxx:697
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
T angle(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
#define VNL_VECTOR_INSTANTIATE_COMMON(T)
Definition: vnl_vector.hxx:824

Definition at line 843 of file vnl_vector.hxx.

◆ VNL_VECTOR_INSTANTIATE_COMMON

#define VNL_VECTOR_INSTANTIATE_COMMON (   T)
Value:
template class VNL_EXPORT vnl_vector<T >; \
/* arithmetic, comparison etc */ \
/*template VNL_EXPORT vnl_vector<T > operator+(T const, vnl_vector<T > const &) ; */ \
/*template VNL_EXPORT vnl_vector<T > operator-(T const, vnl_vector<T > const &) ; */ \
/*template VNL_EXPORT vnl_vector<T > operator*(T const, vnl_vector<T > const &) ; */ \
template VNL_EXPORT vnl_vector<T > operator*(vnl_matrix<T > const &, vnl_vector<T > const &); \
/* element-wise */ \
template VNL_EXPORT vnl_vector<T > element_product(vnl_vector<T > const &, vnl_vector<T > const &); \
template VNL_EXPORT vnl_vector<T > element_quotient(vnl_vector<T > const &, vnl_vector<T > const &); \
/* dot products, angles etc */ \
template VNL_EXPORT T inner_product(vnl_vector<T > const &, vnl_vector<T > const &); \
template VNL_EXPORT T dot_product(vnl_vector<T > const &, vnl_vector<T > const &); \
template VNL_EXPORT T bracket(vnl_vector<T > const &, vnl_matrix<T > const &, vnl_vector<T > const &); \
template VNL_EXPORT vnl_matrix<T > outer_product(vnl_vector<T > const &,vnl_vector<T > const &); \
/* I/O */ \
template VNL_EXPORT std::ostream & operator<<(std::ostream &, vnl_vector<T > const &); \
template VNL_EXPORT std::istream & operator>>(std::istream &, vnl_vector<T > &)
vnl_vector_fixed< T, n > element_quotient(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
vnl_vector_fixed< T, n > element_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
std::ostream & operator<<(std::ostream &s, vnl_decnum const &r)
decimal output.
Definition: vnl_decnum.h:393
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: vnl_vector.hxx:592
An ordinary mathematical matrix.
Definition: vnl_adjugate.h:22
T inner_product(vnl_vector< T > const &v1, vnl_vector< T > const &v2)
Hermitian inner product. O(n).
Definition: vnl_vector.hxx:578
T dot_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
VNL_EXPORT vnl_matrix_fixed< T, m, n > outer_product(vnl_vector_fixed< T, m > const &a, vnl_vector_fixed< T, n > const &b)
VNL_EXPORT std::istream & operator>>(std::istream &s, vnl_decnum &r)
decimal input.
Definition: vnl_decnum.cxx:411
vnl_bignum operator *(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the product of two bignum numbers.
Definition: vnl_bignum.h:302

Definition at line 824 of file vnl_vector.hxx.

◆ VNL_VECTOR_INSTANTIATE_COMPLEX

#define VNL_VECTOR_INSTANTIATE_COMPLEX (   T)
Value:
template VNL_EXPORT T cos_angle(vnl_vector<T > const & , vnl_vector<T > const &)
T cos_angle(vnl_vector< T > const &a, vnl_vector< T > const &b)
Definition: vnl_vector.hxx:697
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
#define VNL_VECTOR_INSTANTIATE_COMMON(T)
Definition: vnl_vector.hxx:824

Definition at line 848 of file vnl_vector.hxx.

Function Documentation

◆ angle()

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 716 of file vnl_vector.hxx.

◆ bracket()

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 592 of file vnl_vector.hxx.

◆ cos_angle()

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

Definition at line 697 of file vnl_vector.hxx.

◆ dot_product()

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 564 of file vnl_vector.hxx.

◆ element_product()

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 514 of file vnl_vector.hxx.

◆ element_quotient()

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 531 of file vnl_vector.hxx.

◆ inner_product()

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

Hermitian inner product. O(n).

Definition at line 578 of file vnl_vector.hxx.

◆ operator<<()

template<class T >
std::ostream& operator<< ( std::ostream &  s,
vnl_vector< T > const &  v 
)

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

Write vector to a std::ostream.

Definition at line 802 of file vnl_vector.hxx.

◆ operator>>()

template<class T >
std::istream& operator>> ( std::istream &  s,
vnl_vector< T > &  M 
)

Read a vnl_vector from an ascii std::istream.

Read vector from a std::istream.

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

Definition at line 814 of file vnl_vector.hxx.

◆ outer_product()

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 610 of file vnl_vector.hxx.