|
Ublas : |
Subject: Re: [ublas] matrix_row fails with symmetric matrix
From: Andrea Cassioli (cassioliandre_at_[hidden])
Date: 2010-05-19 10:03:22
Hi again,
I may suggest to change the main page stating explictly that uBlas in
not actually implementing STL-like containers, forcing in some sense
users in deeply reading the documentation.
On 5/19/10, David Bellot <david.bellot_at_[hidden]> wrote:
> Hi Andrea,
>
> submissions of documentaiton are most welcome... Indeed you're right and
> there is an open bug assigned to me, I must confess, about improving the
> documentation.
>
Maybe a list of duty to be assign to different people may help,
instead of loading the burden to one brave guy! what about a trac
system?
> About the STL conformance: well, ublas is not supposed to implement STL
> containers but acts in the spirit of. However, vectors and matrices can use
> STL containers as their internal storage, allowing STL algorithm to work on
> their "data".
> It might partly solve your problem.
>
> What are your technical suggestions about improving conformance with STL for
> instance ?
>
Well uBlas iterators are quite misleading sometimes, but maybe I'm
confused. In my example, I expect a row_iterator to be usable as any
other iterator. For instance, a loop like the following should be
legal:
typedef symmetric_matrix<double> symm_mat;
symm_mat mat(5);
for(int i=0;i<mat.size1();i++)
mat(i,i)=0.0;
for(int i=0;i<mat.size1();i++)
for(int j=i+1;j<mat.size2();j++)
mat(i,j)=i*j+1;
std::list<vector<double> > vlist;
vector<double> vect(mat.size2()+1,-1.0);
std::cout << mat;
for(int i=0;i<mat.size1();i++){
matrix_row<symm_mat> row_i(mat,i);
matrix_row<symm_mat>::iterator it_b(row_i.begin());
int j(0);
while(it_b!=row_i.end()){
vect[j]=*it_b;
j++;it_b++;
}
vlist.push_back(vect);
std::cout<<vect<<std::endl;
}
what happens is that the end() is the diagonal! so the row ends
there....this is not acceptable in my opinion.
Otherwise iterators make no sense and uBlas could be in principle
remove them, using instead direct access and the row,range and project
function (also I've seen very interesting progress on the assignement
machinery!).
Cheers, Andrea
> Cheers,
> David
>
> On Wed, May 19, 2010 at 13:20, Andrea Cassioli
> <cassioliandre_at_[hidden]>wrote:
>
>> Hi Gunter,
>> I agree with you in using the range and project machinery to get what
>> I need, and I have to say I missed (probably for my lazynesss) this
>> set of functionalities the first time I looked the documentation.
>>
>> Apart from the expressiveness, my major concern is that is not clear
>> at all that ublas vectors are not as std::vector. Indeed, from the
>> very beginning, it is stated : " The glue between containers, views
>> and expression templated operations is a mostly STL conforming
>> iterator interface.". What does it exactly mean "mostly conforming"?
>>
>> Probably It should be better to say that it is not STL conforming,
>> despite some similarity. I fancy if no iterators at all would be
>> provided and only ragne and project functions would be needed...
>>
>> In my opinion, such uncertainties are a major reason for people not to
>> choose or support ublas. I like it and it is very nice to me also
>> because my code is already boost oriented. I think that before going
>> on with new functionalities, a major revision of documentation and
>> tuorial should be started.
>>
>> Andrea
>>
>> On Wed, May 19, 2010 at 1:41 AM, Gunter Winkler <guwi17_at_[hidden]> wrote:
>> > Hello Andrea,
>> >
>> > Andrea Cassioli schrieb:
>> >> I'm pretty sure I'm doing something wrong, but I would expect the
>> >> matrix_row adaptor to behave as a normal vector, that is I would like
>> >> to play with it seamlessly.
>> >>
>> >> Am I wrong or it is a bug??
>> >>
>> >
>> > I am not sure if I understand you code. However, a ublas::vector is
>> > _not_ a STL vector. The reason is that ublas' vectors and matrices
>> > represent object for linear algebra, where STL vectors are simply
>> > containers. An ublas vector is much more like a std::valarray than like
>> > any other STL container. Thus it is not possible to assign a vector of
>> > length n to a vector of length (n+1).
>> >
>> > Despite that: you can use the free functions project(), row() and
>> > column() to get more expressive code. For example:
>> >
>> > matrix<double> A(10,10);
>> > vector<double> v(5);
>> >
>> > // untested
>> > v = project( row(A, 3), range(0,5) );
>> > project( column(A, 4), range(5,10) ) = v;
>> >
>> > see also
>> >
>> http://www.boost.org/doc/libs/1_43_0/libs/numeric/ublas/doc/operations_overview.htm#sub
>> >
>> > mfg
>> > Gunter
>> >
>> >
>> >
>> > __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version
>> 5125 (20100518) __________
>> >
>> > E-Mail wurde geprüft mit ESET NOD32 Antivirus.
>> >
>> > http://www.eset.com
>> >
>> >
>> > _______________________________________________
>> > ublas mailing list
>> > ublas_at_[hidden]
>> > http://lists.boost.org/mailman/listinfo.cgi/ublas
>> > Sent to: cassioliandre_at_[hidden]
>> >
>>
>>
>>
>> --
>> Andrea Cassioli
>> _______________________________________________
>> ublas mailing list
>> ublas_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/ublas
>> Sent to: david.bellot_at_[hidden]
>>
>
>
>
> --
> David Bellot, PhD
> david.bellot_at_[hidden]
> http://david.bellot.free.fr
>
-- Andrea Cassioli