Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double** invertMatrix(double** A, int size)
- {
- double** result = new double* [size];
- for (int i = 0; i < size; i++)
- {
- result[i] = new double[size];
- }
- double* newA = new double [size*size];
- newA = matrixToArray(A, size);
- double cond = 0;;
- int* pivot = new int[size];
- int flag = 0;
- decomp(size, size, newA, &cond, pivot, &flag);
- std::cout << "Decomp arguments: cond = " << cond << "; flag = " << flag << "\n";
- double* B = new double[size];
- for (int i = 0; i < size; i++)
- {
- for (int k = 0; k < size; k++)
- {
- B[k] = 0;
- }
- B[i] = 1;
- solve(size, size, newA, B, pivot);
- for (int j = 0; j < size; j++)
- {
- result[j][i] = B[j];
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement