Boost logo

Ublas :

Subject: Re: [ublas] size1 and size2
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2009-09-10 03:51:03

On Wed, Sep 9, 2009 at 11:13 PM, Gunter Winkler <guwi17_at_[hidden]> wrote:
> Marco Guazzone schrieb:
>> Dear all,
>> Just for curiosity...
>> Why does ublas use names such as "size1" and "size2" instead of
>> something more intuitive (IMO) like "n_rows" and "n_columns"?
> because of historical design decisions of the original authors. Now we
> keep it for compatibility - that's life ;-)

Ohhh ok! :)

Maybe adding inline methods and free functions with more user-friendly
names like the ones below could be a good idea and does not break

--- [code] ---

// in matrix.hpp

template<...> class matrix:...
  size_type n_rows() const { return size1_; }
  size_type n_columns() const { return size2_; }

// same for the other types

// in detail/raw.hpp

template <typename M>
int n_rows(M const& m ) { return m.n_rows(); }

template <typename M>
int n_columns( M const& m) { return m.n_columns(); }

template <typename M>
int n_rows(matrix_reference<M> const& m) { return n_rows(m.expression()); }

template <typename M>
int n_columns(matrix_reference<M> const& m ) { return
n_columns(m.expression()); }

--- [/code] ---

What do you think?

> (btw. we could also use size<1>() and size<2>() ...)

Didn't find that function in uBlas. Where is it?
Maybe did you mean: size1(m) and size2(m)?

-- Marco