void EliminaGaussiana(Matriz& m) { for (int i = 0; i < m.size(); ++i) { int fila_mayor = i; for (int j = i + 1; j < m.size(); ++j) if (fabs(m[fila_mayor][i]) < fabs(m[j][i])) fila_mayor = j; swap(m[i], m[fila_mayor]); if (Igual(m[i][i], 0)) continue; for (int j = m[i].size() - 1; j >= i; --j) m[i][j] /= m[i][i]; for (int j = 0; j < m.size(); ++j) { if (i == j || Igual(m[j][i], 0)) continue; double ratio = m[j][i] / m[i][i]; for (int k = i; k < m[j].size(); ++k) m[j][k] -= m[i][k] * ratio; } } }
void EliminacionGaussiana(Matriz& m) { for (int i = 0; i < m.size(); ++i) { // <comment> int fila_mayor = i; for (int j = i + 1; j < m.size(); ++j) if (fabs(m[fila_mayor][i]) < fabs(m[j][i])) fila_mayor = j; swap(m[i], m[fila_mayor]); // </comment> if (EsCero(m[i][i])) continue; for (int j = m[i].size() - 1; j >= i; --j) m[i][j] = m[i][j] / m[i][i]; for (int j = 0; j < m.size(); ++j) { if (i == j || EsCero(m[j][i])) continue; for (int k = m[j].size() - 1; k >= i; --k) m[j][k] = m[j][k] - m[i][k] * m[j][i]; } } }
void printVector(Matriz &matriz){ int fila = 0,columna = 0; for(int i=0; i<matriz.size(); ++i){ for(int j=0; j<matriz[0].size(); ++j){ // cout << "[" << matriz[i][j] << "]"; cout << "[" << matriz.at(i).at(j) << "]"; fila += matriz.at(i).at(j); } columna = sumaColumna(matriz, i); cout << " suma por fila= " << fila << ", suma por columna= " << columna; columna = 0; fila = 0; cout <<"\n"; } }