git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@306 92aac97c-a6ce-11dd-a772-7fcde58d38e6

This commit is contained in:
chappuis.daniel 2010-04-12 22:28:24 +00:00
parent 5293491b3b
commit 8b1ef8a5fc
2 changed files with 11 additions and 1 deletions

View File

@ -45,6 +45,7 @@ Matrix::Matrix(int nbRow, int nbColumn) throw(std::invalid_argument)
array[i] = new double[nbColumn];
}
// TODO : This initialization loop must be removed carefully
// Fill the matrix with zero's
for (int i=0; i<nbRow; ++i) {
for(int j=0; j<nbColumn; ++j) {
@ -309,6 +310,15 @@ void Matrix::fillInSubMatrix(unsigned int rowIndex, unsigned int colIndex, const
}
}
// Initialize all the matrix with the given value
void Matrix::initWithValue(double value) {
for (unsigned int i=0; i<nbRow; ++i) {
for(unsigned int j=0; j<nbColumn; ++j) {
array[i][j] = value;
}
}
}
// Definition of the operator + for the sum of two matrices with references
Matrix Matrix::operator+(const Matrix& matrix2) const throw(MathematicsException) {
if (nbRow == matrix2.nbRow && nbColumn == matrix2.nbColumn) {

View File

@ -59,7 +59,7 @@ class Matrix {
double getTrace() const throw(MathematicsException); // Return the trace of a square matrix
static Matrix identity(int dimension) throw(std::invalid_argument); // Return the identity matrix I of the given dimension
void fillInSubMatrix(unsigned int i, unsigned int j, const Matrix& subMatrix); // Fill in a sub-matrix of the current matrix with another matrix
void initWithValue(double value); // Initialize all the matrix with the given value
void display() const; // TO DELETE
// --- Overloaded operators --- //