|
Ublas : |
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2008-07-29 16:21:30
Am Mittwoch, 23. Juli 2008 17:01 schrieb Garret McGraw:
> Hi,
>
> I've looked around at the wiki and previous mailing list posts and I
> cannot find the answer to my question there. What I need to do is
> define a custom class and set it to be stored in a matrix such as:
>
> matrix<MyCustomClass> mat1(300, 300);
>
> And then it must be able to be multiplied by another matrix of a
> different type.
>
> matrix<MyCustomClass2> mat2(300, 300);
>
> Then I want to be able to take the product of the two matrices have
> have it go into another matrix of a third type:
>
> matrix<MyCustomClass3> mat3(300, 300);
>
> mat3 = prod(mat1, mat2);
>
> Now I have defined operators to multiply MyCustomClass*MyCustomClass2
> and return MyCustomClass3 and also the operator MyCustomClass3 +=
> MyCustomClass3
The classes have to behave like "scalars". This means you have to
provide overloads for
a + b, a * b, a * number,
and a "constructor from zero" which means that expessions like
MyCustomClass zero = MyCustomClass(0);
should result in something that behaves like a zero:
a + zero == a, zero == a * 0
mfg
Gunter