Modules | Classes | Functions
Sparse Vectors

Modules

 Expressions
 
 CompressedVector
 

Classes

struct  blaze::SparseVector< VT, TF >
 Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dimensional) sparse vectors. It provides an abstraction from the actual type of the sparse vector, but enables a conversion back to this type via the Vector base class. More...
 
class  blaze::VectorAccessProxy< VT >
 Access proxy for sparse, N-dimensional vectors.The VectorAccessProxy provides safe access to the elements of a non-const sparse vector.
The proxied access to the elements of a sparse vector is necessary since it may be possible that several insertion operations happen in the same statement. The following code illustrates this with two examples by means of the CompressedVector class: More...
 

Functions

template<typename T1 , typename T2 , bool TF>
const DVecSVecMultExpr< T1, T2, TF > blaze::operator* (const DenseVector< T1, TF > &lhs, const SparseVector< T2, TF > &rhs)
 Multiplication operator for the componentwise product of a dense vector and a sparse vector ( $ \vec{a}=\vec{b}*\vec{c} $). More...
 
template<typename T1 , typename T2 >
const DisableIf< Or< IsSymmetric< T1 >, IsMatMatMultExpr< T1 > >, SMatSVecMultExpr< T1, T2 > >::Type blaze::operator* (const SparseMatrix< T1, false > &mat, const SparseVector< T2, false > &vec)
 Multiplication operator for the multiplication of a row-major sparse matrix and a sparse vector ( $ \vec{a}=B*\vec{c} $). More...
 
template<typename VT , bool TF>
const SVecAbsExpr< VT, TF > blaze::abs (const SparseVector< VT, TF > &sv)
 Returns a vector containing the absolute values of each single element of sv. More...
 
template<typename VT , bool TF>
const SVecConjExpr< VT, TF > blaze::conj (const SparseVector< VT, TF > &sv)
 Returns a vector containing the complex conjugate of each single element of sv. More...
 
template<typename VT , bool TF>
const CTransExprTrait< VT >::Type blaze::ctrans (const SparseVector< VT, TF > &sv)
 Returns the conjugate transpose vector of sv. More...
 
template<typename T1 , typename T2 , bool TF>
const SVecDVecMultExpr< T1, T2, TF > blaze::operator* (const SparseVector< T1, TF > &lhs, const DenseVector< T2, TF > &rhs)
 Multiplication operator for the componentwise product of a sparse vector and a dense vector ( $ \vec{a}=\vec{b}*\vec{c} $). More...
 
template<typename VT , bool TF>
const SVecEvalExpr< VT, TF > blaze::eval (const SparseVector< VT, TF > &sv)
 Forces the evaluation of the given sparse vector expression sv. More...
 
template<typename VT , bool TF>
const ImagExprTrait< VT >::Type blaze::imag (const SparseVector< VT, TF > &sv)
 Returns a vector containing the imaginary parts of each single element of sv. More...
 
template<typename VT , bool TF>
const RealExprTrait< VT >::Type blaze::real (const SparseVector< VT, TF > &sv)
 Returns a vector containing the real parts of each single element of sv. More...
 
template<typename T1 , typename T2 , bool TF>
const EnableIf< IsNumeric< T2 >, typename DivExprTrait< T1, T2 >::Type >::Type blaze::operator/ (const SparseVector< T1, TF > &vec, T2 scalar)
 Division operator for the divison of a sparse vector by a scalar value ( $ \vec{a}=\vec{b}/s $). More...
 
template<typename VT , bool TF>
const SVecScalarMultExpr< VT, typename UnderlyingBuiltin< VT >::Type, TF > blaze::operator- (const SparseVector< VT, TF > &sv)
 Unary minus operator for the negation of a sparse vector ( $ \vec{a} = -\vec{b} $). More...
 
template<typename T1 , typename T2 , bool TF>
const EnableIf< IsNumeric< T2 >, typename MultExprTrait< T1, T2 >::Type >::Type blaze::operator* (const SparseVector< T1, TF > &vec, T2 scalar)
 Multiplication operator for the multiplication of a sparse vector and a scalar value ( $ \vec{a}=\vec{b}*s $). More...
 
template<typename T1 , typename T2 , bool TF>
const EnableIf< IsNumeric< T1 >, typename MultExprTrait< T1, T2 >::Type >::Type blaze::operator* (T1 scalar, const SparseVector< T2, TF > &vec)
 Multiplication operator for the multiplication of a scalar value and a sparse vector ( $ \vec{a}=s*\vec{b} $). More...
 
template<typename VT , bool TF>
const SVecSerialExpr< VT, TF > blaze::serial (const SparseVector< VT, TF > &sv)
 Forces the serial evaluation of the given sparse vector expression sv. More...
 
template<typename T1 , typename T2 , bool TF>
const SVecSVecAddExpr< T1, T2, TF > blaze::operator+ (const SparseVector< T1, TF > &lhs, const SparseVector< T2, TF > &rhs)
 Addition operator for the addition of two sparse vectors ( $ \vec{a}=\vec{b}+\vec{c} $). More...
 
template<typename T1 , typename T2 , bool TF>
const SVecSVecMultExpr< T1, T2, TF > blaze::operator* (const SparseVector< T1, TF > &lhs, const SparseVector< T2, TF > &rhs)
 Multiplication operator for the componentwise multiplication of two sparse vectors ( $ \vec{a}=\vec{b}*\vec{c} $). More...
 
template<typename T1 , typename T2 , bool TF>
const SVecSVecSubExpr< T1, T2, TF > blaze::operator- (const SparseVector< T1, TF > &lhs, const SparseVector< T2, TF > &rhs)
 Subtraction operator for the subtraction of two sparse vectors ( $ \vec{a}=\vec{b}-\vec{c} $). More...
 
template<typename VT , bool TF>
const SVecTransExpr< VT,!TF > blaze::trans (const SparseVector< VT, TF > &sv)
 Calculation of the transpose of the given sparse vector. More...
 
template<typename T1 , typename T2 >
const MultTrait< typename T1::ElementType, typename T2::ElementType >::Type blaze::operator* (const DenseVector< T1, true > &lhs, const SparseVector< T2, false > &rhs)
 Multiplication operator for the scalar product (inner product) of a dense and a sparse vector ( $ s=\vec{a}*\vec{b} $). More...
 
template<typename T1 , typename T2 >
const DisableIf< IsMatMatMultExpr< T1 >, TSMatSVecMultExpr< T1, T2 > >::Type blaze::operator* (const SparseMatrix< T1, true > &mat, const SparseVector< T2, false > &vec)
 Multiplication operator for the multiplication of a transpose sparse matrix and a sparse vector ( $ \vec{y}=A*\vec{x} $). More...
 
template<typename T1 , typename T2 >
const MultTrait< typename T1::ElementType, typename T2::ElementType >::Type blaze::operator* (const SparseVector< T1, true > &lhs, const DenseVector< T2, false > &rhs)
 Multiplication operator for the scalar product (inner product) of a sparse and a dense vector ( $ s=\vec{a}*\vec{b} $). More...
 
template<typename T1 , typename T2 >
const DisableIf< IsMatMatMultExpr< T2 >, TSVecSMatMultExpr< T1, T2 > >::Type blaze::operator* (const SparseVector< T1, true > &vec, const SparseMatrix< T2, false > &mat)
 Multiplication operator for the multiplication of a transpose sparse vector and a row-major sparse matrix ( $ \vec{y}^T=\vec{x}^T*A $). More...
 
template<typename T1 , typename T2 , bool SO>
const EnableIf< IsMatMatMultExpr< T2 >, typename MultExprTrait< T1, T2 >::Type >::Type blaze::operator* (const SparseVector< T1, true > &vec, const SparseMatrix< T2, SO > &mat)
 Multiplication operator for the multiplication of a transpose sparse vector and a sparse matrix-matrix multiplication expression ( $ \vec{y}^T=\vec{x}^T*(A*B) $). More...
 
template<typename T1 , typename T2 >
const MultTrait< typename T1::ElementType, typename T2::ElementType >::Type blaze::operator* (const SparseVector< T1, true > &lhs, const SparseVector< T2, false > &rhs)
 Multiplication operator for the scalar product (inner product) of two sparse vectors ( $ s=\vec{a}*\vec{b} $). More...
 
template<typename T1 , typename T2 >
const DisableIf< Or< IsSymmetric< T2 >, IsMatMatMultExpr< T2 > >, TSVecTSMatMultExpr< T1, T2 > >::Type blaze::operator* (const SparseVector< T1, true > &vec, const SparseMatrix< T2, true > &mat)
 Multiplication operator for the multiplication of a transpose sparse vector and a column-major sparse matrix ( $ \vec{y}^T=\vec{x}^T*A $). More...
 

SparseVector operators

template<typename T1 , bool TF1, typename T2 , bool TF2>
bool blaze::operator== (const SparseVector< T1, TF1 > &lhs, const SparseVector< T2, TF2 > &rhs)
 Equality operator for the comparison of two sparse vectors. More...
 
template<typename T1 , bool TF1, typename T2 , bool TF2>
bool blaze::operator!= (const SparseVector< T1, TF1 > &lhs, const SparseVector< T2, TF2 > &rhs)
 Inequality operator for the comparison of two sparse vectors. More...
 

SparseVector functions

template<typename VT , bool TF>
bool blaze::isnan (const SparseVector< VT, TF > &sv)
 Checks the given sparse vector for not-a-number elements. More...
 
