【问题标题】:How to reshape a cube to a matrix armadillo如何将立方体重塑为矩阵犰狳
【发布时间】:2014-02-05 04:29:18
【问题描述】:

您知道是否可以使用 Armadillo 库将 Cube 重塑为矩阵,就像在 matlab 中一样,只需一条指令:

A = 重塑(A,M*N,D); , A 以前在哪里,现在是

非常感谢

【问题讨论】:

    标签: matrix cube reshape armadillo


    【解决方案1】:

    尝试以下方法:

    cube A = randu<cube>(5,4,3);
    
    // method 1: 
    A.reshape(5*4, 3, 1);
    mat B = A.slice(0);
    
    // method 2:
    mat C = reshape( mat(A.memptr(), A.n_elem, 1, false), 5*4, 3);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多