Boost logo

Ublas :

Subject: Re: [ublas] size1 and size2
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2009-09-14 08:58:32

> A.size1() ==> m if row_major OR n if column_major
> A.size2() ==> n if row_major OR m if column_major
I think this tries to bring together STL semantics and Mathematical semantics and should be avoided. I argue that it should be: size1()<=>nrows and size2()<=>ncols. After all an implementation like begin<tag::major>(MAT); can provide more elegant STL semantics if someone wants to use it.
If you think that it is useful to have a major and minor size_..() member function I believe the one proposed by er is more apropriate, i.e. size_major, size_minor.
For the record

 basic_column_major and basic_row_major functors already implement this functionality (members size_M and size_m) in functional.hpp. This implementation is a bit odd at first but it is there to avoid exposing matrix into layout_type.


> Date: Mon, 14 Sep 2009 09:47:49 +0200
> From: marco.guazzone_at_[hidden]
> To: ublas_at_[hidden]
> Subject: Re: [ublas] size1 and size2
> On Mon, Sep 14, 2009 at 4:23 AM, er <erwann.rogard_at_[hidden]> wrote:
> > Nasos Iliopoulos wrote:
> >>
> >> I have a problem with rows and cols like other people have with left and
> >> right. I have to think which is which :).
> >> Beyond that I prefer size1 and size2 for the same reasons Curtis does,
> >> but i don't see much of a problem providing overloads to them under the
> >> umbrella of a utils.h header or something.
> >> size<1> and size<2> would be my personal favourite (as Gunter proposed),
> >> but I think it goes too much for the average user.
> >>
> >> Best
> >> Nasos
> >>
> >
> > size_major would be closer to the STL convention, and avoids a new
> > convention (row) on top of another (major). However size1, size<1>, or
> > perhaps size<0> all seem fine.
> >
> Hello!
> I think it would be necessary to distinguish between the matrix
> theoretical concept from implementation detail.
> I'm not a mathematician so correct me if I'm wrong.
> For what I know a matrix is defined in terms of rows and columns; for instance:
> * From
> "A matrix with m rows and n columns is called an m-by-n matrix or m
> × n matrix, while m and n are called its dimensions"
> * From
> "An mXn matrix consists of m rows and n columns, and the set of mXn
> matrices with real coefficients is sometimes denoted R^(mXn)"
> What is argued in the previous emails is about matrix orientation that
> IMO is an implementation detail.
> So, if I declare a ublas::matrix(m,n) what I expect is that this
> matrix has m rows and n columns regardless its orientation
> Note, this is what I expect. Maybe it is not the phylosophy under the uBlas lib.
> Let me know in this case and I'll stop to stress ;))
> Anyway, maybe we can keep the two concept separate. So for a matrix A(m,n):
> A.num_rows() ==> m
> A.num_cols() ==> n
> A.size1() ==> m if row_major OR n if column_major
> A.size2() ==> n if row_major OR m if column_major
> At least this is how the choice made by MTL4 (actually it uses dim1
> and dim2 in place of size1 and size2, respectively).
> What do you think?
> Cheers,
> -- Marco
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> Sent to: nasos_i_at_[hidden]

Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.