def untangent_space(T, Cref):
"""Project a set of Tangent space vectors in the manifold according to the given reference point Cref
:param T: the Tangent space , a matrix of Ntrials X (Nchannels*(Nchannels+1)/2)
:param Cref: The reference covariance matrix
:returns: A set of Covariance matrix, Ntrials X Nchannels X Nchannels
"""
Nt, Nd = T.shape
Ne = int((numpy.sqrt(1 + 8 * Nd) - 1) / 2)
C12 = sqrtm(Cref)
idx = numpy.triu_indices_from(Cref)
covmats = numpy.empty((Nt, Ne, Ne))
covmats[:, idx[0], idx[1]] = T
for i in range(Nt):
covmats[i] = numpy.diag(numpy.diag(covmats[i])) + numpy.triu(
covmats[i], 1) / numpy.sqrt(2) + numpy.triu(covmats[i], 1).T / numpy.sqrt(2)
covmats[i] = expm(covmats[i])
covmats[i] = numpy.dot(numpy.dot(C12, covmats[i]), C12)
return covmats
tangentspace.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录