ВУЗ:
Составители:
Рубрика:
Объектно-ориентированное программирование на С++
out << "\t" << ob.b[0][i];
out << endl;
}
try
{
out << "Решение: " << endl;
ob.PrintSolution(out);
}
catch(Exception& e)
{
e.ShowMessage();
}
return out;
}
// функция решения СЛАУ методом Крамера
template <class T> void Slau<T>::Kramer()
{
if(m != n)
throw NonSquareMatrixException();
T det = a.Determinant();
if(det == 0.0)
throw ZeroDevideException();
rang = m;
Matrix<T> temp = a;
for(int j = 0; j < n; j++)
{
for(int i = 0; i < n; i++)
temp[i][j] = b[0][i];
x[0][j] = temp.Determinant() / det;
for(int i = 0; i < n; i++)
temp[i][j] = a[i][j];
}
isSolved = true;
}
// функция решения СЛАУ с помощью обратной матрицы
template <class T> void Slau<T>::InverseMatrix()
{
if(m != n)
throw NonSquareMatrixException();
Matrix<T> obr = ~ a;
Matrix<T> b = !(this -> b);
x = obr * b;
x = !x;
rang = m;
isSolved = true;
}
223
Объектно-ориентированное программирование на С++ out << "\t" << ob.b[0][i]; out << endl; } try { out << "Решение: " << endl; ob.PrintSolution(out); } catch(Exception& e) { e.ShowMessage(); } return out; } // функция решения СЛАУ методом Крамера templatevoid Slau ::Kramer() { if(m != n) throw NonSquareMatrixException(); T det = a.Determinant(); if(det == 0.0) throw ZeroDevideException(); rang = m; Matrix temp = a; for(int j = 0; j < n; j++) { for(int i = 0; i < n; i++) temp[i][j] = b[0][i]; x[0][j] = temp.Determinant() / det; for(int i = 0; i < n; i++) temp[i][j] = a[i][j]; } isSolved = true; } // функция решения СЛАУ с помощью обратной матрицы template void Slau ::InverseMatrix() { if(m != n) throw NonSquareMatrixException(); Matrix obr = ~ a; Matrix b = !(this -> b); x = obr * b; x = !x; rang = m; isSolved = true; } 223
Страницы
- « первая
- ‹ предыдущая
- …
- 221
- 222
- 223
- 224
- 225
- …
- следующая ›
- последняя »