util
posneg(x, s)
Return x with the sign of s.
\[
\begin{cases}
+x & \text{if $s$ is true} \\
-x & \text{if $s$ is false}
\end{cases}
\]
To use the unary operators (+/pos) & -/neg)
instead of multiplication (*/mul) with \(\pm1\)
as the unary operators may be faster
and multiplication with integers doesn't have to be implemented
(might be the case for custom prototyped number types).
Source code in linalg\util.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
assert_matrix(A)
Assert matrix.
Source code in linalg\util.py
32 33 34 35 36 37 | |
assert_sqmatrix(A)
Assert square matrix.
Source code in linalg\util.py
39 40 41 42 43 44 45 46 | |
swap_rows(A, i, j)
Swap the i-th and j-th row of A in-place.
Source code in linalg\util.py
50 51 52 53 54 55 56 57 | |
swap_columns(A, i, j)
Swap the i-th and j-th column of A in-place.
Source code in linalg\util.py
59 60 61 62 63 64 65 66 | |
swap_pivot(A, p, i, j)
Swap the p-&i-th rows and p-&j-th columns of A in-place.
Source code in linalg\util.py
68 69 70 71 72 73 74 75 76 | |
submatrix(A, i, j)
Return a copy of A without the i-th row and j-th column.
Source code in linalg\util.py
79 80 81 82 83 84 85 86 | |