简体   繁体   中英

How to convert float (*)[6] to float** type?

I want solve a 2D array using Runge Kutta method. However, I am experiencing the error given below which I couldn't solve. Can any one help me to solve this error?

[Error] cannot convert 'float (*)[6]' to 'float**' for argument '2' to 'void rnnW1_1(float**, float**)'

#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define  m          17
void rnnW1_1(float **W1_1, float **rsh)
{
  int i,j;
  for(j=0;j<6;j++)
  {
  for(i=0;i<m;i++)
  {
  *(*(rsh+i)+j)= (A1_1[i][j]-(eta111*NTSMS11+eta121*norm_s1)*norm_s1*W1_1[i][j]);
   }
  }
// 
}
//
void rungeW1(float **W, float d)
{
    float Wdot[m][6], wv[m][6], newW[m][6];
    int i,j;
    rnnW1_1(W, Wdot);
    for (j = 0; j<6; j++)
    {
    for (i = 0; i<m; i++)
    {
        wv[i][j] = d*Wdot[i][j];
        newW[i][j] = W[i][j] + d*Wdot[i][j]/2.;
    }
    }
    rnnW1_1(newW, Wdot);
    for (j = 0; j<6; j++)
    {
    for (i = 0; i<m; i++)
     {
        wv[i][j] = wv[i][j] + d*Wdot[i][j]*2.;
        newW[i][j] = W[i][j] + d*Wdot[i][j]/2.;
     }
   }
    rnnW1_1(newW, Wdot);
    for (j = 0; j<6; j++)
    {
    for (i = 0; i<m; i++)
     {
        wv[i][j] = wv[i][j] + d*Wdot[i][j]*2.;
        newW[i][j] = W[i][j] + d*Wdot[i][j];
     }
   }   
    rnnW1_1(newW, Wdot);
    for (j = 0; j<6; j++)
    {
    for (i = 0; i<m; i++)
    {
        W[i][j] = W[i][j] + (wv[i][j] + d*Wdot[i][j])/6.;
     }
   }
}

Simple, change

void rnnW1_1(float **W1_1, float **rsh)

to

void rnnW1_1(float (*W1_1)[6], float (*rsh)[6])

Incidentally m is undeclared in the code you posted. I'm hoping that doesn't make a difference to my answer. Please always try to post complete code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM