|
Boost : |
From: Pavel Chikulaev (pavel.chikulaev_at_[hidden])
Date: 2005-03-08 05:52:00
"Tobias Schwinger" <tschwinger_at_[hidden]> wrote in message
news:d0igjh$46u$1_at_sea.gmane.org...
> - Custom per element operations
You mean
matrix<double> m;
double d = transpose(m)[5][6]; //
don't you?
It's not yet supported, but I think I can do it.
Thanks.
> - It should not be limited to operators but work with any functions
N-Arity Functions are already supported. It is so called custom operations.
Transpose function is example from sample usage.
Another example:
class product_t;
same class Matrix
{
//..
Matrix(LAZY_CUSTOM_OP(product_tag, (2, (Matrix_, Matrix_)));
LAZY_ENABLE_CUSTOM_OP(product, Matrix_ =
lazy::custom_op<product_tag>((Matrix_, Matrix_)));
};
Matrix::Matrix(LAZY_CUSTOM_OP(product_tag, (2, (Matrix_, Matrix_)) op)
{
//first matrix accessed via op._1
//second matrix accessed via op._2
}
//..
Matrix a, b, c;
//..
a = product(b, c); //No temporaries
The only drawback of such approach is that I can't add a lazy function
without
changing class. But I'm working on it. I think it's not necessary to change
class
definition.
Eurika! I know how to do it.
Template specialiation will help me again.
Thanks again!
> The design should allow to optionally replace operations to make use of
> SIMD hardware.
Library also supports it. AFAIK It's template specialization of lazy
operator, isn't it?
-- Pavel Chikulaev
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk