Matrix-class with Polynoms

For a mathematical problem I need to work with a Matrix of polynomials. So I want to create a class.

For Polynomials I use the library polymul.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include "polymul.h"
#include <vector>
using namespace std;

class Matrix{
public:
   int dimension; 
   vector<vector<polynomial<double, 4, 2> > > entries;
   Matrix();
   Matrix(int dim);
};
Matrix::Matrix(int dim){
	this->dimension = dim;
	this->entries = vector<vector<polynomial<double, 4, 2> > > (dim, polynomial<double, 4, 2> (dim, 0));
}

int main()
{
	return 0;
}


There is an error with the constructor in line 15. Any ideas what`s the problem.
Well, first off, at a quick glance I see a problem with this (literally):
1
2
this->dimension = dim;
this->entries = vector<vector<polynomial<double, 4, 2> > > (dim, polynomial<double, 4, 2> (dim, 0));

You don't need to use the this pointer when working in a class member. It is assumed. So first take this-> out of the constructor.

I'm not quite sure what the template for polynomial is, so if you could post some of that that would be great.
I have a feeling it has to do with the way you are nesting templates.
If you could post the error, it would make things a lot easier.
you are construction a vector of vectors of polynomials and filling it with just polynomials.
Thanks to both Major Tom and viliml!

Would this be correct: (I don't have access to a pc with a c++ compiler in the moment)
entries = vector<vector<polynomial<double, 4, 2> > > (dim, vector<polynomial<double, 4, 2> > (dim, 0));
if your polynomial<double, 4, 2> class has a non-explicit constatructor taking a value of a type that 0 is convertible to, then yes. Just to be sure you can remove do this: entries = vector<vector<polynomial<double, 4, 2> > > (dim, vector<polynomial<double, 4, 2> > (dim));
Then it would impicitly call
entries = vector<vector<polynomial<double, 4, 2> > > (dim, vector<polynomial<double, 4, 2> > (dim, polaynomial<double, 4, 2>()));
Thanks a lot, I will try it tomorow.
Topic archived. No new replies allowed.