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

前端 未结 9 1393
心在旅途
心在旅途 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:08

    There is no type [][]. What you have is in fact m2 which is an array of arrays of size 4 of type double and m1 which is an array of arrays of size 1. An array of arrays of size 4 is not equivalent to double pointer.

    0 讨论(0)
  • 2020-12-29 03:10

    Well I hope I will not turn out stupid here but the notation double [][] is also used when you are addressing a continuous block of memory, while double** is not necessarily continuous.

    I think that is the reason behind the error. Even though you can use the same semantics to access values, they are actually different types.

    0 讨论(0)
  • 2020-12-29 03:12

    No they definitely are not equivalent the former represents a 2D array of doubles while as latter represents a pointer to pointer to double.

    0 讨论(0)
提交回复
热议问题