template<typename VT , bool TF>
bool blaze::isUniform (const SparseVector< VT, TF > &sv)
 Checks if the given sparse vector is a uniform vector. More...
 
template<typename VT , bool TF>
CMathTrait< typename VT::ElementType >::Type blaze::length (const SparseVector< VT, TF > &sv)
 Calculation of the sparse vector length $|\vec{a}|$. More...
 
template<typename VT , bool TF>
const VT::ElementType blaze::sqrLength (const SparseVector< VT, TF > &sv)
 Calculation of the sparse vector square length $|\vec{a}|^2$. More...
 
template<typename VT , bool TF>
const VT::ElementType blaze::min (const SparseVector< VT, TF > &sv)
 Returns the smallest element of the sparse vector. More...
 
template<typename VT , bool TF>
const VT::ElementType blaze::max (const SparseVector< VT, TF > &sv)
 Returns the largest element of the sparse vector. More...
 

VectorAccessProxy global functions

template<typename VT >
ConjExprTrait< typename VectorAccessProxy< VT >::RepresentedType >::Type blaze::conj (const VectorAccessProxy< VT > &proxy)
 Computing the complex conjugate of the represented element. More...
 
template<typename VT >
void blaze::reset (const VectorAccessProxy< VT > &proxy)
 Resetting the represented element to the default initial values. More...
 
template<typename VT >
void blaze::clear (const VectorAccessProxy< VT > &proxy)
 Clearing the represented element. More...
 
template<typename VT >
bool blaze::isDefault (const VectorAccessProxy< VT > &proxy)
 Returns whether the represented element is in default state. More...
 
template<typename VT >
bool blaze::isReal (const VectorAccessProxy< VT > &proxy)
 Returns whether the vector element represents a real number. More...
 
template<typename VT >
bool blaze::isZero (const VectorAccessProxy< VT > &proxy)
 Returns whether the represented element is 0. More...
 
template<typename VT >
bool blaze::isOne (const VectorAccessProxy< VT > &proxy)
 Returns whether the represented element is 1. More...
 
template<typename VT >
bool blaze::isnan (const VectorAccessProxy< VT > &proxy)
 Returns whether the represented element is not a number. More...
 
template<typename VT >
void blaze::swap (const VectorAccessProxy< VT > &a, const VectorAccessProxy< VT > &b)
 Swapping the contents of two access proxies. More...
 
template<typename VT , typename T >
void blaze::swap (const VectorAccessProxy< VT > &a, T &b)
 Swapping the contents of an access proxy with another element. More...
 
template<typename T , typename VT >
void blaze::swap (T &a, const VectorAccessProxy< VT > &b)
 Swapping the contents of an access proxy with another element. More...
 

Detailed Description

Function Documentation

template<typename VT , bool TF>
const SVecAbsExpr<VT,TF> blaze::abs ( const SparseVector< VT, TF > &  sv)
inline

Returns a vector containing the absolute values of each single element of sv.

Parameters
svThe integral sparse input vector.
Returns
The absolute value of each single element of sv.

The abs function calculates the absolute value of each element of the sparse input vector sv. The function returns an expression representing this operation.
The following example demonstrates the use of the abs function:

// ... Resizing and initialization
b = abs( a );
template<typename VT >
void blaze::clear ( const VectorAccessProxy< VT > &  proxy)
inline

Clearing the represented element.

Parameters
proxyThe given access proxy.
Returns
void
template<typename VT >
ConjExprTrait< typename VectorAccessProxy< VT >::RepresentedType >::Type blaze::conj ( const VectorAccessProxy< VT > &  proxy)
inline

Computing the complex conjugate of the represented element.

Parameters
proxyThe given proxy instance.
Returns
The complex conjugate of the represented element.

This function computes the complex conjugate of the element represented by the access proxy. In case the proxy represents a vector- or matrix-like data structure the function returns an expression representing the complex conjugate of the vector/matrix.

template<typename VT , bool TF>
const SVecConjExpr<VT,TF> blaze::conj ( const SparseVector< VT, TF > &  sv)
inline

Returns a vector containing the complex conjugate of each single element of sv.

Parameters
svThe integral sparse input vector.
Returns
The complex conjugate of each single element of sv.

The conj function calculates the complex conjugate of each element of the sparse input vector sv. The function returns an expression representing this operation.
The following example demonstrates the use of the conj function:

// ... Resizing and initialization
b = conj( a );
template<typename VT , bool TF>
const CTransExprTrait<VT>::Type blaze::ctrans ( const SparseVector< VT, TF > &  sv)
inline

Returns the conjugate transpose vector of sv.

Parameters
svThe input vector.
Returns
The conjugate transpose of sv.

