/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matzmul_m(scicos_block *block, int flag) { int mu1 = GetInPortRows(block, 1); int mu2 = GetInPortRows(block, 2); int nu = GetInPortCols(block, 2); double *u1r = GetRealInPortPtrs(block, 1); double *u1i = GetImagInPortPtrs(block, 1); double *u2r = GetRealInPortPtrs(block, 2); double *u2i = GetImagInPortPtrs(block, 2); double *yr = GetRealOutPortPtrs(block, 1); double *yi = GetImagOutPortPtrs(block, 1); C2F(wmmul)(u1r, u1i, &mu1, u2r, u2i, &mu2, yr, yi, &mu1, &mu1, &mu2, &nu); }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void shift_16_RC(scicos_block *block,int flag) { int i = 0; int mu = GetInPortRows(block,1); int nu = GetInPortCols(block,1); short *u=Getint16InPortPtrs(block,1); short *y=Getint16OutPortPtrs(block,1); int *ipar = GetIparPtrs(block); unsigned short k = (unsigned short)pow(2,16-1); for (i=0;i<mu*nu;i++) { int j = 0; short v = u[i]; for(j=0;j<-ipar[0];j++) { y[i]=v&1; if (y[i]==0) { y[i]=v>>1; y[i]=y[i]&(k-1);} else { y[i]=v>>1; y[i]=(y[i])|(k); } v=y[i]; }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void extractz(scicos_block *block,int flag) { double *ur = NULL; double *ui = NULL; double *yr = NULL; double *yi = NULL; int *r = NULL; int nu = 0,mu = 0,nr = 0,i = 0,j = 0,ij = 0,k = 0,nc = 0,nl = 0; mu=GetInPortRows(block,1); nu=GetInPortCols(block,1); nr=GetNipar(block); r=GetIparPtrs(block); ur=GetRealInPortPtrs(block,1); ui=GetImagInPortPtrs(block,1); yr=GetRealOutPortPtrs(block,1); yi=GetImagOutPortPtrs(block,1); nc=r[nr-1]; nl=r[nr-2]; k=0; for (j=0;j<nc;j++) {for (i=0;i<nl;i++) {ij=r[i]-1+(r[nl+j]-1)*mu; *(yr+k)=*(ur+ij); *(yi+k)=*(ui+ij); k++;}} }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matmul_ui8n(scicos_block *block, int flag) { if ((flag == 1) | (flag == 6)) { int mu1 = GetInPortRows(block, 1); int nu1 = GetInPortCols(block, 1); int nu2 = GetInPortCols(block, 2); unsigned char *u1 = Getuint8InPortPtrs(block, 1); unsigned char *u2 = Getuint8InPortPtrs(block, 2); unsigned char *y = Getuint8OutPortPtrs(block, 1); int l = 0; for (l = 0; l < nu2; l++) { int j = 0; for (j = 0; j < mu1; j++) { double D = 0.; int jl = j + l * mu1; int i = 0; for (i = 0; i < nu1; i++) { int ji = j + i * mu1; int il = i + l * nu1; double C = (double)(u1[ji]) * (double)(u2[il]); D = D + C; } y[jl] = (unsigned char)D; } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void shift_32_RC(scicos_block *block, int flag) { int i = 0, j = 0; int mu = GetInPortRows(block, 1); int nu = GetInPortCols(block, 1); SCSINT32_COP *u = Getint32InPortPtrs(block, 1); SCSINT32_COP *y = Getint32OutPortPtrs(block, 1); int *ipar = GetIparPtrs(block); unsigned long k = (unsigned long)pow(2, 32 - 1); for (i = 0; i < mu * nu; i++) { SCSINT32_COP v = u[i]; for (j = 0; j < -ipar[0]; j++) { y[i] = v & 1; if (y[i] == 0) { y[i] = v >> 1; y[i] = y[i] & (k - 1); } else { y[i] = v >> 1; y[i] = (y[i]) | (k); } v = y[i]; }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matmul_i8n(scicos_block *block,int flag) { if ((flag==1)|(flag==6)) { char *u1,*u2,*y; double C,D; int mu1,nu1,nu2,i,j,l,ji,jl,il; int *ipar; mu1=GetInPortRows(block,1); nu1=GetInPortCols(block,1); nu2=GetInPortCols(block,2); u1=Getint8InPortPtrs(block,1); u2=Getint8InPortPtrs(block,2); y=Getint8OutPortPtrs(block,1); ipar=GetIparPtrs(block); for (l=0;l<nu2;l++) {for(j=0;j<mu1;j++) {D=0; jl=j+l*mu1; for(i=0;i<nu1;i++) {ji=j+i*mu1; il=i+l*nu1; C=(double)(u1[ji])*(double)(u2[il]); D=D + C;} y[jl]=(char)D; } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void shift_32_LC(scicos_block *block,int flag) { int mu = GetInPortRows(block,1); int nu = GetInPortCols(block,1); long *u = Getint32InPortPtrs(block,1); long *y = Getint32OutPortPtrs(block,1); int *ipar = GetIparPtrs(block); unsigned long k = (unsigned long)pow(2,32-1); int i = 0; for (i=0;i<mu*nu;i++) { int j = 0; long v=u[i]; for(j=0;j<ipar[0];j++) { y[i]=v&k; if (y[i]==0) y[i]=v<<1; else { y[i]=v<<1; y[i]=(y[i])|(1); } v=y[i]; } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void mattran_m(scicos_block *block,int flag) { int nu = GetInPortRows(block,1); int mu = GetInPortCols(block,1); double *u = GetRealInPortPtrs(block,1); double *y = GetRealOutPortPtrs(block,1); C2F(mtran)(u,&nu,y,&mu,&nu,&mu); }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void shift_32_LA(scicos_block *block,int flag) { int i = 0; int mu = GetInPortRows(block,1); int nu = GetInPortCols(block,1); long *u = Getint32InPortPtrs(block,1); long *y = Getint32OutPortPtrs(block,1); int *ipar = GetIparPtrs(block); for (i=0;i<mu*nu;i++) y[i]=u[i]<<ipar[0]; }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void summation_ui16s(scicos_block *block,int flag) { if((flag==1)|(flag==6)) { int j = 0,k = 0; int nu = 0,mu = 0,nin = 0; unsigned short *y = NULL; int *ipar = NULL; double v = 0.,l = 0.; double *rpar = NULL; unsigned short *u = NULL; y = Getuint16OutPortPtrs(block,1); nu = GetInPortRows(block,1); mu = GetInPortCols(block,1); ipar = GetIparPtrs(block); rpar = GetRparPtrs(block); nin = GetNin(block); l = pow(2,16); if (nin==1) { v=0; u=Getuint16InPortPtrs(block,1); for (j=0;j<nu*mu;j++) { v=v+(double)u[j]; } if (v>=l) v=l-1; else if (v<0) v=0; y[0]=(unsigned short)v; } else { for (j=0;j<nu*mu;j++) { v=0; for (k=0;k<nin;k++) { u=Getuint16InPortPtrs(block,k+1); if(ipar[k]>0) { v=v+(double)u[j]; } else { v=v-(double)u[j];} } if (v>=l) v=l-1; else if (v<0) v=0; y[j]=(unsigned short)v; } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void summation_i32s(scicos_block *block,int flag) { if((flag==1)|(flag==6)) { int j = 0,k = 0; int nu = 0,mu = 0,nin = 0; long *y = NULL; int *ipar = NULL; double v = 0.,l = 0.; double *rpar = NULL; long *u = NULL; y = Getint32OutPortPtrs(block,1); nu = GetInPortRows(block,1); mu = GetInPortCols(block,1); ipar = GetIparPtrs(block); rpar = GetRparPtrs(block); nin = GetNin(block); l = pow(2,32)/2; if (nin==1) { v=0; u=Getint32InPortPtrs(block,1); for (j=0;j<nu*mu;j++) { v=v+(double)u[j]; } if (v>=l) v=l-1; else if (v<-l) v=-l; y[0]=(long)v; } else { for (j=0;j<nu*mu;j++) { v=0; for (k=0;k<nin;k++) { u=Getint32InPortPtrs(block,k+1); if(ipar[k]>0) { v=v+(double)u[j]; } else { v=v-(double)u[j];} } if (v>=l) v=l-1; else if (v<-l) v=-l; y[j]=(long)v; } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void root_coef(scicos_block *block, int flag) { int mu = GetInPortRows(block, 1); double *u = GetRealInPortPtrs(block, 1); double *y = GetRealOutPortPtrs(block, 1); if (flag == 1 || flag == 6) { C2F(dprxc)(&mu, u, y); } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void selector_m(scicos_block *block, int flag) { void *u = NULL; void *y = NULL; double *z = NULL; int nu = 0, mu = 0, ic = 0, nev = 0, nin = 0, so = 0; z = GetDstate(block); nin = GetNin(block); ic = (int)z[0]; if (flag < 3) { ic = 0; nev = GetNevIn(block); while (nev >= 1) { ic = ic + 1; nev = nev / 2; } } if (nin > 1) { mu = GetInPortRows(block, ic); nu = GetInPortCols(block, ic); u = GetInPortPtrs(block, ic); so = GetSizeOfOut(block, 1); y = GetOutPortPtrs(block, 1); memcpy(y, u, mu * nu * so); } else { mu = GetInPortRows(block, 1); nu = GetInPortCols(block, 1); u = GetInPortPtrs(block, 1); y = GetOutPortPtrs(block, ic); so = GetSizeOfIn(block, 1); memcpy(y, u, mu * nu * so); } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void bit_clear_16(scicos_block *block,int flag) { int m = 0,n = 0,i = 0; short *opar = NULL; short *u = NULL,*y = NULL; m=GetInPortRows(block,1); n=GetOutPortCols(block,1); opar=Getint16OparPtrs(block,1); u=Getint16InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); for (i=0; i<m*n; i++) y[i]=((u[i])&(*opar)); }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void gainblk_ui16e(scicos_block *block,int flag) { if ((flag==1)|(flag==6)){ int i = 0,j = 0,l = 0,ji = 0,jl = 0,il = 0; unsigned short *u = NULL,*y = NULL; int mu = 0,ny = 0,my = 0,mo = 0,no = 0; unsigned short *opar = NULL; double k = 0.,D = 0.,C = 0.; mo=GetOparSize(block,1,1); no=GetOparSize(block,1,2); mu=GetInPortRows(block,1); my=GetOutPortRows(block,1); ny=GetOutPortCols(block,1); u=Getuint16InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); opar=Getuint16OparPtrs(block,1); k=pow(2,16); if (mo*no==1){ for (i=0;i<ny*mu;++i){ D=(double)(opar[0])*(double)(u[i]); if ((D>=k)|( D<0)) {sciprint(_("overflow error")); set_block_error(-4); return;} else y[i]=(unsigned short)D; } }else{ for (l=0;l<ny;l++) {for (j=0;j<my;j++) {D=0; jl=j+l*my; for (i=0;i<mu;i++) {ji=j+i*my; il=i+l*mu; C=(double)(opar[ji])*(double)(u[il]); D=D + C;} if ((D>=k)|( D<0)) {sciprint(_("overflow error")); set_block_error(-4); return;} else y[jl]=(unsigned short)D; } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void shift_16_LA(scicos_block *block, int flag) { int i = 0; int mu = GetInPortRows(block, 1); int nu = GetInPortCols(block, 1); short *u = Getint16InPortPtrs(block, 1); short *y = Getint16OutPortPtrs(block, 1); int *ipar = GetIparPtrs(block); for (i = 0; i < mu * nu; i++) { y[i] = u[i] << ipar[0]; } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void bit_set_32(scicos_block *block, int flag) { int n, m, i; SCSINT32_COP *opar; SCSINT32_COP *u, *y; opar = Getint32OparPtrs(block, 1); u = Getint32InPortPtrs(block, 1); y = Getint32OutPortPtrs(block, 1); n = GetInPortCols(block, 1); m = GetInPortRows(block, 1); for (i = 0; i < m * n; i++) { *(y + i) = ((*(u + i)) | (*opar)); } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void bit_clear_32(scicos_block *block, int flag) { int n = 0, m = 0, i = 0; SCSINT32_COP *opar = NULL; SCSINT32_COP *u = NULL, *y = NULL; opar = Getint32OparPtrs(block, 1); u = Getint32InPortPtrs(block, 1); y = Getint32OutPortPtrs(block, 1); m = GetInPortRows(block, 1); n = GetInPortCols(block, 1); for (i = 0; i < m * n; i++) { *(y + i) = ((*(u + i)) & (*opar)); } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void gainblk_i16n(scicos_block *block,int flag) { if ((flag==1)|(flag==6)){ int i = 0,j = 0,l = 0,ji = 0,jl = 0,il = 0; short *u = NULL,*y = NULL; int mu = 0,ny = 0,my = 0,mo = 0,no = 0; short *opar = NULL; double k = 0.,D = 0.,C = 0.,t = 0.; mo=GetOparSize(block,1,1); no=GetOparSize(block,1,2); mu=GetInPortRows(block,1); my=GetOutPortRows(block,1); ny=GetOutPortCols(block,1); u=Getint16InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); opar=Getint16OparPtrs(block,1); k=pow(2,16); if (mo*no==1){ for (i=0;i<ny*mu;++i){ D=(double)(opar[0])*(double)(u[i]); t=D-(double)((int)(D/(k)))*((k)); if ((t>=k/2)|(-(t)>=k/2)) {if (t>=0) (t)=(-((k/2))+fabs(t-(double)((int)((t)/((k/2))))*((k/2)))); else (t)=-(-((k/2))+fabs(t-(double)((int)((t)/((k/2))))*((k/2))));} y[i]=(short)t; } }else{ for (l=0;l<ny;l++) {for (j=0;j<my;j++) {D=0; jl=j+l*my; for (i=0;i<mu;i++) {ji=j+i*my; il=i+l*mu; C=(double)(opar[ji])*(double)(u[il]); D=D + C;} t=D-(double)((int)(D/(k)))*((k)); if ((t>=k/2)|(-(t)>=k/2)) {if (t>=0) (t)=(-((k/2))+fabs(t-(double)((int)((t)/((k/2))))*((k/2)))); else (t)=-(-((k/2))+fabs(t-(double)((int)((t)/((k/2))))*((k/2))));} y[jl]=(short)t; } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void summation_ui32n(scicos_block *block,int flag) { if((flag==1)|(flag==6)) { int j = 0,k = 0; int nu = 0,mu = 0,nin = 0; unsigned long *y = NULL; int *ipar = NULL; double *rpar = NULL; unsigned long *u = NULL; y=Getuint32OutPortPtrs(block,1); nu=GetInPortRows(block,1); mu=GetInPortCols(block,1); ipar=GetIparPtrs(block); rpar=GetRparPtrs(block); nin=GetNin(block); if (nin==1) { y[0]=0; u=Getuint32InPortPtrs(block,1); for (j=0;j<nu*mu;j++) { y[0]=y[0]+u[j]; } } else { for (j=0;j<nu*mu;j++) { y[j]=0; for (k=0;k<nin;k++) { u=Getuint32InPortPtrs(block,k+1); if(ipar[k]>0) { y[j]=y[j]+u[j]; } else { y[j]=y[j]-u[j];} } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matmul_ui32s(scicos_block *block,int flag) { if ((flag==1)|(flag==6)) { int mu1 = GetInPortRows(block,1); int nu1 = GetInPortCols(block,1); int nu2 = GetInPortCols(block,2); unsigned long *u1 = Getuint32InPortPtrs(block,1); unsigned long *u2 = Getuint32InPortPtrs(block,2); unsigned long *y = Getuint32OutPortPtrs(block,1); double k = pow(2,32); int l = 0; for (l=0;l<nu2;l++) { int j = 0; for(j=0;j<mu1;j++) { double D = 0.; int jl = j + l*mu1; int i = 0; for(i=0;i<nu1;i++) { int ji = j + i*mu1; int il = i + l*nu1; double C = (double)(u1[ji])*(double)(u2[il]); D = D + C; } if (D>(k-1)) { y[jl]=(unsigned long)(k-1); } else if (D<0) { y[jl]=0; } else { y[jl]=(unsigned long)(D); } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void samphold4_m(scicos_block *block,int flag) { /* c Copyright INRIA Scicos block simulator returns sample and hold of the input */ if ((flag ==1)) { int m = GetInPortRows(block,1); int n = GetInPortCols(block,1); void *u = GetInPortPtrs(block,1); void *y = GetOutPortPtrs(block,1); int sz = GetSizeOfOut(block,1); memcpy(y,u,m*n*sz); } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void gainblk_i32s(scicos_block *block,int flag) { if ((flag==1)|(flag==6)){ int i = 0,j = 0,l = 0,ji = 0,jl = 0,il = 0; long *u = NULL,*y = NULL; int mu = 0,ny = 0,my = 0,mo = 0,no = 0; long *opar = NULL; double k = 0.,D = 0.,C = 0.; mo=GetOparSize(block,1,1); no=GetOparSize(block,1,2); mu=GetInPortRows(block,1); my=GetOutPortRows(block,1); ny=GetOutPortCols(block,1); u=Getint32InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); opar=Getint32OparPtrs(block,1); k=pow(2,32)/2; if (mo*no==1){ for (i=0;i<ny*mu;++i){ D=(double)(opar[0])*(double)(u[i]); if (D>=k) D=k-1; else if (D<-k) D=-k; y[i]=(long)D; } }else{ for (l=0;l<ny;l++) {for (j=0;j<my;j++) {D=0; jl=j+l*my; for (i=0;i<mu;i++) {ji=j+i*my; il=i+l*mu; C=(double)(opar[ji])*(double)(u[il]); D=D + C;} if (D>=k) D=k-1; else if (D<-k) D=-k; y[jl]=(long)D; } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matmul_i32e(scicos_block *block, int flag) { if ((flag == 1) | (flag == 6)) { int mu1 = GetInPortRows(block, 1); int nu1 = GetInPortCols(block, 1); int nu2 = GetInPortCols(block, 2); SCSINT32_COP *u1 = Getint32InPortPtrs(block, 1); SCSINT32_COP *u2 = Getint32InPortPtrs(block, 2); SCSINT32_COP *y = Getint32OutPortPtrs(block, 1); double k = pow(2, 32); int l = 0; for (l = 0; l < nu2; l++) { int j = 0; for (j = 0; j < mu1; j++) { double D = 0.; int i = 0; int jl = j + l * mu1; for (i = 0; i < nu1; i++) { int ji = j + i * mu1; int il = i + l * nu1; double C = (double)(u1[ji]) * (double)(u2[il]); D = D + C; } if ((D > ((k / 2) - 1)) | (D < -((k / 2)))) { sciprint(_("overflow error")); set_block_error(-4); return; } else { y[jl] = (SCSINT32_COP)(D); } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matmul_ui8e(scicos_block *block, int flag) { if ((flag == 1) | (flag == 6)) { int mu1 = GetInPortRows(block, 1); int nu1 = GetInPortCols(block, 1); int nu2 = GetInPortCols(block, 2); unsigned char *u1 = Getuint8InPortPtrs(block, 1); unsigned char *u2 = Getuint8InPortPtrs(block, 2); unsigned char *y = Getuint8OutPortPtrs(block, 1); double k = pow(2, 8); int l = 0; for (l = 0; l < nu2; l++) { int j = 0; for (j = 0; j < mu1; j++) { double D = 0. ; int jl = j + l * mu1; int i = 0; for (i = 0; i < nu1; i++) { int ji = j + i * mu1; int il = i + l * nu1; double C = (double)(u1[ji]) * (double)(u2[il]); D = D + C; } if ((D > (k - 1)) | (D < 0)) { sciprint(_("overflow error")); set_block_error(-4); return; } else { y[jl] = (unsigned char)(D); } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void summation(scicos_block *block, int flag) { int j = 0, k = 0; double *y = GetRealOutPortPtrs(block, 1); int nu = GetInPortRows(block, 1); int mu = GetInPortCols(block, 1); int *ipar = GetIparPtrs(block); if (flag == 1) { if (GetNin(block) == 1) { double *u = GetRealInPortPtrs(block, 1); y[0] = 0.0; for (j = 0; j < nu * mu; j++) { y[0] = y[0] + u[j]; } } else { for (j = 0; j < nu * mu; j++) { y[j] = 0.0; for (k = 0; k < GetNin(block); k++) { double *u = GetRealInPortPtrs(block, k + 1); if (ipar[k] > 0) { y[j] = y[j] + u[j]; } else { y[j] = y[j] - u[j]; } } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void cumsumz_m(scicos_block *block,int flag) { double *ur = NULL; double *ui = NULL; double *yr = NULL; double *yi = NULL; int nu = 0,mu = 0,j = 0; mu=GetInPortRows(block,1); nu=GetInPortCols(block,1); ur=GetRealInPortPtrs(block,1); ui=GetImagInPortPtrs(block,1); yr=GetRealOutPortPtrs(block,1); yi=GetImagOutPortPtrs(block,1); yr[0]=ur[0]; yi[0]=ui[0]; for(j=1;j<mu*nu;j++) { yr[j]=ur[j]+yr[j-1]; yi[j]=ui[j]+yi[j-1]; } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void summation_i16n(scicos_block *block,int flag) { if((flag==1)|(flag==6)) { int j = 0,k = 0; short *y = Getint16OutPortPtrs(block,1); int nu = GetInPortRows(block,1); int mu = GetInPortCols(block,1); int *ipar=GetIparPtrs(block); int nin = GetNin(block); if (nin==1) { short *u=Getint16InPortPtrs(block,1); y[0]=0; for (j=0;j<nu*mu;j++) { y[0]=y[0]+u[j]; } } else { for (j=0;j<nu*mu;j++) { y[j]=0; for (k=0;k<nin;k++) { short *u=Getint16InPortPtrs(block,k+1); if(ipar[k]>0) { y[j]=y[j]+u[j]; } else { y[j]=y[j]-u[j];} } } } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void mat_suml(scicos_block *block, int flag) { int j = 0; int mu = GetInPortRows(block, 1); int nu = GetInPortCols(block, 1); double *u = GetRealInPortPtrs(block, 1); double *y = GetRealOutPortPtrs(block, 1); for (j = 0; j < mu; j++) { double d = 0.; int i = 0; for (i = 0; i < nu; i++) { int ij = j + i * mu; d += *(u + ij); } *(y + j) = d; } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void matz_sqrt(scicos_block *block,int flag) { if (flag==1) { int i = 0; int mu = GetInPortRows(block,1); int nu = GetInPortCols(block,1); double *ur = GetRealInPortPtrs(block,1); double *ui = GetImagInPortPtrs(block,1); double *yr = GetRealOutPortPtrs(block,1); double *yi = GetImagOutPortPtrs(block,1); for(i=0;i<mu*nu;i++) { double inpr = ur[i]; double inpi = ui[i]; C2F(wsqrt)(&inpr,&inpi,&yr[i],&yi[i]); } } }