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

公式:

从黎曼空间投影到切空间,其中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
相关推荐
slandarer25 分钟前
MATLAB | 趣味编程——动态字符串甜甜圈和爱心
数据结构·matlab·趣味编程
Matlab程序猿1 小时前
【MATLAB源码-第461期】基于matlab的高速铁路 双链路 QPSK 误码性能仿真与风险驱动自适应复制控制仿真
matlab·高速铁路通信·双链路通信·截止期约束
li星野8 小时前
【学习记录】射线补偿原理与实现:从物理模型到MATLAB代码
开发语言·学习·matlab
星夜离尘561 天前
MATLAB 多传感器时间对齐 用 interp1 建立公共时间网格并限制外推
matlab·插值·传感器·时间序列·interp1
北纬的小熊1 天前
Matlab Simulink电力电子仿真-全桥 LLC 谐振变换器调频控制(PFM)仿真研究
嵌入式硬件·matlab
星夜离尘562 天前
MATLAB 清洗 CSV 采样日志:重复时间戳、无效行、分组统计与自动出图
开发语言·matlab·数据分析·数据清洗·csv
星夜离尘562 天前
MATLAB FFT 单边幅度谱:归一化、奇偶长度与频谱泄漏的完整实验
开发语言·matlab·信号处理·频谱分析·fft
星夜离尘562 天前
MATLAB 5 点滑动平均:filter 与 conv 的输出对齐,以及 2 样本延时的含义
开发语言·算法·matlab·滤波·fir
道道_Love3 天前
AI 调 MATLAB 用 MCP 太难用?单元设计规范和测试用例,用原生 AI 一次生成
人工智能·matlab·设计规范
菜鸟~noob2333 天前
【电子战】第31篇:3D AOA 定位——方位+俯仰联合
开发语言·matlab·3d