The ctrans function returns an expression representing the conjugate transpose (also called adjoint matrix, Hermitian conjugate matrix or transjugate matrix) of the given input vector sv.
The following example demonstrates the use of the ctrans function:

// ... Resizing and initialization
b = ctrans( a );

Note that the ctrans function has the same effect as manually applying the conj and trans function in any order:

b = trans( conj( a ) ); // Computing the conjugate transpose vector
b = conj( trans( a ) ); // Computing the conjugate transpose vector
template<typename VT , bool TF>
const SVecEvalExpr<VT,TF> blaze::eval ( const SparseVector< VT, TF > &  sv)
inline

Forces the evaluation of the given sparse vector expression sv.

Parameters
svThe input vector.
Returns
The evaluated sparse vector.

The eval function forces the evaluation of the given sparse vector expression sv. The function returns an expression representing this operation.
The following example demonstrates the use of the eval function:

// ... Resizing and initialization
b = eval( a );
template<typename VT , bool TF>
const ImagExprTrait<VT>::Type blaze::imag ( const SparseVector< VT, TF > &  sv)
inline

Returns a vector containing the imaginary parts of each single element of sv.

Parameters
svThe integral sparse input vector.
Returns
The imaginary part of each single element of sv.

The imag function calculates the imaginary part of each element of the sparse input vector sv. The function returns an expression representing this operation.
The following example demonstrates the use of the imag function:

// ... Resizing and initialization
b = imag( a );
template<typename VT >
bool blaze::isDefault ( const VectorAccessProxy< VT > &  proxy)
inline

Returns whether the represented element is in default state.

Parameters
proxyThe given access proxy.
Returns
true in case the represented element is in default state, false otherwise.

This function checks whether the element represented by the access proxy is in default state. In case it is in default state, the function returns true, otherwise it returns false.

template<typename VT , bool TF>
bool blaze::isnan ( const SparseVector< VT, TF > &  sv)
inline

Checks the given sparse vector for not-a-number elements.

Parameters
svThe sparse vector to be checked for not-a-number elements.
Returns
true if at least one element of the vector is not-a-number, false otherwise.

This function checks the N-dimensional sparse vector for not-a-number (NaN) elements. If at least one element of the vector is not-a-number, the function returns true, otherwise it returns false.

// ... Resizing and initialization
if( isnan( a ) ) { ... }

Note that this function only works for vectors with floating point elements. The attempt to use it for a vector with a non-floating point element type results in a compile time error.

template<typename VT >
bool blaze::isnan ( const VectorAccessProxy< VT > &  proxy)
inline

Returns whether the represented element is not a number.

Parameters
proxyThe given access proxy.
Returns
true in case the represented element is in not a number, false otherwise.

This function checks whether the element represented by the access proxy is not a number (NaN). In case it is not a number, the function returns true, otherwise it returns false.

template<typename VT >
bool blaze::isOne ( const VectorAccessProxy< VT > &  proxy)
inline

Returns whether the represented element is 1.

Parameters
proxyThe given access proxy.
Returns
true in case the represented element is 1, false otherwise.

This function checks whether the element represented by the access proxy represents the numeric value 1. In case it is 1, the function returns true, otherwise it returns false.

template<typename VT >
bool blaze::isReal ( const VectorAccessProxy< VT > &  proxy)
inline

Returns whether the vector element represents a real number.

Parameters
proxyThe given access proxy.
Returns
true in case the vector element represents a real number, false otherwise.

This function checks whether the element represented by the access proxy represents the a real number. In case the element is of built-in type, the function returns true. In case the element is of complex type, the function returns true if the imaginary part is equal to 0. Otherwise it returns false.

template<typename VT , bool TF>
bool blaze::isUniform ( const SparseVector< VT, TF > &  sv)

Checks if the given sparse vector is a uniform vector.

Parameters
svThe sparse vector to be checked.
Returns
true if the vector is a uniform vector, false if not.

This function checks if the given sparse vector is a uniform vector. The vector is considered to be uniform if all its elements are identical. The following code example demonstrates the use of the function:

// ... Initialization
if( isUniform( a ) ) { ... }

It is also possible to check if a vector expression results in a uniform vector:

if( isUniform( a + b ) ) { ... }

However, note that this might require the complete evaluation of the expression, including the generation of a temporary vector.

template<typename VT >
bool blaze::isZero ( const VectorAccessProxy< VT > &  proxy)
inline

Returns whether the represented element is 0.

Parameters
proxyThe given access proxy.
Returns
true in case the represented element is 0, false otherwise.

This function checks whether the element represented by the access proxy represents the numeric value 0. In case it is 0, the function returns true, otherwise it returns false.

template<typename VT , bool TF>
CMathTrait< typename VT::ElementType >::Type blaze::length ( const SparseVector< VT, TF > &  sv)

