Isn't double[][] equivalent to **double?

前端 未结 9 1453
心在旅途
心在旅途 2020-12-29 02:37

I\'m asking this because my program have two functions to multiply matrices, they multiply only 4x4 and 4x1 matrices. The headers are:

 double** mult4x1(doub         


        
9条回答
  •  感情败类
    2020-12-29 03:02

    [][] is not equivalent to **; double ** var; is a pointer of pointers and as you can see from your allocation in memory you hold an array of pointers and each pointer inside points to an array of values of double

    double var [4][4]; is held in memory in on place, and it is somewhat equivalent to double *; In this case the knows the size of the matrix ( 4 x 4 ) so when you use var[2][2], for example, it know where is that located in memory; var[x][y] translates to something like this: var[x + y * 4] and the declaration can be interpreted as double var [16];

    Raxvan.

提交回复
热议问题