Logo MTL4

mtl::vector Namespace Reference

Namespace for vectors and views and operations exclusively on vectors. More...


Namespaces

namespace  fixed
 Namespace for fixed vector dimension types.
namespace  non_fixed
 Namespace for non-fixed vector dimension types, i.e. size dynamically determined at run-time.

Classes

class  givens
 Given's transformator on vector (swap a*line(k) with b*line(k+1) ). More...
struct  crtp_assign< Vector, mat_cvec_times_expr< E1, E2 > >
 Assign matrix vector product by calling mult. More...
struct  crtp_assign< Vector, Value[Rows]>
 Assign c-style 1D-array, because it's easier to initialize. More...
struct  crtp_plus_assign< Vector, mat_cvec_times_expr< E1, E2 > >
 Assign-add matrix vector product by calling mult. More...
struct  crtp_minus_assign< Vector, mat_cvec_times_expr< E1, E2 > >
 Assign-add matrix vector product by calling mult. More...
struct  crtp_vector_assign
 Base class to provide vector assignment operators generically. More...
class  dense_vector
 Dense vector. More...
struct  inserter
 Class for generic insertion into vectors. More...
class  strided_vector_ref
 Class for referring vectors stored in strides, e.g. columns in a row-major matrix. More...
class  unrolled1
 Helper class for unrolling loops. More...
struct  vec_const_ref_expr
 Class for providing interface for a vector given as reference. More...

Functions

template<typename Value , typename Parameters >
dense_vector< Value,
Parameters >::size_type 
num_rows (const dense_vector< Value, Parameters > &vector)
 Number of rows: is size for column vectors and 1 for row vectors.
template<typename Value , typename Parameters >
dense_vector< Value,
Parameters >::size_type 
num_cols (const dense_vector< Value, Parameters > &vector)
 Number of columns: is size for row vectors and 1 for column vectors.
template<typename Vector , typename Functor >
void assign_each_nonzero (Vector &v, const Functor &f)
 Assign the result of f(i) to each non-zero i in non-constant vector v.
template<typename Vector >
mtl::traits::enable_if_vector
< Vector, conj_view< Vector >
>::type 
conj (const Vector &v)
 Conjugate of an vector.
template<typename T >
mtl::traits::enable_if_vector
< T, T & >::type 
crop (T &x)
 Remove all zero entries from a collection.
template<typename Vector1 , typename Vector2 >
detail::cross_result< Vector1,
Vector2 >::type 
cross (const Vector1 &v1, const Vector2 &v2)
 Dot product.
template<typename Vector >
compressed2D< typename
Collection< Vector >
::value_type > 
diagonal (const Vector &v)
 Transform a vector into a diagonal matrix.
template<typename Vector1 , typename Vector2 >
detail::dot_result< Vector1,
Vector2 >::type 
dot (const Vector1 &v1, const Vector2 &v2)
 Dot product defined as hermitian(v) * w.
template<typename Vector1 , typename Vector2 >
detail::dot_result< Vector1,
Vector2 >::type 
dot_real (const Vector1 &v1, const Vector2 &v2)
 Dot product without conjugate defined as trans(v) * w.
template<typename Vector , typename Value >
bool entry_similar (const Vector &x, typename Collection< Vector >::size_type i, const Value &v, const Value &eps)
 Compares x[i] with v returns false if larger than eps.
template<typename Vector >
std::pair< typename
mtl::dense_vector< typename
Collection< Vector >
::value_type >, typename
Collection< Vector >
::value_type > 
householder (Vector &y)
 Computes Householder vector b of y.
template<typename Vector >
mtl::dense_vector< typename
Collection< Vector >
::value_type > 
householder_s (Vector &y)
 Computes Householder vector b of y.
template<unsigned long Unroll, typename Vector >
traits::enable_if_vector
< Vector, typename
RealMagnitude< typename
Collection< Vector >
::value_type >::type >::type 
infinity_norm (const Vector &vector)
template<typename Factor , typename Vector >
mtl::traits::enable_if_vector
< Vector, Vector & >::type 
left_scale_inplace (const Factor &alpha, Vector &v)
 Scale vector c from left with scalar or matrix factor alpha; c is altered.
