mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-22 03:42:19 +00:00
blas level 3 documented
svn path=/branches/ublas-doxygen/; revision=63447
This commit is contained in:
224
blas.hpp
224
blas.hpp
@@ -19,7 +19,6 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
|
||||
/** Interface and implementation of BLAS level 1
|
||||
*
|
||||
* This includes functions which perform \b vector-vector operations.
|
||||
* More information about BLAS can be found at
|
||||
* <a href="http://en.wikipedia.org/wiki/BLAS">http://en.wikipedia.org/wiki/BLAS</a>
|
||||
@@ -28,9 +27,10 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** 1-Norm: \f$\sum_i |x_i|\f$ (also called \f$\f$mathcal{L}_1 or Manhattan norm)
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
* \param v a vector or vector expression
|
||||
* \return the 1-Norm with type of the vector's type
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
*/
|
||||
template<class V>
|
||||
typename type_traits<typename V::value_type>::real_type
|
||||
@@ -40,9 +40,10 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** 2-Norm: \f$\sum_i |x_i|^2\f$ (also called \f$\f$mathcal{L}_2 or Euclidean norm)
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
* \param v a vector or vector expression
|
||||
* \return the 2-Norm with type of the vector's type
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
*/
|
||||
template<class V>
|
||||
typename type_traits<typename V::value_type>::real_type
|
||||
@@ -52,9 +53,10 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
|
||||
/** Infinite-norm: \f$\max_i |x_i|\f$ (also called \f$\f$mathcal{L}_\infty norm)
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
* \param v a vector or vector expression
|
||||
* \return the Infinite-Norm with type of the vector's type
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
*/
|
||||
template<class V>
|
||||
typename type_traits<typename V::value_type>::real_type
|
||||
@@ -62,13 +64,14 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return norm_inf (v);
|
||||
}
|
||||
|
||||
/** Inner product of vectors \a v1 and \a v2
|
||||
/** Inner product of vectors \f$v_1\f$ and \f$v_2\f$
|
||||
*
|
||||
* \tparam V1 type of first vector (not needed by default)
|
||||
* \tparam V2 type of second vector (not needed by default)
|
||||
* \param v1 first vector of the inner product
|
||||
* \param v2 second vector of the inner product
|
||||
* \return the inner product of the type of the most generic type of the 2 vectors
|
||||
*
|
||||
* \tparam V1 type of first vector (not needed by default)
|
||||
* \tparam V2 type of second vector (not needed by default)
|
||||
*/
|
||||
template<class V1, class V2>
|
||||
typename promote_traits<typename V1::value_type, typename V2::value_type>::promote_type
|
||||
@@ -76,59 +79,64 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return inner_prod (v1, v2);
|
||||
}
|
||||
|
||||
/** Copy vector \a v2 to \a v1
|
||||
/** Copy vector \f$v_2\f$ to \f$v_1\f$
|
||||
*
|
||||
* \tparam V1 type of first vector (not needed by default)
|
||||
* \tparam V2 type of second vector (not needed by default)
|
||||
* \param v1 target vector
|
||||
* \param v2 source vector
|
||||
* \return a reference to the target vector
|
||||
*
|
||||
* \tparam V1 type of first vector (not needed by default)
|
||||
* \tparam V2 type of second vector (not needed by default)
|
||||
*/
|
||||
template<class V1, class V2>
|
||||
V1 &
|
||||
copy (V1 &v1, const V2 &v2) {
|
||||
V1 & copy (V1 &v1, const V2 &v2)
|
||||
{
|
||||
return v1.assign (v2);
|
||||
}
|
||||
|
||||
/** Swap vectors \a v1 and \a v2
|
||||
/** Swap vectors \f$v_1\f$ and \f$v_2\f$
|
||||
*
|
||||
* \tparam V1 type of first vector (not needed by default)
|
||||
* \tparam V2 type of second vector (not needed by default)
|
||||
* \param v1 first vector
|
||||
* \param v2 second vector
|
||||
*
|
||||
* \tparam V1 type of first vector (not needed by default)
|
||||
* \tparam V2 type of second vector (not needed by default)
|
||||
*/
|
||||
template<class V1, class V2>
|
||||
void swap (V1 &v1, V2 &v2) {
|
||||
void swap (V1 &v1, V2 &v2)
|
||||
{
|
||||
v1.swap (v2);
|
||||
}
|
||||
|
||||
/** scale vector \a v with scalar \a t
|
||||
/** scale vector \f$v\f$ with scalar \f$t\f$
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
* \tparam T type of the scalar (not needed by default)
|
||||
* \param v vector to be scaled
|
||||
* \param t the scalar
|
||||
* \return \c t*v
|
||||
*
|
||||
* \tparam V type of the vector (not needed by default)
|
||||
* \tparam T type of the scalar (not needed by default)
|
||||
*/
|
||||
template<class V, class T>
|
||||
V &
|
||||
scal (V &v, const T &t) {
|
||||
V & scal (V &v, const T &t)
|
||||
{
|
||||
return v *= t;
|
||||
}
|
||||
|
||||
/** Compute \f$v_1= v_1 + t.v_2\f$
|
||||
*
|
||||
* \tparam V1 type of the first vector (not needed by default)
|
||||
* \tparam T type of the scalar (not needed by default)
|
||||
* \tparam V2 type of the second vector (not needed by default)
|
||||
* \param v1 target and first vector
|
||||
* \param t the scalar
|
||||
* \param v2 second vector
|
||||
* \return a reference to the first and target vector
|
||||
*
|
||||
* \tparam V1 type of the first vector (not needed by default)
|
||||
* \tparam T type of the scalar (not needed by default)
|
||||
* \tparam V2 type of the second vector (not needed by default)
|
||||
*/
|
||||
template<class V1, class T, class V2>
|
||||
V1 &
|
||||
axpy (V1 &v1, const T &t, const V2 &v2) {
|
||||
V1 & axpy (V1 &v1, const T &t, const V2 &v2)
|
||||
{
|
||||
return v1.plus_assign (t * v2);
|
||||
}
|
||||
|
||||
@@ -199,7 +207,7 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return v = solve (m, v, C ());
|
||||
}
|
||||
|
||||
/** \brief compute \f$ v1 = t1.v1 + t2.(m.v2)\f$, a general matrix-vector product
|
||||
/** \brief compute \f$ v_1 = t_1.v_1 + t_2.(m.v_2)\f$, a general matrix-vector product
|
||||
*
|
||||
* \param v1 a vector
|
||||
* \param t1 a scalar
|
||||
@@ -220,7 +228,7 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return v1 = t1 * v1 + t2 * prod (m, v2);
|
||||
}
|
||||
|
||||
/** \brief Rank 1 update: \f$ m = m + t.(v1.v2^T)\f$
|
||||
/** \brief Rank 1 update: \f$ m = m + t.(v_1.v_2^T)\f$
|
||||
*
|
||||
* \param m a matrix
|
||||
* \param t a scalar
|
||||
@@ -285,7 +293,7 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief symmetric rank 2 update: \f$ m=m+ t.(v1.v2^T + v2.v1^T)\f$
|
||||
/** \brief symmetric rank 2 update: \f$ m=m+ t.(v_1.v_2^T + v_2.v_1^T)\f$
|
||||
*
|
||||
* \param m a matrix
|
||||
* \param t a scalar
|
||||
@@ -308,7 +316,7 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief hermitian rank 2 update: \f$m=m+t.(v1.v2^H) + v2.(t.v1)^H)
|
||||
/** \brief hermitian rank 2 update: \f$m=m+t.(v_1.v_2^H) + v_2.(t.v_1)^H)
|
||||
*
|
||||
* \param m a matrix
|
||||
* \param t a scalar
|
||||
@@ -340,73 +348,78 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
*/
|
||||
namespace blas_3 {
|
||||
|
||||
/** \brief triangular matrix multiplication
|
||||
/** \brief triangular matrix multiplication \f$m_1=t.m_2.m_3\f$ where \f$m_2\f$ and \f$m_3\f$ are triangular
|
||||
*
|
||||
* \param m1
|
||||
* \param t
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m1 a matrix for storing result
|
||||
* \param t a scalar
|
||||
* \param m2 a triangular matrix
|
||||
* \param m3 a triangular matrix
|
||||
* \return the matrix \c m1
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T
|
||||
* \tparam M2
|
||||
* \tparam M3
|
||||
* \tparam M1 type of the result matrix (not needed by default)
|
||||
* \tparam T type of the scalar (not needed by default)
|
||||
* \tparam M2 type of the first triangular matrix (not needed by default)
|
||||
* \tparam M3 type of the second triangular matrix (not needed by default)
|
||||
*
|
||||
*/
|
||||
template<class M1, class T, class M2, class M3>
|
||||
M1 &
|
||||
tmm (M1 &m1, const T &t, const M2 &m2, const M3 &m3) {
|
||||
M1 & tmm (M1 &m1, const T &t, const M2 &m2, const M3 &m3)
|
||||
{
|
||||
return m1 = t * prod (m2, m3);
|
||||
}
|
||||
|
||||
/** \brief triangular solve \a m2 * \a x = \a t * \a m1 in place, \a m2 is a triangular matrix
|
||||
/** \brief triangular solve \f$ m_2.x = t.m_1\f$ in place, \f$m_2\f$ is a triangular matrix
|
||||
*
|
||||
* \param m1
|
||||
* \param t
|
||||
* \param m2
|
||||
* \param C
|
||||
* \param m1 a matrix
|
||||
* \param t a scalar
|
||||
* \param m2 a triangular matrix
|
||||
* \param C (not used)
|
||||
* \return the \f$m_1\f$ matrix
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T
|
||||
* \tparam M2
|
||||
* \tparam C
|
||||
* \tparam M1 type of the first matrix (not needed by default)
|
||||
* \tparam T type of the scalar (not needed by default)
|
||||
* \tparam M2 type of the triangular matrix (not needed by default)
|
||||
* \tparam C (n/a)
|
||||
*/
|
||||
template<class M1, class T, class M2, class C>
|
||||
M1 & tsm (M1 &m1, const T &t, const M2 &m2, C) {
|
||||
M1 & tsm (M1 &m1, const T &t, const M2 &m2, C)
|
||||
{
|
||||
return m1 = solve (m2, t * m1, C ());
|
||||
}
|
||||
|
||||
/** \brief general matrix multiplication
|
||||
/** \brief general matrix multiplication \f$m_1=t_1.m_1 + t_2.m_2.m_3\f$
|
||||
*
|
||||
* \param m1
|
||||
* \param t1
|
||||
* \param t2
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m1 first matrix
|
||||
* \param t1 first scalar
|
||||
* \param t2 second scalar
|
||||
* \param m2 second matrix
|
||||
* \param m3 third matrix
|
||||
* \return the matrix \c m1
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T1
|
||||
* \tparam T2
|
||||
* \tparam M2
|
||||
* \tparam M3
|
||||
* \tparam M1 type of the first matrix (not needed by default)
|
||||
* \tparam T1 type of the first scalar (not needed by default)
|
||||
* \tparam T2 type of the second scalar (not needed by default)
|
||||
* \tparam M2 type of the second matrix (not needed by default)
|
||||
* \tparam M3 type of the third matrix (not needed by default)
|
||||
*/
|
||||
template<class M1, class T1, class T2, class M2, class M3>
|
||||
M1 &
|
||||
gmm (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) {
|
||||
M1 & gmm (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3)
|
||||
{
|
||||
return m1 = t1 * m1 + t2 * prod (m2, m3);
|
||||
}
|
||||
|
||||
/** \brief symmetric rank k update: \a m1 = \a t * \a m1 + \a t2 * (\a m2 * \a m2<sup>T</sup>)
|
||||
/** \brief symmetric rank \a k update: \f$m_1=t.m_1+t_2.(m_2.m_2^T)
|
||||
*
|
||||
* \param m1
|
||||
* \param t1
|
||||
* \param t2
|
||||
* \param m2
|
||||
* \param m1 first matrix
|
||||
* \param t1 first scalar
|
||||
* \param t2 second scalar
|
||||
* \param m2 second matrix
|
||||
* \return matrix \c m1
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T1
|
||||
* \tparam T2
|
||||
* \tparam M2
|
||||
* \tparam M1 type of the first matrix (not needed by default)
|
||||
* \tparam T1 type of the first scalar (not needed by default)
|
||||
* \tparam T2 type of the second scalar (not needed by default)
|
||||
* \tparam M2 type of the second matrix (not needed by default)
|
||||
* \todo use opb_prod()
|
||||
*/
|
||||
template<class M1, class T1, class T2, class M2>
|
||||
@@ -415,17 +428,18 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return m1 = t1 * m1 + t2 * prod (m2, trans (m2));
|
||||
}
|
||||
|
||||
/** \brief hermitian rank k update: \a m1 = \a t * \a m1 + \a t2 * (\a m2 * \a m2<sup>H</sup>)
|
||||
/** \brief hermitian rank \a k update: \f$m_1=t.m_1+t_2.(m_2.m2^H)\f$
|
||||
*
|
||||
* \param m1
|
||||
* \param t1
|
||||
* \param t2
|
||||
* \param m2
|
||||
* \param m1 first matrix
|
||||
* \param t1 first scalar
|
||||
* \param t2 second scalar
|
||||
* \param m2 second matrix
|
||||
* \return matrix \c m1
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T1
|
||||
* \tparam T2
|
||||
* \tparam M2
|
||||
* \tparam M1 type of the first matrix (not needed by default)
|
||||
* \tparam T1 type of the first scalar (not needed by default)
|
||||
* \tparam T2 type of the second scalar (not needed by default)
|
||||
* \tparam M2 type of the second matrix (not needed by default)
|
||||
* \todo use opb_prod()
|
||||
*/
|
||||
template<class M1, class T1, class T2, class M2>
|
||||
@@ -434,19 +448,20 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return m1 = t1 * m1 + t2 * prod (m2, herm (m2));
|
||||
}
|
||||
|
||||
/** \brief generalized symmetric rank k update: \a m1 = \a t1 * \a m1 + \a t2 * (\a m2 * \a m3<sup>T</sup>) + \a t2 * (\a m3 * \a m2<sup>T</sup>)
|
||||
/** \brief generalized symmetric rank \a k update: \f$m_1=t_1.m_1+t_2.(m_2.m3^T)+t_2.(m_3.m2^T)\f$
|
||||
*
|
||||
* \param m1
|
||||
* \param t1
|
||||
* \param t1
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m1 first matrix
|
||||
* \param t1 first scalar
|
||||
* \param t2 second scalar
|
||||
* \param m2 second matrix
|
||||
* \param m3 third matrix
|
||||
* \return matrix \c m1
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T1
|
||||
* \tparam T2
|
||||
* \tparam M2
|
||||
* \tparam M3
|
||||
* \tparam M1 type of the first matrix (not needed by default)
|
||||
* \tparam T1 type of the first scalar (not needed by default)
|
||||
* \tparam T2 type of the second scalar (not needed by default)
|
||||
* \tparam M2 type of the second matrix (not needed by default)
|
||||
* \tparam M3 type of the third matrix (not needed by default)
|
||||
* \todo use opb_prod()
|
||||
*/
|
||||
template<class M1, class T1, class T2, class M2, class M3>
|
||||
@@ -455,19 +470,20 @@ namespace boost { namespace numeric { namespace ublas {
|
||||
return m1 = t1 * m1 + t2 * (prod (m2, trans (m3)) + prod (m3, trans (m2)));
|
||||
}
|
||||
|
||||
/** \brief generalized hermitian rank k update: \a m1 = \a t1 * \a m1 + \a t2 * (\a m2 * \a m3<sup>H</sup>) + (\a m3 * (\a t2 * \a m2)<sup>H</sup>)
|
||||
/** \brief generalized hermitian rank \a k update: * \f$m_1=t_1.m_1+t_2.(m_2.m_3^H)+(m_3.(t_2.m_2)^H)\f$
|
||||
*
|
||||
* \param m1
|
||||
* \param t1
|
||||
* \param t2
|
||||
* \param m2
|
||||
* \param m3
|
||||
* \param m1 first matrix
|
||||
* \param t1 first scalar
|
||||
* \param t2 second scalar
|
||||
* \param m2 second matrix
|
||||
* \param m3 third matrix
|
||||
* \return matrix \c m1
|
||||
*
|
||||
* \tparam M1
|
||||
* \tparam T1
|
||||
* \tparam T2
|
||||
* \tparam M2
|
||||
* \tparam M3
|
||||
* \tparam M1 type of the first matrix (not needed by default)
|
||||
* \tparam T1 type of the first scalar (not needed by default)
|
||||
* \tparam T2 type of the second scalar (not needed by default)
|
||||
* \tparam M2 type of the second matrix (not needed by default)
|
||||
* \tparam M3 type of the third matrix (not needed by default)
|
||||
* \todo use opb_prod()
|
||||
*/
|
||||
template<class M1, class T1, class T2, class M2, class M3>
|
||||
|
||||
Reference in New Issue
Block a user