
Ublas : 
Subject: [ublas] subrow/subcolumn functions?
From: Frédéric Devernay (frederic.devernay_at_[hidden])
Date: 20100512 05:34:52
Hello,
I'm trying to use ublas proxies in my ublasJama port, and noticed the following:
I want to do the following:
// elements k..m1 of column j of A += t*(elements k..m1 of column k of A)
I first tried:
subrange(column(A,j),k,m) += t*subrange(column(A,k),k,m); // won't compile
but I get
ublasJama/SingularValueDecomposition.cpp:88: instantiated from here
/opt/local/include/boost/numeric/ublas/functional.hpp:199: error: assignment of readonly reference 't1'
And I found out the correct way to do it in ublas from the doc:
matrix_vector_slice<Matrix> (A, slice(k,1,mk), slice(j,0,mk)) += t*subrange(column(A,k),k,m);
However, nobody can understand anymore what the code above does...
Why not add subcolumn() and subrow() functions which return a matrix_vector_slice and will give much better lisibility to the code?
I made macros of these:
#define subcolumn(M,c,start,stop) matrix_vector_slice<Matrix> ((M), slice((start),1,(stop)(start)), slice((c),0,(stop)(start)))
#define subrow(M,r,start,stop) matrix_vector_slice<Matrix> ((M), slice((r),0,(stop)(start)), slice((start),1,(stop)(start)))
and the code becomes much more readable:
subcolumn(A,j,k,m) += t*subcolumn(A,k,k,m);
I also don't get the advantage of using matrix_row and matrix_column over matrix_vector_slice. Did I miss something?
Fred