• 矩阵知识积累


    [1]norm()

    https://www.zhihu.com/question/29458275

    n=norm(A,p) 功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数。

    • 如果A为矩阵

             n=norm(A) ---返回A的最大奇异值,即max(svd(A))

          n=norm(A,p) ---根据p的不同,返回不同的值

     p值 返回值
    1 返回A中最大一列和,即max(sum(abs(A)))
    2 返回A的最大奇异值,和n=norm(A)用法一样
    inf 返回A中最大一行和,即max(sum(abs(A’)))
    ‘fro’ A和A‘的积的对角线和的平方根,即sqrt(sum(diag(A'*A)))
     
    • 如果A为向量

               norm(A,p)---返回向量A的p范数。即返回 sum(abs(A).^p)^(1/p),对任意 1<p<+∞.
          norm(A)---返回向量A的2范数,即等价于norm(A,2)。
         norm(A,inf) ---返回max(abs(A))
         norm(A,-inf) ---返回min(abs(A))
     
    x = [0 1 2 3]
      x =
      0 1 2 3
    sqrt(0+1+4+9) % Euclidean length
      ans =
      3.7417
    norm(x)
      ans =
      3.7417
    n = length(x) % Number of elements
      n =
      4
    rms = 3.7417/2 % rms = norm(x)/sqrt(n)
      rms =
      1.8708

     [2]noalias() 声明没有混淆

    http://www.cnblogs.com/houkai/p/6349990.html

    在Eigen中,当变量同时出现在左值和右值,赋值操作可能会带来混淆问题.
    MatrixXi mat(3,3); 
    mat << 1, 2, 3,   4, 5, 6,   7, 8, 9;
    cout << "Here is the matrix mat:
    " << mat << endl;
    // This assignment shows the aliasing problem
    mat.bottomRightCorner(2,2) = mat.topLeftCorner(2,2);
    cout << "After the assignment, mat = 
    " << mat << endl;
    
    输出 Here
    is the matrix mat: 1 2 3 4 5 6 7 8 9 After the assignment, mat = 1 2 3 4 1 2 7 4 1
    //原因是Eigen使用了lazy evaluation(懒惰评估).
    组件级是指整体的操作,比如matrix加法、scalar乘、array乘等,这类操作是安全的,不会出现混淆。
    在Eigen中,矩阵的乘法一般都会出现混淆,除非是方阵(实质是元素级的乘)。Eigen默认会解决混淆问题,如果你确定不会出现混淆,可以使用noalias()来提效,使用noalias()函数来声明这里没有混淆。
    混淆出现时,可以用eval()和xxxInPlace()函数解决。
    MatrixXi mat(3,3); 
    mat << 1, 2, 3,   4, 5, 6,   7, 8, 9;
    cout << "Here is the matrix mat:
    " << mat << endl;
    // The eval() solves the aliasing problem
    mat.bottomRightCorner(2,2) = mat.topLeftCorner(2,2).eval();
    cout << "After the assignment, mat = 
    " << mat << endl;
    
    输出
    Here is the matrix mat:
    1 2 3
    4 5 6
    7 8 9
    After the assignment, mat = 
    1 2 3
    4 1 2
    7 4 5

    同样: a = a.transpose().eval(); 当然我们最好使用 transposeInPlace()。如果存在xxxInPlace函数,推荐使用这类函数,它们更加清晰地标明了你在做什么。提供的这类函数:


    Origin In-place

    MatrixBase::adjoint()

                       共轭

    MatrixBase::adjointInPlace()

    DenseBase::reverse()

                       

    DenseBase::reverseInPlace()
    LDLT::solve() LDLT::solveInPlace()
    LLT::solve() LLT::solveInPlace()
    TriangularView::solve() TriangularView::solveInPlace()

    DenseBase::transpose()

                          转置

    DenseBase::transposeInPlace()
     
     
     
     

    [3]有关eigen库的一些基本使用方法

    http://blog.csdn.net/r1254/article/details/47418871

    Identity();单位阵
  • 相关阅读:
    Python 远程开机
    Python 爬虫利器 Selenium
    Python爬虫——Python 岗位分析报告
    Python 爬虫入门(二)——爬取妹子图
    Python 爬虫入门(一)——爬取糗百
    边缘计算—你了解吗?
    关于图片适配不同尺寸的image View(实战)
    HTML页面转换为Sharepoint母版页(实战)
    SharePoint中你不知道的图片库(实战)
    Sharepoint 2013搜索服务配置总结(实战)
  • 原文地址:https://www.cnblogs.com/Jessica-jie/p/7978309.html
Copyright © 2020-2023  润新知