Calculation of the sparse vector length $|\vec{a}|$.

Parameters
svThe given sparse vector.
Returns
The length of the sparse vector.

This function calculates the actual length of the sparse vector. The return type of the length() function depends on the actual element type of the vector instance:

Type LengthType
float float
integral data types and double double
long double long double
Note
: This operation is only defined for numeric data types. In case the element type is not a numeric data type (i.e. a user defined data type or boolean) the attempt to use the length() function results in a compile time error!
template<typename VT , bool TF>
const VT::ElementType blaze::max ( const SparseVector< VT, TF > &  sv)

Returns the largest element of the sparse vector.

Parameters
svThe given sparse vector.
Returns
The largest sparse vector element.

This function returns the largest element of the given sparse vector. This function can only be used for element types that support the smaller-than relationship. In case the vector currently has a size of 0, the returned value is the default value (e.g. 0 in case of fundamental data types).

Note
: In case the compressed vector is not completely filled, the zero elements are also taken into account. Example: the following compressed vector has only 2 non-zero elements. However, the maximum of this vector is 0:

\[ \left(\begin{array}{*{4}{c}} -1 & 0 & -3 & 0 \\ \end{array}\right) \]

template<typename VT , bool TF>
const VT::ElementType blaze::min ( const SparseVector< VT, TF > &  sv)

Returns the smallest element of the sparse vector.

Parameters
svThe given sparse vector.
Returns
The smallest sparse vector element.

This function returns the smallest element of the given sparse vector. This function can only be used for element types that support the smaller-than relationship. In case the vector currently has a size of 0, the returned value is the default value (e.g. 0 in case of fundamental data types).

Note
: In case the sparse vector is not completely filled, the zero elements are also taken into account. Example: the following compressed vector has only 2 non-zero elements. However, the minimum of this vector is 0:

\[ \left(\begin{array}{*{4}{c}} 1 & 0 & 3 & 0 \\ \end{array}\right) \]

template<typename T1 , bool TF1, typename T2 , bool TF2>
bool blaze::operator!= ( const SparseVector< T1, TF1 > &  lhs,
const SparseVector< T2, TF2 > &  rhs 
)
inline

Inequality operator for the comparison of two sparse vectors.

Parameters
lhsThe left-hand side sparse vector for the comparison.
rhsThe right-hand side sparse vector for the comparison.
Returns
true if the two vectors are not equal, false if they are equal.
template<typename T1 , typename T2 >
const MultTrait<typename T1::ElementType,typename T2::ElementType>::Type blaze::operator* ( const SparseVector< T1, true > &  lhs,
const SparseVector< T2, false > &  rhs 
)
inline

Multiplication operator for the scalar product (inner product) of two sparse vectors ( $ s=\vec{a}*\vec{b} $).

Parameters
lhsThe left-hand side sparse vector for the inner product.
rhsThe right-hand side sparse vector for the inner product.
Returns
The scalar product.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the scalar product (inner product) of two sparse vectors:

// ... Resizing and initialization
res = trans(a) * b;

The operator returns a scalar value of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 >
const MultTrait<typename T1::ElementType,typename T2::ElementType>::Type blaze::operator* ( const DenseVector< T1, true > &  lhs,
const SparseVector< T2, false > &  rhs 
)
inline

Multiplication operator for the scalar product (inner product) of a dense and a sparse vector ( $ s=\vec{a}*\vec{b} $).

Parameters
lhsThe left-hand side dense vector for the inner product.
rhsThe right-hand side sparse vector for the inner product.
Returns
The scalar product.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the scalar product (inner product) of a dense vector and a sparse vector:

The operator returns a scalar value of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 >
const MultTrait<typename T1::ElementType,typename T2::ElementType>::Type blaze::operator* ( const SparseVector< T1, true > &  lhs,
const DenseVector< T2, false > &  rhs 
)
inline

Multiplication operator for the scalar product (inner product) of a sparse and a dense vector ( $ s=\vec{a}*\vec{b} $).

Parameters
lhsThe left-hand side sparse vector for the inner product.
rhsThe right-hand side dense vector for the inner product.
Returns
The scalar product.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the scalar product (inner product) of a sparse vector and a dense vector:

The operator returns a scalar value of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool TF>
const SVecSVecMultExpr<T1,T2,TF> blaze::operator* ( const SparseVector< T1, TF > &  lhs,
const SparseVector< T2, TF > &  rhs 
)
inline

Multiplication operator for the componentwise multiplication of two sparse vectors ( $ \vec{a}=\vec{b}*\vec{c} $).

Parameters
lhsThe left-hand side sparse vector for the component product.
rhsThe right-hand side sparse vector for the component product.
Returns
The product of the two sparse vectors.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the componentwise multiplication of two sparse vectors:

