Reducing matrix

Hi everyone,
I'm doing a C++ program for school: it's about reducing an algebraic square matrix, i.e. for a matrix, a line and a column, return the matrix without that line and that column.

Ex:
|3|4|5| lin 2, col 1
|1|8|6| ==============>
|9|2|7|

|4|5|
|2|7|

The function I made seems correct to me, but anyway it doesn't work. That's it:
1
2
3
4
5
6
7
8
9
10
11
typedef vector < vector < double > > matrix;

matrix red_size(matrix mat, int line, int column) {
	matrix mat2(((mat.size())-1), vector <double> ((mat.size())-1));
	for (int i(0); i<mat.size(); i++) {
		for (int j(0); j<mat.size(); j++) {
			if ((i!=line) && (j!=column)) {mat2[i][j]=mat[i][j];}
		}
	}
	return mat2;
}


Any suggestions?
Thanks in advance!
Last edited on
Topic archived. No new replies allowed.