From 4013a87ad6dadfbc5f52d9f17faa7732c7cfd60c Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Mon, 14 Mar 2005 13:41:58 +0000 Subject: [PATCH] Add Gunter's coordinate_matrix axpy_prod specialisation [SVN r27644] --- include/boost/numeric/ublas/operation.hpp | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/boost/numeric/ublas/operation.hpp b/include/boost/numeric/ublas/operation.hpp index 1d15e76c..0dd110cb 100644 --- a/include/boost/numeric/ublas/operation.hpp +++ b/include/boost/numeric/ublas/operation.hpp @@ -103,6 +103,30 @@ namespace boost { namespace numeric { namespace ublas { return axpy_prod (e1, e2, v, true); } + template + BOOST_UBLAS_INLINE + V & + axpy_prod (const coordinate_matrix &e1, + const vector_expression &e2, + V &v, bool init = true) { + typedef typename V::size_type size_type; + typedef typename V::value_type value_type; + typedef L1 layout_type; + + size_type size1 = e1.size1(); + size_type size2 = e1.size2(); + + if (init) { + noalias(v) = zero_vector(size1); + } + + for (size_type i = 0; i < e1.nnz(); ++i) { + size_type row_index = layout_type::element1( e1.index1_data () [i], size1, e1.index2_data () [i], size2 ); + size_type col_index = layout_type::element2( e1.index1_data () [i], size1, e1.index2_data () [i], size2 ); + v( row_index ) += e1.value_data () [i] * e2 () (col_index); + } + } + template BOOST_UBLAS_INLINE V &