Converting multidimensional arrays to pointers in c++ -


I have a program that looks like the following:

  double [4] [4] initial matrix; Double [4] [4] Inverted Matrix; Initialize (startMatrix) // This introduces the information I want in the beginning  

Now I want to calculate the inverse of startMatrix and want to put it in the inverse matrix. I have a library function for this purpose that has a prototype low:

  Zero matrix inversion (double ** a, int order, double ** b)  

Who takes the inverse of A and puts it in B The problem is that to give the function, I should know about double [4] [4] being converted to double form. I have tried to make it "clear path":

  matrix inversion (double **) start matrix, 4, (double **) inverted matrix))  

But it does not seem to work, is this really the right way to do it?

No, there is no right way to do this specifically. A double [4] [4] array is not convertible to a double ** indicator. These are two alternative, incompatible ways to implement 2D arrays. Some need to change: the structure of the array given as the interface's interface or argument.

The simplest way to do the latter, i.e. your current double [4] [4] function with a consistent array, pointing to the beginning of each line in each matrix double * [4] is to create a temporary "index" array

  double * startro [4] = {startmates [0], startmint [1], startmart [ 2], startmint [3]}; Double * Inversions RO [4] = {/ * Here's the same thing;  

and instead pass these "index" arrays

  Matrix Inversion (Startro, 4, Inverver Ross); After the  

function is over, you can forget about startrows and inverseRows arrays, because the result is placed in your original The inverse matrix array will be correct.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -