Chap - 2 (Part - 1)
Chap - 2 (Part - 1)
Cholesky Decomposition
Code:
#include <iostream>
#include <vector>
#include <cmath>
if (j == i) {
for (int k = 0; k < j; k++)
sum += lower[j][k] * lower[j][k];
lower[j][j] = sqrt(matrix[j][j] - sum);
} else {
for (int k = 0; k < j; k++)
sum += lower[i][k] * lower[j][k];
lower[i][j] = (matrix[i][j] - sum) / lower[j][j];
}
}
}
return lower;
}
int main() {
int n;
cout << "Nhap kich thuoc ma tran: ";
cin >> n;
if (!check_doixung(matrix)) {
cout << "Ma tran khong doi xung!" << endl;
return 1;
}
if (!check_xacdinh_duong(matrix)) {
cout << "Ma tran khong xac dinh duong!" << endl;
return 1;
}
return 0;
}
Code:
#include <iostream>
#include <vector>
#include <cmath>
int main() {
int n;
cout << "Nhap kich thuoc ma tran: ";
cin >> n;
if (!check_doixung(matrix)) {
cout << "Ma tran khong doi xung!" << endl;
return 1;
}
return 0;
}