// ... Resizing and initialization
c = a * b;

The operator returns a sparse vector of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool TF>
const SVecDVecMultExpr<T1,T2,TF> blaze::operator* ( const SparseVector< T1, TF > &  lhs,
const DenseVector< T2, TF > &  rhs 
)
inline

Multiplication operator for the componentwise product of a sparse vector and a dense vector ( $ \vec{a}=\vec{b}*\vec{c} $).

Parameters
lhsThe left-hand side sparse vector for the component product.
rhsThe right-hand side dense vector for the component product.
Returns
The product of the two vectors.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the componentwise multiplication of a sparse vector and a dense vector:

// ... Resizing and initialization
c = a * b;

The operator returns an expression representing a sparse vector of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool TF>
const DVecSVecMultExpr<T1,T2,TF> blaze::operator* ( const DenseVector< T1, TF > &  lhs,
const SparseVector< T2, TF > &  rhs 
)
inline

Multiplication operator for the componentwise product of a dense vector and a sparse vector ( $ \vec{a}=\vec{b}*\vec{c} $).

Parameters
lhsThe left-hand side dense vector for the component product.
rhsThe right-hand side sparse vector for the component product.
Returns
The product of the two vectors.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the componentwise multiplication of a dense vector and a sparse vector:

// ... Resizing and initialization
c = a * b;

The operator returns an expression representing a sparse vector of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool TF>
const EnableIf< IsNumeric<T2>, typename MultExprTrait<T1,T2>::Type >::Type blaze::operator* ( const SparseVector< T1, TF > &  vec,
T2  scalar 
)
inline

Multiplication operator for the multiplication of a sparse vector and a scalar value ( $ \vec{a}=\vec{b}*s $).

Parameters
vecThe left-hand side sparse vector for the multiplication.
scalarThe right-hand side scalar value for the multiplication.
Returns
The scaled result vector.

This operator represents the multiplication between a sparse vector and a scalar value:

// ... Resizing and initialization
b = a * 1.25;

The operator returns a sparse vector of the higher-order element type of the involved data types T1::ElementType and T2. Note that this operator only works for scalar values of built-in data type.

template<typename T1 , typename T2 , bool TF>
const EnableIf< IsNumeric<T1>, typename MultExprTrait<T1,T2>::Type >::Type blaze::operator* ( T1  scalar,
const SparseVector< T2, TF > &  vec 
)
inline

Multiplication operator for the multiplication of a scalar value and a sparse vector ( $ \vec{a}=s*\vec{b} $).

Parameters
scalarThe left-hand side scalar value for the multiplication.
vecThe right-hand side sparse vector for the multiplication.
Returns
The scaled result vector.

This operator represents the multiplication between a a scalar value and sparse vector:

// ... Resizing and initialization
b = 1.25 * a;

The operator returns a sparse vector of the higher-order element type of the involved data types T1 and T2::ElementType. Note that this operator only works for scalar values of built-in data type.

template<typename T1 , typename T2 >
const DisableIf< IsMatMatMultExpr<T1>, TSMatSVecMultExpr<T1,T2> >::Type blaze::operator* ( const SparseMatrix< T1, true > &  mat,
const SparseVector< T2, false > &  vec 
)
inline

Multiplication operator for the multiplication of a transpose sparse matrix and a sparse vector ( $ \vec{y}=A*\vec{x} $).

Parameters
matThe left-hand side sparse matrix for the multiplication.
vecThe right-hand side sparse vector for the multiplication.
Returns
The resulting vector.
Exceptions
std::invalid_argumentMatrix and vector sizes do not match.

This operator represents the multiplication between a transpose sparse matrix and a sparse vector:

The operator returns an expression representing a sparse vector of the higher-order element type of the two involved element types T1::ElementType and T2::ElementType. Both the sparse matrix type T1 and the sparse vector type T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current size of the vector vec doesn't match the current number of columns of the matrix mat, a std::invalid_argument is thrown.

template<typename T1 , typename T2 >
const DisableIf< IsMatMatMultExpr<T2>, TSVecSMatMultExpr<T1,T2> >::Type blaze::operator* ( const SparseVector< T1, true > &  vec,
const SparseMatrix< T2, false > &  mat 
)
inline

Multiplication operator for the multiplication of a transpose sparse vector and a row-major sparse matrix ( $ \vec{y}^T=\vec{x}^T*A $).

Parameters
vecThe left-hand side transpose sparse vector for the multiplication.
matThe right-hand side row-major sparse matrix for the multiplication.
Returns
The resulting transpose vector.
Exceptions
std::invalid_argumentVector and matrix sizes do not match.

This operator represents the multiplication between a transpose sparse vector and a row-major sparse matrix:

The operator returns an expression representing a transpose sparse vector of the higher-order element type of the two involved element types T1::ElementType and T2::ElementType. Both the sparse vector type T1 and the sparse matrix type T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current size of the vector vec doesn't match the current number of rows of the matrix mat, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool SO>
const EnableIf< IsMatMatMultExpr<T2>, typename MultExprTrait<T1,T2>::Type >::Type blaze::operator* ( const SparseVector< T1, true > &  vec,
const SparseMatrix< T2, SO > &  mat 
)
inline

Multiplication operator for the multiplication of a transpose sparse vector and a sparse matrix-matrix multiplication expression ( $ \vec{y}^T=\vec{x}^T*(A*B) $).

Parameters
vecThe left-hand side sparse vector for the multiplication.
matThe right-hand side sparse matrix-matrix multiplication.
Returns
The resulting vector.

This operator implements a performance optimized treatment of the multiplication of a sparse vector and a sparse matrix-matrix multiplication expression. It restructures the expression $ \vec{y}^T=\vec{x}^T*(A*B) $ to the expression $ \vec{y}^T=(\vec{x}^T*A)*B $.

template<typename T1 , typename T2 >
const DisableIf< Or< IsSymmetric<T2>, IsMatMatMultExpr<T2> > , TSVecTSMatMultExpr<T1,T2> >::Type blaze::operator* ( const SparseVector< T1, true > &  vec,
const SparseMatrix< T2, true > &  mat 
)
inline

Multiplication operator for the multiplication of a transpose sparse vector and a column-major sparse matrix ( $ \vec{y}^T=\vec{x}^T*A $).

Parameters
vecThe left-hand side transpose sparse vector for the multiplication.
matThe right-hand side column-major sparse matrix for the multiplication.
Returns
The resulting transpose vector.
Exceptions
std::invalid_argumentVector and matrix sizes do not match.

This operator represents the multiplication between a transpose sparse vector and a column-major sparse matrix:

The operator returns an expression representing a transpose sparse vector of the higher-order element type of the two involved element types T1::ElementType and T2::ElementType. Both the sparse vector type T1 and the sparse matrix type T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current size of the vector vec doesn't match the current number of rows of the matrix mat, a std::invalid_argument is thrown.

template<typename T1 , typename T2 >
const DisableIf< Or< IsSymmetric<T1>, IsMatMatMultExpr<T1> > , SMatSVecMultExpr<T1,T2> >::Type blaze::operator* ( const SparseMatrix< T1, false > &  mat,
const SparseVector< T2, false > &  vec 
)
inline

Multiplication operator for the multiplication of a row-major sparse matrix and a sparse vector ( $ \vec{a}=B*\vec{c} $).

Parameters
matThe left-hand side sparse matrix for the multiplication.
vecThe right-hand side sparse vector for the multiplication.
Returns
The resulting vector.
Exceptions
std::invalid_argumentMatrix and vector sizes do not match.

This operator represents the multiplication between a row-major sparse matrix and a sparse vector:

The operator returns an expression representing a sparse vector of the higher-order element type of the two involved element types T1::ElementType and T2::ElementType. Both the sparse matrix type T1 and the sparse vector type T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the MultTrait class template.
In case the current size of the vector vec doesn't match the current number of columns of the matrix mat, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool TF>
const SVecSVecAddExpr<T1,T2,TF> blaze::operator+ ( const SparseVector< T1, TF > &  lhs,
const SparseVector< T2, TF > &  rhs 
)
inline

Addition operator for the addition of two sparse vectors ( $ \vec{a}=\vec{b}+\vec{c} $).

Parameters
lhsThe left-hand side sparse vector for the vector addition.
rhsThe right-hand side sparse vector for the vector addition.
Returns
The sum of the two sparse vectors.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the addition of two sparse vectors:

// ... Resizing and initialization
c = a + b;

The operator returns a sparse vector of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the AddTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename T1 , typename T2 , bool TF>
const SVecSVecSubExpr<T1,T2,TF> blaze::operator- ( const SparseVector< T1, TF > &  lhs,
const SparseVector< T2, TF > &  rhs 
)
inline

Subtraction operator for the subtraction of two sparse vectors ( $ \vec{a}=\vec{b}-\vec{c} $).

Parameters
lhsThe left-hand side sparse vector for the vector subtraction.
rhsThe right-hand side sparse vector to be subtracted from the vector.
Returns
The difference of the two sparse vectors.
Exceptions
std::invalid_argumentVector sizes do not match.

This operator represents the subtraction of two sparse vectors:

// ... Resizing and initialization
c = a - b;

The operator returns a sparse vector of the higher-order element type of the two involved vector element types T1::ElementType and T2::ElementType. Both vector types T1 and T2 as well as the two element types T1::ElementType and T2::ElementType have to be supported by the SubTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.

