1 /*
2 * -------------------------------------------------------------------------
3 * dwt3d_int.c -- 3-D signal decomposition and reconstruction interface
4 * SWT - Scilab wavelet toolbox
5 * Copyright (C) 2005-2006 Roger Liu
6 * Copyright (C) 20010-2012 Holger Nahrstaedt
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * -------------------------------------------------------------------------
22 */
23
24 #include "swt_common.h"
25 // #include <stack-c.h>
26
27 int
int_dwt3(char * fname,void * pvApiCtx)28 int_dwt3
29 #ifdef _SCILAB6_
30 (char *fname, void* pvApiCtx)
31 #else
32 (char *fname)
33 #endif
34 {
35 static int l1, m1, n1, l2, m2, n2, l3, m3, n3, l4, m4, n4;
36 static int l5, m5, n5, l6, m6, n6, l7, m7, n7, l8, m8, n8;
37 static int l9, m9, n9, l10, m10, n10, mL1, nL1, mL2, nL2;
38 static int mL3, nL3, it3, lcL3, lL3, lL2;
39 static int minrhs=2, maxrhs=9, minlhs=1, maxlhs=1;
40 char **Str2;
41 static char *Str[]= { "hm","dims","entries"};
42 int errCode, flow, family, member, ii;
43 Func ana_fun;
44 swt_wavelet pWaveStruct;
45 extend_method extMethod;
46 int mL=3, nL=1, ms=1, ns=3, mi=1, ni=4;
47 int r, c, s, zero, inc, mn, row, col, sli, r2;
48 int val1, val2, val3, stride1, stride2, stride3;
49 int si[4];
50 double *temp, *var3, *var4, *tm1;
51 double *Lo1, *Hi1, *Lo2, *Hi2, *Lo3, *Hi3;
52 int fLen1, fLen2, fLen3;
53 int readFlag;
54 int * dims1;
55 int ndims1;
56 double *input1=NULL;
57 double *input2=NULL;
58 double *input3=NULL;
59 double *input4=NULL;
60 double *input5=NULL;
61 double *input6=NULL;
62 double *input7=NULL;
63 double *input8=NULL;
64 int *int_input1=NULL;
65 int *int_input2=NULL;
66 int *int_input3=NULL;
67 int *int_input4=NULL;
68 int *int_input5=NULL;
69 int *int_input6=NULL;
70 int *int_input7=NULL;
71 int *int_input8=NULL;
72 char *input_string1=NULL;
73 char *input_string2=NULL;
74 char *input_string3=NULL;
75 char *input_string4=NULL;
76 char *input_string5=NULL;
77 char *input_string6=NULL;
78 char *input_string7=NULL;
79 char *input_string8=NULL;
80 char *input_string9=NULL;
81 //SciIntMat ssi, M;
82
83 CheckInputArgument(pvApiCtx,minrhs,maxrhs);
84 CheckOutputArgument(pvApiCtx,minlhs,maxlhs);
85
86 dwt3_form_validate (pvApiCtx, &errCode,&flow, Rhs);
87 if (errCode != SUCCESS)
88 {
89 validate_print (errCode);
90 return 0;
91 }
92
93
94
95 // GetRhsVar(1,"m",&m1,&n1,&l1);
96 // CheckLength(1,m1,3);
97 // GetListRhsVar(1,1,"S",&mL1,&nL1,&Str2);
98 // if ( strcmp(Str2[0],"hm") != 0)
99 // {
100 // Scierror(999,"Argument %d is not an hypermatrix\r\n",1);
101 // return 0;
102 // }
103 // FreeRhsSVar(Str2);
104 // GetListRhsVar(1,2,"I",&mL2,&nL2,&M);
105 // GetListRhsCVar(1,3,"d",&it3,&mL3,&nL3,&lL3,&lcL3);
106 //
107 // if (it3 == 1)
108 // {
109 // Scierror(999,"Argument %d should be real hypermatrix\r\n",1);
110 // return 0;
111 // }
112 // if ((mL2 != 1) || (nL2 != 3))
113 // {
114 // Scierror(999,"Argument %d dimension error\r\n",1);
115 // return 0;
116 // }
117 readFlag = swt_gwsupport_GetRealHypermatofdouble (pvApiCtx, fname, 1, &dims1 , &ndims1 , &input1 );
118 if(readFlag==SWT_GWSUPPORT_ERROR)
119 {
120 return 0;
121 }
122 if ((ndims1 != 3))
123 {
124 Scierror(999,"Argument %d dimension error\r\n",1);
125 return 0;
126 }
127
128 if (flow==3)
129 {
130
131 //GetRhsVar(2, "c", &m2, &n2, &l2);
132 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
133 m2=1;n2=1;
134 if(readFlag==SWT_GWSUPPORT_ERROR)
135 {
136 return 0;
137 }
138 //GetRhsVar(3, "c", &m3, &n3, &l3);
139 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 3 , &input_string3 );
140 m3=1;n3=1;
141 if(readFlag==SWT_GWSUPPORT_ERROR)
142 {
143 return 0;
144 }
145 if(strcmp(input_string3,"mode"))
146 flow = 5;
147 }
148 else
149 {
150 l1 = 0;
151 l2 = 0;
152 l3 = 0;
153 }
154
155
156
157 si[0] = 0;
158 si[1] = 0;
159 si[2] = 0;
160 si[3] = 0;
161
162 mn = mL2*nL2;
163 inc = 1;
164 zero = 0;
165
166 // temp = malloc(m1*n1*sizeof(double));
167 // C2F(tpconv)(&M.it,&zero,&mn, M.D, &inc, temp, &inc);
168 // row = (int)temp[0];
169 // col = (int)temp[1];
170 // sli = (int)temp[2];
171 // free(temp);
172 row = dims1[0];
173 col = dims1[1];
174 sli = dims1[2];
175
176 switch (flow) {
177 case 1:
178 {
179 //printf("flow 1\n");
180 //GetRhsVar(2, "c", &m2, &n2, &l2);
181 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
182 m2=1;n2=1;
183 if(readFlag==SWT_GWSUPPORT_ERROR)
184 {
185 return 0;
186 }
187 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
188
189 if (errCode != SUCCESS)
190 {
191 validate_print (errCode);
192 return 0;
193 }
194 wavelet_parser(input_string2,&family,&member);
195 wavelet_fun_parser (input_string2, &ii);
196 ana_fun = wi[ii].analysis;
197 (*ana_fun)(member, &pWaveStruct);
198
199 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
200 wave_len_validate ( col, pWaveStruct.length, &stride2, &val2);
201 wave_len_validate ( sli, pWaveStruct.length, &stride3, &val3);
202 if ((val1 == 0) || (val2 == 0) || (val3 == 0))
203 {
204 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
205 return 0;
206 }
207
208
209 r = (int)floor((row + pWaveStruct.length - 1)/2);
210 c = (int)floor((col + pWaveStruct.length - 1)/2);
211 s = (int)floor((sli + pWaveStruct.length - 1)/2);
212
213 m3 = r*c*s*8;
214 n3 = 1;
215 si[0] = r;
216 si[1] = c;
217 si[2] = s;
218 si[3] = 8;
219 // ssi.m = 1;
220 // ssi.n = 4;
221 // ssi.it = 4;
222 // ssi.l = 100;
223 // ssi.D = si;
224 var3 = malloc(m3*n3*sizeof(double));
225
226 dwt3(input1, row, col, sli, var3, row, col, sli,
227 r, c, s, pWaveStruct.pLowPass, pWaveStruct.pHiPass,
228 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
229 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
230 pWaveStruct.length, pWaveStruct.length,
231 pWaveStruct.length, getdwtMode());
232
233 //CreateVar(3, "m", &mL, &nL, &l3);
234 //CreateListVarFromPtr(3,1,"S",&ms,&ns,Str);
235 //CreateListVarFromPtr(3,2,"I",&mi,&ni,&ssi);
236 //CreateListVarFromPtr(3,3,"d",&m3, &n3, &var3);
237 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var3 );
238 if(readFlag==SWT_GWSUPPORT_ERROR)
239 {
240 return 0;
241 }
242 free(var3);
243 //AssignOutputVariable(pvApiCtx,1) = 3;
244 break;
245 }
246 case 2:
247 {
248 //sciprint("flow 2\n");
249 //GetRhsVar(2, "d", &m2, &n2, &l2);
250 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
251 if(readFlag==SWT_GWSUPPORT_ERROR)
252 {
253 return 0;
254 }
255 //GetRhsVar(3, "d", &m3, &n3, &l3);
256 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
257 if(readFlag==SWT_GWSUPPORT_ERROR)
258 {
259 return 0;
260 }
261 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
262 if (errCode != SUCCESS)
263 {
264 validate_print (errCode);
265 return 0;
266 }
267
268 if ((row<m2*n2) || (col<m2*n2) || (sli<m2*n2))
269 {
270 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
271 return 0;
272 }
273
274 r = (int)floor((row + m2 * n2 - 1)/2);
275 c = (int)floor((col + m2 * n2 - 1)/2);
276 s = (int)floor((sli + m2 * n2 - 1)/2);
277
278 si[0] = r;
279 si[1] = c;
280 si[2] = s;
281 si[3] = 8;
282 // ssi.m = 1;
283 // ssi.n = 4;
284 // ssi.it = 4;
285 // ssi.l = 100;
286 // ssi.D = si;
287 m4 = r*c*s*8;
288 n4 = 1;
289 var4 = malloc(m4*n4*sizeof(double));
290
291 dwt3(input1, row, col, sli, var4, row, col, sli,
292 r, c, s, input2, input3, input2, input3,
293 input2, input3, m2*n2, m2*n2, m2*n2, getdwtMode());
294
295 //CreateVar(4, "m", &mL, &nL, &l4);
296 //CreateListVarFromPtr(4,1,"S",&ms,&ns,Str);
297 //CreateListVarFromPtr(4,2,"I",&mi,&ni,&ssi);
298 //CreateListVarFromPtr(4,3,"d",&m4, &n4, &var4);
299 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var4 );
300 if(readFlag==SWT_GWSUPPORT_ERROR)
301 {
302 return 0;
303 }
304 free(var4);
305 //AssignOutputVariable(pvApiCtx,1) = 4;
306 break;
307 }
308 case 3:
309 {
310 //sciprint("flow 3\n");
311 //GetRhsVar(4, "c", &m4, &n4, &l4);
312 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 4 , &input_string4 );
313 m4=1;n4=1;
314 if(readFlag==SWT_GWSUPPORT_ERROR)
315 {
316 return 0;
317 }
318 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
319 if (errCode != SUCCESS)
320 {
321 validate_print (errCode);
322 return 0;
323 }
324
325 extend_method_parse (input_string4, &extMethod);
326 wavelet_parser(input_string2,&family,&member);
327 wavelet_fun_parser (input_string2, &ii);
328 ana_fun = wi[ii].analysis;
329 (*ana_fun)(member, &pWaveStruct);
330
331 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
332 wave_len_validate ( col, pWaveStruct.length, &stride2, &val2);
333 wave_len_validate ( sli, pWaveStruct.length, &stride3, &val3);
334 if ((val1 == 0) || (val2 == 0) || (val3 == 0))
335 {
336 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
337 return 0;
338 }
339
340 r = (int)floor((row + pWaveStruct.length - 1)/2);
341 c = (int)floor((col + pWaveStruct.length - 1)/2);
342 s = (int)floor((sli + pWaveStruct.length - 1)/2);
343
344 si[0] = r;
345 si[1] = c;
346 si[2] = s;
347 si[3] = 8;
348 // ssi.m = 1;
349 // ssi.n = 4;
350 // ssi.it = 4;
351 // ssi.l = 100;
352 // ssi.D = si;
353 m5 = r*c*s*8;
354 n5 = 1;
355 var3 = malloc(m5*n5*sizeof(double));
356
357 dwt3(input1, row, col, sli, var3, row, col, sli,
358 r, c, s, pWaveStruct.pLowPass, pWaveStruct.pHiPass,
359 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
360 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
361 pWaveStruct.length, pWaveStruct.length,
362 pWaveStruct.length, extMethod);
363
364 //CreateVar(5, "m", &mL, &nL, &l5);
365 //CreateListVarFromPtr(5,1,"S",&ms,&ns,Str);
366 //CreateListVarFromPtr(5,2,"I",&mi,&ni,&ssi);
367 //CreateListVarFromPtr(5,3,"d",&m5, &n5, &var3);
368 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var3 );
369 if(readFlag==SWT_GWSUPPORT_ERROR)
370 {
371 return 0;
372 }
373 free(var3);
374 //AssignOutputVariable(pvApiCtx,1) = 5;
375
376 break;
377 }
378 case 4:
379 {
380 //sciprint("flow 4\n");
381 //GetRhsVar(2, "d", &m2, &n2, &l2);
382 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
383 if(readFlag==SWT_GWSUPPORT_ERROR)
384 {
385 return 0;
386 }
387 //GetRhsVar(3, "d", &m3, &n3, &l3);
388 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
389 if(readFlag==SWT_GWSUPPORT_ERROR)
390 {
391 return 0;
392 }
393 //GetRhsVar(4, "c", &m4, &n4, &l4);
394 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 4 , &input_string4 );
395 m4=1;n4=1;
396 if(readFlag==SWT_GWSUPPORT_ERROR)
397 {
398 return 0;
399 }
400 //GetRhsVar(5, "c", &m5, &n5, &l5);
401 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 5 , &input_string5 );
402 m5=1;n5=1;
403 if(readFlag==SWT_GWSUPPORT_ERROR)
404 {
405 return 0;
406 }
407 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
408 if (errCode != SUCCESS)
409 {
410 validate_print (errCode);
411 return 0;
412 }
413 if ((row<m2*n2) || (col<m2*n2) || (sli<m2*n2))
414 {
415 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
416 return 0;
417 }
418
419 extend_method_parse (input_string5, &extMethod);
420
421 r = (int)floor((row + m2 * n2 - 1)/2);
422 c = (int)floor((col + m2 * n2 - 1)/2);
423 s = (int)floor((sli + m2 * n2 - 1)/2);
424
425 si[0] = r;
426 si[1] = c;
427 si[2] = s;
428 si[3] = 8;
429 // ssi.m = 1;
430 // ssi.n = 4;
431 // ssi.it = 4;
432 // ssi.l = 100;
433 // ssi.D = si;
434 m6 = r*c*s*8;
435 n6 = 1;
436 var4 = malloc(m6*n6*sizeof(double));
437
438 dwt3(input1, row, col, sli, var4, row, col, sli,
439 r, c, s, input2, input3, input2, input3,
440 input2, input3, m2*n2, m2*n2, m2*n2, extMethod);
441
442 //CreateVar(6, "m", &mL, &nL, &l6);
443 //CreateListVarFromPtr(6,1,"S",&ms,&ns,Str);
444 //CreateListVarFromPtr(6,2,"I",&mi,&ni,&ssi);
445 //CreateListVarFromPtr(6,3,"d",&m6, &n6, &var4);
446 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var4 );
447 if(readFlag==SWT_GWSUPPORT_ERROR)
448 {
449 return 0;
450 }
451 free(var4);
452 //AssignOutputVariable(pvApiCtx,1) = 6;
453
454 break;
455 }
456 case 5:
457 {
458 //sciprint("flow 5\n");
459 //GetRhsVar(4, "c", &m4, &n4, &l4);
460 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 4 , &input_string4 );
461 m4=1;n4=1;
462 if(readFlag==SWT_GWSUPPORT_ERROR)
463 {
464 return 0;
465 }
466 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
467 if (errCode != SUCCESS)
468 {
469 validate_print (errCode);
470 return 0;
471 }
472
473 wavelet_parser(input_string2,&family,&member);
474 wavelet_fun_parser (input_string2, &ii);
475 ana_fun = wi[ii].analysis;
476 (*ana_fun)(member, &pWaveStruct);
477 wave_len_validate ( col, pWaveStruct.length, &stride1, &val1);
478 if (val1 == 0)
479 {
480 sciprint("Input signal (column length) is not valid for selected decompostion level and wavelets!\n");
481 return 0;
482 }
483 fLen1 = pWaveStruct.length;
484 Lo1 = malloc(fLen1*sizeof(double));
485 Hi1 = malloc(fLen1*sizeof(double));
486 verbatim_copy(pWaveStruct.pLowPass, fLen1, Lo1, fLen1);
487 verbatim_copy(pWaveStruct.pHiPass, fLen1, Hi1, fLen1);
488 c = (int)floor((col + fLen1 - 1)/2);
489 filter_clear();
490
491 wavelet_parser(input_string3,&family,&member);
492 wavelet_fun_parser (input_string3, &ii);
493 ana_fun = wi[ii].analysis;
494 (*ana_fun)(member, &pWaveStruct);
495 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
496 if (val1 == 0)
497 {
498 sciprint("Input signal (row length) is not valid for selected decompostion level and wavelets!\n");
499 return 0;
500 }
501 fLen2 = pWaveStruct.length;
502 Lo2 = malloc(fLen2*sizeof(double));
503 Hi2 = malloc(fLen2*sizeof(double));
504 verbatim_copy(pWaveStruct.pLowPass, fLen2, Lo2, fLen2);
505 verbatim_copy(pWaveStruct.pHiPass, fLen2, Hi2, fLen2);
506 r = (int)floor((row + fLen2 - 1)/2);
507 filter_clear();
508
509 wavelet_parser(input_string4,&family,&member);
510 wavelet_fun_parser (input_string4, &ii);
511 ana_fun = wi[ii].analysis;
512 (*ana_fun)(member, &pWaveStruct);
513 wave_len_validate ( sli, pWaveStruct.length, &stride1, &val1);
514 if (val1 == 0)
515 {
516 sciprint("Input signal (slice length) is not valid for selected decompostion level and wavelets!\n");
517 return 0;
518 }
519 fLen3 = pWaveStruct.length;
520 Lo3 = malloc(fLen3*sizeof(double));
521 Hi3 = malloc(fLen3*sizeof(double));
522 verbatim_copy(pWaveStruct.pLowPass, fLen3, Lo3, fLen3);
523 verbatim_copy(pWaveStruct.pHiPass, fLen3, Hi3, fLen3);
524 s = (int)floor((sli + fLen3 - 1)/2);
525 filter_clear();
526
527 si[0] = r;
528 si[1] = c;
529 si[2] = s;
530 si[3] = 8;
531 // ssi.m = 1;
532 // ssi.n = 4;
533 // ssi.it = 4;
534 // ssi.l = 100;
535 // ssi.D = si;
536 m5 = r*c*s*8;
537 n5 = 1;
538 var3 = malloc(m5*n5*sizeof(double));
539
540 dwt3(input1, row, col, sli, var3, row, col, sli,
541 r, c, s, Lo1, Hi1, Lo2, Hi2, Lo3, Hi3,
542 fLen1, fLen2, fLen3, getdwtMode());
543
544 free(Lo1);
545 free(Hi1);
546 free(Lo2);
547 free(Hi2);
548 free(Lo3);
549 free(Hi3);
550
551 //CreateVar(5, "m", &mL, &nL, &l5);
552 //CreateListVarFromPtr(5,1,"S",&ms,&ns,Str);
553 //CreateListVarFromPtr(5,2,"I",&mi,&ni,&ssi);
554 //CreateListVarFromPtr(5,3,"d",&m5, &n5, &var3);
555 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var3 );
556 if(readFlag==SWT_GWSUPPORT_ERROR)
557 {
558 return 0;
559 }
560 free(var3);
561 //AssignOutputVariable(pvApiCtx,1) = 5;
562
563
564 break;
565 }
566 case 6:
567 {
568 //sciprint("flow 6\n");
569 //GetRhsVar(2, "d", &m2, &n2, &l2);
570 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
571 if(readFlag==SWT_GWSUPPORT_ERROR)
572 {
573 return 0;
574 }
575 //GetRhsVar(3, "d", &m3, &n3, &l3);
576 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
577 if(readFlag==SWT_GWSUPPORT_ERROR)
578 {
579 return 0;
580 }
581 //GetRhsVar(4, "d", &m4, &n4, &l4);
582 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,4, &m4, &n4 , &input4 );
583 if(readFlag==SWT_GWSUPPORT_ERROR)
584 {
585 return 0;
586 }
587 //GetRhsVar(5, "d", &m5, &n5, &l5);
588 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,5, &m5, &n5 , &input5 );
589 if(readFlag==SWT_GWSUPPORT_ERROR)
590 {
591 return 0;
592 }
593 //GetRhsVar(6, "d", &m6, &n6, &l6);
594 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,6, &m6, &n6 , &input6 );
595 if(readFlag==SWT_GWSUPPORT_ERROR)
596 {
597 return 0;
598 }
599 //GetRhsVar(7, "d", &m7, &n7, &l7);
600 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,7, &m7, &n7 , &input7 );
601 if(readFlag==SWT_GWSUPPORT_ERROR)
602 {
603 return 0;
604 }
605 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
606 if (errCode != SUCCESS)
607 {
608 validate_print (errCode);
609 return 0;
610 }
611 if ((col<m2*n2) || (row<m4*n4) || (sli<m6*n6))
612 {
613 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
614 return 0;
615 }
616 c = (int)floor((col + m2 * n2 - 1)/2);
617 r = (int)floor((row + m4 * n4 - 1)/2);
618 s = (int)floor((sli + m6 * n6 - 1)/2);
619
620 si[0] = r;
621 si[1] = c;
622 si[2] = s;
623 si[3] = 8;
624 // ssi.m = 1;
625 // ssi.n = 4;
626 // ssi.it = 4;
627 // ssi.l = 100;
628 // ssi.D = si;
629 m8 = r*c*s*8;
630 n8 = 1;
631 var3 = malloc(m8*n8*sizeof(double));
632
633 dwt3(input1, row, col, sli, var3, row, col, sli,
634 r, c, s, input2, input3, input4, input5,
635 input6, input7, m2*n2, m4*n4, m6*n6, getdwtMode());
636
637 //CreateVar(8, "m", &mL, &nL, &l8);
638 //CreateListVarFromPtr(8,1,"S",&ms,&ns,Str);
639 //CreateListVarFromPtr(8,2,"I",&mi,&ni,&ssi);
640 //CreateListVarFromPtr(8,3,"d",&m8, &n8, &var3);
641 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var3 );
642 if(readFlag==SWT_GWSUPPORT_ERROR)
643 {
644 return 0;
645 }
646 free(var3);
647 //AssignOutputVariable(pvApiCtx,1) = 8;
648 break;
649 }
650 case 7:
651 {
652 //sciprint("flow 7\n");
653 //GetRhsVar(2, "c", &m2, &n2, &l2);
654 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
655 m2=1;n2=1;
656 if(readFlag==SWT_GWSUPPORT_ERROR)
657 {
658 return 0;
659 }
660 //GetRhsVar(3, "c", &m3, &n3, &l3);
661 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 3 , &input_string3 );
662 m3=1;n3=1;
663 if(readFlag==SWT_GWSUPPORT_ERROR)
664 {
665 return 0;
666 }
667 //GetRhsVar(4, "c", &m4, &n4, &l4);
668 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 4 , &input_string4 );
669 m4=1;n4=1;
670 if(readFlag==SWT_GWSUPPORT_ERROR)
671 {
672 return 0;
673 }
674 //GetRhsVar(5, "c", &m5, &n5, &l5);
675 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 5 , &input_string5 );
676 m5=1;n5=1;
677 if(readFlag==SWT_GWSUPPORT_ERROR)
678 {
679 return 0;
680 }
681 //GetRhsVar(6, "c", &m6, &n6, &l6);
682 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 6 , &input_string6 );
683 m6=1;n5=1;
684 if(readFlag==SWT_GWSUPPORT_ERROR)
685 {
686 return 0;
687 }
688 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
689 if (errCode != SUCCESS)
690 {
691 validate_print (errCode);
692 return 0;
693 }
694
695 extend_method_parse (input_string6, &extMethod);
696
697 wavelet_parser(input_string2,&family,&member);
698 wavelet_fun_parser (input_string2, &ii);
699 ana_fun = wi[ii].analysis;
700 (*ana_fun)(member, &pWaveStruct);
701 wave_len_validate ( col, pWaveStruct.length, &stride1, &val1);
702 if (val1 == 0)
703 {
704 sciprint("Input signal (column length) is not valid for selected decompostion level and wavelets!\n");
705 return 0;
706 }
707 fLen1 = pWaveStruct.length;
708 Lo1 = malloc(fLen1*sizeof(double));
709 Hi1 = malloc(fLen1*sizeof(double));
710 verbatim_copy(pWaveStruct.pLowPass, fLen1, Lo1, fLen1);
711 verbatim_copy(pWaveStruct.pHiPass, fLen1, Hi1, fLen1);
712 c = (int)floor((col + fLen1 - 1)/2);
713 filter_clear();
714
715 wavelet_parser(input_string3,&family,&member);
716 wavelet_fun_parser (input_string3, &ii);
717 ana_fun = wi[ii].analysis;
718 (*ana_fun)(member, &pWaveStruct);
719 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
720 if (val1 == 0)
721 {
722 sciprint("Input signal (row length) is not valid for selected decompostion level and wavelets!\n");
723 return 0;
724 }
725 fLen2 = pWaveStruct.length;
726 Lo2 = malloc(fLen2*sizeof(double));
727 Hi2 = malloc(fLen2*sizeof(double));
728 verbatim_copy(pWaveStruct.pLowPass, fLen2, Lo2, fLen2);
729 verbatim_copy(pWaveStruct.pHiPass, fLen2, Hi2, fLen2);
730 r = (int)floor((row + fLen2 - 1)/2);
731 filter_clear();
732
733 wavelet_parser(input_string4,&family,&member);
734 wavelet_fun_parser (input_string4, &ii);
735 ana_fun = wi[ii].analysis;
736 (*ana_fun)(member, &pWaveStruct);
737 wave_len_validate ( sli, pWaveStruct.length, &stride1, &val1);
738 if (val1 == 0)
739 {
740 sciprint("Input signal (slice length) is not valid for selected decompostion level and wavelets!\n");
741 return 0;
742 }
743 fLen3 = pWaveStruct.length;
744 Lo3 = malloc(fLen3*sizeof(double));
745 Hi3 = malloc(fLen3*sizeof(double));
746 verbatim_copy(pWaveStruct.pLowPass, fLen3, Lo3, fLen3);
747 verbatim_copy(pWaveStruct.pHiPass, fLen3, Hi3, fLen3);
748 s = (int)floor((sli + fLen3 - 1)/2);
749 filter_clear();
750
751 si[0] = r;
752 si[1] = c;
753 si[2] = s;
754 si[3] = 8;
755 // ssi.m = 1;
756 // ssi.n = 4;
757 // ssi.it = 4;
758 // ssi.l = 100;
759 // ssi.D = si;
760 m7 = r*c*s*8;
761 n7 = 1;
762 var3 = malloc(m7*n7*sizeof(double));
763
764 dwt3(input1, row, col, sli, var3, row, col, sli,
765 r, c, s, Lo1, Hi1, Lo2, Hi2, Lo3, Hi3,
766 fLen1, fLen2, fLen3, extMethod);
767
768 free(Lo1);
769 free(Hi1);
770 free(Lo2);
771 free(Hi2);
772 free(Lo3);
773 free(Hi3);
774
775 //CreateVar(7, "m", &mL, &nL, &l7);
776 //CreateListVarFromPtr(7,1,"S",&ms,&ns,Str);
777 //CreateListVarFromPtr(7,2,"I",&mi,&ni,&ssi);
778 //CreateListVarFromPtr(7,3,"d",&m7, &n7, &var3);
779 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var3 );
780 if(readFlag==SWT_GWSUPPORT_ERROR)
781 {
782 return 0;
783 }
784 free(var3);
785 //AssignOutputVariable(pvApiCtx,1) = 7;
786
787 break;
788 }
789 case 8:
790 {
791 //sciprint("flow 8\n");
792 //GetRhsVar(2, "d", &m2, &n2, &l2);
793 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
794 if(readFlag==SWT_GWSUPPORT_ERROR)
795 {
796 return 0;
797 }
798 //GetRhsVar(3, "d", &m3, &n3, &l3);
799 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
800 if(readFlag==SWT_GWSUPPORT_ERROR)
801 {
802 return 0;
803 }
804 //GetRhsVar(4, "d", &m4, &n4, &l4);
805 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,4, &m4, &n4 , &input4 );
806 if(readFlag==SWT_GWSUPPORT_ERROR)
807 {
808 return 0;
809 }
810 //GetRhsVar(5, "d", &m5, &n5, &l5);
811 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,5, &m5, &n5 , &input5 );
812 if(readFlag==SWT_GWSUPPORT_ERROR)
813 {
814 return 0;
815 }
816 //GetRhsVar(6, "d", &m6, &n6, &l6);
817 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,6, &m6, &n6 , &input6 );
818 if(readFlag==SWT_GWSUPPORT_ERROR)
819 {
820 return 0;
821 }
822 //GetRhsVar(7, "d", &m7, &n7, &l7);
823 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,7, &m7, &n7 , &input7 );
824 if(readFlag==SWT_GWSUPPORT_ERROR)
825 {
826 return 0;
827 }
828 //GetRhsVar(8, "c", &m8, &n8, &l8);
829 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname,8 , &input_string8 );
830 m8=1;n8=1;
831 if(readFlag==SWT_GWSUPPORT_ERROR)
832 {
833 return 0;
834 }
835 //GetRhsVar(9, "c", &m9, &n9, &l9);
836 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname,9 , &input_string9 );
837 m9=1;n9=1;
838 if(readFlag==SWT_GWSUPPORT_ERROR)
839 {
840 return 0;
841 }
842 dwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,input_string4,input_string5,input_string6,input_string8,input_string9);
843 if (errCode != SUCCESS)
844 {
845 validate_print (errCode);
846 return 0;
847 }
848
849 if ((col<m2*n2) || (row<m4*n4) || (sli<m6*n6))
850 {
851 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
852 return 0;
853 }
854
855 extend_method_parse (input_string9, &extMethod);
856
857 c = (int)floor((col + m2 * n2 - 1)/2);
858 r = (int)floor((row + m4 * n4 - 1)/2);
859 s = (int)floor((sli + m6 * n6 - 1)/2);
860
861 si[0] = r;
862 si[1] = c;
863 si[2] = s;
864 si[3] = 8;
865 // ssi.m = 1;
866 // ssi.n = 4;
867 // ssi.it = 4;
868 // ssi.l = 100;
869 // ssi.D = si;
870 m10 = r*c*s*8;
871 n10 = 1;
872 var3 = malloc(m10*n10*sizeof(double));
873
874 dwt3(input1, row, col, sli, var3, row, col, sli,
875 r, c, s, input2, input3, input4, input5,
876 input6, input7, m2*n2, m4*n4, m6*n6, extMethod);
877
878 //CreateVar(10, "m", &mL, &nL, &l10);
879 //CreateListVarFromPtr(10,1,"S",&ms,&ns,Str);
880 //CreateListVarFromPtr(10,2,"I",&mi,&ni,&ssi);
881 //CreateListVarFromPtr(10,3,"d",&m10, &n10, &var3);
882 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 4 , var3 );
883 if(readFlag==SWT_GWSUPPORT_ERROR)
884 {
885 return 0;
886 }
887 free(var3);
888 //AssignOutputVariable(pvApiCtx,1) = 10;
889
890 break;
891 }
892 default:
893 sciprint("input not valid\n");
894 break;
895 }
896 return 0;
897 }
898
899 int
int_idwt3(char * fname,void * pvApiCtx)900 int_idwt3
901 #ifdef _SCILAB6_
902 (char *fname, void* pvApiCtx)
903 #else
904 (char *fname)
905 #endif
906 {
907 static int l1, m1, n1, l2, m2, n2, l3, m3, n3, l4, m4, n4;
908 static int l5, m5, n5, l6, m6, n6, l7, m7, n7, l8, m8, n8;
909 static int l9, m9, n9, l10, m10, n10, mL1, nL1, mL2, nL2;
910 static int mL3, nL3, it3, lcL3, lL3, lL2;
911 static int minrhs=2, maxrhs=9, minlhs=1, maxlhs=1;
912 char **Str2;
913 static char *Str[]= { "hm","dims","entries"};
914 int errCode, flow, family, member, ii;
915 int stride1, val1, stride2, val2, stride3, val3;
916 Func syn_fun;
917 swt_wavelet pWaveStruct;
918 extend_method extMethod;
919 int mL=3, nL=1, ms=1, ns=3, mi=1, ni=3;
920 int r, c, s, zero, inc, mn;
921 int si[3];
922 //SciIntMat ssi, M;
923 int row, col, sli, blo, s3;
924 double *temp, *var3, *var4, *outTemp;
925 double *Lo1, *Hi1, *Lo2, *Hi2, *Lo3, *Hi3;
926 int fLen1, fLen2, fLen3;
927 int readFlag;
928 int ndims1;
929 int *dims1;
930 double *input1=NULL;
931 double *input2=NULL;
932 double *input3=NULL;
933 double *input4=NULL;
934 double *input5=NULL;
935 double *input6=NULL;
936 double *input7=NULL;
937 double *input8=NULL;
938 int *int_input1=NULL;
939 int *int_input2=NULL;
940 int *int_input3=NULL;
941 int *int_input4=NULL;
942 int *int_input5=NULL;
943 int *int_input6=NULL;
944 int *int_input7=NULL;
945 int *int_input8=NULL;
946 char *input_string1=NULL;
947 char *input_string2=NULL;
948 char *input_string3=NULL;
949 char *input_string4=NULL;
950 char *input_string5=NULL;
951 char *input_string6=NULL;
952 char *input_string7=NULL;
953 char *input_string8=NULL;
954
955 CheckInputArgument(pvApiCtx,minrhs,maxrhs);
956 CheckOutputArgument(pvApiCtx,minlhs,maxlhs);
957
958 idwt3_form_validate (pvApiCtx, &errCode,&flow, Rhs);
959 if (errCode != SUCCESS)
960 {
961 validate_print (errCode);
962 return 0;
963 }
964 l1 = 0;
965 l2 = 0;
966 l3 = 0;
967 l4 = 0;
968 l5 = 0;
969 l6 = 0;
970 l7 = 0;
971 l8 = 0;
972
973 // GetRhsVar(1,"m",&m1,&n1,&l1);
974 // CheckLength(1,m1,3);
975 // GetListRhsVar(1,1,"S",&mL1,&nL1,&Str2);
976 // if ( strcmp(Str2[0],"hm") != 0)
977 // {
978 // Scierror(999,"Argument %d is not an hypermatrix\r\n",1);
979 // return 0;
980 // }
981 // FreeRhsSVar(Str2);
982 // GetListRhsVar(1,2,"I",&mL2,&nL2,&M);
983 // GetListRhsCVar(1,3,"d",&it3,&mL3,&nL3,&lL3,&lcL3);
984 //
985 // if (it3 == 1)
986 // {
987 // Scierror(999,"Argument %d should be real hypermatrix\r\n",1);
988 // return 0;
989 // }
990 // if ((mL2 != 1) || (nL2 != 4))
991 // {
992 // Scierror(999,"Argument %d dimension error\r\n",1);
993 // return 0;
994 // }
995
996 readFlag = swt_gwsupport_GetRealHypermatofdouble (pvApiCtx, fname, 1, &dims1 , &ndims1 , &input1 );
997 if(readFlag==SWT_GWSUPPORT_ERROR)
998 {
999 return 0;
1000 }
1001 if ((ndims1 != 4))
1002 {
1003 Scierror(999,"Argument %d dimension error\r\n",1);
1004 return 0;
1005 }
1006
1007 // mn = mL2*nL2;
1008 // inc = 1;
1009 // zero = 0;
1010 // //temp = malloc((m1*n1)*sizeof(double));
1011 // temp = malloc((4)*sizeof(double));
1012 // C2F(tpconv)(&M.it,&zero,&mn, M.D, &inc, temp, &inc);
1013 // row = (int)temp[0];
1014 // col = (int)temp[1];
1015 // sli = (int)temp[2];
1016 // blo = (int)temp[3];
1017 // free(temp);
1018 row = dims1[0];
1019 col = dims1[1];
1020 sli = dims1[2];
1021 blo = dims1[3];
1022
1023 if (blo != 8)
1024 {
1025 sciprint("Input is not dwt3 result!\n");
1026 return 0;
1027 }
1028
1029 switch (flow) {
1030 case 1:
1031 {
1032 //GetRhsVar(2, "c", &m2, &n2, &l2);
1033 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
1034 m2=1;n2=1;
1035 if(readFlag==SWT_GWSUPPORT_ERROR)
1036 {
1037 return 0;
1038 }
1039 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1040
1041 if (errCode != SUCCESS)
1042 {
1043 validate_print (errCode);
1044 return 0;
1045 }
1046
1047 wavelet_parser(input_string2,&family,&member);
1048 wavelet_fun_parser (input_string2, &ii);
1049 syn_fun = wi[ii].synthesis;
1050 (*syn_fun)(member, &pWaveStruct);
1051
1052 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
1053 wave_len_validate ( col, pWaveStruct.length, &stride2, &val2);
1054 wave_len_validate ( sli, pWaveStruct.length, &stride3, &val3);
1055 if ((val1 == 0) || (val2 == 0) || (val3 == 0))
1056 {
1057 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
1058 return 0;
1059 }
1060
1061 r = row * 2 - pWaveStruct.length + 2;
1062 c = col * 2 - pWaveStruct.length + 2;
1063 s = sli * 2 - pWaveStruct.length + 2;
1064
1065 si[0] = r;
1066 si[1] = c;
1067 si[2] = s;
1068
1069 // ssi.m = 1;
1070 // ssi.n = 3;
1071 // ssi.it = 4;
1072 // ssi.l = 100;
1073 // ssi.D = si;
1074 m3 = r*c*s;
1075 n3 = 1;
1076 var3 = malloc(m3*n3*sizeof(double));
1077
1078 idwt3(input1, row, col, sli, var3, r, c, s,
1079 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
1080 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
1081 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
1082 pWaveStruct.length, pWaveStruct.length,
1083 pWaveStruct.length);
1084
1085 /* output */
1086 //CreateVar(3, "m", &mL, &nL, &l3);
1087 //CreateListVarFromPtr(3,1,"S",&ms,&ns,Str);
1088 //CreateListVarFromPtr(3,2,"I",&mi,&ni,&ssi);
1089 //CreateListVarFromPtr(3,3,"d",&m3, &n3, &var3);
1090 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1091 if(readFlag==SWT_GWSUPPORT_ERROR)
1092 {
1093 return 0;
1094 }
1095 free(var3);
1096 //AssignOutputVariable(pvApiCtx,1) = 3;
1097 break;
1098 }
1099 case 2:
1100 {
1101 //sciprint("flow 2\n");
1102 //GetRhsVar(2, "c", &m2, &n2, &l2);
1103 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
1104 m2=1;n2=1;
1105 if(readFlag==SWT_GWSUPPORT_ERROR)
1106 {
1107 return 0;
1108 }
1109 //GetRhsVar(3, "i", &m3, &n3, &l3);
1110 readFlag = swt_gwsupport_GetRealMatrixOfDoublesAsInteger (pvApiCtx, fname, 3, &m3, &n3 , &int_input3 );
1111 if(readFlag==SWT_GWSUPPORT_ERROR)
1112 {
1113 return 0;
1114 }
1115 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1116 if (errCode != SUCCESS)
1117 {
1118 validate_print (errCode);
1119 return 0;
1120 }
1121
1122 wavelet_parser(input_string2,&family,&member);
1123 wavelet_fun_parser (input_string2, &ii);
1124 syn_fun = wi[ii].synthesis;
1125 (*syn_fun)(member, &pWaveStruct);
1126
1127 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
1128 wave_len_validate ( col, pWaveStruct.length, &stride2, &val2);
1129 wave_len_validate ( sli, pWaveStruct.length, &stride3, &val3);
1130 if ((val1 == 0) || (val2 == 0) || (val3 == 0))
1131 {
1132 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
1133 return 0;
1134 }
1135
1136 r = int_input3[0];
1137 c = int_input3[1];
1138 s = int_input3[2];
1139
1140 if ((r>(row * 2 - pWaveStruct.length + 2)) ||
1141 (c>(col * 2 - pWaveStruct.length + 2)) ||
1142 (s>(sli * 2 - pWaveStruct.length + 2)))
1143 {
1144 sciprint("size argument is not valid!\n");
1145 return 0;
1146 }
1147
1148 si[0] = r;
1149 si[1] = c;
1150 si[2] = s;
1151
1152 // ssi.m = 1;
1153 // ssi.n = 3;
1154 // ssi.it = 4;
1155 // ssi.l = 100;
1156 // ssi.D = si;
1157 m4 = r*c*s;
1158 n4 = 1;
1159 var3 = malloc(m4*n4*sizeof(double));
1160
1161 idwt3(input1, row, col, sli, var3, r, c, s,
1162 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
1163 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
1164 pWaveStruct.pLowPass, pWaveStruct.pHiPass,
1165 pWaveStruct.length, pWaveStruct.length,
1166 pWaveStruct.length);
1167
1168
1169 //CreateVar(4, "m", &mL, &nL, &l4);
1170 //CreateListVarFromPtr(4,1,"S",&ms,&ns,Str);
1171 //CreateListVarFromPtr(4,2,"I",&mi,&ni,&ssi);
1172 //CreateListVarFromPtr(4,3,"d",&m4, &n4, &var3);
1173 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1174 if(readFlag==SWT_GWSUPPORT_ERROR)
1175 {
1176 return 0;
1177 }
1178 free(var3);
1179 //AssignOutputVariable(pvApiCtx,1) = 4;
1180 break;
1181 }
1182 case 3:
1183 {
1184 //sciprint("flow 3\n");
1185 ////GetRhsVar(2, "d", &m2, &n2, &l2);
1186 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
1187 if(readFlag==SWT_GWSUPPORT_ERROR)
1188 {
1189 return 0;
1190 }
1191 //GetRhsVar(3, "d", &m3, &n3, &l3);
1192 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
1193 if(readFlag==SWT_GWSUPPORT_ERROR)
1194 {
1195 return 0;
1196 }
1197 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1198 if (errCode != SUCCESS)
1199 {
1200 validate_print (errCode);
1201 return 0;
1202 }
1203 if ((row<m2*n2) || (col<m2*n2) || (sli<m2*n2))
1204 {
1205 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
1206 return 0;
1207 }
1208
1209 r = row * 2 - m2 * n2 + 2;
1210 c = col * 2 - m2 * n2 + 2;
1211 s = sli * 2 - m2 * n2 + 2;
1212
1213 si[0] = r;
1214 si[1] = c;
1215 si[2] = s;
1216
1217 // ssi.m = 1;
1218 // ssi.n = 3;
1219 // ssi.it = 4;
1220 // ssi.l = 100;
1221 // ssi.D = si;
1222 m4 = r*c*s;
1223 n4 = 1;
1224 var3 = malloc(m4*n4*sizeof(double));
1225
1226 idwt3(input1, row, col, sli, var3, r, c, s,
1227 input2, input3, input2, input3,
1228 input2, input3, m2 * n2, m2 * n2, m2 * n2);
1229
1230 /* output */
1231 //CreateVar(4, "m", &mL, &nL, &l4);
1232 //CreateListVarFromPtr(4,1,"S",&ms,&ns,Str);
1233 //CreateListVarFromPtr(4,2,"I",&mi,&ni,&ssi);
1234 //CreateListVarFromPtr(4,3,"d",&m4, &n4, &var3);
1235 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1236 if(readFlag==SWT_GWSUPPORT_ERROR)
1237 {
1238 return 0;
1239 }
1240 free(var3);
1241 //AssignOutputVariable(pvApiCtx,1) = 4;
1242 break;
1243 }
1244 case 4:
1245 {
1246 //sciprint("flow 4\n");
1247 //GetRhsVar(2, "d", &m2, &n2, &l2);
1248 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
1249 if(readFlag==SWT_GWSUPPORT_ERROR)
1250 {
1251 return 0;
1252 }
1253 //GetRhsVar(3, "d", &m3, &n3, &l3);
1254 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
1255 if(readFlag==SWT_GWSUPPORT_ERROR)
1256 {
1257 return 0;
1258 }
1259 //GetRhsVar(4, "i", &m4, &n4, &l4);
1260 readFlag = swt_gwsupport_GetRealMatrixOfDoublesAsInteger (pvApiCtx, fname,4, &m4, &n4 , &int_input4 );
1261 if(readFlag==SWT_GWSUPPORT_ERROR)
1262 {
1263 return 0;
1264 }
1265 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1266 if (errCode != SUCCESS)
1267 {
1268 validate_print (errCode);
1269 return 0;
1270 }
1271 if ((row<m2*n2) || (col<m2*n2) || (sli<m2*n2))
1272 {
1273 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
1274 return 0;
1275 }
1276
1277 r = int_input4[0];
1278 c = int_input4[1];
1279 s = int_input4[2];
1280
1281 if ((r>(row * 2 - m2*n2 + 2)) ||
1282 (c>(col * 2 - m2*n2 + 2)) ||
1283 (s>(sli * 2 - m2*n2 + 2)))
1284 {
1285 sciprint("size argument is not valid!\n");
1286 return 0;
1287 }
1288
1289 si[0] = r;
1290 si[1] = c;
1291 si[2] = s;
1292
1293 // ssi.m = 1;
1294 // ssi.n = 3;
1295 // ssi.it = 4;
1296 // ssi.l = 100;
1297 // ssi.D = si;
1298 m5 = r*c*s;
1299 n5 = 1;
1300 var3 = malloc(m5*n5*sizeof(double));
1301
1302 idwt3(input1, row, col, sli, var3, r, c, s,
1303 input2, input3, input2, input3,
1304 input2, input3, m2 * n2, m2 * n2, m2 * n2);
1305
1306 /* output */
1307 //CreateVar(5, "m", &mL, &nL, &l5);
1308 //CreateListVarFromPtr(5,1,"S",&ms,&ns,Str);
1309 //CreateListVarFromPtr(5,2,"I",&mi,&ni,&ssi);
1310 //CreateListVarFromPtr(5,3,"d",&m5, &n5, &var3);
1311 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1312 if(readFlag==SWT_GWSUPPORT_ERROR)
1313 {
1314 return 0;
1315 }
1316 free(var3);
1317 //AssignOutputVariable(pvApiCtx,1) = 5;
1318 break;
1319 }
1320 case 5:
1321 {
1322 //sciprint("flow 5\n");
1323
1324 //GetRhsVar(2, "c", &m2, &n2, &l2);
1325 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
1326 m2=1;n2=1;
1327 if(readFlag==SWT_GWSUPPORT_ERROR)
1328 {
1329 return 0;
1330 }
1331 //GetRhsVar(3, "c", &m3, &n3, &l3);
1332 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 3 , &input_string3 );
1333 m3=1;n3=1;
1334 if(readFlag==SWT_GWSUPPORT_ERROR)
1335 {
1336 return 0;
1337 }
1338 //GetRhsVar(4, "c", &m4, &n4, &l4);
1339 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 4 , &input_string4 );
1340 m4=1;n4=1;
1341 if(readFlag==SWT_GWSUPPORT_ERROR)
1342 {
1343 return 0;
1344 }
1345 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1346 if (errCode != SUCCESS)
1347 {
1348 validate_print (errCode);
1349 return 0;
1350 }
1351
1352 wavelet_parser(input_string2,&family,&member);
1353 wavelet_fun_parser (input_string2, &ii);
1354 syn_fun = wi[ii].synthesis;
1355 (*syn_fun)(member, &pWaveStruct);
1356 wave_len_validate ( col, pWaveStruct.length, &stride1, &val1);
1357 if (val1 == 0)
1358 {
1359 sciprint("Input signal (column length) is not valid for selected decompostion level and wavelets!\n");
1360 return 0;
1361 }
1362 fLen1 = pWaveStruct.length;
1363 Lo1 = malloc(fLen1*sizeof(double));
1364 Hi1 = malloc(fLen1*sizeof(double));
1365 verbatim_copy(pWaveStruct.pLowPass, fLen1, Lo1, fLen1);
1366 verbatim_copy(pWaveStruct.pHiPass, fLen1, Hi1, fLen1);
1367 c = (col * 2 - fLen1 + 2);
1368
1369 wavelet_parser(input_string3,&family,&member);
1370 wavelet_fun_parser (input_string3, &ii);
1371 syn_fun = wi[ii].synthesis;
1372 (*syn_fun)(member, &pWaveStruct);
1373 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
1374 if (val1 == 0)
1375 {
1376 sciprint("Input signal (row length) is not valid for selected decompostion level and wavelets!\n");
1377 return 0;
1378 }
1379 fLen2 = pWaveStruct.length;
1380 Lo2 = malloc(fLen2*sizeof(double));
1381 Hi2 = malloc(fLen2*sizeof(double));
1382 verbatim_copy(pWaveStruct.pLowPass, fLen2, Lo2, fLen2);
1383 verbatim_copy(pWaveStruct.pHiPass, fLen2, Hi2, fLen2);
1384 r = (row * 2 - fLen2 + 2);
1385
1386 wavelet_parser(input_string4,&family,&member);
1387 wavelet_fun_parser (input_string4, &ii);
1388 syn_fun = wi[ii].synthesis;
1389 (*syn_fun)(member, &pWaveStruct);
1390 wave_len_validate ( sli, pWaveStruct.length, &stride1, &val1);
1391 if (val1 == 0)
1392 {
1393 sciprint("Input signal (slice length) is not valid for selected decompostion level and wavelets!\n");
1394 return 0;
1395 }
1396 fLen3 = pWaveStruct.length;
1397 Lo3 = malloc(fLen3*sizeof(double));
1398 Hi3 = malloc(fLen3*sizeof(double));
1399 verbatim_copy(pWaveStruct.pLowPass, fLen3, Lo3, fLen3);
1400 verbatim_copy(pWaveStruct.pHiPass, fLen3, Hi3, fLen3);
1401 s = (sli * 2 - fLen3 + 2);
1402
1403 si[0] = r;
1404 si[1] = c;
1405 si[2] = s;
1406
1407 // ssi.m = 1;
1408 // ssi.n = 3;
1409 // ssi.it = 4;
1410 // ssi.l = 100;
1411 // ssi.D = si;
1412 m5 = r*c*s;
1413 n5 = 1;
1414 var3 = malloc(m5*n5*sizeof(double));
1415
1416 idwt3(input1, row, col, sli, var3, r, c, s,
1417 Lo3, Hi3, Lo2, Hi2, Lo1, Hi1, fLen3, fLen2, fLen1);
1418
1419 free(Lo1);
1420 free(Hi1);
1421 free(Lo2);
1422 free(Hi2);
1423 free(Lo3);
1424 free(Hi3);
1425
1426 /* output */
1427 //CreateVar(5, "m", &mL, &nL, &l5);
1428 //CreateListVarFromPtr(5,1,"S",&ms,&ns,Str);
1429 //CreateListVarFromPtr(5,2,"I",&mi,&ni,&ssi);
1430 //CreateListVarFromPtr(5,3,"d",&m5, &n5, &var3);
1431 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1432 if(readFlag==SWT_GWSUPPORT_ERROR)
1433 {
1434 return 0;
1435 }
1436 free(var3);
1437 //AssignOutputVariable(pvApiCtx,1) = 5;
1438
1439 break;
1440 }
1441 case 6:
1442 {
1443 //sciprint("flow 6\n");
1444 //GetRhsVar(2, "c", &m2, &n2, &l2);
1445 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 2 , &input_string2 );
1446 m2=1;n2=1;
1447 if(readFlag==SWT_GWSUPPORT_ERROR)
1448 {
1449 return 0;
1450 }
1451 //GetRhsVar(3, "c", &m3, &n3, &l3);
1452 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 3 , &input_string3 );
1453 m3=1;n3=1;
1454 if(readFlag==SWT_GWSUPPORT_ERROR)
1455 {
1456 return 0;
1457 }
1458 //GetRhsVar(4, "c", &m4, &n4, &l4);
1459 readFlag = swt_gwsupport_GetScalarString(pvApiCtx, fname, 4 , &input_string4 );
1460 m4=1;n4=1;
1461 if(readFlag==SWT_GWSUPPORT_ERROR)
1462 {
1463 return 0;
1464 }
1465 //GetRhsVar(5, "i", &m5, &n5, &l5);
1466 readFlag = swt_gwsupport_GetRealMatrixOfDoublesAsInteger (pvApiCtx, fname, 5, &m5, &n5, &int_input5 );
1467 if(readFlag==SWT_GWSUPPORT_ERROR)
1468 {
1469 return 0;
1470 }
1471 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1472 if (errCode != SUCCESS)
1473 {
1474 validate_print (errCode);
1475 return 0;
1476 }
1477
1478 wavelet_parser(input_string2,&family,&member);
1479 wavelet_fun_parser (input_string2, &ii);
1480 syn_fun = wi[ii].synthesis;
1481 (*syn_fun)(member, &pWaveStruct);
1482 wave_len_validate ( col, pWaveStruct.length, &stride1, &val1);
1483 if (val1 == 0)
1484 {
1485 sciprint("Input signal (column length) is not valid for selected decompostion level and wavelets!\n");
1486 return 0;
1487 }
1488 fLen1 = pWaveStruct.length;
1489 Lo1 = malloc(fLen1*sizeof(double));
1490 Hi1 = malloc(fLen1*sizeof(double));
1491 verbatim_copy(pWaveStruct.pLowPass, fLen1, Lo1, fLen1);
1492 verbatim_copy(pWaveStruct.pHiPass, fLen1, Hi1, fLen1);
1493 r = int_input5[0];
1494 c = int_input5[1];
1495 s = int_input5[2];
1496 if (c>(col * 2 - pWaveStruct.length + 2))
1497
1498 {
1499 sciprint("column size argument is not valid!\n");
1500 return 0;
1501 }
1502
1503 wavelet_parser(input_string3,&family,&member);
1504 wavelet_fun_parser (input_string3, &ii);
1505 syn_fun = wi[ii].synthesis;
1506 (*syn_fun)(member, &pWaveStruct);
1507 wave_len_validate ( row, pWaveStruct.length, &stride1, &val1);
1508 if (val1 == 0)
1509 {
1510 sciprint("Input signal (row length) is not valid for selected decompostion level and wavelets!\n");
1511 return 0;
1512 }
1513 fLen2 = pWaveStruct.length;
1514 Lo2 = malloc(fLen2*sizeof(double));
1515 Hi2 = malloc(fLen2*sizeof(double));
1516 verbatim_copy(pWaveStruct.pLowPass, fLen2, Lo2, fLen2);
1517 verbatim_copy(pWaveStruct.pHiPass, fLen2, Hi2, fLen2);
1518 if (r>(row * 2 - pWaveStruct.length + 2))
1519
1520 {
1521 sciprint("row size argument is not valid!\n");
1522 return 0;
1523 }
1524
1525 wavelet_parser(input_string4,&family,&member);
1526 wavelet_fun_parser (input_string4, &ii);
1527 syn_fun = wi[ii].synthesis;
1528 (*syn_fun)(member, &pWaveStruct);
1529 wave_len_validate ( sli, pWaveStruct.length, &stride1, &val1);
1530 if (val1 == 0)
1531 {
1532 sciprint("Input signal (slice length) is not valid for selected decompostion level and wavelets!\n");
1533 return 0;
1534 }
1535 fLen3 = pWaveStruct.length;
1536 Lo3 = malloc(fLen3*sizeof(double));
1537 Hi3 = malloc(fLen3*sizeof(double));
1538 verbatim_copy(pWaveStruct.pLowPass, fLen3, Lo3, fLen3);
1539 verbatim_copy(pWaveStruct.pHiPass, fLen3, Hi3, fLen3);
1540 if (s>(sli * 2 - pWaveStruct.length + 2))
1541
1542 {
1543 sciprint("slice size argument is not valid!\n");
1544 return 0;
1545 }
1546
1547 si[0] = r;
1548 si[1] = c;
1549 si[2] = s;
1550
1551 // ssi.m = 1;
1552 // ssi.n = 3;
1553 // ssi.it = 4;
1554 // ssi.l = 100;
1555 // ssi.D = si;
1556 m6 = r*c*s;
1557 n6 = 1;
1558 var3 = malloc(m6*n6*sizeof(double));
1559
1560 idwt3(input1, row, col, sli, var3, r, c, s,
1561 Lo3, Hi3, Lo2, Hi2, Lo1, Hi1, fLen3, fLen2, fLen1);
1562
1563 free(Lo1);
1564 free(Hi1);
1565 free(Lo2);
1566 free(Hi2);
1567 free(Lo3);
1568 free(Hi3);
1569
1570 /* output */
1571 //CreateVar(6, "m", &mL, &nL, &l6);
1572 //CreateListVarFromPtr(6,1,"S",&ms,&ns,Str);
1573 //CreateListVarFromPtr(6,2,"I",&mi,&ni,&ssi);
1574 //CreateListVarFromPtr(6,3,"d",&m6, &n6, &var3);
1575 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1576 if(readFlag==SWT_GWSUPPORT_ERROR)
1577 {
1578 return 0;
1579 }
1580 free(var3);
1581 //AssignOutputVariable(pvApiCtx,1) = 6;
1582 break;
1583 }
1584 case 7:
1585 {
1586 //sciprint("flow 7\n");
1587 //GetRhsVar(2, "d", &m2, &n2, &l2);
1588 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
1589 if(readFlag==SWT_GWSUPPORT_ERROR)
1590 {
1591 return 0;
1592 }
1593 //GetRhsVar(3, "d", &m3, &n3, &l3);
1594 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
1595 if(readFlag==SWT_GWSUPPORT_ERROR)
1596 {
1597 return 0;
1598 }
1599 //GetRhsVar(4, "d", &m4, &n4, &l4);
1600 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,4, &m4, &n4 , &input4 );
1601 if(readFlag==SWT_GWSUPPORT_ERROR)
1602 {
1603 return 0;
1604 }
1605 //GetRhsVar(5, "d", &m5, &n5, &l5);
1606 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,5, &m5, &n5 , &input5 );
1607 if(readFlag==SWT_GWSUPPORT_ERROR)
1608 {
1609 return 0;
1610 }
1611 //GetRhsVar(6, "d", &m6, &n6, &l6);
1612 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,6, &m6, &n6 , &input6 );
1613 if(readFlag==SWT_GWSUPPORT_ERROR)
1614 {
1615 return 0;
1616 }
1617 //GetRhsVar(7, "d", &m7, &n7, &l7);
1618 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,7, &m7, &n7 , &input7 );
1619 if(readFlag==SWT_GWSUPPORT_ERROR)
1620 {
1621 return 0;
1622 }
1623 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1624 if (errCode != SUCCESS)
1625 {
1626 validate_print (errCode);
1627 return 0;
1628 }
1629 if ((row<m4*n4) || (col<m2*n2) || (sli<m6*n6))
1630 {
1631 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
1632 return 0;
1633 }
1634
1635 c = col * 2 - m2 * n2 + 2;
1636 r = row * 2 - m4 * n4 + 2;
1637 s = sli * 2 - m6 * n6 + 2;
1638
1639 si[0] = r;
1640 si[1] = c;
1641 si[2] = s;
1642
1643 // ssi.m = 1;
1644 // ssi.n = 3;
1645 // ssi.it = 4;
1646 // ssi.l = 100;
1647 // ssi.D = si;
1648 m8 = r*c*s;
1649 n8 = 1;
1650 var3 = malloc(m8*n8*sizeof(double));
1651
1652 idwt3(input1, row, col, sli, var3, r, c, s,
1653 input6, input7, input4, input5,
1654 input2, input3, m6*n6, m4*n4, m2*n2);
1655
1656 /* output */
1657 //CreateVar(8, "m", &mL, &nL, &l8);
1658 //CreateListVarFromPtr(8,1,"S",&ms,&ns,Str);
1659 //CreateListVarFromPtr(8,2,"I",&mi,&ni,&ssi);
1660 //CreateListVarFromPtr(8,3,"d",&m8, &n8, &var3);
1661 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si ,3 , var3 );
1662 if(readFlag==SWT_GWSUPPORT_ERROR)
1663 {
1664 return 0;
1665 }
1666 free(var3);
1667 //AssignOutputVariable(pvApiCtx,1) = 8;
1668 break;
1669 }
1670 case 8:
1671 {
1672 //sciprint("flow 8\n");
1673 //GetRhsVar(2, "d", &m2, &n2, &l2);
1674 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname, 2, &m2, &n2 , &input2 );
1675 if(readFlag==SWT_GWSUPPORT_ERROR)
1676 {
1677 return 0;
1678 }
1679 //GetRhsVar(3, "d", &m3, &n3, &l3);
1680 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,3, &m3, &n3 , &input3 );
1681 if(readFlag==SWT_GWSUPPORT_ERROR)
1682 {
1683 return 0;
1684 }
1685 //GetRhsVar(4, "d", &m4, &n4, &l4);
1686 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,4, &m4, &n4 , &input4 );
1687 if(readFlag==SWT_GWSUPPORT_ERROR)
1688 {
1689 return 0;
1690 }
1691 //GetRhsVar(5, "d", &m5, &n5, &l5);
1692 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,5, &m5, &n5 , &input5 );
1693 if(readFlag==SWT_GWSUPPORT_ERROR)
1694 {
1695 return 0;
1696 }
1697 //GetRhsVar(6, "d", &m6, &n6, &l6);
1698 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,6, &m6, &n6 , &input6 );
1699 if(readFlag==SWT_GWSUPPORT_ERROR)
1700 {
1701 return 0;
1702 }
1703 //GetRhsVar(7, "d", &m7, &n7, &l7);
1704 readFlag = swt_gwsupport_GetRealMatrixOfDoubles (pvApiCtx, fname,7, &m7, &n7 , &input7 );
1705 if(readFlag==SWT_GWSUPPORT_ERROR)
1706 {
1707 return 0;
1708 }
1709 //GetRhsVar(8, "i", &m8, &n8, &l8);
1710 readFlag = swt_gwsupport_GetRealMatrixOfDoublesAsInteger (pvApiCtx, fname,8, &m8, &n8, &int_input8 );
1711 if(readFlag==SWT_GWSUPPORT_ERROR)
1712 {
1713 return 0;
1714 }
1715 idwt3_content_validate (pvApiCtx, &errCode,flow,input_string2,input_string3,int_input3,input_string4,int_input4,int_input5,int_input8);
1716 if (errCode != SUCCESS)
1717 {
1718 validate_print (errCode);
1719 return 0;
1720 }
1721 if ((row<m4*n4) || (col<m2*n2) || (sli<m6*n6))
1722 {
1723 sciprint("Input signal is not valid for selected decompostion level and wavelets!\n");
1724 return 0;
1725 }
1726
1727 r = int_input8[0];
1728 c = int_input8[1];
1729 s = int_input8[2];
1730
1731 if ((r>(row * 2 - m4*n4 + 2)) ||
1732 (c>(col * 2 - m2*n2 + 2)) ||
1733 (s>(sli * 2 - m6*n6 + 2)))
1734 {
1735 sciprint("size argument is not valid!\n");
1736 return 0;
1737 }
1738 //c = col * 2 - m2 * n2 + 2;
1739 //r = row * 2 - m4 * n4 + 2;
1740 //s = sli * 2 - m6 * n6 + 2;
1741
1742 si[0] = r;
1743 si[1] = c;
1744 si[2] = s;
1745
1746 // ssi.m = 1;
1747 // ssi.n = 3;
1748 // ssi.it = 4;
1749 // ssi.l = 100;
1750 // ssi.D = si;
1751 m9 = r*c*s;
1752 n9 = 1;
1753 var3 = malloc(m9*n9*sizeof(double));
1754
1755 idwt3(input1, row, col, sli, var3, r, c, s,
1756 input6, input7, input4, input5,
1757 input2, input3, m6*n6, m4*n4, m2*n2);
1758
1759 /* output */
1760 //CreateVar(9, "m", &mL, &nL, &l9);
1761 //CreateListVarFromPtr(9,1,"S",&ms,&ns,Str);
1762 //CreateListVarFromPtr(9,2,"I",&mi,&ni,&ssi);
1763 //CreateListVarFromPtr(9,3,"d",&m9, &n9, &var3);
1764 readFlag = swt_gwsupport_CreateHypermatOfDouble (pvApiCtx, fname, 1, si , 3 , var3 );
1765 if(readFlag==SWT_GWSUPPORT_ERROR)
1766 {
1767 return 0;
1768 }
1769 free(var3);
1770 //AssignOutputVariable(pvApiCtx,1) = 9;
1771 break;
1772 }
1773 default:
1774 sciprint("input not valid\n");
1775 break;
1776 }
1777 return 0;
1778 }
1779