黎曼几何与切空间之间的投影

公式:

从黎曼空间投影到切空间,其中P为黎曼均值,也是切空间的参考中心点,Pi是要投影到切空间的点。

从切空间投影回来,其中Si为切空间中的向量。

Matlab 复制代码
function Tcov = CovToTan(cov,Mcov)
    Cm12 = Mcov^(-1/2);
    X_new = logm(Cm12 * cov * Cm12);
    C12 = Mcov^(1/2);
    Tcov = Mupper(C12 * X_new * C12);
end

function Cov = TanToCov(vec,Mcov)
    X = Munupper(vec);
    Cm12 = Mcov^(-1/2);
    X = Cm12 * X * Cm12;
    C12 = Mcov^(1/2);
    Cov = C12 * expm(X) * C12;
end

function T = Mupper(X)
    % Upper triangular part vectorization with diagonal preservation.
    % This function keeps the upper triangular part of the matrix and
    % vectorizes it while multiplying non-diagonal elements by sqrt(2).

    % Get the size of X
    [M, N] = size(X);
    
    % Check if matrices are square
    if M ~= N
        error('Matrices must be square');
    end
    
    % Initialize T with zeros
    T = zeros(M, M, 'like', X);
    
    % Calculate the multiplier for non-diagonal elements
    multiplier = sqrt(2);
    
    % Fill T with the upper triangular part, preserving the diagonal
    for i = 1:M
        for j = i:M
            if i == j
                T(i, j) = X(i, j);  % Diagonal element remains the same
            else
                T(i, j) = X(i, j) * multiplier;  % Non-diagonal elements multiplied by sqrt(2)
            end
        end
    end
    
    % Flatten the upper triangular part of T to a vector
    T = T(triu(true(size(T))) == 1);
    T = T';
end

function X = Munupper(T, n)
    % Reverse the operation to reconstruct the matrix from its upper triangular part.
    
    % Calculate the size of the square matrix based on the length of the input vector T
    n = round((sqrt(1 + 8 * length(T)) - 1) / 2);
    
    % Check if T is a valid upper triangular vector
    m = n * (n + 1) / 2;
    if numel(T) ~= m
        error('Invalid input. Input vector size does not match the expected size for upper triangular vectors.');
    end
    
    % Initialize the symmetric matrix X with zeros
    X = zeros(n, n, 'like', T);
    
    % Calculate the indices for the upper triangular part
    [I, J] = find(triu(ones(n)));
    
    % Reverse the vectorization and apply the appropriate scaling to non-diagonal elements
    for k = 1:numel(I)
        i = I(k);
        j = J(k);
        if i == j
            X(i, j) = T(k);  % Diagonal elements remain the same
        else
            X(i, j) = T(k) / sqrt(2);  % Reverse scaling for non-diagonal elements
            X(j, i) = X(i, j);  % Symmetric matrix
        end
    end
end
相关推荐
kaikaile199518 小时前
MATLAB 灰度图像的二维傅里叶变换
算法·计算机视觉·matlab
具***719 小时前
探索 S7 - 1200 地铁屏蔽门控制系统
matlab
yugi98783819 小时前
MATLAB在卫星姿态控制系统中的应用
开发语言·matlab
Dev7z1 天前
基于MATLAB的GA–PSO混合算法无线传感器网络节点部署优化研究
网络·算法·matlab
机器学习之心1 天前
MATLAB基于RSM和MOGWO的440C不锈钢外圆磨削参数优化
matlab·rsm·不锈钢外圆磨削参数优化
元周民1 天前
非厄米矩阵高精度计算预先判定需要的计算精度(matlab)
线性代数·matlab·矩阵
天`南1 天前
【群智能算法改进】一种改进的金豺优化算法IGJO[1](动态折射反向学习、黄金正弦策略、自适应能量因子)【Matlab代码#94】
学习·算法·matlab
机器学习之心1 天前
基于组合赋权法(BWM+CRITIC)与可拓云理论的综合风险评估模型MATLAB代码
matlab·组合赋权法·可拓云理论·综合风险评估模型
Dev7z1 天前
基于MATLAB的5G通信信号频谱分析与信道性能仿真研究
开发语言·5g·matlab
我爱C编程1 天前
基于大衍数构造的稀疏校验矩阵LDPC误码率matlab仿真,对比不同译码迭代次数,码率以及码长
matlab·ldpc·大衍数·稀疏校验矩阵