gauss
det_gauss(A, progress=set())
Return the determinant.
\[
\det A \qquad \mathbb{K}^{N\times N}\to\mathbb{K}
\]
Uses Gaussian elimination with complete pivoting.
The matrix will be transformed in-place into an upper triangular matrix (columns left of pivot won't be reduced).
Complexity
There will be at most
- \(\frac{N(N^2-1)}{3}\) scalar subtractions (
-), - \(\begin{cases} \frac{N(N^2+2)}{3}-1 & N>0 \\ 0 & N=0 \end{cases}\) scalar multiplications (
*) & - \(\frac{N(N-1)}{2}\) scalar true divisions (
/).
Source code in linalg\gauss.py
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 61 62 63 64 65 66 67 68 69 | |
inv_gauss(A, progress=set())
Return the inverse.
\[
A^{-1} \qquad \mathbb{K}^{N\times N}\to\mathbb{K}^{N\times N}
\]
Uses Gaussian elimination with complete pivoting. The matrix will be transformed in-place into the identity matrix.
TODO: Still unnecessary operations like A[i, i]/A[i, i].
Complexity
There here will be
- \(2N^3-2N^2\) scalar subtractions (
-), - \(2N^3-2N^2\) scalar multiplications (
*), - \(2N^2\) scalar true divisions (
/),
so \(4N^3-2N^2\) arithmetic operations in total.
Source code in linalg\gauss.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |