-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaussElim.h
60 lines (54 loc) · 1.57 KB
/
gaussElim.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
///////////////////////////////////////////////////////////////////////////////
// GAUSS ELIMINATION (with partial pivoting)
// Ax = b
//
// This package contains three functions to perform
// A = PLU (luFactorize)
// x = U^{-1} L^{-1} P^T b (luSolve)
// Both (solve)
//
// luFactorize
// Factors the matrix
//
// Inputs
// a The matrix
// Outputs
// a The LU factored matrix
// p The permutation of the factorization
// Return
// s The status (SUCCESS, SINGULAR, or BADDATA)
//
// luSolve
// Call only after factoring the matrix! Solves the system.
//
// Inputs
// a The factored matrix
// p The permutation of the factorization
// x The vector b
// Outputs
// x The solution
// Return
// s The status (SUCCESS, SINGULAR, or BADDATA)
//
// solve
// Solves the system by calling the above two functions.
//
// Inputs
// a The matrix
// x The vector b
// Outputs
// a The LU factored matrix
// p The permutation of the factorization
// x The solution
// Return
// s The status (SUCCESS, SINGULAR, or BADDATA)
//
///////////////////////////////////////////////////////////////////////////////
#ifndef GAUSSELIM_INCLUDED
#define GAUSSELIM_INCLUDED
#include "matrix.h"
enum ge_state {SUCCESS, SINGULAR, BADDATA};
ge_state luFactorize(Matrix& a, Permutation& p);
ge_state luSolve(const Matrix& a, const Permutation& p, Vector& x);
ge_state solve(Matrix& a, Permutation& p, Vector& x);
#endif