Matrix mulitply
python
a1 = np.arange(2) # [0,1] (2,)
a2 = np.arange(6).reshape(2,3) # [[1,2,3][4,5,6]] (2,3)
a1@a2
> array([3, 4, 5]) # (3,)
a2[None,:]@b
> array([[3, 4, 5]]) # (1,3)
a1 * a2
>array([[0, 3],
[0, 4],
[0, 5]])
Q: what's the order of a a2 @ a2.T:
a1 a2 @ a2.T = (a1 * a2 ) @ a2.T
实质,将系数a1平均分给a2的列向量上
Julia
CPP
Cholesky Decompostion
The cholesky decompostion is exclusively defined for symmetric or Hermitian positive definite matrices,
A = LL*.
Python:
1. chol_xx_cov = np.linalg.cholesky(x_cov)
2.
s1,v1,d1 = np.linalg.svd(x_cov)
v1 = np.clip(v1,a_min = 1e-8,a_max = None)
q1 = np.linalg.qr(np.sqrt(v1)[:,None] * d1)[-1]
chol_xx_cov = q1.T
Julia:
CPP