2 * Convolution-decimation functions and their adjoints.
4 * Copyright (C) 1991--94 Wickerhauser Consulting. All Rights Reserved.
5 * May be freely copied for noncommercial use. See
6 * ``Adapted Wavelet Analysis from Theory to Software'' ISBN 1-56881-041-5
7 * by Mladen Victor Wickerhauser [AK Peters, Ltd., Wellesley, Mass., 1994]
14 #include "common.h" /* for `min()' and `max()'. */
16 /***************************************************************
19 * [C]onvolution and [D]ecimation by 2;
20 * [A]periodic, sequential [I]nput, superposition.
25 * Let BEGIN = ICH(J+F.ALPHA)
26 * Let END = IFH(J+F.OMEGA)
27 * For I = BEGIN to END
28 * OUT[I*STEP] += F.F[2*I-J]*IN[J]
31 * cdai(out, step, in, a, b, F)
34 * (real *)out This output array must be preallocated so
35 * that `out[step*ICH(a+F->alpha)]' through
36 * `out[step*IFH(b+F->omega)]' are defined.
37 * (int)step This integer is the increment between
39 * (const real *)in This input array must be preallocated
40 * so that `in[a],...,in[b]' are all defined.
41 * (int)a,b These are the first and last valid indices
43 * (const pqf *)F This specifies the QF to use.
46 * (real *)out Computed values are added into this array
47 * by side effect, at elements separated
48 * by offsets of `step' starting at
49 * `out + step*ICH(a + F->alpha)'.
53 real
*out
, /* Preallocated output array */
54 int step
, /* Increment for `out[]' */
55 const real
*in
, /* Preallocated input array */
56 int a
, /* First valid `in[]' offset */
57 int b
, /* Last valid `in[]' offset */
58 const pqf
*F
) /* QF data structure */
69 while( i
<= IFH(j
+F
->omega
) )
71 *outp
+= (*filt
) * in
[j
];
72 outp
+= step
; filt
+= 2; ++i
;
78 /**************************************************************
81 * [C]onvolution and [D]ecimation by 2;
82 * [A]periodic, sequential [O]utput, superposition.
86 * Let APRIME = ICH(A+F.ALPHA)
87 * Let BPRIME = IFH(B+F.OMEGA)
88 * For I = APRIME to BPRIME
89 * Let BEGIN = max( F.ALPHA, 2*I-B )
90 * Let END = min( F.OMEGA, 2*I-A )
91 * For J = BEGIN to END
92 * OUT[I*STEP] += F.F[J]*IN[2*I-J]
95 * cdao(out, step, in, a, b, F)
98 * (real *)out This output array must be preallocated so
99 * that `out[step*ICH(a+F->alpha)]' through
100 * `out[step*IFH(b+F->omega)]' are defined.
101 * (int)step This integer is the increment between
103 * (const real *)in This input array must be preallocated
104 * so that `in[a],...,in[b]' are all defined.
105 * (int)a,b These are the first and last valid indices
107 * (const pqf *)F This specifies the QF to use.
110 * (real *)out Computed values are added into this array
111 * by side effect, at elements separated
112 * by offsets of `step' starting at
113 * `out + step*ICH(a+F->alpha)'.
117 real
*out
, /* Preallocated output array */
118 int step
, /* Increment for `out[]' */
119 const real
*in
, /* Preallocated input array */
120 int a
, /* First valid `in[]' offset */
121 int b
, /* Last valid `in[]' offset */
122 const pqf
*F
) /* QF data structure */
129 while( i
<= IFH(b
+F
->omega
) )
134 j
=F
->alpha
; /* j = max(F->alpha,2*i-b) */
135 inp
= in
+ 2*i
-j
; /* *inp = in[2*i-j] */
139 inp
= in
+ b
; /* *inp = in[2*i-j] */
142 end
= min( F
->omega
, end
);
144 *out
+= F
->f
[j
++]*(*inp
--);
151 /**************************************************************
154 * [C]onvolution and [D]ecimation by 2;
155 * [A]periodic, set output using [E]quals.
159 * Let APRIME = ICH(A+F.ALPHA)
160 * Let BPRIME = IFH(B+F.OMEGA)
161 * For I = APRIME to BPRIME
162 * Let OUT[I*STEP] = 0
163 * Let BEGIN = max( F.ALPHA, 2*I-B )
164 * Let END = min( F.OMEGA, 2*I-A )
165 * For J = BEGIN to END
166 * OUT[I*STEP] += F.F[J]*IN[2*I-J]
169 * cdae(out, step, in, a, b, F)
172 * (real *)out This output array must be preallocated so
173 * that `out[step*ICH(a+F->alpha)]' through
174 * `out[step*IFH(b+F->omega)]' are defined.
175 * (int)step This integer is the increment between
177 * (const real *)in This input array must be preallocated
178 * so that `in[a],...,in[b]' are all defined.
179 * (int)a,b These are the first and last valid indices
181 * (const pqf *)F This specifies the QF to use.
184 * (real *)out Computed values are assigned into this array
185 * by side effect, at elements separated
186 * by offsets of `step' starting at
187 * `out + step*ICH(a+F->alpha)'.
191 real
*out
, /* Preallocated output array */
192 int step
, /* Increment for `out[]' */
193 const real
*in
, /* Preallocated input array */
194 int a
, /* First valid `in[]' offset */
195 int b
, /* Last valid `in[]' offset */
196 const pqf
*F
) /* QF data structure */
203 while( i
<= IFH(b
+F
->omega
) )
209 j
=F
->alpha
; /* j = max(F->alpha,2*i-b) */
210 inp
= in
+ 2*i
-j
; /* *inp = in[2*i-j] */
214 inp
= in
+ b
; /* *inp = in[2*i-j] */
217 end
= min( F
->omega
, end
);
219 *out
+= F
->f
[j
++]*(*inp
--);
226 /*************************************************************
229 * [A]djoint [C]onvolution and [D]ecimation:
230 * [A]periodic, sequential [I]nput, superposition.
235 * Let BEGIN = 2*I-F.OMEGA
236 * Let END = 2*I-F.ALPHA
237 * For J = BEGIN to END
238 * OUT[J*STEP] += F.F[2*I-J]*IN[I]
240 * We change variables to save operations:
243 * For J = F.ALPHA to F.OMEGA
244 * OUT[(2*I-J)*STEP] += F.F[J]*IN[I]
247 * acdai(out, step, in, c, d, F)
250 * (real *)out This output array must be preallocated so
251 * that `out[step*(2*c-F->omega)]' through
252 * `out[step*(2*d-F->alpha)]' are defined.
253 * (int)step This integer is the increment between
255 * (const real *)in This input array must be preallocated
256 * so that `in[c],...,in[d]' are all defined.
257 * (int)a,b These are the first and last valid indices
259 * (const pqf *)F This specifies the QF to use.
262 * (real *)out Computed values are added into this array
263 * by side effect, at elements separated
264 * by offsets of `step' starting at
265 * `out + (2*c-F->omega)*step'.
269 real
*out
, /* Preallocated output array */
270 int step
, /* Increment for `out[]' values */
271 const real
*in
, /* Preallocated input array */
272 int c
, /* First valid `in[]' offset */
273 int d
, /* Last valid `in[]' offset */
274 const pqf
*F
) /* QF data structure */
279 for( i
=c
; i
<= d
; i
++ )
282 outp
= out
+ (2*i
-j
)*step
;
283 while( j
<= F
->omega
)
285 *outp
+= F
->f
[j
++] * in
[i
];
292 /***************************************************************
295 * [A]djoint [C]onvolution and [D]ecimation:
296 * [A]periodic, sequential [O]utput, superposition.
300 * Let CPRIME = 2*C-F.OMEGA
301 * Let DPRIME = 2*D-F.ALPHA
302 * For J = CPRIME to DPRIME
303 * Let BEGIN = max( ICH(J+F.ALPHA ), C )
304 * Let END = min( IFH(J+F.OMEGA ), D )
305 * For I = BEGIN to END
306 * OUT[J*STEP] += F.F[2*I-J]*IN[I]
309 * acdao(out, step, in, c, d, F)
312 * (real *)out This output array must be preallocated so
313 * that `out[step*(2*c-F->omega)]' through
314 * `out[step*(2*d-F->alpha)]' are defined.
315 * (int)step This integer is the increment between
317 * (const real *)in This input array must be preallocated
318 * so that `in[c],...,in[d]' are all defined.
319 * (int)a,b These are the first and last valid indices
321 * (const pqf *)F This specifies the QF to use.
324 * (real *)out Computed values are added into this array
325 * by side effect, at elements separated
326 * by offsets of `step' starting at
327 * `out + (2*c - F->omega)*step'.
331 real
*out
, /* Preallocated output array */
332 int step
, /* Increment for `out[]' values */
333 const real
*in
, /* Preallocated input array */
334 int c
, /* First valid `in[]' offset */
335 int d
, /* Last valid `in[]' offset */
336 const pqf
*F
) /* QF data structure */
344 while( j
<= 2*d
-F
->alpha
)
346 i
= ICH( j
+ F
->alpha
);
348 end
= IFH( j
+ F
->omega
);
353 *out
+= (*filt
)*in
[i
++];
362 /***************************************************************
365 * [A]djoint [C]onvolution and [D]ecimation:
366 * [A]periodic, set output using [E]quals.
370 * Let CPRIME = 2*C-F.OMEGA
371 * Let DPRIME = 2*D-F.ALPHA
372 * For J = CPRIME to DPRIME
373 * Let OUT[J*STEP] = 0
374 * Let BEGIN = max( ICH(J+F.ALPHA ), C )
375 * Let END = min( IFH(J+F.OMEGA ), D )
376 * For I = BEGIN to END
377 * OUT[J*STEP] += F.F[2*I-J]*IN[I]
380 * acdae(out, step, in, c, d, F)
383 * (real *)out This output array must be preallocated so
384 * that `out[step*(2*c-F->omega)]' through
385 * `out[step*(2*d-F->alpha)]' are defined.
386 * (int)step This integer is the increment between
388 * (const real *)in This input array must be preallocated
389 * so that `in[c],...,in[d]' are all defined.
390 * (int)a,b These are the first and last valid indices
392 * (const pqf *)F This specifies the QF to use.
395 * (real *)out Computed values are added into this array
396 * by side effect, at elements separated
397 * by offsets of `step' starting at
398 * `out + (2*c - F->omega)*step'.
402 real
*out
, /* Preallocated output array */
403 int step
, /* Increment for `out[]' values */
404 const real
*in
, /* Preallocated input array */
405 int c
, /* First valid `in[]' offset */
406 int d
, /* Last valid `in[]' offset */
407 const pqf
*F
) /* QF data structure */
415 while( j
<= 2*d
-F
->alpha
)
418 i
= ICH( j
+ F
->alpha
);
420 end
= IFH( j
+ F
->omega
);
425 *out
+= (*filt
)*in
[i
++];
434 /*******************************************************
437 * [C]onvolution and [D]ecimation by 2, using the
438 * [M]od operator, sequential [I]nput, superposition.
443 * If Q > F.OMEGA-F.ALPHA then
446 * Let JA2 = ICH(J+F.ALPHA)
447 * Let JO2 = IFH(J+F.OMEGA)
448 * For I = 0 to JO2-Q2
449 * OUT[I*STEP] += FILTER[Q+2*I-J]*IN[J]
450 * For I = max(0,JA2) to min(Q2-1,JO2)
451 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
452 * For I = JA2+Q2 to Q2-1
453 * OUT[I*STEP] += FILTER[2*I-J-Q]*IN[J]
455 * Let FILTER = F.FP+PQFO(Q2)
458 * OUT[I*STEP] += FILTER[(Q+2*I-J)%Q]*IN[J]
461 * cdmi(out, step, in, q, F)
464 * (real *)out This output array must be preallocated so
465 * that elements `out[0]' through
466 * `out[step*(q/2-1)]' are defined.
467 * (int)step This integer is the increment between
469 * (const real *)in This input array must be preallocated
470 * so that `in[0],...,in[q-1]' are defined.
471 * (int)q This is the period of the input array.
472 * (const pqf *)F This specifies the periodized QF struct.
475 * (real *)out Computed values are added into this array
476 * by side effect, at elements separated
477 * by offsets of `step' starting at `out'.
479 * Assumptions: We assume that `q' is even.
483 real
*out
, /* Preallocated array, length `q/2' */
484 int step
, /* Increment between `out[]' values */
485 const real
*in
, /* Preallocated array, length `q' */
486 int q
, /* Number of inputs---must be even */
487 const pqf
*F
) /* Periodized QF data structure */
493 assert( (q
&1)==0 ); /* Assume `q' is even. */
495 q2
= q
/2; /* Number of outputs. */
496 if( q
> F
->omega
-F
->alpha
) /* Long input case. */
502 ja2
= ICH(j
+F
->alpha
);
503 jo2
= IFH(j
+F
->omega
);
505 i
=0; outp
= out
; filt
= F
->f
+ q
-j
;
508 *outp
+= (*filt
) * (*in
);
509 ++i
; outp
+= step
; filt
+= 2;
512 i
= max(0, ja2
); outp
= out
+i
*step
; filt
= F
->f
+ 2*i
-j
;
513 while( i
<= min(q2
-1,jo2
) )
515 *outp
+= (*filt
) * (*in
);
516 ++i
; outp
+= step
; filt
+= 2;
519 i
= ja2
+q2
; outp
= out
+i
*step
; filt
= F
->f
+ 2*i
-j
-q
;
522 *outp
+=(*filt
) * (*in
);
523 ++i
; outp
+= step
; filt
+= 2;
529 else /* Short input case. */
531 filt
= F
->fp
+ PQFO(q2
);
535 for( i
=0; i
<q2
; i
++ )
537 *outp
+= filt
[(q
+2*i
-j
)%q
]*(*in
);
546 /************************************************************
549 * [C]onvolution and [D]ecimation by 2, using the
550 * [M]od operator, sequential [O]utput, superposition.
555 * If Q > F.OMEGA-F.ALPHA then
558 * For J = F.ALPHA to F.OMEGA
559 * OUT[I*STEP] += FILTER[J]*IN[(Q+2*I-J)%Q]
561 * Let FILTER = F.FP + PQFO[Q2]
564 * OUT[I*STEP] += FILTER[J]*IN[(Q+2*I-J)%Q]
567 * cdmo(out, step, in, q, F)
570 * (real *)out This output array must be preallocated so
571 * that elements `out[0]' through
572 * `out[step*(q/2-1)]' are defined.
573 * (int)step This integer is the increment between
575 * (const real *)in This input array must be preallocated
576 * so that `in[0],...,in[q-1]' are defined.
577 * (int)q This is the period of the input array.
578 * (const pqf *)F This specifies the periodized QF struct.
581 * (real *)out Computed values are added into this array
582 * by side effect, at elements separated
583 * by offsets of `step' starting at `out'.
585 * Assumptions: We assume that `q' is even.
589 real
*out
, /* Preallocated array, length `q/2' */
590 int step
, /* Increment between `out[]' values */
591 const real
*in
, /* Preallocated array, length `q' */
592 int q
, /* Number of inputs---must be even */
593 const pqf
*F
) /* Periodized QF data structure */
597 assert( (q
&1)==0 ); /* Test that `q' is even. */
600 if( q
> F
->omega
- F
->alpha
) /* Long input case. */
606 while( j
<= F
->omega
)
607 *out
+= F
->f
[j
++]*in
[(k
--)%q
];
611 else /* Short input case. */
615 j
= PQFO(q2
); /* q-periodized coefs. */
618 *out
+= F
->fp
[j
++]*in
[(k
--)%q
];
625 /************************************************************
628 * [C]onvolution and [D]ecimation by 2:
629 * [P]eriodic, sequential [I]nput, superposition.
634 * If Q > F.OMEGA-F.ALPHA then
637 * Let JA2 = ICH(J+F.ALPHA)
638 * Let JO2 = IFH(J+F.OMEGA)
639 * For I = 0 to JO2-Q2
640 * OUT[I*STEP] += FILTER[Q+2*I-J]*IN[J]
641 * For I = max(0,JA2) to min(Q2-1,JO2)
642 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
643 * For I = JA2+Q2 to Q2-1
644 * OUT[I*STEP] += FILTER[2*I-J-Q]*IN[J]
646 * Let FILTER = F.FP+PQFO(Q2)
649 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
652 * cdpi(out, step, in, q, F)
655 * (real *)out This output array must be preallocated so
656 * that elements `out[0]' through
657 * `out[step*(q/2-1)]' are defined.
658 * (int)step This integer is the increment between
660 * (const real *)in This input array must be preallocated
661 * so that `in[0],...,in[q-1]' are defined.
662 * (int)q This is the period of the input array.
663 * (const pqf *)F This specifies the periodized QF struct.
666 * (real *)out Computed values are added into this array
667 * by side effect, at elements separated
668 * by offsets of `step' starting at `out'.
670 * Assumptions: We assume that `q' is even.
674 real
*out
, /* Preallocated array, length `q/2' */
675 int step
, /* Increment between `out[]' values */
676 const real
*in
, /* Preallocated array, length `q' */
677 int q
, /* Number of inputs---must be even */
678 const pqf
*F
) /* Periodized QF data structure */
684 assert( (q
&1)==0 ); /* Test that `q' is even. */
686 q2
= q
/2; /* Number of outputs. */
687 if( q
> F
->omega
-F
->alpha
) /* Long input case. */
693 ja2
= ICH(j
+F
->alpha
);
694 jo2
= IFH(j
+F
->omega
);
696 i
=0; outp
= out
; filt
= F
->f
+ q
-j
;
699 *outp
+= (*filt
) * (*in
);
700 ++i
; outp
+= step
; filt
+= 2;
703 i
= max(0, ja2
); outp
= out
+i
*step
; filt
= F
->f
+ 2*i
-j
;
704 while( i
<=min(q2
-1,jo2
) )
706 *outp
+= (*filt
) * (*in
);
707 ++i
; outp
+= step
; filt
+= 2;
710 i
= ja2
+q2
; outp
= out
+i
*step
; filt
= F
->f
+ 2*i
-j
-q
;
713 *outp
+=(*filt
) * (*in
);
714 ++i
; outp
+= step
; filt
+= 2;
720 else /* Short input case. */
724 filt
= F
->fp
+ PQFO(q2
) - j
;
726 for( i
=0; i
<q2
; i
++ )
728 *outp
+= (*filt
) * (*in
);
729 filt
+= 2; outp
+= step
;
737 /*********************************************************
740 * [C]onvolution and [D]ecimation by 2:
741 * [P]eriodic, sequential [O]utput, superposition (1).
746 * If Q > F.OMEGA-F.ALPHA then
749 * Let A2I = 2*I-F.ALPHA
750 * Let O2I = 2*I-F.OMEGA
752 * OUT[I*STEP] += FILTER[2*I-J-Q]*IN[J]
753 * For J = max(0,O2I) to min(Q-1,A2I)
754 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
755 * For J = O2I+Q to Q-1
756 * OUT[I*STEP] += FILTER[Q+2*I-J]*IN[J]
758 * Let FILTER = F.FP+PQFO(Q2)
761 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
765 * cdpo1(out, step, in, q, F)
768 * (real *)out This output array must be preallocated so
769 * that elements `out[0]' through
770 * `out[step*(q/2-1)]' are defined.
771 * (int)step This integer is the increment between
773 * (const real *)in This input array must be preallocated
774 * so that `in[0],...,in[q-1]' are defined.
775 * (int)q This is the period of the input array.
776 * (const pqf *)F This specifies the periodized QF struct.
779 * (real *)out Computed values are added into this array
780 * by side effect, at elements separated
781 * by offsets of `step' starting at `out'.
783 * Assumptions: We assume that `q' is even.
787 real
*out
, /* Preallocated array, length `q/2' */
788 int step
, /* Increment between `out[]' values */
789 const real
*in
, /* Preallocated array, length `q' */
790 int q
, /* Number of inputs---must be even */
791 const pqf
*F
) /* Periodized QF data structure */
797 assert( (q
&1)==0 ); /* Test that `q' is even. */
800 if( q
> F
->omega
-F
->alpha
) /* Long input case. */
804 for( ii
=0; ii
<q
; ii
+=2 )
810 for( j
=0; j
<=a2i
-q
; j
++ )
811 *out
+= (*filt
--)* in
[j
];
813 j
= max(0, o2i
); filt
= F
->f
+ ii
-j
;
814 for( ; j
<=min(q
-1,a2i
); j
++ )
815 *out
+= (*filt
--)* in
[j
];
817 j
= o2i
+ q
; filt
= F
->f
+ q
+ii
-j
;
819 *out
+= (*filt
--) * in
[j
];
824 else /* Short input case. */
826 for( ii
=0; ii
<q
; ii
+=2 )
828 filt
= F
->fp
+ PQFO(q2
) + ii
;
830 *out
+= (*filt
--) * in
[j
];
837 /*********************************************************
840 * [C]onvolution and [D]ecimation by 2:
841 * [P]eriodic, sequential [O]utput, superposition (2).
846 * If Q > F.OMEGA-F.ALPHA then
850 * For J = F.ALPHA to END
851 * OUT[I*STEP] += FILTER[J]*IN[2*I-J-Q]
852 * Let BEGIN = max(F.ALPHA, END+1)
853 * Let END = min(F.OMEGA, 2*I)
854 * For J = BEGIN to END
855 * OUT[I*STEP] += FILTER[J]*IN[2*I-J]
857 * For J = BEGIN to F.OMEGA
858 * OUT[I*STEP] += FILTER[J]*IN[Q+2*I-J]
860 * Let FILTER = F.FP + PQFO(Q2)
863 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
866 * cdpo2(out, step, in, q, F)
869 * (real *)out This output array must be preallocated so
870 * that elements `out[0]' through
871 * `out[step*(q/2-1)]' are defined.
872 * (int)step This integer is the increment between
874 * (const real *)in This input array must be preallocated
875 * so that `in[0],...,in[q-1]' are defined.
876 * (int)q This is the period of the input array.
877 * (const pqf *)F This specifies the periodized QF struct.
880 * (real *)out Computed values are added into this array
881 * by side effect, at elements separated
882 * by offsets of `step' starting at `out'.
884 * Assumptions: We assume that `q' is even.
888 real
*out
, /* Preallocated array, length `q/2' */
889 int step
, /* Increment between `out[]' values */
890 const real
*in
, /* Preallocated array, length `q' */
891 int q
, /* Number of inputs---must be even */
892 const pqf
*F
) /* Periodized QF data structure */
898 assert( (q
&1)==0 ); /* Test that `q' is even. */
901 if( q
> F
->omega
-F
->alpha
) /* Long input case. */
905 for( ii
=0; ii
<q
; ii
+=2 )
909 for( j
=F
->alpha
; j
<=end
; j
++ )
910 *out
+= F
->f
[j
]* (*ptr
--);
912 j
= max(F
->alpha
, j
);
913 end
= min(F
->omega
, ii
);
916 *out
+= F
->f
[j
]* (*ptr
--);
920 for( ; j
<=F
->omega
; j
++ )
921 *out
+= F
->f
[j
] * (*ptr
--);
926 else /* Short input case. */
928 for( ii
=0; ii
<q
; ii
+=2 )
930 ptr
= F
->fp
+ PQFO(q2
) + ii
;
932 *out
+= (*ptr
--) * in
[j
];
939 /*********************************************************
942 * [C]onvolution and [D]ecimation by 2:
943 * [P]eriodic, set output using [E]quals (1).
948 * If Q > F.OMEGA-F.ALPHA then
951 * Let OUT[I*STEP] = 0
952 * Let A2I = 2*I-F.ALPHA
953 * Let O2I = 2*I-F.OMEGA
955 * OUT[I*STEP] += FILTER[2*I-J-Q]*IN[J]
956 * For J = max(0,O2I) to min(Q-1,A2I)
957 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
958 * For J = O2I+Q to Q-1
959 * OUT[I*STEP] += FILTER[Q+2*I-J]*IN[J]
961 * Let FILTER = F.FP+PQFO(Q2)
963 * Let OUT[I*STEP] = 0
965 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
969 * cdpe1(out, step, in, q, F)
972 * (real *)out This output array must be preallocated so
973 * that elements `out[0]' through
974 * `out[step*(q/2-1)]' are defined.
975 * (int)step This integer is the increment between
977 * (const real *)in This input array must be preallocated
978 * so that `in[0],...,in[q-1]' are defined.
979 * (int)q This is the period of the input array.
980 * (const pqf *)F This specifies the periodized QF struct.
983 * (real *)out Computed values are assigned into this array
984 * by side effect, at elements separated
985 * by offsets of `step' starting at `out'.
987 * Assumptions: We assume that `q' is even.
991 real
*out
, /* Preallocated array, length `q/2' */
992 int step
, /* Increment between `out[]' values */
993 const real
*in
, /* Preallocated array, length `q' */
994 int q
, /* Number of inputs---must be even */
995 const pqf
*F
) /* Periodized QF data structure */
1001 assert( (q
&1)==0 ); /* Test that `q' is even. */
1004 if( q
> F
->omega
-F
->alpha
) /* Long input case. */
1008 for( ii
=0; ii
<q
; ii
+=2 )
1011 a2i
= ii
- F
->alpha
;
1012 o2i
= ii
- F
->omega
;
1015 for( j
=0; j
<=a2i
-q
; j
++ )
1016 *out
+= (*filt
--)* in
[j
];
1018 j
= max(0, o2i
); filt
= F
->f
+ ii
-j
;
1019 for( ; j
<=min(q
-1,a2i
); j
++ )
1020 *out
+= (*filt
--)* in
[j
];
1022 j
= o2i
+ q
; filt
= F
->f
+ q
+ii
-j
;
1024 *out
+= (*filt
--) * in
[j
];
1029 else /* Short input case. */
1031 for( ii
=0; ii
<q
; ii
+=2 )
1034 filt
= F
->fp
+ PQFO(q2
) + ii
;
1035 for( j
=0; j
<q
; j
++ )
1036 *out
+= (*filt
--) * in
[j
];
1043 /*********************************************************
1046 * [C]onvolution and [D]ecimation by 2:
1047 * [P]eriodic, output set by [E]qual sign (2).
1052 * If Q > F.OMEGA-F.ALPHA then
1055 * Let OUT[I*STEP] = 0
1057 * For J = F.ALPHA to END
1058 * OUT[I*STEP] += FILTER[J]*IN[2*I-J-Q]
1059 * Let BEGIN = max(F.ALPHA, END+1)
1060 * Let END = min(F.OMEGA, 2*I)
1061 * For J = BEGIN to END
1062 * OUT[I*STEP] += FILTER[J]*IN[2*I-J]
1064 * For J = BEGIN to F.OMEGA
1065 * OUT[I*STEP] += FILTER[J]*IN[Q+2*I-J]
1067 * Let FILTER = F.FP + PQFO(Q2)
1069 * Let OUT[I*STEP] = 0
1071 * OUT[I*STEP] += FILTER[2*I-J]*IN[J]
1074 * cdpe2(out, step, in, q, F)
1077 * (real *)out This output array must be preallocated so
1078 * that elements `out[0]' through
1079 * `out[step*(q/2-1)]' are defined.
1080 * (int)step This integer is the increment between
1082 * (const real *)in This input array must be preallocated
1083 * so that `in[0],...,in[q-1]' are defined.
1084 * (int)q This is the period of the input array.
1085 * (const pqf *)F This specifies the periodized QF struct.
1088 * (real *)out Computed values are assigned into this array
1089 * by side effect, at elements separated
1090 * by offsets of `step' starting at `out'.
1092 * Assumptions: We assume that `q' is even.
1096 real
*out
, /* Preallocated array, length `q/2' */
1097 int step
, /* Increment between `out[]' values */
1098 const real
*in
, /* Preallocated array, length `q' */
1099 int q
, /* Number of inputs---must be even */
1100 const pqf
*F
) /* Periodized QF data structure */
1106 assert( (q
&1)==0 ); /* Test that `q' is even. */
1109 if( q
> F
->omega
-F
->alpha
) /* Long input case. */
1113 for( ii
=0; ii
<q
; ii
+=2 )
1118 for( j
=F
->alpha
; j
<=end
; j
++ )
1119 *out
+= F
->f
[j
]* (*ptr
--);
1121 j
= max(F
->alpha
, j
);
1122 end
= min(F
->omega
, ii
);
1124 for( ; j
<=end
; j
++ )
1125 *out
+= F
->f
[j
]* (*ptr
--);
1129 for( ; j
<=F
->omega
; j
++ )
1130 *out
+= F
->f
[j
] * (*ptr
--);
1135 else /* Short input case. */
1137 for( ii
=0; ii
<q
; ii
+=2 )
1140 ptr
= F
->fp
+ PQFO(q2
) + ii
;
1141 for( j
=0; j
<q
; j
++ )
1142 *out
+= (*ptr
--) * in
[j
];
1149 /************************************************************
1152 * [A]djoint [C]onvolution-[D]ecimation:
1153 * [P]eriodic, sequential [I]nput, superposition.
1158 * If Q > F.OMEGA-F.ALPHA then
1161 * Let A2I = 2*I-F.ALPHA
1162 * Let O2I = 2*I-F.OMEGA
1163 * For J = 0 to A2I-Q
1164 * OUT[J*STEP] += FILTER[2*I-J-Q]*IN[I]
1165 * For J = max(0,O2I) to min(Q-1,A2I)
1166 * OUT[J*STEP] += FILTER[2*I-J]*IN[I]
1167 * For J = O2I+Q to Q-1
1168 * OUT[J*STEP] += FILTER[Q+2*I-J]*IN[I]
1170 * Let FILTER = F.FP + PQFO(Q2)
1173 * OUT[J*STEP] += FILTER[2*I-J]*IN[I]
1177 * acdpi(out, step, in, q2, F)
1180 * (real *)out This output array must be preallocated so
1181 * that elements `out[0]' through
1182 * `out[step*(q-1)]' are defined, q=2*q2.
1183 * (int)step This integer is the increment between
1185 * (const real *)in This input array must be preallocated
1186 * so that `in[0],...,in[q2-1]' are defined.
1187 * (int)q2 This is the period of the input array.
1188 * (const pqf *)F This specifies the periodized QF struct.
1191 * (real *)out Computed values are added into this array
1192 * by side effect, at elements separated
1193 * by offsets of `step' starting at `out'.
1197 real
*out
, /* Preallocated array, length `2*q2' */
1198 int step
, /* Increment between `out[]' values */
1199 const real
*in
, /* Preallocated array, length `q2' */
1200 int q2
, /* Number of elements of `in[]' */
1201 const pqf
*F
) /* Periodized QF data structure */
1207 q
= 2*q2
; /* Output array length. */
1208 if( q
> F
->omega
-F
->alpha
) /* Long signal case: */
1212 for( ii
=0; ii
<q
; ii
+=2 )
1214 a2i
= ii
- F
->alpha
;
1215 o2i
= ii
- F
->omega
;
1217 j
= 0; outp
= out
; filt
= F
->f
+ ii
-q
;
1220 *outp
+= (*filt
--) * (*in
);
1224 j
= max(0, o2i
); outp
= out
+j
*step
; filt
= F
->f
+ii
-j
;
1225 while( j
<=min(a2i
, q
-1) )
1227 *outp
+= (*filt
--) * (*in
);
1231 j
= o2i
+q
; outp
= out
+j
*step
; filt
= F
->f
+ q
+ii
-j
;
1234 *outp
+= (*filt
--) * (*in
);
1240 else /* Short signal case: */
1242 for( ii
=0; ii
<q
; ii
+=2 )
1244 outp
= out
; filt
= F
->fp
+ PQFO(q2
) + ii
;
1247 *outp
+= (*filt
--) * (*in
);
1256 /*************************************************************
1259 * [A]djoint [C]onvolution-[D]ecimation:
1260 * [P]eriodic, sequential [O]utput, superposition.
1265 * If Q > F.OMEGA-F.ALPHA then
1268 * Let JA2 = ICH(J+F.ALPHA)
1269 * Let JO2 = IFH(J+F.OMEGA)
1270 * For I = 0 to JO2-Q2
1271 * OUT[J*STEP] += FILTER[Q+2*I-J]*IN[I]
1272 * For I = max(0,JA2) to min(Q2-1,JO2)
1273 * OUT[J*STEP] += FILTER[2*I-J]*IN[I]
1274 * For I = JA2+Q2 to Q2-1
1275 * OUT[J*STEP] += FILTER[2*I-J-Q]*IN[I]
1277 * Let FILTER = F.FP+PQFO(Q2)
1280 * OUT[J*STEP] += FILTER[2*I-J]*IN[I]
1283 * acdpo(out, step, in, q2, F)
1286 * (real *)out This output array must be preallocated so
1287 * that elements `out[0]' through
1288 * `out[step*(q-1)]' are defined, q=2*q2.
1289 * (int)step This integer is the increment between
1291 * (const real *)in This input array must be preallocated
1292 * so that `in[0],...,in[q2-1]' are defined.
1293 * (int)q2 This is the period of the input array.
1294 * (const pqf *)F This specifies the periodized QF struct.
1297 * (real *)out Computed values are added into this array
1298 * by side effect, at elements separated
1299 * by offsets of `step' starting at `out'.
1303 real
*out
, /* Preallocated array, length `2*q2' */
1304 int step
, /* Increment between `out[]' values */
1305 const real
*in
, /* Preallocated array, length `q2' */
1306 int q2
, /* Number of elements of `in[]' */
1307 const pqf
*F
) /* Periodized qf data structure */
1313 q
= 2*q2
; /* Output array length. */
1314 if( q
> F
->omega
-F
->alpha
) /* Long signal case: */
1318 for( j
=0; j
<q
; j
++ )
1320 ja2
= ICH(j
+F
->alpha
);
1321 jo2
= IFH(j
+F
->omega
);
1323 i
=0; filt
= F
->f
+q
-j
; inp
= in
;
1326 *out
+= (*filt
) * (*inp
++);
1330 i
=max(0, ja2
); filt
= F
->f
+ 2*i
-j
; inp
= in
+i
;
1331 while( i
<=min(q2
-1,jo2
) )
1333 *out
+= (*filt
) * (*inp
++);
1337 i
=q2
+ja2
; filt
= F
->f
+2*i
-j
-q
; inp
= in
+i
;
1340 *out
+= (*filt
) * (*inp
++);
1346 else /* Short signal case: */
1348 for( j
=0; j
<q
; j
++ )
1350 inp
= in
; filt
= F
->fp
+ PQFO(q2
) - j
;
1351 for( i
=0; i
<q2
; i
++)
1353 *out
+= (*filt
) * (*inp
++);
1362 /*************************************************************
1365 * [A]djoint [C]onvolution-[D]ecimation:
1366 * [P]eriodic, assign output with [E]quals.
1371 * If Q > F.OMEGA-F.ALPHA then
1373 * Let OUT[J*STEP] = 0
1375 * Let JA2 = ICH(J+F.ALPHA)
1376 * Let JO2 = IFH(J+F.OMEGA)
1377 * For I = 0 to JO2-Q2
1378 * OUT[J*STEP] += FILTER[Q+2*I-J]*IN[I]
1379 * For I = max(0,JA2) to min(Q2-1,JO2)
1380 * OUT[J*STEP] += FILTER[2*I-J]*IN[I]
1381 * For I = JA2+Q2 to Q2-1
1382 * OUT[J*STEP] += FILTER[2*I-J-Q]*IN[I]
1384 * Let FILTER = F.FP+PQFO(Q2)
1386 * Let OUT[J*STEP] = 0
1388 * OUT[J*STEP] += FILTER[2*I-J]*IN[I]
1391 * acdpe(out, step, in, q2, F)
1394 * (real *)out This output array must be preallocated so
1395 * that elements `out[0]' through
1396 * `out[step*(q-1)]' are defined, q=2*q2.
1397 * (int)step This integer is the increment between
1399 * (const real *)in This input array must be preallocated
1400 * so that `in[0],...,in[q2-1]' are defined.
1401 * (int)q2 This is the period of the input array.
1402 * (const pqf *)F This specifies the periodized QF struct.
1405 * (real *)out Computed values are assigned into this array
1406 * by side effect, at elements separated
1407 * by offsets of `step' starting at `out'.
1411 real
*out
, /* Preallocated array, length `2*q2' */
1412 int step
, /* Increment between `out[]' values */
1413 const real
*in
, /* Preallocated array, length `q2' */
1414 int q2
, /* Number of elements of `in[]' */
1415 const pqf
*F
) /* Periodized QF data structure */
1421 q
= 2*q2
; /* Output array length. */
1422 if( q
> F
->omega
-F
->alpha
) /* Long signal case: */
1426 for( j
=0; j
<q
; j
++ )
1429 ja2
= ICH(j
+F
->alpha
);
1430 jo2
= IFH(j
+F
->omega
);
1432 i
=0; filt
= F
->f
+q
-j
; inp
= in
;
1435 *out
+= (*filt
) * (*inp
++);
1439 i
=max(0, ja2
); filt
= F
->f
+ 2*i
-j
; inp
= in
+i
;
1440 while( i
<=min(q2
-1,jo2
) )
1442 *out
+= (*filt
) * (*inp
++);
1446 i
=q2
+ja2
; filt
= F
->f
+2*i
-j
-q
; inp
= in
+i
;
1449 *out
+= (*filt
) * (*inp
++);
1455 else /* Short signal case: */
1457 for( j
=0; j
<q
; j
++ )
1460 inp
= in
; filt
= F
->fp
+ PQFO(q2
) - j
;
1461 for( i
=0; i
<q2
; i
++)
1463 *out
+= (*filt
) * (*inp
++);