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


    公式:

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

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

    1. function Tcov = CovToTan(cov,Mcov)
    2. Cm12 = Mcov^(-1/2);
    3. X_new = logm(Cm12 * cov * Cm12);
    4. C12 = Mcov^(1/2);
    5. Tcov = Mupper(C12 * X_new * C12);
    6. end
    7. function Cov = TanToCov(vec,Mcov)
    8. X = Munupper(vec);
    9. Cm12 = Mcov^(-1/2);
    10. X = Cm12 * X * Cm12;
    11. C12 = Mcov^(1/2);
    12. Cov = C12 * expm(X) * C12;
    13. end
    14. function T = Mupper(X)
    15. % Upper triangular part vectorization with diagonal preservation.
    16. % This function keeps the upper triangular part of the matrix and
    17. % vectorizes it while multiplying non-diagonal elements by sqrt(2).
    18. % Get the size of X
    19. [M, N] = size(X);
    20. % Check if matrices are square
    21. if M ~= N
    22. error('Matrices must be square');
    23. end
    24. % Initialize T with zeros
    25. T = zeros(M, M, 'like', X);
    26. % Calculate the multiplier for non-diagonal elements
    27. multiplier = sqrt(2);
    28. % Fill T with the upper triangular part, preserving the diagonal
    29. for i = 1:M
    30. for j = i:M
    31. if i == j
    32. T(i, j) = X(i, j); % Diagonal element remains the same
    33. else
    34. T(i, j) = X(i, j) * multiplier; % Non-diagonal elements multiplied by sqrt(2)
    35. end
    36. end
    37. end
    38. % Flatten the upper triangular part of T to a vector
    39. T = T(triu(true(size(T))) == 1);
    40. T = T';
    41. end
    42. function X = Munupper(T, n)
    43. % Reverse the operation to reconstruct the matrix from its upper triangular part.
    44. % Calculate the size of the square matrix based on the length of the input vector T
    45. n = round((sqrt(1 + 8 * length(T)) - 1) / 2);
    46. % Check if T is a valid upper triangular vector
    47. m = n * (n + 1) / 2;
    48. if numel(T) ~= m
    49. error('Invalid input. Input vector size does not match the expected size for upper triangular vectors.');
    50. end
    51. % Initialize the symmetric matrix X with zeros
    52. X = zeros(n, n, 'like', T);
    53. % Calculate the indices for the upper triangular part
    54. [I, J] = find(triu(ones(n)));
    55. % Reverse the vectorization and apply the appropriate scaling to non-diagonal elements
    56. for k = 1:numel(I)
    57. i = I(k);
    58. j = J(k);
    59. if i == j
    60. X(i, j) = T(k); % Diagonal elements remain the same
    61. else
    62. X(i, j) = T(k) / sqrt(2); % Reverse scaling for non-diagonal elements
    63. X(j, i) = X(i, j); % Symmetric matrix
    64. end
    65. end
    66. end

  • 相关阅读:
    使用低代码可视化开发平台快速搭建应用
    MyBatis基础教程
    基于QT的考试管理系统设计与实现
    JAVA编程思想N刷
    2019新鲜出炉的BAT通关面试题 Java岗
    基于非局部滤波图像去噪方法
    马斯克 VS 乔布斯,谁是21世纪最伟大的创业家
    使用 EMQX Cloud 实现物联网设备一机一密验证
    JavaScript_Date对象_实例方法_set类
    数学学习与研究杂志数学学习与研究杂志社数学学习与研究编辑部2022年第24期目录
  • 原文地址:https://blog.csdn.net/aaalswaaa1/article/details/133958047