template<typename VT , bool TF>
const SVecScalarMultExpr<VT,typename UnderlyingBuiltin<VT>::Type,TF> blaze::operator- ( const SparseVector< VT, TF > &  sv)
inline

Unary minus operator for the negation of a sparse vector ( $ \vec{a} = -\vec{b} $).

Parameters
svThe sparse vector to be negated.
Returns
The negation of the vector.

This operator represents the negation of a sparse vector:

// ... Resizing and initialization
b = -a;

The operator returns an expression representing the negation of the given sparse vector.

template<typename T1 , typename T2 , bool TF>
const EnableIf< IsNumeric<T2>, typename DivExprTrait<T1,T2>::Type >::Type blaze::operator/ ( const SparseVector< T1, TF > &  vec,
T2  scalar 
)
inline

Division operator for the divison of a sparse vector by a scalar value ( $ \vec{a}=\vec{b}/s $).

Parameters
vecThe left-hand side sparse vector for the division.
scalarThe right-hand side scalar value for the division.
Returns
The scaled result vector.

This operator represents the division of a sparse vector by a scalar value:

// ... Resizing and initialization
b = a / 0.24;

The operator returns a sparse vector of the higher-order element type of the involved data types T1::ElementType and T2. Note that this operator only works for scalar values of built-in data type.

Note
: A division by zero is only checked by an user assert.
template<typename T1 , bool TF1, typename T2 , bool TF2>
bool blaze::operator== ( const SparseVector< T1, TF1 > &  lhs,
const SparseVector< T2, TF2 > &  rhs 
)
inline

Equality operator for the comparison of two sparse vectors.

Parameters
lhsThe left-hand side sparse vector for the comparison.
rhsThe right-hand side sparse vector for the comparison.
Returns
true if the two sparse vectors are equal, false if not.
template<typename VT , bool TF>
const RealExprTrait<VT>::Type blaze::real ( const SparseVector< VT, TF > &  sv)
inline

Returns a vector containing the real parts of each single element of sv.

Parameters
svThe integral sparse input vector.
Returns
The real part of each single element of sv.

The real function calculates the real part of each element of the sparse input vector sv. The function returns an expression representing this operation.
The following example demonstrates the use of the real function:

// ... Resizing and initialization
b = real( a );
template<typename VT >
void blaze::reset ( const VectorAccessProxy< VT > &  proxy)
inline

Resetting the represented element to the default initial values.

Parameters
proxyThe given access proxy.
Returns
void
template<typename VT , bool TF>
const SVecSerialExpr< VT, TF > blaze::serial ( const SparseVector< VT, TF > &  sv)
inline

Forces the serial evaluation of the given sparse vector expression sv.

Parameters
svThe input vector.
Returns
The evaluated sparse vector.

The serial function forces the serial evaluation of the given sparse vector expression sv. The function returns an expression representing this operation.
The following example demonstrates the use of the serial function:

// ... Resizing and initialization
b = serial( a );
template<typename VT , bool TF>
const VT::ElementType blaze::sqrLength ( const SparseVector< VT, TF > &  sv)

Calculation of the sparse vector square length $|\vec{a}|^2$.

Parameters
svThe given sparse vector.
Returns
The square length of the vector.

This function calculates the actual square length of the sparse vector.

Note
: This operation is only defined for numeric data types. In case the element type is not a numeric data type (i.e. a user defined data type or boolean) the attempt to use the sqrLength() function results in a compile time error!
template<typename VT >
void blaze::swap ( const VectorAccessProxy< VT > &  a,
const VectorAccessProxy< VT > &  b 
)
inline

Swapping the contents of two access proxies.

Parameters
aThe first access proxy to be swapped.
bThe second access proxy to be swapped.
Returns
void
Exceptions
no-throwguarantee.
template<typename VT , typename T >
void blaze::swap ( const VectorAccessProxy< VT > &  a,
T &  b 
)
inline

Swapping the contents of an access proxy with another element.

Parameters
aThe access proxy to be swapped.
bThe other element to be swapped.
Returns
void
Exceptions
no-throwguarantee.
template<typename T , typename VT >
void blaze::swap ( T &  a,
const VectorAccessProxy< VT > &  b 
)
inline

Swapping the contents of an access proxy with another element.

Parameters
aThe other element to be swapped.
bThe access proxy to be swapped.
Returns
void
Exceptions
no-throwguarantee.
template<typename VT , bool TF>
const SVecTransExpr< VT,!TF > blaze::trans ( const SparseVector< VT, TF > &  sv)
inline

Calculation of the transpose of the given sparse vector.

Parameters
svThe sparse vector to be transposed.
Returns
The transpose of the sparse vector.

This function returns an expression representing the transpose of the given sparse vector: