• Create Account

### #Actualalvaro

Posted 03 October 2012 - 08:25 PM

"Solving" a matrix or a determinant doesn't mean anything. You can solve a system of linear equations (which can be expressed in matrix form) and you can compute a determinant. Precise language does matter for math, so try to learn to use the way people express these things.

This is how I would start a Matrix class:
#include <vector>

class Matrix {
int size;
std::vector<double> m;

public:
Matrix(int size) : size(size), m(size*size) {
}

double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


If the size of the matrix will be known at compile time, you have the option of using templates instead:
template <int size>
class Matrix {
double m[size*size];

public:
double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


### #3alvaro

Posted 03 October 2012 - 08:24 PM

"Solving" a matrix or a determinant doesn't mean anything. You can solve a system of linear equations (which can be expressed in matrix form) and you can compute a determinant. Precise language does matter for math, so try to learn to use the way people express these things.

This is how I would start a Matrix class:
#include <vector>

template <int size>
class Matrix {
int size;
std::vector<double> m;

public:
Matrix(int size) : size(size), m(size*size) {
}

double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


If the size of the matrix will be known at compile time, you have the option of using templates instead:
template <int size>
class Matrix {
double m[size*size];

public:
double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


### #2alvaro

Posted 03 October 2012 - 08:22 PM

"Solving" a matrix or a determinant doesn't mean anything. You can solve a system of linear equations (which can be expressed in matrix form) and you can compute a determinant. Precise language does matter for math, so try to learn to use the way people express these things.

This is how I would start a Matrix class:
#include <vector>

template <int size>
class Matrix {
int size;
std::vector<double> m;

public:
Matrix(int size) : size(size), m(size*size) {
}

double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


If the size of the matrix will be known at compile time, you have the option of using templates instead:
template <int size>

class Matrix {
double m[size*size];

public:
double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


### #1alvaro

Posted 03 October 2012 - 08:22 PM

"Solving" a matrix or a determinant doesn't mean anything. You can solve a system of linear equations (which can be expressed in matrix form) and you can compute a determinant. Precise language does matter for math, so try to learn to use the way people express these things.

This is how I would start a Matrix class:
#include <vector>

class Matrix {
int size;
std::vector<double> m;

public:
Matrix(int size) : size(size), m(size*size) {
}

double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


If the size of the matrix will be known at compile time, you have the option of using templates instead:
template <int size>

class Matrix {
double m[size*size];

public:
double &operator()(int row, int col) {
return m[row * size + col];
}

double operator()(int row, int col) const {
return m[row * size + col];
}
};


PARTNERS