mult algorithm: matrix with custom elements

Irek Szczesniak <[email protected]> Mon, 08 May 2006 15:07:00 -0700
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <[email protected]>
Hi,

My previous email was about printing a matrix with some custom element
types.  Now I've got a similar problem: this time I want to use the
mult algorithm.  My sample code is shown at the bottom of my email.
I'm using the newest MTL v. 2.1.2-22 with GCC 3.4.4-2 on Linux 2.6.10.

I read the docs to make sure that I do the right things.  At your
website (http://osl.iu.edu/research/mtl/intro.php3) you write that an
arbitrary type can be used for matrix elements as long as I meet some
requirements of the algorithm I want to use.  I want to use the mult
algorithm which, according to the docs, requires that:

- the multiplication operator must be defined for Matrix::value_type,
- the addition operator must be defined for Matrix::value_type.

Unfortunately, my code doesn't compile and the compiler complains
about the missing multiplication operator.  If I comment out the mult
function, the code compiles.

What should I do to make my program compile?

Thanks for reading.


Best,
Irek

********************************************************************

#include <iostream>
#include <map>
#include <vector>
#include <mtl/matrix.h>
#include <mtl/mtl.h>
#include <mtl/utils.h>
#include <mtl/blais.h>
#include <mtl/sparse1D.h>

using namespace mtl;
using namespace std;

typedef map<int, double> polynomial;

typedef matrix<polynomial,
                rectangle<>,
                array< dense<> >,
                row_major>::type Mat;

Mat::value_type operator *(const Mat::value_type &p1,
			   const Mat::value_type &p2)
{
   return Mat::value_type();
}

Mat::value_type operator +(const Mat::value_type &p1,
			   const Mat::value_type &p2)
{
   return Mat::value_type();
}


int
main()
{
   Mat A(10, 10);

   dense1D<polynomial> c(10), result(10);

   c[0] = polynomial();
   c[1] = polynomial();
   c[2] = polynomial();

   mult(A, c, result);

   return 0;
}
_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/