Algebra¶
Important linear algebra operations for Gaussian Process
-
algebra.
diagonal
(matrix: numpy.ndarray) → bool[source]¶ Check if a matrix is diagonal
- Param
matrix (np.ndarray) : matrix of size N x N
- Returns
cond (bool) : if diagonal, True
-
algebra.
matrix_inverse
(matrix: numpy.ndarray, return_chol: bool = False) → numpy.ndarray[source]¶ Sometimes, we would need the matrix inverse as well
If we are dealing with diagonal matrix, inversion is simple
- Param
matrix (np.ndarray) : matrix of size N x N
- Param
return_chol (bool) : if True, the Cholesky factor will be returned
- Returns
dummy (np.ndarray) : matrix inverse
If we also want the Cholesky factor:
- Returns
chol_factor (np.ndarray) : the Cholesky factor
-
algebra.
solve
(matrix: numpy.ndarray, b_vec: numpy.ndarray, return_chol: bool = False) → numpy.ndarray[source]¶ Given a matrix and a vector, this solves for x in the following:
Ax = b
If A is diagonal, the calculations are simpler (do not require any inversions)
- Param
matrix (np.ndarray) : ‘A’ matrix of size N x N
- Param
b_vec (np.ndarray) : ‘b’ vector of size N
- Param
return_chol (bool) : if True, the Cholesky factor will be retuned
- Returns
dummy (np.ndarray) : ‘x’ in the equation above
If we want the Cholesky factor:
- Returns
chol_factor (np.ndarray) : the Cholesky factor is returned