template<typename Vector , typename Functor >
void look_at_each_nonzero (const Vector &v, Functor &f)
 Perform f(v[i]) on each non-zero i in constant vector v; thus the must keep the result in its state.
template<typename Vector , typename Functor >
mtl::traits::enable_if_vector
< Vector >::type 
look_at_each_nonzero_pos (const Vector &v, Functor &f)
 Perform f(v[i], i) on each non-zero i in constant vector v; thus the must keep the result in its state.
template<unsigned long Unroll, typename Value >
Collection< Value >::value_type max (const Value &value)
 Returns maximal entry of vector v.
template<typename Vector >
mtl::traits::enable_if_vector
< Vector, typename Collection
< Vector >::size_type >::type 
max_abs_pos (const Vector &v)
 Returns position from absolut maximal entry of vector v.
template<typename Vector >
max_pos_functor< Vector >::pos_type max_pos (const Vector &v)
 Returns position of maximal entry of vector v.
template<typename VectorReal , typename VectorImaginary , typename VectorComplex >
void merge_complex_vector (const VectorReal &r, const VectorImaginary &i, VectorComplex &c)
 Merge two real-valued vectors into one complex-valued vector.
template<unsigned long Unroll, typename Value >
Collection< Value >::value_type min (const Value &value)
 Returns minimal value of vector v.
template<typename Vector >
min_pos_functor< Vector >::pos_type min_pos (const Vector &v)
 Returns position of minimal entry of vector v.
template<unsigned long Unroll, typename Vector >
traits::enable_if_vector
< Vector, typename
RealMagnitude< typename
Collection< Vector >
::value_type >::type >::type 
one_norm (const Vector &vector)
template<typename Op1 , typename Op2 >
mtl::traits::vec_mult_result
< Op1, Op2 >::type 
operator* (const Op1 &op1, const Op2 &op2)
 Multiplication for all supported types of operations.
template<typename Op1 , typename Op2 >
traits::div_result< Op1, Op2 >
::type 
operator/ (const Op1 &op1, const Op2 &op2)
 Division of matrices and vectors by salars.
template<typename Value >
void orth (Value &value)
template<typename Value >
void orth (Value &value, typename mtl::Collection< Value >::size_type i)
template<typename Value >
dense2D< typename
mtl::Collection< typename
mtl::Collection< Value >
::value_type >::value_type > 
orthogonalize_factors (Value &v)
template<typename Vector , typename Generator >
mtl::traits::enable_if_vector
< Vector >::type 
random (Vector &v, Generator &generator)
 Fill vector with random values; generator must be a nullary function.
template<typename Vector >
mtl::traits::enable_if_vector
< Vector >::type 
random (Vector &v)
 Fill vector with random values.
template<typename Vector >
mtl::traits::vector_resource
< Vector >::type 
resource (const Vector &v)
 Describes the resources need for a certain vector.
template<typename Coll >
mtl::traits::enable_if_vector
< Coll >::type 
set_to_zero (Coll &collection)
template<typename VectorComplex , typename VectorReal , typename VectorImaginary >
void split_complex_vector (const VectorComplex &c, VectorReal &r, VectorImaginary &i)
 Split one complex-valued vector into two real-valued vectors.
template<typename Vector >
mtl::traits::enable_if_vector
< Vector >::type 
swap_row (Vector &v, typename Collection< Vector >::size_type i, typename Collection< Vector >::size_type j)
 Entry i and j are swapped in vector v.
template<typename Vector >
transposed_vector< Vector >
::type const 
trans (const Vector &v)
 Returns tranposed view of vector v.
template<unsigned long Unroll, typename Value >
RealMagnitude< typename
Collection< Value >
::value_type >::type 
two_norm (const Value &value)
template<typename Value , typename Parameters >
dense_vector< Value, Parameters > sub_vector (dense_vector< Value, Parameters > &v, typename dense_vector< Value, Parameters >::size_type start, typename dense_vector< Value, Parameters >::size_type finish)
 Sub-vector function, more convenient with irange.
template<typename Value >
traits::unit_vector< Value >::type unit_vector (std::size_t k, std::size_t n)
 Return k-th unit vector of size n.


Detailed Description

Namespace for vectors and views and operations exclusively on vectors.


Function Documentation

template<typename T >
mtl::traits::enable_if_vector<T, T&>::type mtl::vector::crop ( T &  x  )  [inline]

Remove all zero entries from a collection.

Does nothing for dense collections

template<typename Vector1 , typename Vector2 >
detail::cross_result<Vector1, Vector2>::type mtl::vector::cross ( const Vector1 &  v1,
const Vector2 &  v2 
) [inline]

Dot product.

Only exists for 3 and 7 dimensions. Consider specialization for fixed-size types

template<typename Vector1 , typename Vector2 >
detail::dot_result< Vector1, Vector2 >::type mtl::vector::dot ( const Vector1 &  v1,
const Vector2 &  v2 
) [inline]

Dot product defined as hermitian(v) * w.

Dot product with user-specified unrolling defined as hermitian(v) * w.

Unrolled eight times by default

template<typename Vector1 , typename Vector2 >
detail::dot_result< Vector1, Vector2 >::type mtl::vector::dot_real ( const Vector1 &  v1,
const Vector2 &  v2 
) [inline]

Dot product without conjugate defined as trans(v) * w.

Dot product without conjugate with user-specified unrolling defined as trans(v) * w.

Unrolled eight times by default

template<typename Vector , typename Value >
bool mtl::vector::entry_similar ( const Vector &  x,
typename Collection< Vector >::size_type  i,
const Value &  v,
const Value &  eps 
) [inline]

Compares x[i] with v returns false if larger than eps.

Function works on distributed matrices where only one process tests and the other return true. The functions enables writing tests that work in parallel (and all other platforms).

template<typename Vector >
std::pair<typename mtl::dense_vector<typename Collection<Vector>::value_type>, typename Collection<Vector>::value_type> mtl::vector::householder ( Vector &  y  )  [inline]

Computes Householder vector b of y.

such that identity_matrix(size(v))-b*v*v' projects the vector y to a positive multiple of the first unit vector.

template<typename Vector >
mtl::dense_vector<typename Collection<Vector>::value_type> mtl::vector::householder_s ( Vector &  y  )  [inline]

Computes Householder vector b of y.

stabilere Householder transformation, auch für nicht-quadratische Matrizen

template<unsigned long Unroll, typename Vector >
mtl::traits::enable_if_vector< Vector, typename RealMagnitude< typename Collection< Vector >::value_type >::type >::type mtl::vector::infinity_norm ( const Vector &  vector  )  [inline]

Infinity-norm for vectors: infinity_norm(x) $\rightarrow |x|_\infty$.

Return values:
The magnitude type of the respective value type, see Magnitude.
The norms are defined as $|v|_\infty=\max_i |v_i|$.

Vector norms are unrolled 8-fold by default. An n-fold unrolling can be generated with infinity_norm<n>(x). The maximum for n is 8 (it might be increased later).

template<typename VectorReal , typename VectorImaginary , typename VectorComplex >
void mtl::vector::merge_complex_vector ( const VectorReal &  r,
const VectorImaginary &  i,
VectorComplex &  c 
) [inline]

Merge two real-valued vectors into one complex-valued vector.

Elements of the complex vector must be constructible from two real elements. Complex vector is resized if its size is 0 otherwise the vectors must have the same length.

template<unsigned long Unroll, typename Vector >
traits::enable_if_vector< Vector, typename RealMagnitude< typename Collection< Vector >::value_type >::type >::type mtl::vector::one_norm ( const Vector &  vector  )  [inline]

One-norm for vectors: one_norm(x) $\rightarrow |x|_1$.

Return values:
The magnitude type of the respective value type, see Magnitude.
The norms are defined as $|v|_1=\sum_i |v_i|$. Vector norms are unrolled 8-fold by default. An n-fold unrolling can be generated with one_norm<n>(x). The maximum for n is 8 (it might be increased later).

template<typename Op1 , typename Op2 >
traits::lazy_enable_if_rvec_cvec_mult< Op1, Op2, detail::dot_result< Op1, Op2 > >::type mtl::vector::operator* ( const Op1 &  op1,
const Op2 &  op2 
) [inline]

Multiplication for all supported types of operations.

Multiply row vector with column vector; result is scalar.

Enable-if-like technique make sure that only called when properly defined

template<typename Op1 , typename Op2 >
traits::div_result<Op1,Op2>::type mtl::vector::operator/ ( const Op1 &  op1,
const Op2 &  op2 
) [inline]

Division of matrices and vectors by salars.

Enable-if-like technique make sure that only called when properly defined

template<typename Value >
void mtl::vector::orth ( Value &  value,
typename mtl::Collection< Value >::size_type  i 
) [inline]

Orthonormalize the i-th entry of a vector of vectors.

The i-th vector is orthogonalized w.r.t. to the preceeding ones and consecutively normalized. The outer type must be a random access collection and the vector type must provide a dot function. For instance dense_vector<dense_vector<double> > or std::vector<dense_vector<std::complex<double> > > are eligible. It is planned to implement the function for matrices as well where the columns will be ortho-normalized.

template<typename Value >
void mtl::vector::orth ( Value &  value  )  [inline]

Orthonormalize a vector of vectors.

The outer type must be a random access collection and the vector type must provide a dot function. For instance dense_vector<dense_vector<double> > or std::vector<dense_vector<std::complex<double> > > are eligible. It is planned to implement the function for matrices as well where the columns will be ortho-normalized.

template<typename Value >
dense2D<typename mtl::Collection <typename mtl::Collection<Value>::value_type >::value_type > mtl::vector::orthogonalize_factors ( Value &  v  )  [inline]

Orthogonalize a vector of vectors.

Opposed to orth the vectors are not normalized. An upper matrix with the factors used in the orthogonalization is returned. The diagonal contains dot(v[i], v[i]). The returned factors are for instance used in bicgstab_ell. The outer type must be a random access collection and the vector type must provide a dot function. For instance dense_vector<dense_vector<double> > or std::vector<dense_vector<std::complex<double> > > are eligible.

template<typename Vector >
mtl::traits::enable_if_vector<Vector>::type mtl::vector::random ( Vector &  v  )  [inline]

Fill vector with random values.

Currently done with rand(). Will be improved one day. You can provide your own generator as second argument.

template<typename Vector >
mtl::traits::vector_resource<Vector>::type mtl::vector::resource ( const Vector &  v  )  [inline]

Describes the resources need for a certain vector.

All necessary information to construct appropriate/consistent temporary vectors. Normally, this is just the size of the vector. For distributed vector we also need its distribution.

template<typename Coll >
mtl::traits::enable_if_vector< Coll >::type mtl::vector::set_to_zero ( Coll &  collection  )  [inline]

Sets all values of a collection to 0 More spefically the defined multiplicative identity element

template<typename VectorComplex , typename VectorReal , typename VectorImaginary >
void mtl::vector::split_complex_vector ( const VectorComplex &  c,
VectorReal &  r,
VectorImaginary &  i 
) [inline]

Split one complex-valued vector into two real-valued vectors.

Elements of the real vector must be assignable from the real and imaginary part of the complex elements. Real vectors are resized if their size is 0 otherwise the vectors must have the same length.

template<unsigned long Unroll, typename Value >
RealMagnitude< typename Collection< Value >::value_type >::type mtl::vector::two_norm ( const Value &  value  )  [inline]

Two-norm for vectors: two_norm(x) $\rightarrow |x|_2$.

Return values:
The magnitude type of the respective value type, see Magnitude. The norms are defined as $|v|_2=\sqrt{\sum_i |v_i|^2}$.
Vector norms are unrolled 8-fold by default. An n-fold unrolling can be generated with two_norm<n>(x). The maximum for n is 8 (it might be increased later).

template<typename Value >
traits::unit_vector< double >::type mtl::vector::unit_vector ( std::size_t  k,
std::size_t  n 
) [inline]

Return k-th unit vector of size n.

Unit vector of type double.

The result is a dense column vector. In the future this will be replaced by a proxy for the sake of efficiency. If you use unit_vector in an expression you will not encounter this change. If you define a variable you should use traits::unit_vector, e.g.:

        typename mtl::traits::unit_vector<float>::type  e_k(mtl::vector::unit_vector(k, n));


mtl::vector Namespace Reference -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine -- Gen. with rev. 7542 on 7 Apr 2011 by doxygen 1.5.9 -- © 2010 by SimuNova UG.