warnings + initialize values
[scilab.git] / scilab / modules / scicos_blocks / src / c / convert.c
1 /*  Scicos
2 *
3 *  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * See the file ./license.txt
20 */
21 /*--------------------------------------------------------------------------*/ 
22 #include <math.h>
23 #include <memory.h>
24 #include "scicos_block4.h"
25 #include "sciprint.h"
26 #include "localization.h"
27 #include "MALLOC.h"
28 /*--------------------------------------------------------------------------*/ 
29 void convert(scicos_block *block,int flag)
30 {
31  int m = 0,n = 0,i = 0;
32  int *ipar = NULL;
33  double v = 0.,w = 0.,k = 0.;
34  
35  m=GetInPortRows(block,1);
36  n=GetInPortCols(block,1);
37  ipar=GetIparPtrs(block);
38  
39  if ((flag==1)|(flag==6))
40     {
41      switch (*ipar){
42             case 1:{ 
43                    void *u = NULL,*y = NULL;
44                    int so;
45                    so=GetSizeOfOut(block,1);
46            u=GetInPortPtrs(block,1);
47            y=GetOutPortPtrs(block,1);
48            memcpy(y,u,m*n*so);
49           break;
50                            }
51             case 2:{
52                    double *u = NULL;
53                    long *y = NULL;
54                    u=GetRealInPortPtrs(block,1);
55                    y=Getint32OutPortPtrs(block,1);
56                    k=pow(2,32);
57                    for (i=0;i<m*n;i++) 
58                         {v=(double)u[i];
59                          w=v-(double)((int)(v/k))*k;
60                          if (fabs(w)>k/2-1)
61                              {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
62                              else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
63                              }
64                          y[i]=(long)w;}
65                    break;}
66             case 3:{
67                    double *u = NULL;
68                    short *y = NULL;
69                    u=GetRealInPortPtrs(block,1);
70                    y=Getint16OutPortPtrs(block,1);
71                    k=pow(2,16);
72                    for (i=0;i<m*n;i++) 
73                         {v=(double)u[i];
74                          w=v-(double)((int)(v/k))*k;
75                          if (fabs(w)>k/2-1)
76                              {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
77                              else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
78                              }
79                          y[i]=(short)w;}
80                    break;}
81             case 4:{
82                    double *u = NULL;
83                    char *y = NULL;
84                    u=GetRealInPortPtrs(block,1);
85                    y=Getint8OutPortPtrs(block,1);
86                    k=pow(2,8);
87                    for (i=0;i<m*n;i++) 
88                         {v=(double)u[i];
89                          w=v-(double)((int)(v/k))*k;
90                          if (fabs(w)>k/2-1)
91                              {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
92                              else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
93                              }
94                          y[i]=(char)w;}
95                    break;}
96             case 5:{
97                    double *u = NULL;
98                    unsigned long *y = NULL;
99                    u=GetRealInPortPtrs(block,1);
100                    y=Getuint32OutPortPtrs(block,1);
101                    k=pow(2,32);
102                    for (i=0;i<m*n;i++) 
103                         {v=(double)u[i];
104                          w=v-(double)((int)(v/k))*k;
105                          y[i]=(unsigned long)w;}
106                    break;}
107             case 6:{
108                    double *u = NULL;
109                    unsigned short *y = NULL;
110                    u=GetRealInPortPtrs(block,1);
111                    y=Getuint16OutPortPtrs(block,1);
112                    k=pow(2,16);
113                    for (i=0;i<m*n;i++) 
114                         {v=(double)u[i];
115                          w=v-(double)((int)(v/k))*k;
116                          y[i]=(unsigned short)w;}
117                    break;}
118             case 7:{
119                    double *u = NULL;
120                    unsigned char *y = NULL;
121                    u=GetRealInPortPtrs(block,1);
122                    y=Getuint8OutPortPtrs(block,1);
123                    k=pow(2,8);
124                    for (i=0;i<m*n;i++) 
125                         {v=(double)u[i];
126                          w=v-(double)((int)(v/k))*k;
127                          y[i]=(unsigned char)w;}
128                    break;}
129             case 8:{
130                    long *u = NULL;
131                    double *y = NULL;
132                    u=Getint32InPortPtrs(block,1);
133                    y=GetRealOutPortPtrs(block,1);
134                    for (i=0;i<m*n;i++) y[i]=(double) u[i];
135                    break;}
136             case 9:{
137                    long *u = NULL;
138                    short *y = NULL;
139                    u=Getint32InPortPtrs(block,1);
140                    y=Getint16OutPortPtrs(block,1);
141                    k=pow(2,16);
142                    for (i=0;i<m*n;i++) 
143                         {v=(double)u[i];
144                          w=v-(double)((int)(v/k))*k;
145                          if (fabs(w)>k/2-1)
146                              {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
147                              else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
148                              }
149                          y[i]=(short)w;}
150                    break;}
151             case 10:{
152                    long *u = NULL;
153                    char *y = NULL;
154                    u=Getint32InPortPtrs(block,1);
155                    y=Getint8OutPortPtrs(block,1);
156                    k=pow(2,8);
157                    for (i=0;i<m*n;i++) 
158                         {v=(double)u[i];
159                          w=v-(double)((int)(v/k))*k;
160                          if (fabs(w)>k/2-1)
161                              {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
162                              else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
163                              }
164                          y[i]=(char)w;}
165                    break;}
166             case 11:{
167                    long *u = NULL;
168                    unsigned short *y = NULL;
169                    u=Getint32InPortPtrs(block,1);
170                    y=Getuint16OutPortPtrs(block,1);
171                    k=pow(2,16);
172                    for (i=0;i<m*n;i++) 
173                         {v=(double)u[i];
174                          w=v-(double)((int)(v/k))*k;
175                          y[i]=(unsigned short)w;}
176                    break;}
177             case 12:{
178                    long *u = NULL;
179                    unsigned char *y = NULL;
180                    u=Getint32InPortPtrs(block,1);
181                    y=Getuint8OutPortPtrs(block,1);
182                    k=pow(2,8);
183                    for (i=0;i<m*n;i++) 
184                         {v=(double)u[i];
185                          w=v-(double)((int)(v/k))*k;
186                          y[i]=(unsigned char)w;}
187                    break;}
188             case 13:{
189                    short *u = NULL;
190                    double *y = NULL;
191                    u=Getint16InPortPtrs(block,1);
192                    y=GetRealOutPortPtrs(block,1);
193                    for (i=0;i<m*n;i++) y[i]=(double) u[i];
194                    break;}
195             case 14:{
196                    short *u = NULL;
197                    long *y = NULL;
198                    u=Getint16InPortPtrs(block,1);
199                    y=Getint32OutPortPtrs(block,1);
200                    for (i=0;i<m*n;i++) 
201                         {y[i]=(long)u[i];}
202                    break;}
203             case 15:{
204                    short *u = NULL;
205                    char *y = NULL;
206                    u=Getint16InPortPtrs(block,1);
207                    y=Getint8OutPortPtrs(block,1);
208                    k=pow(2,8);
209                    for (i=0;i<m*n;i++) 
210                         {v=(double)u[i];
211                          w=v-(double)((int)(v/k))*k;
212                          if (fabs(w)>k/2-1)
213                              {if (w>=0) w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
214                              else w=-(-(k/2)+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
215                              }
216                          y[i]=(char)w;}
217                    break;}
218             case 16:{
219                    short *u = NULL;
220                    unsigned long *y = NULL;
221                    u=Getint16InPortPtrs(block,1);
222                    y=Getuint32OutPortPtrs(block,1);
223                    for (i=0;i<m*n;i++) 
224                         {y[i]=(unsigned long)u[i];}
225                    break;}
226             case 17:{
227                    short *u = NULL;
228                    unsigned char *y = NULL;
229                    u=Getint16InPortPtrs(block,1);
230                    y=Getuint8OutPortPtrs(block,1);
231                    k=pow(2,8);
232                    for (i=0;i<m*n;i++) 
233                         {v=(double)u[i];
234                          w=v-(double)((int)(v/k))*k;
235                          y[i]=(unsigned char)w;}
236                    break;}
237             case 18:{
238                    char *u = NULL;
239                    double *y = NULL;
240                    u=Getint8InPortPtrs(block,1);
241                    y=GetRealOutPortPtrs(block,1);
242                    for (i=0;i<m*n;i++) y[i]=(double) u[i];
243                    break;}
244             case 19:{
245                    char *u = NULL;
246                    long *y = NULL;
247                    u=Getint8InPortPtrs(block,1);
248                    y=Getint32OutPortPtrs(block,1);
249                    for (i=0;i<m*n;i++) 
250                         {y[i]=(long)u[i];}
251                    break;}
252             case 20:{
253                    char *u = NULL;
254                    short *y = NULL;
255                    u=Getint8InPortPtrs(block,1);
256                    y=Getint16OutPortPtrs(block,1);
257                    for (i=0;i<m*n;i++) 
258                         {y[i]=(short)u[i];}
259                    break;}
260             case 21:{
261                    char *u = NULL;
262                    unsigned long *y = NULL;
263                    u=Getint8InPortPtrs(block,1);
264                    y=Getuint32OutPortPtrs(block,1);
265                    for (i=0;i<m*n;i++) 
266                         {y[i]=(unsigned long)u[i];}
267                    break;}
268             case 22:{
269                    char *u = NULL;
270                    unsigned short *y = NULL;
271                    u=Getint8InPortPtrs(block,1);
272                    y=Getuint16OutPortPtrs(block,1);
273                    for (i=0;i<m*n;i++) 
274                         {y[i]=(unsigned short)u[i];}
275                    break;}
276             case 23:{
277                    unsigned long *u = NULL;
278                    double *y = NULL;
279                    u=Getuint32InPortPtrs(block,1);
280                    y=GetRealOutPortPtrs(block,1);
281                    for (i=0;i<m*n;i++) y[i]=(double) u[i];
282                    break;}
283             case 24:{
284                    unsigned long *u = NULL;
285                    short *y = NULL;
286                    u=Getuint32InPortPtrs(block,1);
287                    y=Getint16OutPortPtrs(block,1);
288                    k=pow(2,16);
289                    for (i=0;i<m*n;i++) 
290                         {v=(double)u[i];
291                          w=v-(double)((int)(v/k))*k;
292                          if ((w)>k/2-1)
293                              { w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
294                              }
295                          y[i]=(short)w;}
296                    break;}
297             case 25:{
298                    unsigned long *u = NULL;
299                    char *y = NULL;
300                    u=Getuint32InPortPtrs(block,1);
301                    y=Getint8OutPortPtrs(block,1);
302                    k=pow(2,8);
303                    for (i=0;i<m*n;i++) 
304                         {v=(double)u[i];
305                          w=v-(double)((int)(v/k))*k;
306                          if ((w)>k/2-1)
307                              {w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
308                              }
309                          y[i]=(char)w;}
310                    break;}
311             case 26:{
312                    unsigned long *u = NULL;
313                    unsigned short *y = NULL;
314                    u=Getuint32InPortPtrs(block,1);
315                    y=Getuint16OutPortPtrs(block,1);
316                    k=pow(2,16);
317                    for (i=0;i<m*n;i++) 
318                         {v=(double)u[i];
319                          w=v-(double)((int)(v/k))*k;
320                          y[i]=(unsigned short)w;}
321                    break;}
322             case 27:{
323                    unsigned long *u = NULL;
324                    unsigned char *y = NULL;
325                    u=Getuint32InPortPtrs(block,1);
326                    y=Getuint8OutPortPtrs(block,1);
327                    k=pow(2,8);
328                    for (i=0;i<m*n;i++) 
329                         {v=(double)u[i];
330                          w=v-(double)((int)(v/k))*k;
331                          y[i]=(unsigned char)w;}
332                    break;}
333             case 28:{
334                    unsigned short *u = NULL;
335                    double *y = NULL;
336                    u=Getuint16InPortPtrs(block,1);
337                    y=GetRealOutPortPtrs(block,1);
338                    for (i=0;i<m*n;i++) y[i]=(double) u[i];
339                    break;}
340             case 29:{
341                    unsigned short *u = NULL;
342                    long *y = NULL;
343                    u=Getuint16InPortPtrs(block,1);
344                    y=Getint32OutPortPtrs(block,1);
345                    for (i=0;i<m*n;i++) 
346                         {y[i]=(long)u[i];}
347                    break;}
348             case 30:{
349                    unsigned short *u = NULL;
350                    char *y = NULL;
351                    u=Getuint16InPortPtrs(block,1);
352                    y=Getint8OutPortPtrs(block,1);
353                    k=pow(2,8);
354                    for (i=0;i<m*n;i++) 
355                         {v=(double)u[i];
356                          w=v-(double)((int)(v/k))*k;
357                          if (w>k/2-1)
358                              {w=(-k/2+fabs(w-(double)((int)(w/(k/2)))*(k/2)));
359                              }
360                          y[i]=(char)w;}
361                    break;}
362             case 31:{
363                    unsigned short *u = NULL;
364                    unsigned long *y = NULL;
365                    u=Getuint16InPortPtrs(block,1);
366                    y=Getuint32OutPortPtrs(block,1);
367                    for (i=0;i<m*n;i++) 
368                         {y[i]=(unsigned long)u[i];}
369                    break;}
370             case 32:{
371                    unsigned short *u = NULL;
372                    unsigned char *y = NULL;
373                    u=Getuint16InPortPtrs(block,1);
374                    y=Getuint8OutPortPtrs(block,1);
375                    k=pow(2,8);
376                    for (i=0;i<m*n;i++) 
377                         {v=(double)u[i];
378                          w=v-(double)((int)(v/k))*k;
379                          y[i]=(unsigned char)w;}
380                    break;}
381             case 33:{
382                    unsigned char *u = NULL;
383                    double *y = NULL;
384                    u=Getuint8InPortPtrs(block,1);
385                    y=GetRealOutPortPtrs(block,1);
386                    for (i=0;i<m*n;i++) y[i]=(double) u[i];
387                    break;}
388             case 34:{
389                    unsigned char *u = NULL;
390                    long *y = NULL;
391                    u=Getuint8InPortPtrs(block,1);
392                    y=Getint32OutPortPtrs(block,1);
393                    for (i=0;i<m*n;i++) 
394                         {y[i]=(long)u[i];}
395                    break;}
396             case 35:{
397                    unsigned char *u = NULL;
398                    short *y = NULL;
399                    u=Getuint8InPortPtrs(block,1);
400                    y=Getint16OutPortPtrs(block,1);
401                    for (i=0;i<m*n;i++) 
402                         {y[i]=(short)u[i];}
403                    break;}
404             case 36:{
405                    unsigned char *u = NULL;
406                    unsigned long *y = NULL;
407                    u=Getuint8InPortPtrs(block,1);
408                    y=Getuint32OutPortPtrs(block,1);
409                    for (i=0;i<m*n;i++) 
410                         {y[i]=(unsigned long)u[i];}
411                    break;}
412             case 37:{
413                    unsigned char *u = NULL;
414                    unsigned short *y = NULL;
415                    u=Getuint8InPortPtrs(block,1);
416                    y=Getuint16OutPortPtrs(block,1);
417                    for (i=0;i<m*n;i++) 
418                         {y[i]=(unsigned short)u[i];}
419                    break;}
420             case 38:{
421                    double *u = NULL;
422                    long *y = NULL;
423                    u=GetRealInPortPtrs(block,1);
424                    y=Getint32OutPortPtrs(block,1);
425                    k=pow(2,32);
426                    for (i=0;i<m*n;i++)
427                        {if (u[i]>k/2-1)
428                            {y[i]=(long)(k/2-1);}
429                         else if (u[i]<-(k/2))
430                            {y[i]=-(long)(k/2);}
431                         else {y[i]=(long)(u[i]);}
432                        }
433                    break;}
434             case 39:{
435                    double *u = NULL;
436                    short *y = NULL;
437                    u=GetRealInPortPtrs(block,1);
438                    y=Getint16OutPortPtrs(block,1);
439                    k=pow(2,16);
440                    for (i=0;i<m*n;i++) 
441                         {if (u[i]>k/2-1)
442                            {y[i]=(short)(k/2-1);}
443                         else if (u[i]<-(k/2))
444                            {y[i]=-(short)(k/2);}
445                         else {y[i]=(short)(u[i]);}
446                        }
447                    break;}
448             case 40:{
449                    double *u = NULL;
450                    char *y = NULL;
451                    u=GetRealInPortPtrs(block,1);
452                    y=Getint8OutPortPtrs(block,1);
453                    k=pow(2,8);
454                    for (i=0;i<m*n;i++) 
455                         {if (u[i]>k/2-1)
456                            {y[i]=(char)(k/2-1);}
457                         else if (u[i]<-(k/2))
458                            {y[i]=-(char)(k/2);}
459                         else {y[i]=(char)(u[i]);}
460                        }
461                    break;}
462             case 41:{
463                    double *u = NULL;
464                    unsigned long *y = NULL;
465                    u=GetRealInPortPtrs(block,1);
466                    y=Getuint32OutPortPtrs(block,1);
467                    k=pow(2,32);
468                    for (i=0;i<m*n;i++) 
469                         {if (u[i]>=k)
470                              {y[i]=(unsigned long)(k-1);}
471                         else if (u[i]<0)
472                              {y[i]=0;}
473                         else {y[i]=(unsigned long)(u[i]);}
474                         }
475                    break;}
476             case 42:{
477                    double *u = NULL;
478                    unsigned short *y = NULL;
479                    u=GetRealInPortPtrs(block,1);
480                    y=Getuint16OutPortPtrs(block,1);
481                    k=pow(2,16);
482                    for (i=0;i<m*n;i++) 
483                         {if (u[i]>=k)
484                              {y[i]=(unsigned short)(k-1);}
485                         else if (u[i]<0)
486                              {y[i]=0;}
487                         else {y[i]=(unsigned short)(u[i]);}
488                         }
489                    break;}
490             case 43:{
491                    double *u = NULL;
492                    unsigned char *y = NULL;
493                    u=GetRealInPortPtrs(block,1);
494                    y=Getuint8OutPortPtrs(block,1);
495                    k=pow(2,8);
496                    for (i=0;i<m*n;i++) 
497                         {if (u[i]>=k)
498                              {y[i]=(unsigned char)(k-1);}
499                         else if (u[i]<0)
500                              {y[i]=0;}
501                         else {y[i]=(unsigned char)(u[i]);}
502                         }
503                    break;}
504             case 44:{
505                    long *u = NULL;
506                    short *y = NULL;
507                    u=Getint32InPortPtrs(block,1);
508                    y=Getint16OutPortPtrs(block,1);
509                    k=pow(2,16);
510                    for (i=0;i<m*n;i++) 
511                         {if (u[i]>(long)(k/2-1))
512                            {y[i]=(short)(k/2-1);}
513                         else if (u[i]<-(long)(k/2))
514                            {y[i]=-(short)(k/2);}
515                         else {y[i]=(short)(u[i]);}
516                        }
517                    break;}
518             case 45:{
519                    long *u = NULL;
520                    char *y = NULL;
521                    u=Getint32InPortPtrs(block,1);
522                    y=Getint8OutPortPtrs(block,1);
523                    k=pow(2,8);
524                    for (i=0;i<m*n;i++) 
525                         {if (u[i]>(long)(k/2-1))
526                            {y[i]=(char)(k/2-1);}
527                         else if (u[i]<-(long)(k/2))
528                            {y[i]=-(char)(k/2);}
529                         else {y[i]=(char)(u[i]);}
530                        }
531                    break;}
532             case 46:{
533                    long *u = NULL;
534                    unsigned long *y = NULL;
535                    u=Getint32InPortPtrs(block,1);
536                    y=Getuint32OutPortPtrs(block,1);
537                    for (i=0;i<m*n;i++) 
538                         {if (u[i]<0)
539                              {y[i]=0;}
540                         else {y[i]=(unsigned long)(u[i]);}
541                         }
542                    break;}
543             case 47:{
544                    long *u = NULL;
545                    unsigned short *y = NULL;
546                    u=Getint32InPortPtrs(block,1);
547                    y=Getuint16OutPortPtrs(block,1);
548                    k=pow(2,16);
549                    for (i=0;i<m*n;i++) 
550                         {if (u[i]>=(long)(k))
551                              {y[i]=(unsigned short)(k-1);}
552                         else if (u[i]<0)
553                              {y[i]=0;}
554                         else {y[i]=(unsigned short)(u[i]);}
555                         }
556                    break;}
557             case 48:{
558                    long *u = NULL;
559                    unsigned char *y = NULL;
560                    u=Getint32InPortPtrs(block,1);
561                    y=Getuint8OutPortPtrs(block,1);
562                    k=pow(2,8);
563                    for (i=0;i<m*n;i++) 
564                         {if (u[i]>=(long)k)
565                              {y[i]=(unsigned char)(k-1);}
566                         else if (u[i]<0)
567                              {y[i]=0;}
568                         else {y[i]=(unsigned char)(u[i]);}
569                         }
570                    break;}
571             case 49:{
572                    short *u = NULL;
573                    char *y = NULL;
574                    u=Getint16InPortPtrs(block,1);
575                    y=Getint8OutPortPtrs(block,1);
576                    k=pow(2,8);
577                    for (i=0;i<m*n;i++) 
578                         {if (u[i]>(short)(k/2-1))
579                            {y[i]=(char)(k/2-1);}
580                         else if (u[i]<-(short)(k/2))
581                            {y[i]=-(char)(k/2);}
582                         else {y[i]=(char)(u[i]);}
583                        }
584                    break;}
585             case 50:{
586                    short *u = NULL;
587                    unsigned long *y = NULL;
588                    u=Getint16InPortPtrs(block,1);
589                    y=Getuint32OutPortPtrs(block,1);
590                    for (i=0;i<m*n;i++) 
591                         {if (u[i]<0)  y[i]=0;
592                          else y[i]=(unsigned long)u[i];}
593                    break;}
594             case 51:{
595                    short *u = NULL;
596                    unsigned short *y = NULL;
597                    u=Getint16InPortPtrs(block,1);
598                    y=Getuint16OutPortPtrs(block,1);
599                    for (i=0;i<m*n;i++) 
600                         {if (u[i]<0)
601                              {y[i]=0;}
602                         else {y[i]=(unsigned short)(u[i]);}
603                         }
604                    break;}
605             case 52:{
606                    short *u = NULL;
607                    unsigned char *y = NULL;
608                    u=Getint16InPortPtrs(block,1);
609                    y=Getuint8OutPortPtrs(block,1);
610                    k=pow(2,8);
611                    for (i=0;i<m*n;i++) 
612                         {if (u[i]>=(short)k)
613                              {y[i]=(unsigned char)(k-1);}
614                         else if (u[i]<0)
615                              {y[i]=0;}
616                         else {y[i]=(unsigned char)(u[i]);}
617                         }
618                    break;}
619             case 53:{
620                    char *u = NULL;
621                    unsigned long *y = NULL;
622                    u=Getint8InPortPtrs(block,1);
623                    y=Getuint32OutPortPtrs(block,1);
624                    for (i=0;i<m*n;i++) 
625                         {if (u[i]<0)  y[i]=0;
626                          else y[i]=(unsigned long)u[i];}
627                    break;}
628             case 54:{
629                    char *u = NULL;
630                    unsigned short *y = NULL;
631                    u=Getint8InPortPtrs(block,1);
632                    y=Getuint16OutPortPtrs(block,1);
633                    for (i=0;i<m*n;i++) 
634                         {if (u[i]<0)
635                              {y[i]=0;}
636                         else {y[i]=(unsigned short)(u[i]);}
637                         }
638                    break;}
639             case 55:{
640                    char *u = NULL;
641                    unsigned char *y = NULL;
642                    u=Getint8InPortPtrs(block,1);
643                    y=Getuint8OutPortPtrs(block,1);
644                    for (i=0;i<m*n;i++) 
645                         {if (u[i]<0)
646                              {y[i]=0;}
647                         else {y[i]=(unsigned char)(u[i]);}
648                         }
649                    break;}
650             case 56:{
651                    long *y = NULL;
652                    unsigned long *u = NULL;
653                    u=Getuint32InPortPtrs(block,1);
654                    y=Getint32OutPortPtrs(block,1);
655                    k=pow(2,32);
656                    for (i=0;i<m*n;i++) 
657                         {if (u[i]>(unsigned long)(k/2-1))
658                              {y[i]=(long)(k/2-1);}
659                         else {y[i]=(long)(u[i]);}
660                         }
661                    break;}
662             case 57:{
663                    unsigned long *u = NULL;
664                    short *y = NULL;
665                    u=Getuint32InPortPtrs(block,1);
666                    y=Getint16OutPortPtrs(block,1);
667                    k=pow(2,16);
668                    for (i=0;i<m*n;i++) 
669                         {if (u[i]>(unsigned long)(k/2-1))
670                              {y[i]=(short)(k/2-1);}
671                         else {y[i]=(short)(u[i]);}
672                         }
673                    break;}
674             case 58:{
675                    unsigned long *u = NULL;
676                    char *y = NULL;
677                    u=Getuint32InPortPtrs(block,1);
678                    y=Getint8OutPortPtrs(block,1);
679                    k=pow(2,8);
680                    for (i=0;i<m*n;i++) 
681                         {if (u[i]>(unsigned long)(k/2-1))
682                              {y[i]=(char)(k/2-1);}
683                         else {y[i]=(char)(u[i]);}
684                         }
685                    break;}
686             case 59:{
687                    unsigned long *u = NULL;
688                    unsigned short *y = NULL;
689                    u=Getuint32InPortPtrs(block,1);
690                    y=Getuint16OutPortPtrs(block,1);
691                    k=pow(2,16);
692                    for (i=0;i<m*n;i++) 
693                         {if (u[i]>(unsigned long)(k/2-1))
694                              {y[i]=(unsigned short)(k/2-1);}
695                         else {y[i]=(unsigned short)(u[i]);}
696                         }
697                    break;}
698             case 60:{
699                    unsigned long *u = NULL;
700                    unsigned char *y = NULL;
701                    u=Getuint32InPortPtrs(block,1);
702                    y=Getuint8OutPortPtrs(block,1);
703                    k=pow(2,8);
704                    for (i=0;i<m*n;i++) 
705                         {if (u[i]>(unsigned long)(k/2-1))
706                              {y[i]=(unsigned char)(k/2-1);}
707                         else {y[i]=(unsigned char)(u[i]);}
708                         }
709                    break;}
710             case 61:{
711                    unsigned short *u = NULL;
712                    short *y = NULL;
713                    u=Getuint16InPortPtrs(block,1);
714                    y=Getint16OutPortPtrs(block,1);
715                    k=pow(2,16);
716                    for (i=0;i<m*n;i++) 
717                         {if (u[i]>(unsigned short)(k/2-1))
718                              {y[i]=(short)(k/2-1);}
719                         else {y[i]=(short)(u[i]);}
720                         }
721                    break;}
722             case 62:{
723                    unsigned short *u = NULL;
724                    char *y = NULL;
725                    u=Getuint16InPortPtrs(block,1);
726                    y=Getint8OutPortPtrs(block,1);
727                    k=pow(2,8);
728                    for (i=0;i<m*n;i++) 
729                         {if (u[i]>(unsigned short)(k/2-1))
730                              {y[i]=(char)(k/2-1);}
731                         else {y[i]=(char)(u[i]);}
732                         }
733                    break;}
734             case 63:{
735                    unsigned short *u = NULL;
736                    unsigned char *y = NULL;
737                    u=Getuint16InPortPtrs(block,1);
738                    y=Getuint8OutPortPtrs(block,1);
739                    k=pow(2,8);
740                    for (i=0;i<m*n;i++) 
741                         {if (u[i]>(unsigned short)(k/2-1))
742                              {y[i]=(unsigned char)k/2-1;}
743                         else {y[i]=(unsigned char)(u[i]);}
744                         }
745                    break;}
746             case 64:{
747                    unsigned char *u = NULL;
748                    char *y = NULL;
749                    u=Getuint8InPortPtrs(block,1);
750                    y=Getint8OutPortPtrs(block,1);
751                    k=pow(2,8);
752                    for (i=0;i<m*n;i++) 
753                         {if (u[i]>(unsigned char)(k/2-1))
754                              {y[i]=(char)(k/2-1);}
755                         else {y[i]=(char)(u[i]);}
756                         }
757                    break;}
758             case 65:{
759                    double *u = NULL;
760                    long *y = NULL;
761                    u=GetRealInPortPtrs(block,1);
762                    y=Getint32OutPortPtrs(block,1);
763                    k=pow(2,32);
764                    for (i=0;i<m*n;i++)
765                    {if ((u[i]>k/2-1) | (u[i]<-(k/2)))
766                            {if (flag==1)
767                                {sciprint(_("overflow error"));
768                                 set_block_error(-4);
769                                 return;}}
770                         else {y[i]=(long)(u[i]);}
771                        }
772                    break;}
773             case 66:{
774                    double *u = NULL;
775                    short *y = NULL;
776                    u=GetRealInPortPtrs(block,1);
777                    y=Getint16OutPortPtrs(block,1);
778                    k=pow(2,16);
779                    for (i=0;i<m*n;i++) 
780                         {if ((u[i]>k/2-1) | (u[i]<-(k/2)))
781                            {if (flag==1)
782                                {sciprint(_("overflow error"));
783                                 set_block_error(-4);
784                                 return;}}
785                         else {y[i]=(short)(u[i]);}
786                        }
787                    break;}
788             case 67:{
789                    double *u = NULL;
790                    char *y = NULL;
791                    u=GetRealInPortPtrs(block,1);
792                    y=Getint8OutPortPtrs(block,1);
793                    k=pow(2,8);
794                    for (i=0;i<m*n;i++) 
795                         {if ((u[i]>k/2-1) | (u[i]<-(k/2)))
796                            {if (flag==1)
797                                {sciprint(_("overflow error"));
798                                 set_block_error(-4);
799                                 return;}}
800                         else {y[i]=(char)(u[i]);}
801                        }
802                    break;}
803             case 68:{
804                    double *u = NULL;
805                    unsigned long *y = NULL;
806                    u=GetRealInPortPtrs(block,1);
807                    y=Getuint32OutPortPtrs(block,1);
808                    k=pow(2,32);
809                    for (i=0;i<m*n;i++) 
810                         {if ((u[i]>=k) | (u[i]<0))
811                            {if (flag==1)
812                                {sciprint(_("overflow error"));
813                                 set_block_error(-4);
814                                 return;}}
815                         else {y[i]=(unsigned long)(u[i]);}
816                         }
817                    break;}
818             case 69:{
819                    double *u = NULL;
820                    unsigned short *y = NULL;
821                    u=GetRealInPortPtrs(block,1);
822                    y=Getuint16OutPortPtrs(block,1);
823                    k=pow(2,16);
824                    for (i=0;i<m*n;i++) 
825                         {if ((u[i]>=k) | (u[i]<0))
826                             {if (flag==1)
827                                {sciprint(_("overflow error"));
828                                 set_block_error(-4);
829                                 return;}}
830                         else {y[i]=(unsigned short)(u[i]);}
831                         }
832                    break;}
833             case 70:{
834                    double *u = NULL;
835                    unsigned char *y = NULL;
836                    u=GetRealInPortPtrs(block,1);
837                    y=Getuint8OutPortPtrs(block,1);
838                    k=pow(2,8);
839                    for (i=0;i<m*n;i++) 
840                         {if ((u[i]>=k) | (u[i]<0))
841                             {if (flag==1)
842                                {sciprint(_("overflow error"));
843                                 set_block_error(-4);
844                                 return;}}
845                         else {y[i]=(unsigned char)(u[i]);}
846                         }
847                    break;}
848             case 71:{
849                    long *u = NULL;
850                    short *y = NULL;
851                    u=Getint32InPortPtrs(block,1);
852                    y=Getint16OutPortPtrs(block,1);
853                    k=pow(2,16);
854                    for (i=0;i<m*n;i++) 
855                         {if ((u[i]>k/2-1) | (u[i]<-(k/2)))
856                             {if (flag==1)
857                                {sciprint(_("overflow error"));
858                                 set_block_error(-4);
859                                 return;}}
860                         else {y[i]=(short)(u[i]);}
861                        }
862                    break;}
863             case 72:{
864                    long *u = NULL;
865                    char *y = NULL;
866                    u=Getint32InPortPtrs(block,1);
867                    y=Getint8OutPortPtrs(block,1);
868                    k=pow(2,8);
869                    for (i=0;i<m*n;i++) 
870                         {if ((u[i]>k/2-1) | (u[i]<-(k/2)))
871                             {if (flag==1)
872                                {sciprint(_("overflow error"));
873                                 set_block_error(-4);
874                                 return;}}
875                         else {y[i]=(char)(u[i]);}
876                        }
877                    break;}
878             case 73:{
879                    long *u = NULL;
880                    unsigned long *y = NULL;
881                    u=Getint32InPortPtrs(block,1);
882                    y=Getuint32OutPortPtrs(block,1);
883                    for (i=0;i<m*n;i++) 
884                         {if (u[i]<0)
885                             {if (flag==1)
886                                {sciprint(_("overflow error"));
887                                 set_block_error(-4);
888                                 return;}}
889                         else {y[i]=(unsigned long)(u[i]);}
890                         }
891                    break;}
892             case 74:{
893                    long *u = NULL;
894                    unsigned short *y = NULL;
895                    u=Getint32InPortPtrs(block,1);
896                    y=Getuint16OutPortPtrs(block,1);
897                    k=pow(2,16);
898                    for (i=0;i<m*n;i++) 
899                         {if ((u[i]>=k) | (u[i]<0))
900                             {if (flag==1)
901                                {sciprint(_("overflow error"));
902                                 set_block_error(-4);
903                                 return;}}
904                         else {y[i]=(unsigned short)(u[i]);}
905                         }
906                    break;}
907             case 75:{
908                    long *u = NULL;
909                    unsigned char *y = NULL;
910                    u=Getint32InPortPtrs(block,1);
911                    y=Getuint8OutPortPtrs(block,1);
912                    k=pow(2,8);
913                    for (i=0;i<m*n;i++) 
914                         {if ((u[i]>=k) | (u[i]<0))
915                             {if (flag==1)
916                                {sciprint(_("overflow error"));
917                                 set_block_error(-4);
918                                 return;}}
919                         else {y[i]=(unsigned char)(u[i]);}
920                         }
921                    break;}
922             case 76:{
923                    short *u = NULL;
924                    char *y = NULL;
925                    u=Getint16InPortPtrs(block,1);
926                    y=Getint8OutPortPtrs(block,1);
927                    k=pow(2,8);
928                    for (i=0;i<m*n;i++) 
929                         {if ((u[i]>k/2-1) | (u[i]<-(k/2)))
930                             {if (flag==1)
931                                {sciprint(_("overflow error"));
932                                 set_block_error(-4);
933                                 return;}}
934                         else {y[i]=(char)(u[i]);}
935                        }
936                    break;}
937             case 77:{
938                    short *u = NULL;
939                    unsigned long *y = NULL;
940                    u=Getint16InPortPtrs(block,1);
941                    y=Getuint32OutPortPtrs(block,1);
942                    for (i=0;i<m*n;i++) 
943                         {if (u[i]<0)  
944                             {if (flag==1)
945                                {sciprint(_("overflow error"));
946                                 set_block_error(-4);
947                                 return;}}
948                          else y[i]=(unsigned long)u[i];}
949                    break;}
950             case 78:{
951                    short *u = NULL;
952                    unsigned short *y = NULL;
953                    u=Getint16InPortPtrs(block,1);
954                    y=Getuint16OutPortPtrs(block,1);
955                    for (i=0;i<m*n;i++) 
956                         {if (u[i]<0)
957                             {if (flag==1) 
958                                 {sciprint(_("overflow error"));
959                                  set_block_error(-4);
960                                  return;}}
961                         else {y[i]=(unsigned short)(u[i]);}
962                         }
963                    break;}
964             case 79:{
965                    short *u = NULL;
966                    unsigned char *y = NULL;
967                    u=Getint16InPortPtrs(block,1);
968                    y=Getuint8OutPortPtrs(block,1);
969                    k=pow(2,8);
970                    for (i=0;i<m*n;i++) 
971                         {if (((u[i]>=k) | (u[i]<0))& (flag==1))
972                             {if (flag==1) 
973                                  {sciprint(_("overflow error"));
974                                   set_block_error(-4);
975                                   return;}}
976                         else {y[i]=(unsigned char)(u[i]);}
977                         }
978                    break;}
979             case 80:{
980                    char *u = NULL;
981                    unsigned long *y = NULL;
982                    u=Getint8InPortPtrs(block,1);
983                    y=Getuint32OutPortPtrs(block,1);
984                    for (i=0;i<m*n;i++) 
985                         {if (u[i]<0)
986                             {if (flag==1)
987                                {sciprint(_("overflow error"));
988                                 set_block_error(-4);
989                                 return;}}
990                          else y[i]=(unsigned long)u[i];}
991                    break;}
992             case 81:{
993                    char *u = NULL;
994                    unsigned short *y = NULL;
995                    u=Getint8InPortPtrs(block,1);
996                    y=Getuint16OutPortPtrs(block,1);
997                    for (i=0;i<m*n;i++) 
998                         {if (u[i]<0)
999                             {if (flag==1)
1000                                {sciprint(_("overflow error"));
1001                                 set_block_error(-4);
1002                                 return;}}
1003                         else {y[i]=(unsigned short)(u[i]);}
1004                         }
1005                    break;}
1006             case 82:{
1007                    char *u = NULL;
1008                    unsigned char *y = NULL;
1009                    u=Getint8InPortPtrs(block,1);
1010                    y=Getuint8OutPortPtrs(block,1);
1011                    for (i=0;i<m*n;i++) 
1012                         {if (u[i]<0)
1013                             {if (flag==1)
1014                                {sciprint(_("overflow error"));
1015                                 set_block_error(-4);
1016                                 return;}}
1017                         else {y[i]=(unsigned char)(u[i]);}
1018                         }
1019                    break;}
1020             case 83:{
1021                    long *y = NULL;
1022                    unsigned long *u = NULL;
1023                    u=Getuint32InPortPtrs(block,1);
1024                    y=Getint32OutPortPtrs(block,1);
1025                    k=pow(2,32);
1026                    for (i=0;i<m*n;i++) 
1027                         {if (u[i]>(k/2-1))
1028                             {if (flag==1)
1029                                {sciprint(_("overflow error"));
1030                                 set_block_error(-4);
1031                                 return;}}
1032                         else {y[i]=(long)(u[i]);}
1033                         }
1034                    break;}
1035             case 84:{
1036                    unsigned long *u = NULL;
1037                    short *y = NULL;
1038                    u=Getuint32InPortPtrs(block,1);
1039                    y=Getint16OutPortPtrs(block,1);
1040                    k=pow(2,16);
1041                    for (i=0;i<m*n;i++) 
1042                         {if (u[i]>(k/2-1))
1043                             {if (flag==1)
1044                                {sciprint(_("overflow error"));
1045                                 set_block_error(-4);
1046                                 return;}}
1047                         else {y[i]=(short)(u[i]);}
1048                         }
1049                    break;}
1050             case 85:{
1051                    unsigned long *u = NULL;
1052                    char *y = NULL;
1053                    u=Getuint32InPortPtrs(block,1);
1054                    y=Getint8OutPortPtrs(block,1);
1055                    k=pow(2,8);
1056                    for (i=0;i<m*n;i++) 
1057                         {if (u[i]>(k/2-1))
1058                             {if (flag==1)
1059                                {sciprint(_("overflow error"));
1060                                 set_block_error(-4);
1061                                 return;}}
1062                         else {y[i]=(char)(u[i]);}
1063                         }
1064                    break;}
1065             case 86:{
1066                    unsigned long *u = NULL;
1067                    unsigned short *y = NULL;
1068                    u=Getuint32InPortPtrs(block,1);
1069                y=Getuint16OutPortPtrs(block,1);
1070                    k=pow(2,16);
1071                    for (i=0;i<m*n;i++) 
1072                         {if (u[i]>(k/2-1))
1073                             {if (flag==1)
1074                                {sciprint(_("overflow error"));
1075                                 set_block_error(-4);
1076                                 return;}}
1077                         else {y[i]=(unsigned short)(u[i]);}
1078                         }
1079                    break;}
1080             case 87:{
1081                    unsigned long *u = NULL;
1082                    unsigned char *y = NULL;
1083                    u=Getuint32InPortPtrs(block,1);
1084                    y=Getuint8OutPortPtrs(block,1);
1085                    k=pow(2,8);
1086                    for (i=0;i<m*n;i++) 
1087                         {if (u[i]>(k/2-1))
1088                             {if (flag==1)
1089                                {sciprint(_("overflow error"));
1090                                 set_block_error(-4);
1091                                 return;}}
1092                         else {y[i]=(unsigned char)(u[i]);}
1093                         }
1094                    break;}
1095             case 88:{
1096                    unsigned short *u = NULL;
1097                    short *y = NULL;
1098                    u=Getuint16InPortPtrs(block,1);
1099                    y=Getint16OutPortPtrs(block,1);
1100                    k=pow(2,16);
1101                    for (i=0;i<m*n;i++) 
1102                         {if (u[i]>(k/2-1))
1103                             {if (flag==1)
1104                                {sciprint(_("overflow error"));
1105                                 set_block_error(-4);
1106                                 return;}}
1107                         else {y[i]=(short)(u[i]);}
1108                         }
1109                    break;}
1110             case 89:{
1111                    unsigned short *u = NULL;
1112                    char *y = NULL;
1113                    u=Getuint16InPortPtrs(block,1);
1114                    y=Getint8OutPortPtrs(block,1);
1115                    k=pow(2,8);
1116                    for (i=0;i<m*n;i++) 
1117                         {if (u[i]>(k/2-1))
1118                             {if (flag==1)
1119                                {sciprint(_("overflow error"));
1120                                 set_block_error(-4);
1121                                 return;}}
1122                         else {y[i]=(char)(u[i]);}
1123                         }
1124                    break;}
1125             case 90:{
1126                    unsigned short *u = NULL;
1127                    unsigned char *y = NULL;
1128                    u=Getuint16InPortPtrs(block,1);
1129                    y=Getuint8OutPortPtrs(block,1);
1130                    k=pow(2,8);
1131                    for (i=0;i<m*n;i++) 
1132                         {if (u[i]>(k/2-1))
1133                             {if (flag==1)
1134                                {sciprint(_("overflow error"));
1135                                 set_block_error(-4);
1136                                 return;}}
1137                         else {y[i]=(unsigned char)(u[i]);}
1138                         }
1139                    break;}
1140             case 91:{
1141                    unsigned char *u = NULL;
1142                    char *y = NULL;
1143                    u=Getuint8InPortPtrs(block,1);
1144                    y=Getint8OutPortPtrs(block,1);
1145                    k=pow(2,8);
1146                    for (i=0;i<m*n;i++) 
1147                         {if (u[i]>(k/2-1))
1148                             {if (flag==1)
1149                                {sciprint(_("overflow error"));
1150                                 set_block_error(-4);
1151                                 return;}}
1152                         else {y[i]=(char)(u[i]);}
1153                         }
1154                    break;}
1155            }
1156         }
1157  }
1158 /*--------------------------------------------------------------------------*/