Numpy array and Matlab Matrix are mismatching [3D]

前端 未结 5 1461
失恋的感觉
失恋的感觉 2021-01-06 17:32

The following octave code shows a sample 3D matrix using Octave/Matlab

octave:1> A=zeros(3,3,3);
octave:2> 
octave:2> A(:,:,1)= [[1 2 3];[4 5 6];[7         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 18:02

    I think better than just calling the difference "row major" or "column major" is numpy's way of describing them:

    ‘C’ means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest.

    Some gifs to illustrate the difference: The first is row-major (python / c), second is column-major (MATLAB/ Fortran)

提交回复
热议问题