Boost logo

Ublas :

Subject: Re: [ublas] template parameters of ublas Types while extending ublas
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2009-08-04 16:54:57

Michael Norel schrieb:
> Hi Everyone!
> Currently I am working under Cholesky implementation.
> I saw Gunter Winkler Cholesky implementation at (1).
> Also I reviewed boost/numeric/ublas/lu.hpp (2) and
> (3).
> Most of functions in (1), (2) declared as follows :
> template < class MATRIX, class TRIA>
> void someFunc(const MATRIX& A, TRIA& L);//(A)
Here are no visible restrictions on the types and the caller can use any
classes that defines the correct member types and functions.
> Some functions in (3) follows declaration :
> template<class E1, class E2>
> void someFunc(matrix_expression<E1> &e1, matrix_expression<E2> &e2);//(B)
Here you explicitly request matrix expressions. This means you can only
use sub classes of a matrix_expression. This is the key idea of CRTP
( and
should be the preferred definition. The disadvantage is that the
function cannot make any assumptions on e1 and e2 except that it
fulfills the matrix expression concept. (This means you should not
assume anything about storage layout, orientation ...)

> and
> template<class T>
> void someFunc(matrix<T> &m); //(C)
Here you explicitly request the argument to be of type matrix. Thus you
can use any possible optimization for this special class. However you
cannot use the method for a submatrix (matrix_range) or a banded or
sparse matrix.

> So, what is better varint ?
> Are there some important concepts of ublas?
Yes, see concepts page: