Blitz logo

Blitz Support :

From: Navneet Dalal (Navneet.Dalal_at_[hidden])
Date: 2003-11-04 10:14:43


TinyMatrix is not really fully supported in blitz.
It lacks all unary and binary operators (like *, /, - +, +=, -=, *=, /=)
for all type of arguments (e.g. double and TinyMatrix itself).

You need to define these functions on your own in blitz/tinymat.h
(blitz/tinyvec.h file may provide you a good starting template)

Also, following two lines will not compile.
TinyMatrix<double,3,3> A(3.0);
TinyMatrix<double,3,3> B(A);
So you may want to add corresponding constructors.

-navneet

On Tue, 4 Nov 2003 14:54:01 +0100, van den Bosch
<vandenbosch_at_[hidden]> wrote:

> Hello,
>
> I have a problem for multiplying a TinyMatrix with a double. Here is the
> code:
>
> #include <iostream>
> #include <complex>
> #include <blitz/array.h>
> #include <blitz/tinyvec-et.h>
> #include <blitz/tinymat.h>
>
> using namespace blitz;
>
> int main (void) {
> double a = 3.0;
> TinyMatrix<double, 3, 3> A, B;
> TinyVector<double, 3> x, y, z;
> A = 1.0, -2.0, 0.0,
> 2.0, 1.0, 0.0,
> 0.0, 0.0, 1.0;
> cout << A << endl;
> B = A * a;
> cout << B << endl;
>
> x = 2.0, 3.0, 4.0;
> cout << x << endl;
>
> y = product(A, x);
> cout << y << endl;
> z = y*2.0;
> cout << z << endl;
> }
>
> and here is the error compilation message :
>
> [denbosch_at_lorentz TinyMatrix]$ make
> g++ -c -O3 -I../../../blitz++/include tiny.cpp
> tiny.cpp: In function `int main()':
> tiny.cpp:20: no match for `blitz::TinyMatrix<double, 3, 3>& * double&'
> operator
> .../../../blitz++/include/blitz/vecbops.cc:3736: candidates are:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::_bz_VecExprConstant<long
> double>, blitz::Range, blitz::_bz_Multiply<long double, int> > >
> blitz::operator*(long double, blitz::Range)
> .../../../blitz++/include/blitz/vecbops.cc:3651:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::_bz_VecExprConstant<double>,
> blitz::Range, blitz::_bz_Multiply<double, int> > >
> blitz::operator*(double,
> blitz::Range)
> .../../../blitz++/include/blitz/vecbops.cc:3566:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::_bz_VecExprConstant<float>,
> blitz::Range, blitz::_bz_Multiply<float, int> > >
> blitz::operator*(float,
> blitz::Range)
> .../../../blitz++/include/blitz/vecbops.cc:3237:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::Range,
> blitz::_bz_VecExprConstant<long double>, blitz::_bz_Multiply<int, long
> double> > > blitz::operator*(blitz::Range, long double)
> .../../../blitz++/include/blitz/vecbops.cc:3220:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::Range,
> blitz::_bz_VecExprConstant<double>, blitz::_bz_Multiply<int, double>
> > >
> blitz::operator*(blitz::Range, double)
> .../../../blitz++/include/blitz/vecbops.cc:3203:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::Range,
> blitz::_bz_VecExprConstant<float>, blitz::_bz_Multiply<int, float> > >
> blitz::operator*(blitz::Range, float)
> .../../../blitz++/include/blitz/vecbops.cc:3169:
> blitz::_bz_VecExpr<blitz::_bz_VecExprOp<blitz::Range, blitz::Range,
> blitz::_bz_Multiply<int, int> > > blitz::operator*(blitz::Range,
> blitz::Range)
> .../../../blitz++/include/blitz/meta/metaprog.h:58: T
> blitz::operator*(const T&, blitz::_bz_meta_nullOperand) [with T =
> blitz::TinyMatrix<double, 3, 3>]
> make: *** [tiny.o] Error 1
> [denbosch_at_lorentz TinyMatrix]$
>
> Anyone has a clue about what's wrong in my code ? Thanks,
>
> Ides
>

-- 
Navneet DALAL               http://www.inrialpes.fr/lear/people/Dalal
INRIA Rhone-Alpes                       Ph(work): +33 (0)476 61 54 97
ZIRST-655, av. de l'Europe - 38334      FAX     : +33 (0)476 61 54 54
Montbonnot St. Martin, France           Mobile  : +33 (0)677 54 33 33