Hello,
Had a quick look into uBLAS library, and noted the incompatibility between
std::vector<> and ublas' binary operations. For example, I have an
ublas::matrix<> and wanted to multiply it by a std::vector<>.
Since _all_ of ublas data containers provide iterators, I'm wondering why
the library doesn't provide algorithms that work on iterators? In this way
data structures and operators will be decoupled.
For example, to do the product between a matrix and a vector:
********* untested code *********
template
OutputIterator prod(MatrixRowIterator first_row, MatrixRowIterator
last_row,
MatrixColIterator, InputIterator first_vec, OutputIterator result) {
InputIterator cp_first=first_vec;
while(first_row!=last_row) {
typename MatrixRowIterator::value_type val(0);
MatrixColIterator first_col, last_col;
first_col=first_row.begin();
last_col=first_row.end();
while(first_col!=last_col) val+= *first_col++ * *first_vec++;
*result++ = val;
++first_row;
first_vec=cp_first;
}
return result;
}
// user side :
prod(umatrix.begin1(), umatrix.end1(), umatrix.begin2(), std_vector.begin(),
std::back_inserter(std_vector_result));
This of course with the respective preconditions.
Also, wouldn't be a good idea to provide copy c'tor and operators accepting
std::vector<> for the ublas::vector<> ?
Regards,
--
vladimir josef sykora
morphochem AG
gmunder str. 37-37a
81379 muenchen
tel. ++49-89-78005-0
fax ++49-89-78005-555
vladimir.sykora@morphochem.de
http://www.morphochem.de