|
Ublas : |
From: Russell Coggrave (c.r.coggrave_at_[hidden])
Date: 2006-04-24 06:53:39
I have been working with uBlas for about a week now, and am slowly getting
my head around the main concepts. The library clearly reflects a lot of work
on the part of the authors, however, the internal workings are rather
obfuscated by the lack of comments in the code. I have posted quite a few
questions to the mailing list over the last few days and I am grateful to
those that have responded. Whilst I don't want to bombard the list with too
many messages, this seems to be the only option to resolve those difficult
uBlas questions :)
I recently successfully implemented binary relational operators for vector
and matrix expressions that model the following
V3 = lt( V1, V2 )
where
V3[i] = (V1[i] < V2[i])
and the value_type for V3 is vector_expression<bool>
However, I would like to extend this to a more general implementation as
follows:
V3 = lt_quad( V1, V2, r1, r2 )
where
V3[i] = (V1[i] < V2[i]) ? r1 : r2
and the value_type for V3 is is promote_type<r1::value_type,r2::value_type>.
For example, consider the following...
ublas::vector<double> V1(2);
V1(0) = 0.0;
V1(1) = 1.0;
ublas::vector<double> V2(2);
V2(0) = 0.0;
V2(1) = 1.0;
ublas::scalar_value<bool> r1(true), r2(false);
std::cout << "lt_quad( V1, V2, r1, r2) = " << lt_quad( V1, V2, r1, r2) <<
std::endl;
The last line should evaluate to a vector_expression<bool>.
Unforuntately I am struggling with this, partly since there are not
currently any functor examples in ublas that take more than 2 arguments. I
have attached my current implementation (which fails to compile) together
with the compiler output and would very much appreciate any suggests where I
might be going wrong with this.
Regards,
Russ