在 mlock 中发生了“System.Runtime.InteropServices.SEHException”类型的未处理异常。c 在 __cdecl _unlock() 函数中。
我的代码在下面`
void Compute_AB(double *gpos,double **x, double *nv,double **ds,double ***a,double ***b,int mm2,int nx, int ndex)
{
//!------------------------------------------------------------------
//! Compute A matrix and B matrix and their derivatives
//! input--gpos,x,nv,dm,nx,numnode,ndex,mm
//! output--a,b
//! From 1 to 10 of the third dimension of a denotes
//! a,dax,day,daxx,daxy,dayy, dadxxx,dadxxy,dadxyy,dadyyy
//! From 1 to 10 of the third dimension of b denotes
//! b,dbx,dby,dbxx,dbxy,dbyy,dbdxxx,dbdxxy,dbdxyy,dbdyyy
//!----------------------------------------------------------------
double **w;
int numnode=ndex;
double **p=new double*[6];
for(int i=0;i<6;i++)
{p[i]=new double[ndex];
for (int j=0;j<ndex;j++)
p[i][j]=0.0;
}
//inintial pp
double ***pp=new double**[numnode];
for(int i=0;i<numnode;i++)
{
pp[i]=new double*[mm2];
for(int j=0;j<mm2;j++)
{ pp[i][j]=new double[mm2];
/*for(int k=0;k<mm2;k++)
pp[i][j][k]=0.0;*/}
}
//initial diff;
double **dif;
dif=new double*[nx];
for(int i=0;i<nx;i++)
{
dif[i]=new double[ndex];
for(int j=0;j<ndex;j++)
{
dif[i][j]=0.0;
//std::cout<<dif[i][j]<<", " ;
}
//std::cout<<std::endl;*/
}
//end initial
//////////////////////////////////
//initial **w
w=new double*[numnode];
for (int i=0;i<numnode;i++)
{
w[i]=new double[10];
for(int j=0;j<10;j++)
w[i][j]=0.0;
}
// initial xv
double **xv=new double*[nx];
for(int j=0;j<nx;j++)
xv[j]=new double[numnode];
//////////////////////////////////
/// INITIAL P
for(int i=0;i<ndex;i++){
int nn;
nn=int(nv[i]);
xv[0][i]=x[0][nn];
xv[1][i]=x[1][nn];
p[0][i]=1.0;
p[1][i]=xv[0][i];
p[2][i]=xv[1][i];
p[3][i]=xv[0][i]*xv[0][i];
p[4][i]=xv[0][i]*xv[1][i];
p[5][i]=xv[1][i]*xv[1][i];
dif[0][i]=gpos[0]-xv[0][i];
dif[1][i]=gpos[1]-xv[1][i];
}
///////////////////////// end initial
/*mexPrintf("out w before calculation:\n");
for(int i=0;i<ndex;i++)
{
for(int j=0;j<10;j++)
mexPrintf("%g ",w[i][j]);
mexPrintf("\n");
}*/
Weight_W1(dif,nv,ds,w,ndex);// another function, it works as a single function
// ************* Compute b and its derivatives
for(int ii=0;ii<mm2;ii++)
{ for( int jj=0;jj<ndex;jj++)
{ for(int kk=0;kk<10;kk++)
{ b[ii][jj][kk]=p[ii][jj]*w[jj][kk];
}
}
}
// display B
// ************* Compute a and its derivatives
for(int ie=0;ie<mm2;ie++)
for(int je=0;je<mm2;je++)
for(int ke=0;ke<10;ke++)
{ a[ie][je][ke]=0.0;}
for(int iii=0;iii<ndex;iii++)
{ for(int ik=0;ik<mm2;ik++){
for(int jk=0;jk<mm2;jk++ )
{pp[iii][ik][jk]=p[ik][iii]*p[jk][iii] ;
}
}
}
for(int iii=0;iii<ndex;iii++)
for(int ikk=0;ikk<mm2;ikk++)
for(int jkk=0;jkk<mm2;jkk++)
for(int kkk=0;kkk<10;kkk++)
{
a[ikk][jkk][kkk]=a[ikk][jkk][kkk]+w[iii][kkk]*pp[iii][ikk][jkk];
}
for(int ikk=0;ikk<mm2;ikk++)
{for(int jkk=0;jkk<mm2;jkk++)
{for(int kkk=0;kkk<10;kkk++)
{
}
}
}
}`
代码运行时发生错误
double ***pp=new double**[numnode];
for(int i=0;i<numnode;i++)
{
pp[i]=new double*[mm2];
for(int j=0;j<mm2;j++)
{ pp[i][j]=new double[mm2];
/*for(int k=0;k<mm2;k++)
pp[i][j][k]=0.0;*/}
}
节点数=47092;mm2=3,nx=2;索引=numnode2
有帮助。谢谢