#include "stdlib.h"
int lman(n,m,k,f,q,r,h,y,x,p,g)
int n,m,k;
double f[],q[],r[],h[],y[],x[],p[],g[];
{ int i,j,kk,ii,l,jj,js;
double *e,*a,*b;
e=malloc(m*m*sizeof(double));
l=m;
if (l<n) l=n;
a=malloc(l*l*sizeof(double));
b=malloc(l*l*sizeof(double));
for (i=0; i<=n-1; i++)
for (j=0; j<=n-1; j++)
{ ii=i*l+j; a[ii]=0.0;
for (kk=0; kk<=n-1; kk++)
a[ii]=a[ii]+p[i*n+kk]*f[j*n+kk];
}
for (i=0; i<=n-1; i++)
for (j=0; j<=n-1; j++)
{ ii=i*n+j; p[ii]=q[ii];
for (kk=0; kk<=n-1; kk++)
p[ii]=p[ii]+f[i*n+kk]*a[kk*l+j];
}
for (ii=2; ii<=k; ii++)
{ for (i=0; i<=n-1; i++)
for (j=0; j<=m-1; j++)
{ jj=i*l+j; a[jj]=0.0;
for (kk=0; kk<=n-1; kk++)
a[jj]=a[jj]+p[i*n+kk]*h[j*n+kk];
}
for (i=0; i<=m-1; i++)
for (j=0; j<=m-1; j++)
{ jj=i*m+j; e[jj]=r[jj];
for (kk=0; kk<=n-1; kk++)
e[jj]=e[jj]+h[i*n+kk]*a[kk*l+j];
}
js=rinv(e,m);
if (js==0)
{ free(e); free(a); free(b); return(js);}
for (i=0; i<=n-1; i++)
for (j=0; j<=m-1; j++)
{ jj=i*m+j; g[jj]=0.0;
for (kk=0; kk<=m-1; kk++)
g[jj]=g[jj]+a[i*l+kk]*e[j*m+kk];
}
for (i=0; i<=n-1; i++)
{ jj=(ii-1)*n+i; x[jj]=0.0;
for (j=0; j<=n-1; j++)
x[jj]=x[jj]+f[i*n+j]*x[(ii-2)*n+j];
}
for (i=0; i<=m-1; i++)
{ jj=i*l; b[jj]=y[(ii-1)*m+i];
for (j=0; j<=n-1; j++)
b[jj]=b[jj]-h[i*n+j]*x[(ii-1)*n+j];
}
for (i=0; i<=n-1; i++)
{ jj=(ii-1)*n+i;
for (j=0; j<=m-1; j++)
x[jj]=x[jj]+g[i*m+j]*b[j*l];
}
if (ii<k)
{ for (i=0; i<=n-1; i++)
for (j=0; j<=n-1; j++)
{ jj=i*l+j; a[jj]=0.0;
for (kk=0; kk<=m-1; kk++)
a[jj]=a[jj]-g[i*m+kk]*h[kk*n+j];
if (i==j) a[jj]=1.0+a[jj];
}
for (i=0; i<=n-1; i++)
for (j=0; j<=n-1; j++)
{ jj=i*l+j; b[jj]=0.0;
for (kk=0; kk<=n-1; kk++)
b[jj]=b[jj]+a[i*l+kk]*p[kk*n+j];
}
for (i=0; i<=n-1; i++)
for (j=0; j<=n-1; j++)
{ jj=i*l+j; a[jj]=0.0;
for (kk=0; kk<=n-1; kk++)
a[jj]=a[jj]+b[i*l+kk]*f[j*n+kk];
}
for (i=0; i<=n-1; i++)
for (j=0; j<=n-1; j++)
{ jj=i*n+j; p[jj]=q[jj];
for (kk=0; kk<=n-1; kk++)
p[jj]=p[jj]+f[i*n+kk]*a[j*l+kk];
}
}
}
free(e); free(a); free(b);
return(js);
}
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【笔记】生成报错synthdesignERROR被打赏50分 | |
【STM32H7S78-DK评测】LTDC+DMA2D驱动RGBLCD屏幕被打赏50分 | |
【STM32H7S78-DK评测】Coremark基准测试被打赏50分 | |
【STM32H7S78-DK评测】浮点数计算性能测试被打赏50分 | |
【STM32H7S78-DK评测】Execute in place(XIP)模式学习笔记被打赏50分 | |
每周了解几个硬件知识+buckboost电路(五)被打赏10分 | |
【换取逻辑分析仪】RA8 PMU 模块功能寄存器功能说明被打赏20分 | |
野火启明6M5适配SPI被打赏20分 | |
NUCLEO-U083RC学习历程2-串口输出测试被打赏20分 | |
【笔记】STM32CUBEIDE的Noruletomaketarget编译问题被打赏50分 |