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

公式:

从黎曼空间投影到切空间,其中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
相关推荐
硬汉嵌入式5 小时前
Matlab2025b发布,全新的Simulink示波器
matlab·simulink
机器学习之心13 小时前
一个基于自适应图卷积神经微分方程(AGCNDE)的时空序列预测Matlab实现。这个模型结合了图卷积网络和神经微分方程,能够有效捕捉时空数据的动态演化规律
人工智能·深度学习·matlab·时空序列预测
ytttr8731 天前
混合动力汽车MATLAB建模实现方案
开发语言·matlab·汽车
尤利乌斯.X1 天前
复杂网络仿真从入门到精通:0 学习路线
网络·学习·matlab·仿真·复杂网络
feifeigo1231 天前
MATLAB的无线传感器网络(WSN)算法仿真
网络·算法·matlab
CUMT_DJ2 天前
matlab计算算法的运行时间
开发语言·算法·matlab
weixin_514221852 天前
FDTD与matlab、python耦合
python·学习·matlab·fdtd
Evand J3 天前
组合导航的MATLAB例程,二维平面上的CKF滤波,融合IMU和GNSS数据,仿真,观测为X和Y轴的坐标,附代码下载链接
开发语言·matlab·平面·imu·组合导航
CappuccinoRose4 天前
MATLAB学习文档(二十三)
matlab·信息可视化·数据挖掘·数据分析
民乐团扒谱机4 天前
【微实验】激光测径系列(四)关于硬件上的一些实验
计算机视觉·matlab·激光测径