Boost logo

Ublas :

From: Peter Schmitteckert (peter_at_[hidden])
Date: 2007-09-20 03:57:28

Dear Ian,

Ian McCulloch wrote:

> IMHO, there is no advantage to using an unsigned int, and it is a shame
> that the STL standardized on an unsigned size_type. Unsigned has a
> positive range that is twice as big, but really, how often is that
> needed? For anything other than arrays of char, the answer is never, and
> personally I've never seen an array of char bigger than 2^31 anyway.

Well, already 2 years ago I did calcultaion (for Ingo Peschel) where I was
bounded by the 2^31 limit for diagonalizing a tridiagonal matrix in LaPack,
and had to go to long int versions.

64GB machines are more and more common, and with the switch to multi-core
we'll see more and more memory even in desktop workstations.

> The rules for mixing signed and unsigned arithmetic in C/C++ are such a
> trap that you want to avoid it, it almost never gives what you want, or

The real problem are the implicit type conversions in C++, which are so dangerous.
Convenient but can cause serious problems.

In that context I'd like to suggest to add an explicit statement to the construcutor
of matrices in ublas:

in matrix.hpp changing

         matrix (const matrix_expression<AE> &ae):
         explicit matrix (const matrix_expression<AE> &ae):

It gave me some surprise recently in my code, as it involves unnecessary copying of submatrices
I wasn't aware of.

Best regards,

Dr. Peter Schmitteckert                                 Center for Functional Nanostructures
Institut für Theorie der Kondensierten Materie          Karlsruhe Institute of Technology
Universität Karlsruhe
Wolfgang-Gaede Str. 1
D-76128 Karlsruhe