|
Ublas : |
From: Michael Stevens (mail_at_[hidden])
Date: 2007-05-20 04:42:48
On Sunday 20 May 2007 09:48, Markus Weimer wrote:
> Hi,
>
> > } // note the extra () !
>
> What are they good for?
>
> I have little success with the following code:
>
>
> void printDimension(const matrix_expression<double>& m){
> cout << ()m.size1() << "x" << ()m.size2();
> }
>
> int main(int argc, char argv){
> matrix<double> m(1,2);
> printDimension(m);
> }
The correct syntax is:
cout << m().size1() << "x" << m().size2();
The matrix_expression and vector_expression types are base classes of the
various Matrix and Vector types. The operator() returns a reference to the
derived type. In this case a matrix<double> which you can then access
with .size1() etc.
The operator() syntax is a little confusing but compact!
Michael
-- ___________________________________ Michael Stevens Systems Engineering 34128 Kassel, Germany Phone/Fax: +49 561 5218038 Navigation Systems, Estimation and Bayesian Filtering http://bayesclasses.sf.net ___________________________________