/*--------------------------------------------------------------------------*/ 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 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_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 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 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 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 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 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 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 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 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 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 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 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 matmul_ui32n(scicos_block *block, int flag) { if ((flag == 1) | (flag == 6)) { unsigned long *u1, *u2, *y; double k, C, D, t; 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 = Getuint32InPortPtrs(block, 1); u2 = Getuint32InPortPtrs(block, 2); y = Getuint32OutPortPtrs(block, 1); ipar = GetIparPtrs(block); k = pow(2, 32); 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; } t = D - (int)(D / (k)) * ((k)); y[jl] = (unsigned long)t; } } } }
/*--------------------------------------------------------------------------*/ 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_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_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 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 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 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 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 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]); } } }
/*--------------------------------------------------------------------------*/ 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 exttriu(scicos_block *block, int flag) { double *u = NULL; double *y = NULL; int nu = 0, mu = 0, i = 0, j = 0, ij = 0; mu = GetInPortRows(block, 1); nu = GetInPortCols(block, 1); u = GetRealInPortPtrs(block, 1); y = GetRealOutPortPtrs(block, 1); for (i = 0; i < mu * nu; i++) { *(y + i) = *(u + i); } for (j = 0; j < nu; j++) { for (i = j + 1; i < mu; i++) { ij = i + j * mu; *(y + ij) = 0; } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void cumsum_r(scicos_block *block, int flag) { double *u = NULL; double *y = NULL; int nu = 0, mu = 0, i = 0, j = 0, ij = 0; mu = GetInPortRows(block, 1); nu = GetInPortCols(block, 1); u = GetRealInPortPtrs(block, 1); y = GetRealOutPortPtrs(block, 1); for (j = 0; j < nu; j++) { i = 0; ij = i + j * mu; y[ij] = u[ij]; for (i = 1; i < mu; i++) { ij = i + j * mu; y[ij] = u[ij] + y[ij - 1]; } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void convert(scicos_block *block,int flag) { int m = 0,n = 0,i = 0; int *ipar = NULL; double v = 0.,w = 0.,k = 0.; m=GetInPortRows(block,1); n=GetInPortCols(block,1); ipar=GetIparPtrs(block); if ((flag==1)|(flag==6)) { switch (*ipar){ case 1:{ void *u = NULL,*y = NULL; int so; so=GetSizeOfOut(block,1); u=GetInPortPtrs(block,1); y=GetOutPortPtrs(block,1); memcpy(y,u,m*n*so); break; } case 2:{ double *u = NULL; long *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (fabs(w)>k/2-1) {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(long)w;} break;} case 3:{ double *u = NULL; short *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (fabs(w)>k/2-1) {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(short)w;} break;} case 4:{ double *u = NULL; char *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (fabs(w)>k/2-1) {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(char)w;} break;} case 5:{ double *u = NULL; unsigned long *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned long)w;} break;} case 6:{ double *u = NULL; unsigned short *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned short)w;} break;} case 7:{ double *u = NULL; unsigned char *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned char)w;} break;} case 8:{ long *u = NULL; double *y = NULL; u=Getint32InPortPtrs(block,1); y=GetRealOutPortPtrs(block,1); for (i=0;i<m*n;i++) y[i]=(double) u[i]; break;} case 9:{ long *u = NULL; short *y = NULL; u=Getint32InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (fabs(w)>k/2-1) {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(short)w;} break;} case 10:{ long *u = NULL; char *y = NULL; u=Getint32InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (fabs(w)>k/2-1) {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(char)w;} break;} case 11:{ long *u = NULL; unsigned short *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned short)w;} break;} case 12:{ long *u = NULL; unsigned char *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned char)w;} break;} case 13:{ short *u = NULL; double *y = NULL; u=Getint16InPortPtrs(block,1); y=GetRealOutPortPtrs(block,1); for (i=0;i<m*n;i++) y[i]=(double) u[i]; break;} case 14:{ short *u = NULL; long *y = NULL; u=Getint16InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(long)u[i];} break;} case 15:{ short *u = NULL; char *y = NULL; u=Getint16InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (fabs(w)>k/2-1) {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(char)w;} break;} case 16:{ short *u = NULL; unsigned long *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(unsigned long)u[i];} break;} case 17:{ short *u = NULL; unsigned char *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned char)w;} break;} case 18:{ char *u = NULL; double *y = NULL; u=Getint8InPortPtrs(block,1); y=GetRealOutPortPtrs(block,1); for (i=0;i<m*n;i++) y[i]=(double) u[i]; break;} case 19:{ char *u = NULL; long *y = NULL; u=Getint8InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(long)u[i];} break;} case 20:{ char *u = NULL; short *y = NULL; u=Getint8InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(short)u[i];} break;} case 21:{ char *u = NULL; unsigned long *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(unsigned long)u[i];} break;} case 22:{ char *u = NULL; unsigned short *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(unsigned short)u[i];} break;} case 23:{ unsigned long *u = NULL; double *y = NULL; u=Getuint32InPortPtrs(block,1); y=GetRealOutPortPtrs(block,1); for (i=0;i<m*n;i++) y[i]=(double) u[i]; break;} case 24:{ unsigned long *u = NULL; short *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if ((w)>k/2-1) { w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(short)w;} break;} case 25:{ unsigned long *u = NULL; char *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if ((w)>k/2-1) {w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(char)w;} break;} case 26:{ unsigned long *u = NULL; unsigned short *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned short)w;} break;} case 27:{ unsigned long *u = NULL; unsigned char *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned char)w;} break;} case 28:{ unsigned short *u = NULL; double *y = NULL; u=Getuint16InPortPtrs(block,1); y=GetRealOutPortPtrs(block,1); for (i=0;i<m*n;i++) y[i]=(double) u[i]; break;} case 29:{ unsigned short *u = NULL; long *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(long)u[i];} break;} case 30:{ unsigned short *u = NULL; char *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; if (w>k/2-1) {w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2))); } y[i]=(char)w;} break;} case 31:{ unsigned short *u = NULL; unsigned long *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(unsigned long)u[i];} break;} case 32:{ unsigned short *u = NULL; unsigned char *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {v=(double)u[i]; w=v-(double)((int)(v/k))*k; y[i]=(unsigned char)w;} break;} case 33:{ unsigned char *u = NULL; double *y = NULL; u=Getuint8InPortPtrs(block,1); y=GetRealOutPortPtrs(block,1); for (i=0;i<m*n;i++) y[i]=(double) u[i]; break;} case 34:{ unsigned char *u = NULL; long *y = NULL; u=Getuint8InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(long)u[i];} break;} case 35:{ unsigned char *u = NULL; short *y = NULL; u=Getuint8InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(short)u[i];} break;} case 36:{ unsigned char *u = NULL; unsigned long *y = NULL; u=Getuint8InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(unsigned long)u[i];} break;} case 37:{ unsigned char *u = NULL; unsigned short *y = NULL; u=Getuint8InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {y[i]=(unsigned short)u[i];} break;} case 38:{ double *u = NULL; long *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {if (u[i]>k/2-1) {y[i]=(long)(k/2-1);} else if (u[i]<-(k/2)) {y[i]=-(long)(k/2);} else {y[i]=(long)(u[i]);} } break;} case 39:{ double *u = NULL; short *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>k/2-1) {y[i]=(short)(k/2-1);} else if (u[i]<-(k/2)) {y[i]=-(short)(k/2);} else {y[i]=(short)(u[i]);} } break;} case 40:{ double *u = NULL; char *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>k/2-1) {y[i]=(char)(k/2-1);} else if (u[i]<-(k/2)) {y[i]=-(char)(k/2);} else {y[i]=(char)(u[i]);} } break;} case 41:{ double *u = NULL; unsigned long *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {if (u[i]>=k) {y[i]=(unsigned long)(k-1);} else if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned long)(u[i]);} } break;} case 42:{ double *u = NULL; unsigned short *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>=k) {y[i]=(unsigned short)(k-1);} else if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned short)(u[i]);} } break;} case 43:{ double *u = NULL; unsigned char *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>=k) {y[i]=(unsigned char)(k-1);} else if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned char)(u[i]);} } break;} case 44:{ long *u = NULL; short *y = NULL; u=Getint32InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(long)(k/2-1)) {y[i]=(short)(k/2-1);} else if (u[i]<-(long)(k/2)) {y[i]=-(short)(k/2);} else {y[i]=(short)(u[i]);} } break;} case 45:{ long *u = NULL; char *y = NULL; u=Getint32InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(long)(k/2-1)) {y[i]=(char)(k/2-1);} else if (u[i]<-(long)(k/2)) {y[i]=-(char)(k/2);} else {y[i]=(char)(u[i]);} } break;} case 46:{ long *u = NULL; unsigned long *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned long)(u[i]);} } break;} case 47:{ long *u = NULL; unsigned short *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>=(long)(k)) {y[i]=(unsigned short)(k-1);} else if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned short)(u[i]);} } break;} case 48:{ long *u = NULL; unsigned char *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>=(long)k) {y[i]=(unsigned char)(k-1);} else if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned char)(u[i]);} } break;} case 49:{ short *u = NULL; char *y = NULL; u=Getint16InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(short)(k/2-1)) {y[i]=(char)(k/2-1);} else if (u[i]<-(short)(k/2)) {y[i]=-(char)(k/2);} else {y[i]=(char)(u[i]);} } break;} case 50:{ short *u = NULL; unsigned long *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) y[i]=0; else y[i]=(unsigned long)u[i];} break;} case 51:{ short *u = NULL; unsigned short *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned short)(u[i]);} } break;} case 52:{ short *u = NULL; unsigned char *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>=(short)k) {y[i]=(unsigned char)(k-1);} else if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned char)(u[i]);} } break;} case 53:{ char *u = NULL; unsigned long *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) y[i]=0; else y[i]=(unsigned long)u[i];} break;} case 54:{ char *u = NULL; unsigned short *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned short)(u[i]);} } break;} case 55:{ char *u = NULL; unsigned char *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {y[i]=0;} else {y[i]=(unsigned char)(u[i]);} } break;} case 56:{ long *y = NULL; unsigned long *u = NULL; u=Getuint32InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {if (u[i]>(unsigned long)(k/2-1)) {y[i]=(long)(k/2-1);} else {y[i]=(long)(u[i]);} } break;} case 57:{ unsigned long *u = NULL; short *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(unsigned long)(k/2-1)) {y[i]=(short)(k/2-1);} else {y[i]=(short)(u[i]);} } break;} case 58:{ unsigned long *u = NULL; char *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(unsigned long)(k/2-1)) {y[i]=(char)(k/2-1);} else {y[i]=(char)(u[i]);} } break;} case 59:{ unsigned long *u = NULL; unsigned short *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(unsigned long)(k/2-1)) {y[i]=(unsigned short)(k/2-1);} else {y[i]=(unsigned short)(u[i]);} } break;} case 60:{ unsigned long *u = NULL; unsigned char *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(unsigned long)(k/2-1)) {y[i]=(unsigned char)(k/2-1);} else {y[i]=(unsigned char)(u[i]);} } break;} case 61:{ unsigned short *u = NULL; short *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(unsigned short)(k/2-1)) {y[i]=(short)(k/2-1);} else {y[i]=(short)(u[i]);} } break;} case 62:{ unsigned short *u = NULL; char *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(unsigned short)(k/2-1)) {y[i]=(char)(k/2-1);} else {y[i]=(char)(u[i]);} } break;} case 63:{ unsigned short *u = NULL; unsigned char *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(unsigned short)(k/2-1)) {y[i]=(unsigned char)k/2-1;} else {y[i]=(unsigned char)(u[i]);} } break;} case 64:{ unsigned char *u = NULL; char *y = NULL; u=Getuint8InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(unsigned char)(k/2-1)) {y[i]=(char)(k/2-1);} else {y[i]=(char)(u[i]);} } break;} case 65:{ double *u = NULL; long *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {if ((u[i]>k/2-1) | (u[i]<-(k/2))) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(long)(u[i]);} } break;} case 66:{ double *u = NULL; short *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if ((u[i]>k/2-1) | (u[i]<-(k/2))) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(short)(u[i]);} } break;} case 67:{ double *u = NULL; char *y = NULL; u=GetRealInPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if ((u[i]>k/2-1) | (u[i]<-(k/2))) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(char)(u[i]);} } break;} case 68:{ double *u = NULL; unsigned long *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {if ((u[i]>=k) | (u[i]<0)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned long)(u[i]);} } break;} case 69:{ double *u = NULL; unsigned short *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if ((u[i]>=k) | (u[i]<0)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned short)(u[i]);} } break;} case 70:{ double *u = NULL; unsigned char *y = NULL; u=GetRealInPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if ((u[i]>=k) | (u[i]<0)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned char)(u[i]);} } break;} case 71:{ long *u = NULL; short *y = NULL; u=Getint32InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if ((u[i]>k/2-1) | (u[i]<-(k/2))) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(short)(u[i]);} } break;} case 72:{ long *u = NULL; char *y = NULL; u=Getint32InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if ((u[i]>k/2-1) | (u[i]<-(k/2))) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(char)(u[i]);} } break;} case 73:{ long *u = NULL; unsigned long *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned long)(u[i]);} } break;} case 74:{ long *u = NULL; unsigned short *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if ((u[i]>=k) | (u[i]<0)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned short)(u[i]);} } break;} case 75:{ long *u = NULL; unsigned char *y = NULL; u=Getint32InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if ((u[i]>=k) | (u[i]<0)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned char)(u[i]);} } break;} case 76:{ short *u = NULL; char *y = NULL; u=Getint16InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if ((u[i]>k/2-1) | (u[i]<-(k/2))) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(char)(u[i]);} } break;} case 77:{ short *u = NULL; unsigned long *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else y[i]=(unsigned long)u[i];} break;} case 78:{ short *u = NULL; unsigned short *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned short)(u[i]);} } break;} case 79:{ short *u = NULL; unsigned char *y = NULL; u=Getint16InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (((u[i]>=k) | (u[i]<0))& (flag==1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned char)(u[i]);} } break;} case 80:{ char *u = NULL; unsigned long *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint32OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else y[i]=(unsigned long)u[i];} break;} case 81:{ char *u = NULL; unsigned short *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned short)(u[i]);} } break;} case 82:{ char *u = NULL; unsigned char *y = NULL; u=Getint8InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); for (i=0;i<m*n;i++) {if (u[i]<0) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned char)(u[i]);} } break;} case 83:{ long *y = NULL; unsigned long *u = NULL; u=Getuint32InPortPtrs(block,1); y=Getint32OutPortPtrs(block,1); k=pow(2,32); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(long)(u[i]);} } break;} case 84:{ unsigned long *u = NULL; short *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(short)(u[i]);} } break;} case 85:{ unsigned long *u = NULL; char *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(char)(u[i]);} } break;} case 86:{ unsigned long *u = NULL; unsigned short *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getuint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned short)(u[i]);} } break;} case 87:{ unsigned long *u = NULL; unsigned char *y = NULL; u=Getuint32InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned char)(u[i]);} } break;} case 88:{ unsigned short *u = NULL; short *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getint16OutPortPtrs(block,1); k=pow(2,16); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(short)(u[i]);} } break;} case 89:{ unsigned short *u = NULL; char *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(char)(u[i]);} } break;} case 90:{ unsigned short *u = NULL; unsigned char *y = NULL; u=Getuint16InPortPtrs(block,1); y=Getuint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(unsigned char)(u[i]);} } break;} case 91:{ unsigned char *u = NULL; char *y = NULL; u=Getuint8InPortPtrs(block,1); y=Getint8OutPortPtrs(block,1); k=pow(2,8); for (i=0;i<m*n;i++) {if (u[i]>(k/2-1)) {if (flag==1) {sciprint(_("overflow error")); set_block_error(-4); return;}} else {y[i]=(char)(u[i]);} } break;} } } }
/*--------------------------------------------------------------------------*/ SCICOS_BLOCKS_IMPEXP void mat_bksl(scicos_block *block,int flag) { double *u1 = NULL; double *u2 = NULL; double *y = NULL; int mu = 0; int nu1 = 0; int nu2 = 0; int info = 0; int i = 0,l = 0,lw = 0,lu = 0; mat_bksl_struct *ptr = NULL; double rcond = 0., ANORM = 0., EPS = 0.; mu =GetInPortRows(block,1); nu1 =GetInPortCols(block,1); nu2 =GetInPortCols(block,2); u1=GetRealInPortPtrs(block,1); u2=GetRealInPortPtrs(block,2); y=GetRealOutPortPtrs(block,1); l=Max(mu,nu1); lu=Max(4*nu1,Min(mu,nu1)+3*nu1+1); lw=Max(lu,2*Min(mu,nu1)+nu2); /*init : initialization*/ if (flag==4) {if((*(block->work)=(mat_bksl_struct*) scicos_malloc(sizeof(mat_bksl_struct)))==NULL) {set_block_error(-16); return;} ptr=*(block->work); if((ptr->ipiv=(int*) scicos_malloc(sizeof(int)*nu1))==NULL) {set_block_error(-16); scicos_free(ptr); return;} if((ptr->rank=(int*) scicos_malloc(sizeof(int)))==NULL) {set_block_error(-16); scicos_free(ptr->ipiv); scicos_free(ptr); return;} if((ptr->jpvt=(int*) scicos_malloc(sizeof(int)*nu1))==NULL) {set_block_error(-16); scicos_free(ptr->rank); scicos_free(ptr->ipiv); scicos_free(ptr); return;} if((ptr->iwork=(int*) scicos_malloc(sizeof(int)*nu1))==NULL) {set_block_error(-16); scicos_free(ptr->jpvt); scicos_free(ptr->rank); scicos_free(ptr->ipiv); scicos_free(ptr); return;} if((ptr->dwork=(double*) scicos_malloc(sizeof(double)*lw))==NULL) {set_block_error(-16); scicos_free(ptr->iwork); scicos_free(ptr->jpvt); scicos_free(ptr->rank); scicos_free(ptr->ipiv); scicos_free(ptr); return;} if((ptr->LAF=(double*) scicos_malloc(sizeof(double)*(mu*nu1)))==NULL) {set_block_error(-16); scicos_free(ptr->dwork); scicos_free(ptr->iwork); scicos_free(ptr->jpvt); scicos_free(ptr->rank); scicos_free(ptr->ipiv); scicos_free(ptr); return;} if((ptr->LA=(double*) scicos_malloc(sizeof(double)*(mu*nu1)))==NULL) {set_block_error(-16); scicos_free(ptr->LAF); scicos_free(ptr->dwork); scicos_free(ptr->iwork); scicos_free(ptr->jpvt); scicos_free(ptr->rank); scicos_free(ptr->ipiv); scicos_free(ptr); return;} if((ptr->LXB=(double*) scicos_malloc(sizeof(double)*(l*nu2)))==NULL) {set_block_error(-16); scicos_free(ptr->LA); scicos_free(ptr->LAF); scicos_free(ptr->dwork); scicos_free(ptr->iwork); scicos_free(ptr->jpvt); scicos_free(ptr->rank); scicos_free(ptr->ipiv); scicos_free(ptr); return;} } /* Terminaison */ else if (flag==5) {ptr=*(block->work); if(ptr->LXB!=NULL){ scicos_free(ptr->ipiv); scicos_free(ptr->rank); scicos_free(ptr->jpvt); scicos_free(ptr->iwork); scicos_free(ptr->LAF); scicos_free(ptr->LA); scicos_free(ptr->LXB); scicos_free(ptr->dwork); scicos_free(ptr); return;} } else { ptr=*(block->work); EPS=C2F(dlamch)("e",1L); ANORM=C2F(dlange)("1",&mu,&nu1,u1,&mu,ptr->dwork); C2F(dlacpy)("F",&mu,&nu1,u1,&mu,ptr->LA,&mu); if (mu==nu1) {C2F(dlacpy)("F",&mu,&nu1,ptr->LA,&mu,ptr->LAF,&mu); C2F(dgetrf)(&nu1,&nu1,ptr->LAF,&nu1,ptr->ipiv,&info); rcond=0; if (info==0) {C2F(dgecon)("1",&nu1,ptr->LAF,&nu1,&ANORM,&rcond,ptr->dwork,ptr->iwork,&info); if (rcond>pow(EPS,0.5)) {C2F(dlacpy)("F",&nu1,&nu2,u2,&nu1,ptr->LXB,&nu1); C2F(dgetrs)("N",&nu1,&nu2,ptr->LAF,&nu1,ptr->ipiv,ptr->LXB,&nu1,&info); C2F(dlacpy)("F",&nu1,&nu2,ptr->LXB,&nu1,y,&nu1); return; } } } rcond=pow(EPS,0.5); C2F(dlacpy)("F",&mu,&nu2,u2,&mu,ptr->LXB,&l); for (i=0;i<nu1;i++) *(ptr->jpvt+i)=0; C2F(dgelsy1)(&mu,&nu1,&nu2,ptr->LA,&mu,ptr->LXB,&l,ptr->jpvt,&rcond,ptr->rank,ptr->dwork,&lw,&info); if (info!=0) {if (flag!=6) {set_block_error(-7); return; } } C2F(dlacpy)("F",&nu1,&nu2,ptr->LXB,&l,y,&nu1); } }