2 |
#include "mathfunc.h" |
#include "mathfunc.h" |
3 |
#include "gadget.h" |
#include "gadget.h" |
4 |
|
|
|
//TODO doc |
|
|
//TODO usar mallock |
|
5 |
Matrix::Matrix(int nr, int nc, double value) { |
Matrix::Matrix(int nr, int nc, double value) { |
6 |
|
|
7 |
m = new double[nr * nc]; |
m = new double[nr * nc]; |
14 |
} |
} |
15 |
} |
} |
16 |
|
|
|
//Matrix::Matrix(const DoubleMatrix& initial) : nrow(initial.nrow) { |
|
|
// int i; |
|
|
// if (nrow >= 0) { |
|
|
//// v = new DoubleVector*[nrow]; |
|
|
//// for (i = 0; i < nrow; i++) |
|
|
//// v[i] = new DoubleVector(initial[i]); |
|
|
// v = new double[nrow][initial.Ncol(0)]; |
|
|
// int i,j; |
|
|
// |
|
|
// for (i = 0; i < nrow; i++) |
|
|
// for (j = 0; j < initial.Ncol(0); j++) |
|
|
// v[i][j] = initial[i][j]; |
|
|
// } else { |
|
|
// v = 0; |
|
|
// nrow = 0; |
|
|
// } |
|
|
//} |
|
|
|
|
17 |
Matrix::~Matrix() { |
Matrix::~Matrix() { |
18 |
int i; |
int i; |
19 |
if (m != 0) { |
if (m != 0) { |
54 |
} |
} |
55 |
} |
} |
56 |
|
|
|
//void Matrix::Delete(int pos) { |
|
|
// delete v[pos]; |
|
|
// int i; |
|
|
// if (nrow > 1) { |
|
|
// DoubleVector** vnew = new DoubleVector*[nrow - 1]; |
|
|
// for (i = 0; i < pos; i++) |
|
|
// vnew[i] = v[i]; |
|
|
// for (i = pos; i < nrow - 1; i++) |
|
|
// vnew[i] = v[i + 1]; |
|
|
// delete[] v; |
|
|
// v = vnew; |
|
|
// nrow--; |
|
|
// } else { |
|
|
// delete[] v; |
|
|
// v = 0; |
|
|
// nrow = 0; |
|
|
// } |
|
|
//} |
|
|
|
|
|
//Matrix &Matrix::operator = (const Matrix& d) { |
|
|
// int i,j; |
|
|
//// if (v != 0) { |
|
|
//// for (i = 0; i < nrow; i++) |
|
|
//// delete v[i]; |
|
|
//// delete[] v; |
|
|
//// } |
|
|
// if (m != 0) |
|
|
// delete[] m; |
|
|
// |
|
|
// nrow = d.nrow; |
|
|
// ncol = d.ncol; |
|
|
// |
|
|
// double* aux; |
|
|
// if (nrow > 0) { |
|
|
// m = d.m; |
|
|
////// v = new double*[nrow]; |
|
|
//// m = new double[nrow * ncol]; |
|
|
////// for (i = 0; i < nrow; i++) |
|
|
////// v[i] = new double(*d[i]); |
|
|
//// cout << "0000000?????????:" << d[20] << endl; |
|
|
//// for (i = 0; i < nrow; i++) { |
|
|
//// for (j = 0; j < ncol; j++){ |
|
|
////// cout << "j:" << j << endl; |
|
|
//// cout << "????????????????????0" << endl; |
|
|
//// aux = (double*) d[i*ncol+j]; |
|
|
//// cout << "????????????????????1" << endl; |
|
|
//// m[i*ncol+j] = 0; |
|
|
////// cout << "????????????????????2" << endl; |
|
|
//// } |
|
|
//// } |
|
|
// } else |
|
|
// m = 0; |
|
|
// |
|
|
// return *this; |
|
|
//} |
|
|
|
|
57 |
void Matrix::Reset() { |
void Matrix::Reset() { |
58 |
if (nrow > 0) { |
if (nrow > 0) { |
59 |
int i; |
int i; |