
Ublas : 
From: Riccardo Rossi (rrossi_at_[hidden])
Date: 20060215 08:38:47
Dear Gunther,
first of all thanks for your quick answer, i have however a doubt
concerning your proposal:
first of all let's consider the code
Matrix A(3,3);
Vector b(3);
Vector c(3);
c = A * b;
using boost 1.32.0 ( i still didn't upgrade to 1.33.1) i get an error
message due to the existance of two candidates for the overloaded operator *
... the error message reads
..\..\..\..\external_libraries\boost\boost_1_32_0\boost\numeric\ublas\vector_expression.hpp(1468):
could be
'boost::numeric::ublas::vector_binary_scalar1_traits<E1,E2,F,C1>::result_type
boost::numeric::ublas::operator
*<Kratos::Matrix,boost::numeric::ublas::vector<T>>(const T1 &,const
boost::numeric::ublas::vector_expression<E> &)'
with
[
E1=const Kratos::Matrix,
E2=boost::numeric::ublas::vector<double>,
F=boost::numeric::ublas::scalar_multiplies<Kratos::Matrix,double>,
C1=boost::numeric::ublas::scalar_reference<const Kratos::Matrix>,
T=double,
T1=Kratos::Matrix,
E=boost::numeric::ublas::vector<double>
]
..\..\..\..\external_libraries\boost\boost_1_32_0\boost\numeric\ublas\matrix_expression.hpp(3631):
or
'boost::numeric::ublas::matrix_binary_scalar2_traits<E1,E2,F,C2>::result_type
boost::numeric::ublas::operator
*<boost::numeric::ublas::matrix<T>,Kratos::Vector>(const
boost::numeric::ublas::matrix_expression<E> &,const T2 &)'
with
[
E1=boost::numeric::ublas::matrix<double>,
E2=const Kratos::Vector,
F=boost::numeric::ublas::scalar_multiplies<double,Kratos::Vector>,
C2=boost::numeric::ublas::scalar_reference<const Kratos::Vector>,
T=double,
E=boost::numeric::ublas::matrix<double>,
T2=Kratos::Vector
]
while trying to match the argument list '(Kratos::Matrix, Kratos::Vector)'
\kra
in any case even if i define univocally my operator *, as i understand the
operation
c = A * b
is not efficient as a temporary is created for each multiplication, while
the correct form would be
noalias(c) = prod(A,b);
for me efficiency is crucial ...
concerning the Symmetric Product wouldn't it work if i define i binary prod
Vector Vector as a scalar prod?
i mean
trans(a)*a = inner_prod(a,a)?
okkk
thanks for the attention
grettings
Riccardo
 Original Message 
From: "Gunter Winkler" <guwi17_at_[hidden]>
To: "ublas mailing list" <ublas_at_[hidden]>
Sent: Wednesday, February 15, 2006 12:53 PM
Subject: Re: [ublas] blocked products and relation UBLAS/GLAS
> On Tuesday 14 February 2006 19:37, Riccardo Rossi wrote:
>> dear list,
>> i am more or less a Newbie at using ublas for sparse operations
>> and i would love a little advice on some delicate questions.
>>
>> in particular i would like to work with a sparse matrix in which all of
>> the
>> single terms are vectors or matrices instead of double. All the
>> containers
>> are templated matrices which implies that i am free to do it
>> nevertheless...
>
> You can use the matrix and vector classes as a container for any type
> provided
> the type is default and zero constructable. That means you need a
> constructor
> like
>
> my_type(const int zero) : ...
> { assert( 0 == zero ); }
>
> which is necessary to let the sparse types know what "zero element" means.
>
>> how can i make the library to know how to perform the multiplication
>> between all of the different terms? the case is for example of a
>> SparseMatrix of Matrices to be multiplied by a vector of vectors.
>
> the easiest way is to use a custom type as value type which behaves like a
> scalar. That means you have to overload the usual arithmetic operators for
> your type.
>
>> Similarly i would like to create a matrix doing something like A =
>> trans(B)*B (i think it is called Symmetric Product)... is it available
>> in
>> ublas?
>
> this is more complicated because ublas assumes that a scalar is symmetric
> and
> therefore never calls trans(x) for any scalar x. Maybe you can create a
> new
> specialization of
>
> matrix_unary2_traits (in matrix_expression.hpp, lines 1648ff)
>
> that defines a new result type.
>
> // (trans m) [i] [j] = m [j] [i]
> template<class E>
> BOOST_UBLAS_INLINE
> typename matrix_unary2_traits<const E,
> scalar_identity<typename E::value_type> >::result_type
> trans (const matrix_expression<E> &e) {
> typedef typename matrix_unary2_traits<const E,
> scalar_identity<typename E::value_type>
> >::expression_type expression_type;
> return expression_type (e ());
> }
>
> (you have to replace scalar_identity by scalar_transpose and write you own
> scalar_transpose, see functional.hpp  ask me if you need help doing
> this.)
>
>> finally i would like to know what is the relation of ublas to GLAS
>
> GLAS is (will be) a general linear algebra library supporting different
> back
> ends, e.g. ublas. Maybe Karl can better comment on that.
>
> mfg
> Gunter
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
>