123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 |
- /* wavelet/bspline.c
- *
- * Copyright (C) 2004 Ivo Alxneit
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
- /* Coefficients are from A. Cohen, I. Daubechies, and J.-C. Feauveau;
- * "Biorthogonal Bases of Compactly Supported Wavelets", Communications
- * on Pure and Applied Mathematics, 45 (1992) 485--560 (table 6.1).
- *
- * Note the following errors in table 1:
- *
- * N = 2, N~ = 4, m0~
- * the second term in z^-1 (45/64 z^-1) should be left out.
- *
- * N = 3, N~ = 7, m0~
- * the term 336z^-3 should read 363z^-3.
- */
- #include "gsl__config.h"
- #include "gsl_errno.h"
- #include "gsl_math.h"
- #include "gsl_wavelet.h"
- static const double h1_103[6] = { -0.0883883476483184405501055452631,
- 0.0883883476483184405501055452631,
- M_SQRT1_2,
- M_SQRT1_2,
- 0.0883883476483184405501055452631,
- -0.0883883476483184405501055452631
- };
- static const double g2_103[6] = { -0.0883883476483184405501055452631,
- -0.0883883476483184405501055452631,
- M_SQRT1_2,
- -(M_SQRT1_2),
- 0.0883883476483184405501055452631,
- 0.0883883476483184405501055452631
- };
- static const double h1_105[10] = { 0.0165728151840597076031447897368,
- -0.0165728151840597076031447897368,
- -0.1215339780164378557563951247368,
- 0.1215339780164378557563951247368,
- M_SQRT1_2,
- M_SQRT1_2,
- 0.1215339780164378557563951247368,
- -0.1215339780164378557563951247368,
- -0.0165728151840597076031447897368,
- 0.0165728151840597076031447897368
- };
- static const double g2_105[10] = { 0.0165728151840597076031447897368,
- 0.0165728151840597076031447897368,
- -0.1215339780164378557563951247368,
- -0.1215339780164378557563951247368,
- M_SQRT1_2,
- -(M_SQRT1_2),
- 0.1215339780164378557563951247368,
- 0.1215339780164378557563951247368,
- -0.0165728151840597076031447897368,
- -0.0165728151840597076031447897368
- };
- static const double g1_1[10] = { 0.0, 0.0, 0.0, 0.0,
- M_SQRT1_2,
- -(M_SQRT1_2),
- 0.0, 0.0, 0.0, 0.0
- };
- static const double h2_1[10] = { 0.0, 0.0, 0.0, 0.0,
- M_SQRT1_2,
- M_SQRT1_2,
- 0.0, 0.0, 0.0, 0.0
- };
- static const double h1_202[6] = { -0.1767766952966368811002110905262,
- 0.3535533905932737622004221810524,
- 1.0606601717798212866012665431573,
- 0.3535533905932737622004221810524,
- -0.1767766952966368811002110905262,
- 0.0
- };
- static const double g2_202[6] = { 0.0,
- -0.1767766952966368811002110905262,
- -0.3535533905932737622004221810524,
- 1.0606601717798212866012665431573,
- -0.3535533905932737622004221810524,
- -0.1767766952966368811002110905262
- };
- static const double h1_204[10] = { 0.0331456303681194152062895794737,
- -0.0662912607362388304125791589473,
- -0.1767766952966368811002110905262,
- 0.4198446513295125926130013399998,
- 0.9943689110435824561886873842099,
- 0.4198446513295125926130013399998,
- -0.1767766952966368811002110905262,
- -0.0662912607362388304125791589473,
- 0.0331456303681194152062895794737,
- 0.0
- };
- static const double g2_204[10] = { 0.0,
- 0.0331456303681194152062895794737,
- 0.0662912607362388304125791589473,
- -0.1767766952966368811002110905262,
- -0.4198446513295125926130013399998,
- 0.9943689110435824561886873842099,
- -0.4198446513295125926130013399998,
- -0.1767766952966368811002110905262,
- 0.0662912607362388304125791589473,
- 0.0331456303681194152062895794737
- };
- static const double h1_206[14] = { -0.0069053396600248781679769957237,
- 0.0138106793200497563359539914474,
- 0.0469563096881691715422435709210,
- -0.1077232986963880994204411332894,
- -0.1698713556366120029322340948025,
- 0.4474660099696121052849093228945,
- 0.9667475524034829435167794013152,
- 0.4474660099696121052849093228945,
- -0.1698713556366120029322340948025,
- -0.1077232986963880994204411332894,
- 0.0469563096881691715422435709210,
- 0.0138106793200497563359539914474,
- -0.0069053396600248781679769957237,
- 0.0
- };
- static const double g2_206[14] = { 0.0,
- -0.0069053396600248781679769957237,
- -0.0138106793200497563359539914474,
- 0.0469563096881691715422435709210,
- 0.1077232986963880994204411332894,
- -0.1698713556366120029322340948025,
- -0.4474660099696121052849093228945,
- 0.9667475524034829435167794013152,
- -0.4474660099696121052849093228945,
- -0.1698713556366120029322340948025,
- 0.1077232986963880994204411332894,
- 0.0469563096881691715422435709210,
- -0.0138106793200497563359539914474,
- -0.0069053396600248781679769957237,
- };
- static const double h1_208[18] = { 0.0015105430506304420992449678146,
- -0.0030210861012608841984899356291,
- -0.0129475118625466465649568669819,
- 0.0289161098263541773284036695929,
- 0.0529984818906909399392234421792,
- -0.1349130736077360572068505539514,
- -0.1638291834340902345352542235443,
- 0.4625714404759165262773590010400,
- 0.9516421218971785225243297231697,
- 0.4625714404759165262773590010400,
- -0.1638291834340902345352542235443,
- -0.1349130736077360572068505539514,
- 0.0529984818906909399392234421792,
- 0.0289161098263541773284036695929,
- -0.0129475118625466465649568669819,
- -0.0030210861012608841984899356291,
- 0.0015105430506304420992449678146,
- 0.0
- };
- static const double g2_208[18] = { 0.0,
- 0.0015105430506304420992449678146,
- 0.0030210861012608841984899356291,
- -0.0129475118625466465649568669819,
- -0.0289161098263541773284036695929,
- 0.0529984818906909399392234421792,
- 0.1349130736077360572068505539514,
- -0.1638291834340902345352542235443,
- -0.4625714404759165262773590010400,
- 0.9516421218971785225243297231697,
- -0.4625714404759165262773590010400,
- -0.1638291834340902345352542235443,
- 0.1349130736077360572068505539514,
- 0.0529984818906909399392234421792,
- -0.0289161098263541773284036695929,
- -0.0129475118625466465649568669819,
- 0.0030210861012608841984899356291,
- 0.0015105430506304420992449678146,
- };
- static const double h2_2[18] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.3535533905932737622004221810524,
- 0.7071067811865475244008443621048,
- 0.3535533905932737622004221810524,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
- };
- static const double g1_2[18] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- -0.3535533905932737622004221810524,
- 0.7071067811865475244008443621048,
- -0.3535533905932737622004221810524,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
- };
- static const double h1_301[4] = { -0.3535533905932737622004221810524,
- 1.0606601717798212866012665431573,
- 1.0606601717798212866012665431573,
- -0.3535533905932737622004221810524
- };
- static const double g2_301[4] = { 0.3535533905932737622004221810524,
- 1.0606601717798212866012665431573,
- -1.0606601717798212866012665431573,
- -0.3535533905932737622004221810524
- };
- static const double h1_303[8] = { 0.0662912607362388304125791589473,
- -0.1988737822087164912377374768420,
- -0.1546796083845572709626847042104,
- 0.9943689110435824561886873842099,
- 0.9943689110435824561886873842099,
- -0.1546796083845572709626847042104,
- -0.1988737822087164912377374768420,
- 0.0662912607362388304125791589473
- };
- static const double g2_303[8] = { -0.0662912607362388304125791589473,
- -0.1988737822087164912377374768420,
- 0.1546796083845572709626847042104,
- 0.9943689110435824561886873842099,
- -0.9943689110435824561886873842099,
- -0.1546796083845572709626847042104,
- 0.1988737822087164912377374768420,
- 0.0662912607362388304125791589473
- };
- static const double h1_305[12] = { -0.0138106793200497563359539914474,
- 0.0414320379601492690078619743421,
- 0.0524805814161890740766251675000,
- -0.2679271788089652729175074340788,
- -0.0718155324642587329469607555263,
- 0.9667475524034829435167794013152,
- 0.9667475524034829435167794013152,
- -0.0718155324642587329469607555263,
- -0.2679271788089652729175074340788,
- 0.0524805814161890740766251675000,
- 0.0414320379601492690078619743421,
- -0.0138106793200497563359539914474
- };
- static const double g2_305[12] = { 0.0138106793200497563359539914474,
- 0.0414320379601492690078619743421,
- -0.0524805814161890740766251675000,
- -0.2679271788089652729175074340788,
- 0.0718155324642587329469607555263,
- 0.9667475524034829435167794013152,
- -0.9667475524034829435167794013152,
- -0.0718155324642587329469607555263,
- 0.2679271788089652729175074340788,
- 0.0524805814161890740766251675000,
- -0.0414320379601492690078619743421,
- -0.0138106793200497563359539914474
- };
- static const double h1_307[16] = { 0.0030210861012608841984899356291,
- -0.0090632583037826525954698068873,
- -0.0168317654213106405344439270765,
- 0.0746639850740189951912512662623,
- 0.0313329787073628846871956180962,
- -0.3011591259228349991008967259990,
- -0.0264992409453454699696117210896,
- 0.9516421218971785225243297231697,
- 0.9516421218971785225243297231697,
- -0.0264992409453454699696117210896,
- -0.3011591259228349991008967259990,
- 0.0313329787073628846871956180962,
- 0.0746639850740189951912512662623,
- -0.0168317654213106405344439270765,
- -0.0090632583037826525954698068873,
- 0.0030210861012608841984899356291
- };
- static const double g2_307[16] = { -0.0030210861012608841984899356291,
- -0.0090632583037826525954698068873,
- 0.0168317654213106405344439270765,
- 0.0746639850740189951912512662623,
- -0.0313329787073628846871956180962,
- -0.3011591259228349991008967259990,
- 0.0264992409453454699696117210896,
- 0.9516421218971785225243297231697,
- -0.9516421218971785225243297231697,
- -0.0264992409453454699696117210896,
- 0.3011591259228349991008967259990,
- 0.0313329787073628846871956180962,
- -0.0746639850740189951912512662623,
- -0.0168317654213106405344439270765,
- 0.0090632583037826525954698068873,
- 0.0030210861012608841984899356291
- };
- static const double h1_309[20] = { -0.0006797443727836989446602355165,
- 0.0020392331183510968339807065496,
- 0.0050603192196119810324706421788,
- -0.0206189126411055346546938106687,
- -0.0141127879301758447558029850103,
- 0.0991347824942321571990197448581,
- 0.0123001362694193142367090236328,
- -0.3201919683607785695513833204624,
- 0.0020500227115698857061181706055,
- 0.9421257006782067372990864259380,
- 0.9421257006782067372990864259380,
- 0.0020500227115698857061181706055,
- -0.3201919683607785695513833204624,
- 0.0123001362694193142367090236328,
- 0.0991347824942321571990197448581,
- -0.0141127879301758447558029850103,
- -0.0206189126411055346546938106687,
- 0.0050603192196119810324706421788,
- 0.0020392331183510968339807065496,
- -0.0006797443727836989446602355165
- };
- static const double g2_309[20] = { 0.0006797443727836989446602355165,
- 0.0020392331183510968339807065496,
- -0.0050603192196119810324706421788,
- -0.0206189126411055346546938106687,
- 0.0141127879301758447558029850103,
- 0.0991347824942321571990197448581,
- -0.0123001362694193142367090236328,
- -0.3201919683607785695513833204624,
- -0.0020500227115698857061181706055,
- 0.9421257006782067372990864259380,
- -0.9421257006782067372990864259380,
- 0.0020500227115698857061181706055,
- 0.3201919683607785695513833204624,
- 0.0123001362694193142367090236328,
- -0.0991347824942321571990197448581,
- -0.0141127879301758447558029850103,
- 0.0206189126411055346546938106687,
- 0.0050603192196119810324706421788,
- -0.0020392331183510968339807065496,
- -0.0006797443727836989446602355165
- };
- static const double h2_3[20] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.1767766952966368811002110905262,
- 0.5303300858899106433006332715786,
- 0.5303300858899106433006332715786,
- 0.1767766952966368811002110905262,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
- };
- static const double g1_3[20] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- -0.1767766952966368811002110905262,
- 0.5303300858899106433006332715786,
- -0.5303300858899106433006332715786,
- 0.1767766952966368811002110905262,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
- };
- static int
- bspline_init (const double **h1, const double **g1,
- const double **h2, const double **g2, size_t * nc,
- size_t * offset, size_t member)
- {
- switch (member)
- {
- case 103:
- *nc = 6;
- *h1 = h1_103;
- *g1 = &g1_1[2];
- *h2 = &h2_1[2];
- *g2 = g2_103;
- break;
- case 105:
- *nc = 10;
- *h1 = h1_105;
- *g1 = g1_1;
- *h2 = h2_1;
- *g2 = g2_105;
- break;
- case 202:
- *nc = 6;
- *h1 = h1_202;
- *g1 = &g1_2[6];
- *h2 = &h2_2[6];
- *g2 = g2_202;
- break;
- case 204:
- *nc = 10;
- *h1 = h1_204;
- *g1 = &g1_2[4];
- *h2 = &h2_2[4];
- *g2 = g2_204;
- break;
- case 206:
- *nc = 14;
- *h1 = h1_206;
- *g1 = &g1_2[2];
- *h2 = &h2_2[2];
- *g2 = g2_206;
- break;
- case 208:
- *nc = 18;
- *h1 = h1_208;
- *g1 = g1_2;
- *h2 = h2_2;
- *g2 = g2_208;
- break;
- case 301:
- *nc = 4;
- *h1 = h1_301;
- *g1 = &g1_3[8];
- *h2 = &h2_3[8];
- *g2 = g2_301;
- break;
- case 303:
- *nc = 8;
- *h1 = h1_303;
- *g1 = &g1_3[6];
- *h2 = &h2_3[6];
- *g2 = g2_303;
- break;
- case 305:
- *nc = 12;
- *h1 = h1_305;
- *g1 = &g1_3[4];
- *h2 = &h2_3[4];
- *g2 = g2_305;
- break;
- case 307:
- *nc = 16;
- *h1 = h1_307;
- *g1 = &g1_3[2];
- *h2 = &h2_3[2];
- *g2 = g2_307;
- break;
- case 309:
- *nc = 20;
- *h1 = h1_309;
- *g1 = g1_3;
- *h2 = h2_3;
- *g2 = g2_309;
- break;
- default:
- return GSL_FAILURE;
- }
- *offset = 0;
- return GSL_SUCCESS;
- }
- static int
- bspline_centered_init (const double **h1, const double **g1,
- const double **h2, const double **g2, size_t * nc,
- size_t * offset, size_t member)
- {
- switch (member)
- {
- case 103:
- *nc = 6;
- *h1 = h1_103;
- *g1 = &g1_1[2];
- *h2 = &h2_1[2];
- *g2 = g2_103;
- break;
- case 105:
- *nc = 10;
- *h1 = h1_105;
- *g1 = g1_1;
- *h2 = h2_1;
- *g2 = g2_105;
- break;
- case 202:
- *nc = 6;
- *h1 = h1_202;
- *g1 = &g1_2[6];
- *h2 = &h2_2[6];
- *g2 = g2_202;
- break;
- case 204:
- *nc = 10;
- *h1 = h1_204;
- *g1 = &g1_2[4];
- *h2 = &h2_2[4];
- *g2 = g2_204;
- break;
- case 206:
- *nc = 14;
- *h1 = h1_206;
- *g1 = &g1_2[2];
- *h2 = &h2_2[2];
- *g2 = g2_206;
- break;
- case 208:
- *nc = 18;
- *h1 = h1_208;
- *g1 = g1_2;
- *h2 = h2_2;
- *g2 = g2_208;
- break;
- case 301:
- *nc = 4;
- *h1 = h1_301;
- *g1 = &g1_3[8];
- *h2 = &h2_3[8];
- *g2 = g2_301;
- break;
- case 303:
- *nc = 8;
- *h1 = h1_303;
- *g1 = &g1_3[6];
- *h2 = &h2_3[6];
- *g2 = g2_303;
- break;
- case 305:
- *nc = 12;
- *h1 = h1_305;
- *g1 = &g1_3[4];
- *h2 = &h2_3[4];
- *g2 = g2_305;
- break;
- case 307:
- *nc = 16;
- *h1 = h1_307;
- *g1 = &g1_3[2];
- *h2 = &h2_3[2];
- *g2 = g2_307;
- break;
- case 309:
- *nc = 20;
- *h1 = h1_309;
- *g1 = g1_3;
- *h2 = h2_3;
- *g2 = g2_309;
- break;
- default:
- return GSL_FAILURE;
- }
- *offset = ((*nc) >> 1);
- return GSL_SUCCESS;
- }
- static const gsl_wavelet_type bspline_type = {
- "bspline",
- &bspline_init
- };
- static const gsl_wavelet_type bspline_centered_type = {
- "bspline-centered",
- &bspline_centered_init
- };
- const gsl_wavelet_type *gsl_wavelet_bspline = &bspline_type;
- const gsl_wavelet_type *gsl_wavelet_bspline_centered = &bspline_centered_type;
|