(* :Title: Discrete Wavelet Transformations *) (* :Authors: Alistair C. H. Rowe & Paul C. Abbott *) (* :Summary: This package calculates the discrete wavelet transformation of a vector of dyadic length. It performs this calculation for any of the Daubechies wavelet bases. In addition, a user may select the precision of the filter coefficients used in the calculation. The user may also perform the associated inverse wavelet transform. For larger order systems, the precision of the result will be less than the requested precision. For this reason the user should attempt to calculate to a precision higher than that necessary. The package will also allow the user to display the wavelet transform of a vector using a spectral density plot. *) (* :Context: WaveletTransform` *) (* :Package Version: 1.0 *) (* :Keywords: Daubechies wavelets, forward discrete wavelet transform, inverse discrete wavelet transform, dyadic, quadrature mirror filters, spectral density plot, Bezout's theorem, Riesz factorization. *) (* :Source: Strang G (1989) Wavelets and Dilation Equations: A Brief Introduction SIAM Review 31(4) 614-627 *) (* :Source: Daubechies I (1992) Ten Lectures on Wavelets 61 in CBMS-NSF Series in Applied Mathematics SIAM *) (* :Source: Newland D (1993) Introduction to Random Vibrations, spectral and wavelet analysis 3rd Ed. (Essex:Longman) 295-370 *) (* :Mathematica Version: 2.2 *) BeginPackage["WaveletTransform`"] Wavelet::usage= "Wavelet[data,Daubechies[n]] evaluates the discrete wavelet transform of a dyadic vector (data) in the Daubechies basis, Daubechies[n]. Daubechies[n] may be of any even order (i.e. D4, D6, etc...). It will return the transform vector, equal in length to the real space vector. Wavelet[data] returns the discrete wavelet transform of the dyadic (data) vector in the Daubechies[4] basis." InverseWavelet::usage= "InverseWavelet[invdata,Daubechies[n]] evaluates the inverse discrete wavelet transform of the dyadic vector (invdata) in the Daubechies basis, Daubechies[n]. It will return a real space vector of length equal to the length of the transform space vector (invdata). InverseWavelet[invdata] evaluates the inverse discrete wavelet transform in the Daubechies[4] basis." SpectralDensityPlot::usage= "SpectralDensityPlot[{w0,w1,w2,...},t,f] re-orders {w0,w1,w2,...} and displays the result using a spectral density plot with t tickmarks along the position axis (default is 4). The function f, operates on the wavelet coefficients (default is the Identity operation)." Daubechies::usage= "Daubechies[n] gives the Dn hard coded filter coefficients. The coefficients are given to a precision of 60, up to and including Daubechies[50]." GenerateCoefficients::usage= "GenerateCoefficients[n,x] may be used to generate the Dn coefficients, {c0,c1,c2,...,cn}, to a requested precision x. GenerateCoefficients[n] generates the order n filter coefficients to a requested precision of 100." Begin["WaveletTransform`Private`"]; (*------------------FILTER COEFFICIENTS----------------*) (* Hard code for Daubechies basis filter coefficients *) Daubechies::order = "The order of the system you have specified is either odd or out of range." Daubechies[4] = {0.48296291314453414337487159986444868381695241950420227520\ 1172, 0.836516303737807905575293780916873203459370388348\ 43929349534, 0.22414386804201338102597276224040035546788\ 351818427176138717, -0.129409522551260381174449418812024\ 16417453445065996525690700}; Daubechies[6] = {0.33267055295008261599851158913900563001292339924506835970\ 847, 0.8068915093110925764944936040887134905192973949948\ 2361816509, 0.459877502118491570095151942147616720808110\ 17743149230664339, -0.1350110200102545886963899066993744\ 8056221984522378119197569, -0.085441273882026661692819169181773311536197638988086629\ 76352, 0.0352262918857095366027406647155100293277583879\ 17431610398934}; Daubechies[8] = {0.23037781330889650086329118304407085000161524824830929779\ 110, 0.7148465705529156470899219552739926037076084010993\ 081758450, 0.6308807679298589078817163383006152202032229\ 226771951174057, -0.027983769416859854211413747180075385\ 4119873202244917528400, -0.187034811719093084079570672789081419584544174374580091\ 2058, 0.03084138183556076362721936253495905017031482172\ 00340334182, 0.03288301166688519973540751354924438866454\ 194113754971259727, -0.010597401785069032104883208524027\ 229181099964906376419834850}; Daubechies[10] = {0.16010239797419291448072374802042073365054412462505783277\ 26, 0.60382926979718967054011930652506210750742216310169\ 86987969, 0.72430852843777292772807124410221864076875621\ 8232007372577, 0.138428145901320731505397146339024697314\ 105791173956102269, -0.242294887066382031862571379474616\ 361991490808062618598391, -0.032244869584638374648479755062134928313564984163798472\ 254, 0.077571493840045713523130489388601819806230994520\ 125279832, -0.006241490212798274274190519112920192970763\ 5571656876073234, -0.0125807519990819994685097399317757\ 929492045916260978502017, 0.0033357252854737712779981834158173557476365247423053150\ 9971}; Daubechies[12] = {0.1115407433501094636213239172409234390425395919844216759\ 08, 0.49462389039845308567720417687785558863778638289627\ 4362353, 0.751133908021095350678934498439731685580254783\ 33826120097, 0.31525035170919762908598965481092639664951\ 992351729452444, -0.226264693965439820076314500660903465\ 67054015397289699401, -0.129766867567261935562289605876585460845233749223581470\ 16, 0.0975016055873230491023435525381253423398307474952\ 5514280, 0.027522865530305728625540839504193213657387587\ 830434543215, -0.031582039317486029565079080699848669057\ 479532373148423375, 0.000553842201161496139251918398046\ 5012206110262773864964295, 0.0047772575109455106396359752468207070502305012165814342\ 976, -0.001077301085308479564852621609587200035235233609\ 33441968982}; Daubechies[14] = {0.0778520540850091790199635219578937483791830529279556843\ 87, 0.39653931948191730653900039093684285635871511493332\ 874011, 0.7291320908462351199169430703392820517179660611\ 9013637827, 0.469782287405193122471591160974451738681791\ 30567873595324, -0.1439060039285649754050683622130460017\ 952735705499084834, -0.22403618499387498263814042023325\ 09644757830896773246553, 0.07130921926683026475087657050112904822711327451412314\ 66, 0.08061260915108307191292248035938190585823820965629\ 48906, -0.0380299369350144135795920616018580358544619693\ 8467869898, -0.0165745416306668806541076748917026547920\ 4504394820713705, 0.01255099855609984061298988603418777\ 957289474046048710038, 0.0004295779729213665211321291228197322228235350396942409\ 74, -0.0018016407040474909152682629127395509625856514696\ 410906253, 0.000353713799974520248446295836306425431095\ 90600595200400125}; Daubechies[16] = {0.054415842243104009955009405202999355035995542947330503\ 98, 0.31287159091429997065916237550571772194973197403702\ 29186, 0.67563073629728980680780076704718314998691159063\ 36364228, 0.58535468365420671277126552004509819443032666\ 78053369056, -0.0158291052563493056673805478764663041577\ 447115450282656, -0.28401554296154692651620313237416473\ 2468435012487145179, 0.000472484573913282770360590009825894986194801128877007, 0.128747426620478458857029287509708384302260157555648880, -0.0173693010018075461696161488680959831141308652948839\ 43, -0.044088253930794751506763723238963501897518391901\ 1099647, 0.01398102791739828164872293057263345144239559\ 53293434717, 0.00874609404740577671638274324647564018040\ 214708114067674, -0.004870352993451574310422181557109824\ 01663497851215700376, -0.000391740373376947046298080357323776267522935007389049\ 372, 0.000675449406450569366369547573879299121848963001\ 3558432104, -0.00011747678412476953373062823169889094440\ 866939503115039276}; Daubechies[18] = {0.0380779473638783465886976588795511844877171449627841748, 0.243834674612590353732041581649284415526361108560923136, 0.604823123690111111903076867434236170895956271189611757, 0.657288078051300538078212639045173214030585866924591885, 0.133197385825007576190954945899795553692178076843366114, -0.2932737832791749088064031952421987310438961628589906\ 83, -0.096840783222976460513508133537696602248254581045\ 99100, 0.1485407493381063801350727175060423024791258577\ 2806031, 0.030725681479333379212317400720378827141058050\ 24670745, -0.0676328290613299736756422748297190159257879\ 0871353740, 0.00025094711483145195758718974998855433151\ 7627199370963, 0.022361662123679097205373782702690952418\ 556466883088538, -0.004723204757751397277925707848242465\ 405729514912627938, -0.00428150368246342983449679500231\ 45318764811818114632884, 0.001847646883056226476619129491125677051121081359600318\ 16, 0.00023038576352319596720521639282454216929406620524\ 637120, -0.000251963188942710136974988684287860660728218\ 154347802821, 0.000039347320316271599480689883065891507\ 0778247705551701351}; Daubechies[20] = {0.026670057900555553586617448771308582771924982908512899, 0.18817680007769148902089297367909399427025467586403935, 0.52720118893172558648174482795950819249814026808402234, 0.68845903945360356574187178254923585397713640424073395, 0.28117234366057746074872699844558928762438888590261504, -0.24984642432731537941610189792077910005646697371320737, -0.19594627437737704350429925431909813187667764763827785, 0.1273693403357932600826772332014009770786177480422246, 0.0930573646035723511603522898354527322694291799894693, -0.0713941471663970871453360930760506476729261198370215, -0.02945753682187581285828323760141839199388200516064949, 0.03321267405934100173976365318215912897978337413267096, 0.00360655356695616965542329141713340329951735051861899, -0.01073317548333057504431811410651364448111548781143923, 0.001395351747052901165789318447957707567660542855688552, 0.001992405295185056117158742242640643211762555365514105, -0.00068585669495971162656137098192657141966250433367869\ 21, -0.000116466855129285450951480971025899189152746185\ 43475974, 0.0000935886703200695913340501303422285439968\ 8456215297276, -0.00001326420289452124481243667531226683\ 3057492409606058298}; Daubechies[22] = {0.01869429776147108402543572939561975728967774455921959, 0.14406702115062451279519158493610011430237189675562396, 0.4498997643560453347688940373853603677806895378648933, 0.6856867749162005111209386316963097935940204964567703, 0.4119643689479074629259396485710667307430400410187845, -0.1622752450274903622405827269985511540744264324212130, -0.2742308468179469612021009452835266628648089521775178, 0.0660435881966831919006145788812630265675314216894079, 0.149812012466378496406656261704419329858827242026748, -0.046479955116684187271617225890237445772232609668483, -0.066438785695025205278992155369712031918195668960797, 0.0313350902190460760309479840830314453635810568088003, 0.0208409043601810630229481125565649101515776183273472, -0.0153648209062015994261981160995882274401432649577300, -0.0033408588730144456060908086179824061019306583594992, 0.00492841765605904112317073974170827369028554772991580, -0.00030859285881514316517545907262789533071802166050785, -0.0008930232506662646133900824622648653989879519878620\ 73, 0.0002491525235528234988712216872666801088221199302\ 855425, 0.0000544390746993684716735785687957683219193667\ 8525600794, -0.00003463498418698499554128085159974043214\ 506488048233458, 4.494274277236510095415648282310130916\ 410497987383753*10^-6}; Daubechies[24] = {0.01311225795722951750674609088893328065665510641931325, 0.1095662728211851546057045050248905426075680503066774, 0.377355135214212657092821260487920614901094170605753, 0.657198722579307089302761128664116983425020328998841, 0.515886478427815608756032648054303270067769308703609, -0.044763885653774626667627473115401665292845436315059, -0.316178453752785536864802935347803109850883903254736, -0.023779257256069727683997546091332257845533665583317, 0.18247860592757967985404361161892417102947714480963, 0.00535956967435215032827627672976833228886266518419, -0.09643212009650708202650320534322484127430880143045, 0.01084913025582218438089010237748152188661630567603, 0.041546277495084440739270946819065748645135322213884, -0.012218649069748280719987982664715677129824660931166, -0.012840825198300683294660344718947284962061098323141, 0.006711499008795509177767027068215672450648112185856, 0.0022486072409952375999508652112672340183431997861462, -0.0021795036186277604715989033795841711878400752918606, 6.54512821250959556650043039932711072911177056890*10^-6, 0.000388653062820931443589728883779598179191748857342018, -0.0000885041092082043242082164596155372659873832215147\ 19, -0.000024241545757030784029789153205317195804237783\ 6266428, 0.00001277695221937976658714046362616620887375\ 960941439429, -(1.52907175806851090271223916452290122319\ 7615439660341*10^-6)}; Daubechies[26] = {0.0092021335389623679729701634756441846675341719164166, 0.082861243872902779644320271312304664052081133328901, 0.31199632216043806339607841122140496939466835289672, 0.61105585115878765282119951367441805620736126760182, 0.58888957043121890807103953473953339276659863828128, 0.08698572617964723731023739838087494399231884076620, -0.31497290771138863299816982559322825828768884506788, -0.12457673075081525894138083360212601807927392951736, 0.17947607942933984323484500723393690135819662562441, 0.0729489336567771638090283061047766198332592902688, -0.1058076181879343264509667304196464849478860754801, -0.0264884064753436946396391224803478572641960484430, 0.0561394771002834288621450199838733111998837879254, 0.00237997225405907881146517095855420835809439461205, -0.02383142071032364903206403067757739134252922717636, 0.00392394144879741624331637022081552655882474662345, 0.00725558940161756619451839330050269889897352967965, -0.002761911234656862178014576266098445995350093330502, -0.001315673911892298936613835370593643376060412592654, 0.0009323261308672633862226517802548514100918088299802, 0.0000492515251262894619214095738786659621010377829939, -0.00016512898855650548946166877092380007558985482146598, 0.000030678537579325493466494832285754762366004282172379, 0.00001044193057140813708170714991080596951670706436217\ 33, -(4.70041647936086832565019516506177132165038358297\ 10*10^-6), 5.2200350984548646917364243548431769767470\ 521552436*10^-7}; Daubechies[28] = {0.006461153460087947818166397448622814272327159419201, 0.06236475884939889832798566758434877428305333693408, 0.2548502677926213536659077886778286686187042416367, 0.5543056179408938359926831449851154844078269830952, 0.6311878491048567795576617135358172348623952456570, 0.2186706877589065214917475918217517051765774321270, -0.2716885522787480414142192476181171094604882465683, -0.2180335299932760447555558812702311911975240669471, 0.1383952138648065910739939690021573713989900463230, 0.1399890165844607012492943162271163440328221555614, -0.086748411568169689045608220667277953829791495395, -0.071548955504046130735841451151738079909580696731, 0.055237126259216044116188340605334033979138336325, 0.026981408307912916973990314032151933433757665958, -0.0301853515403906351871482262348913757378157540666, -0.0056150495303569591332183713676914986374572972039, 0.0127894932663334089615733070578407929937490386157, -0.0007462189892683849371817160739181780971958187989, -0.00384963886802218744578634931609555177409681850829, 0.00106169108560676184303256674938841117303394158215, 0.000708021154235527858644297769761712898347186346418, -0.000386831947312954482107666339805731442732890210784, -0.0000417772457703725973526797953983925892838972659013, 0.00006875504252697509603873437021628031601890370687652, -0.00001033720918457077394661407342594814586269272509491, -(4.389704901781394115254042561367169829323085360801*10^ -6), 1.7249946753678127698857126927417985235878947098\ 67*10^-6, -(1.78713996831135907633419293847083934388299\ 0309977*10^-7)}; Daubechies[30] = {0.00453853736157889888145939491021169634666367124379, 0.0467433948927662718917096933484357577657915170021, 0.206023863986995731539891500947630721930613850564, 0.492631771708139623606775707402994637261722156513, 0.645813140357424358176420912010691799643260828749, 0.339002535454731527691264114383577391875676949179, -0.193204139609145428706399053432147174630409003914, -0.288882596566965646248412500982233298131143563044, 0.065282952848772816922831079198695748820391742856, 0.190146714007122982348489311658602051795950125817, -0.03966617655579094448384366751896200668381742821, -0.11112093603723169336567103246740586088586237622, 0.03387714392350768620854817844433523770864744687, 0.05478055058450761268913790312581879108609415997, -0.02576700732843996258594525754269826392203641635, -0.020810050169693081677884834246770001620546579514, 0.015083918027835902363292744601703227362448928233, 0.005101000360407543169708860185565314724801066527, -0.006487734560315744995181683149218690816955845639, -0.0002417564907616242811667225326300179605229946996, 0.0019433239803822115417649123325410874410114248656, -0.00037348235413761699200980942136454146113876309680, -0.00035956524436246881216496200759098088581942024541, 0.000155896489920599747947165824122710881625556705963, 0.0000257926991553189368092586241761685591294404236877, -0.0000281332962660478136475532477707847866579144387629, 3.36298718173757980312484521042017747213484665586*10^-6, 1.81127040794057708376851091228584116057708592534*10^-6, -(6.31688232588166442120159729951765765416613791512*10^ -7), 6.133359913305752029056299460289788601989190450\ 89*10^-8}; Daubechies[32] = {0.0031892209253477380297695475646459586870670867501, 0.034907714323673346410301472240230200092182414305, 0.165064283488853117899125273056113481158483500234, 0.43031272284600381374039254243576846206339704780, 0.63735633208378889863198524129960305364985959408, 0.44029025688635690003908691635716792885278030351, -0.089751089402489642857187180774425974306592474456, -0.32706331052791770464629056756891196417572289182, -0.02791820813302827668264519595026873204339971219, 0.21119069394710428872096801632688379009284914262, 0.02734026375271604136485245757201617965429027820, -0.1323883055638103904500474147756493375092287818, -0.0062397227524748717656745033941200258654446563, 0.0759242360442763158214849874394142246153040595, -0.0075889743688577376384948908646369957965869751, -0.0368883976917301423335266632089455431471874843, 0.01029765964095596941165000580076616900528856266, 0.01399376885982873102950451873670329726409840292, -0.00699001456341391667028424953651728833805785620, -0.00364427962149838993216900054093362938705533397, 0.003128023381206268831661202559854678767821471906, 0.000407896980849712836241747032340609578243195297, -0.0009410217493595675889266453953635875407754747217, 0.0001142415200387223926440228099555662945839684345, 0.00017478724522533818038017586376607468749860247286, -0.00006103596621410935835162369150522212811957259982, -0.000013945668988208893451990783119984019823252735692, 0.0000113366086612762585875884876288653699751947106820, -(1.04357134231160650152545473726261540488747893064*10^ -6), -(7.36365678545120551209969571972556364658544554\ 58*10^-7), 2.3087840868575458664054127329420061213063\ 067359*10^-7, -(2.1093396301007430970005726236034899068\ 362975846*10^-8)}; Daubechies[34] = {0.002241807001037312853535962677074436914062191881, 0.02598539370360604338914864591720788315473944525, 0.13121490330782440657755062318590699601442936093, 0.3703507241526411504492548190721886449477078877, 0.6109966156846228181886678867679372082737093893, 0.5183157640569378393254538528085968046216817198, 0.02731497040329363500431250719147586480350469819, -0.3283207483639617360909665340725061767581597698, -0.1265997522158827028744679110933825505053966260, 0.1973105895650109927854047044781930142551422414, 0.1011354891774702721509699856433434802196622545, -0.1268156917782863110948571128662331680384792186, -0.057091419631676927289112394786513823241611609, 0.081105986654160885079658857485554292010243642, 0.022312336178103795953391360595348137562322421, -0.046922438389269737333008970592114005071387681, -0.003270955535819293781655360222177494452069526, 0.0227336765839462703184561624478844896990671374, -0.0030429899813546370685924826379072060786333955, -0.0086029215203228548317137064132436599179267363, 0.0029679966915260948728064850600080382699594638, 0.00230120524215354562430205986903842360424197668, -0.00143684530480297612622289040298038490350367453, -0.000328132519409837971395444401752011507581240244, 0.000439465427768643677838567752731784163228924932, -0.0000256101095665484588272989121094992022166408206, -0.0000820480320245339183909548257628218986613627305, 0.00002318681379874595084482068205706277572106695174, 6.99060098507675127320454970085537862776275859*10^-6, -(4.505942477222988194102268206378312129713572601*10^-6), 3.016549609994557415605207594879939763476168705*10^-7, 2.957700933316856754979905258816151367870345629*10^-7, -(8.423948446002680178787071296922877068410310942*10^-8), 7.267492968561608110879767441409035034158581720*10^-9}; Daubechies[36] = {0.001576310218440760431540744929939777747670753711, 0.0192885317241463770592139171582905241995466703, 0.1035884658224235962241910491937253596470696555, 0.314678941337031699057199825565257993178670619, 0.571826807766607223481858937090062341939367374, 0.571801654888651335289111999406596502566804788, 0.147223111969928141575097727108107231255786411, -0.293654040736558744247903099498115072393571073, -0.216480934005142971123767862566827147143793724, 0.149533975565377789350930173891366720880481669, 0.167081312763257404514931813995013474532420565, -0.092331884150846280604293725586594597314318480, -0.10675224665982848559322005816149848613852664, 0.06488721621190544281947577955141911463129382, 0.05705124773853688412090768846499622260596226, -0.04452614190298232471556143559744653492971478, -0.02373321039586000103275209582665216110197519, 0.02667070592647059029987908631672020343207896, 0.006262167954305707485236093144497882501990325, -0.013051480946612001772776364476008071697551911, 0.000118630033858117465730174159216181908454490, 0.004943343605466738130665529516802974834299638, -0.0011187326669924970728006588552386501823180605, -0.0013405962983361066295175672282515836098230445, 0.0006284656829651457125619449885420838217551023, 0.00021358156191034068840390528143419260258732003, -0.00019864855231174794857982454163624895549277979, -(1.53591712353472467506977033587671719370047*10^-7), 0.0000374123788074003818109220813803539395230429262, -(8.5206025374466952039192549116555230224375970*10^-6), -(3.33263447888582188878245203334103682731150591*10^-6), 1.76871298362761545587632873075537517641250136*10^-6, -(7.69163268988517614600015287853959840581739759*10^-8), -(1.176098767028231698450982356561292561347579778*10^-7), 3.06883586304517480093547829493397537245017979*10^-8, -(2.50793445494859826719517318314712673180631714*10^-9)}; Daubechies[38] = {0.00110866976318171057109915419520971516424529968, 0.0142810984507643973743988915295019923474566344, 0.081278113265459550652963067849016248398449800, 0.26438843174089678467481003802894268738623778, 0.52443637746465491533605759754840646260446336, 0.60170454912753789488670771359218026205365656, 0.26089495265103882928724566753105283241726731, -0.22809139421548264637463257760546372070937872, -0.28583863175582624185459756950289842372173561, 0.07465226970810326636763433111878819005865866, 0.21234974330627848880906085670598241970770742, -0.03351854190230287868169388418785731506977845, -0.14278569503873657497796027316261128129984977, 0.0275843506256286687501474352016219865537447, 0.0869067555558122324884764542880844303478521, -0.0265012362501230408990183584367638736107507, -0.0456742262772309080564544421429579601793894, 0.0216237674095850471303298425717237235431810, 0.0193755498891761276463709435445799981449689, -0.01398838867853514163250401235248662521916814, -0.00586692228101217472658449343605437377381461, 0.00704074736710524315301451120740062010940169, 0.00076895435925754835597491391486739551634779, -0.002687551800701582003957363855070398636534039, 0.000341808653458595776565165729046380813521421, 0.000735802520505435207026048190539728187518318, -0.0002606761356786280057318315130897522790383939, -0.0001246007917341587753449784408901653990317341, 0.00008711270467219922965416862388191128268412934, 5.105950487073886053049222809934231573687368*10^-6, -0.000016640176297154944546206777198991986303336756, 3.0109643162965263396953344547259436326457989*10^-6, 1.5319314766911930639318323810866360312031230*10^-6, -(6.8627556577691427018835546134867328544527408*10^-7), 1.4470882987978445420782198632916154205516736*10^-8, 4.6369377757826042234308577282109488988717483*10^-8, -(1.11640206703582581639050476914247258646497580*10^-8), 8.6668488389976193503230135407821246272897422*10^-10}; Daubechies[40] = {0.0007799536136668463215861994818889370970510722, 0.010549394624950398324544809730156414982319615, 0.06342378045908151497587346582668785136406523, 0.2199421135513970450080335972537209392121307, 0.4726961853109016963710241465101446230757804, 0.6104932389385938201631515660084201906858629, 0.3615022987393310629195602665268631744967085, -0.13921208801148387258069705451555305182649449, -0.3267868004340349674031122837905370666716646, -0.0167270883090770075751717499730429705400374, 0.2282910508199163229728429126648223086437547, 0.0398502464577712021979058107652217418110403, -0.1554587507072679559315307870562464374359996, -0.024716827338613584015879922991699222629152, 0.102291719174442557886101368101686608388838, 0.005632246857307435506953246988215209861567, -0.061722899624680459733186583340832835582093, 0.005874681811811826491300679742081997167210, 0.032294299530769581758854408606172191175646, -0.008789324923901561348753650366700695916503, -0.0138105261371519200781960642386035659049690, 0.0067216273022594568353368505214054255605200, 0.0044205423870457909630582295266735140888090, -0.0035814942596096227775561696383582383757652, -0.00083156217282255691924825851993732309569245, 0.00139255961932313632390525499934796728376054, -0.00005349759843997695051759716377213680036186, -0.000385104748699217606065028850147571646326623, 0.000101532889736702905079748878530605652252998, 0.0000677428082837772955801118440672797822129580, -0.0000371058618339471286422722127121640841695823, -(4.37614386218399681037309582252860760690062*10^-6), 7.241248287673620102843105877497181565468726*10^-6, -(1.011994010018886150340475413756849103197395*10^-6), -(6.847079597000556894163334787575159759109091*10^-7), 2.633924226270001084129057791994367121555770*10^-7, 2.01432202355051269432475784594402604790441*10^-10, -(1.8148432482996959732106052582270240814585311*10^-8), 4.056127055551832766099146230616888024627381*10^-9, -(2.998836489619319566407767078372705385732460*10^-10)}; Daubechies[42] = {0.000548822509852683708677633667599252142675067, 0.00777663905235478375433878739808879986251078, 0.0492477715381772749139985337834005696810448, 0.181359625440381515626037872276462419093195, 0.419687944939362773094685060908926633997360, 0.601506094935003897562988066402095595306654, 0.444590451927600340364329099452360101615134, -0.0357229196172552904592291417800530718903676, -0.335664089530529509483297886711436306998758, -0.112397071568450981351500498134030690164182, 0.211564527680872392384678164523846865943086, 0.115233298439687104199343441168173042810316, -0.139940424932547224924775876483977690322650, -0.081775942980863828873873036341937905425226, 0.09660039032372422070232189700372539681628, 0.04572340574922879239251202944731235421035, -0.06497750489373232063332311106008616685749, -0.01865385920211851534093244412008141266131, 0.03972683542785044175197464400756126818300, 0.00335775639033811084253260476637620076079, -0.02089205367797907948785235479746212371728, 0.002403470920805434762380632169785689545911, 0.008988824381971911875349463398395464114418, -0.002891334348588901247375268718015882610845, -0.002958374038932831280750770228215510959830, 0.0017166070406306241384945062825692301263333, 0.0006394185005120302146432543767052865436100, -0.0006906711170821016507268939228893784790518, -0.00003196406277680437193708834220804640347637, 0.00019366465041650806153236966898560049105798, -0.000036355202500863383094428550061863707522063, -0.000034996659849874479539740794900465972402763, 0.0000153548250927604928312423349864605047209648, 2.79033053981448704610616958269176791628379*10^-6, -(3.09001716454569919715855593685269732598586*10^-6), 3.16609544236703055660388900983395444005855*10^-7, 2.99213663046485279440129460753681368277129*10^-7, -(1.000400879030597332045460600516621971679364*10^-7), -(2.25401497467333013156318485145682599161792*10^-9), 7.05803354123112185902094797690390468546451*10^-9, -(1.471954197650365265189549600816698778213247*10^-9), 1.038805571023706553035373138760372703492943*10^-10}; Daubechies[44] = {0.00038626323149109821585243589006154603688779, 0.0057218546313345391208097834034844933335554, 0.038069937236411084947698730463918255744477, 0.14836754089011142850144044487102498373858, 0.36772868344603747886146908184523728274305, 0.57843273100952442714211818317354441063851, 0.50790109062216390183915233253907168365687, 0.073724501183630151655701390165306531137252, -0.31272658042829619180332262226217885370785, -0.20056840610488709393243612440422001741329, 0.16409318810676648186062232262868857125544, 0.17997318799289130372521542953130831683878, -0.09711079840911470969274209179691733251457, -0.13176813768668341075136485181468383454779, 0.0680763143927322155673920214700458055937, 0.0845573763668260750336281365935678649436, -0.0513642542974441324572794998401888470791, -0.0465308118275067134787583360784697999783, 0.0369708466206980205761531889298858182564, 0.0205867076275653604406024971067665680728, -0.0234800013444931886856014285451936498736, -0.0062137828493646584990693361238076082931, 0.01256472521834337406887017835495604463815, 0.00030013739850764359512291292555882557469, -0.00545569198615671707659535316307167910787, 0.00104426073918602532335075565918473406081, 0.001827010495657279080112597436850157110235, -0.000770690988123119623288037272295551978166, -0.000423787399839180079953194776800397697820, 0.0003286094142136787341983758471405935405823, 0.0000434589990453200337904699262557507609282, -0.00009405223634815760421845190098352673647881, 0.00001137434966212593172736144274866639210340, 0.000017373756957561893561635650745054059068597, -(6.166729316467578372152251668422979152170*10^-6), -(1.5651791319951601593074269935782047333781*10^-6), 1.2951820573188775738897112323450681478004*10^-6, -(8.779879873361286276888117046153049053917*10^-8), -(1.28333622875175441781969393211406488707510*10^-7), 3.7612287493373623661567116481877433991642*10^-8, 1.6801714049229888855543311836912802459623*10^-9, -(2.7296231466329760834493273617391047544432*10^-9), 5.3359388216674899051697832270368045332530*10^-10, -(3.6021134843395547037948078109393018472991*10^-11)}; Daubechies[46] = {0.0002719041941282888414192673609703302357098, 0.004202748893183833538390034372523511472345, 0.02931000365788411514736204018929480427874, 0.12051553178397193363060538956118990890043, 0.3184508138528652363416527748460472152791, 0.5449311478735204282674240672421984387504, 0.5510185172419193913452724227212507720514, 0.1813926253638400136259098302138614937264, -0.2613921480306441118856795735210118413900, -0.2714020986078430556604069575184718123764, 0.0921254070824180526064603091073489425858, 0.2235736582420402317149513960822561717690, -0.0330374470942893787500661279246303140946, -0.1640113215318759250156057837165276039181, 0.0202830745756492997489728660755131332342, 0.112297043618107288695073446507564597775, -0.021126212356227241007047832935494670490, -0.070207391574901109462042190119575653439, 0.021765856834499975607768824721687301658, 0.038495332522569199010571543204075960732, -0.018523513650156159797946899607406747828, -0.017537101003035845379158461174086135511, 0.012751943931528286462431574044749471151, 0.0060318406500241628162898782060378416408, -0.0070753192737061528141940394814665562045, -0.0011348654733562516912893371200132867563, 0.0031228764498181449974191447651257505224, -0.00024650140051635120319404731003753772109, -0.00106123122888665132113935762568380564219, 0.00031942049270990115036765303596923669909, 0.000256762452007873720556385667537663609231, -0.000150021850349034096767316329044783223626, -0.0000337889483412090343427096245267453433090, 0.0000442607120310924607762187530344093533570, -(2.63520788924918623720922593317089782543*10^-6), -(8.34787556785462554436604374884418308677*10^-6), 2.397569546840240057403739507525641239510*10^-6, 8.14757483477944777808544304142288143986*10^-7, -(5.339005405209421154584783682848780965054*10^-7), 1.853091785633965019353699857864654181729*10^-8, 5.417549179539278736503176166323685597634*10^-8, -(1.3999354954379988451309096873618471032742*10^-8), -(9.472885901812050535221582074673490573092*10^-10), 1.0504464536965434040711051110964385734231*10^-9, -(1.932405111313417542192651899622541612314*10^-10), 1.2502033023510409414332167182175042405414*10^-11}; Daubechies[48] = {0.000191435800947551369502613833647411559944, 0.00308208171490549443620619942454440472098, 0.0224823399497164107235841515718482562823, 0.0972622358336251966380654573400835591453, 0.272908916067726326870613713441255726875, 0.504371040839924991977187689040281410925, 0.574939221095541996846080790192340703314, 0.280985553233711883344262608511540294184, -0.187271406885156237698188715977579146906, -0.317943078999362737545394848979770755090, 0.0047766136843447281879501983230313608663, 0.239237388780310855197326829194582482221, 0.042528729641483832581473644721706452327, -0.171175351370346889689763851508057239395, -0.038777173577920016201775947261995726884, 0.12101630346922423623126373111490622867, 0.02098011370914481534980883827326017063, -0.08216165420800166702291466006164189461, -0.00457843624181922163799751633976506883, 0.05130162003998087915555334881398688959, -0.00494470942812562829981592003264955081, -0.02821310709490189098113895361900699229, 0.00766172188164658589732989990430876441, 0.01304997087108573583052494067883717533, -0.006291435370018187780721843581169343901, -0.004746568786323113800477796959513558402, 0.003736046178282523345179052160810332869, 0.001153764936839481504858282495202271984, -0.001696456818974824394274534636412116243, -0.0000441618485614152006336595890007940674, 0.0005861270593183109933716735450272894035, -0.00011812332379695547406130212277565689668, -0.00014600798177626168389243018180827290363, 0.00006559388639305634085303738560455061974, 0.000021832414604665583633650440329842577098, -0.0000202288829261269768286085998720045570261, 1.34115775080911471931993755318602366*10^-8, 3.90110033859770261040901412902422385313*10^-6, -(8.9802531439384077241499266699807911664*10^-7), -(4.03250775687997162409898324735898342524*10^-7), 2.16633965327857463917639397851024633548*10^-7, -(5.0576454197925003084925089243432489793*10^-10), -(2.25574038817608610736882167494717580401*10^-8), 5.15777678967199963895077426631320871502*10^-9, 4.74837582425623111809445354979917582453*10^-10, -(4.02465864458437977425149957446819511860*10^-10), 6.99180115763823097413269643350962593402*10^-11, -(4.34278250380371024725903755288674945795*10^-12)}; Daubechies[50] = {0.00013480297934701889945784892471593560554, 0.0022569595918547795201213910496280561493, 0.017186741254040155338171869149548489022, 0.078035862872132675597506593204814036684, 0.23169350788602181999006215180570891049, 0.45968341514609459378969738645396599440, 0.58163689674605778335348920387570856358, 0.36788507480294669843713197408555322787, -0.097174640964638142761300481690408926071, -0.33647307964174613095621101488488452189, -0.087587614587654661402266876738800061543, 0.22453781974510171295251765104095431559, 0.11815528671995986045630678768199318826, -0.15056021375057963095180942068314332709, -0.09850861528996022153725952822686729410, 0.10663380501847795288312745405224147113, 0.0667521644940186066689598307244398470, -0.0770841110565741935620856767169903205, -0.0371739628611225088759813732404687046, 0.0536179093987794996062904141954653690, 0.0155426059291022916398129585460320363, -0.0340423204606533409932062858403372915, -0.0030798367948470366616366939635702887, 0.0189228044766276284108658117869103936, -0.0019894257822027364942894618963862353, -0.0088607026180463683990130642524565570, 0.00272693625873849573987146924461004279, 0.00332270777397319178011819735719482929, -0.00184248429020333128083778043001419574, -0.00089997742374629504910853825240084296, 0.000877258193674827484348880619017592138, 0.000115321244046630045646018145534563987, -0.000309880099098469798953054424535627112, 0.0000354371452327605900528428983055925981, 0.0000790464000396552825513749630316600174, -0.00002733048119960041746353244004225286858, -0.00001277195293199783804144903848434605691, 8.990661393062588905369930197413951232*10^-6, 5.232827708153076417963912065899772684*10^-7, -(1.7792013326536345625659485560390091495*10^-6), 3.2120375188625190948950058166610939883*10^-7, 1.9228067901423716012781042447112674208*10^-7, -(8.6569417322785071633880315179309749480*10^-8), -(2.6115985561117708642598430891517822069*10^-9), 9.2792244800813723722500733547265113597*10^-9, -(1.8804157550621555371977825957409751899*10^-9), -(2.2284749102281688993147933520647959573*10^-10), 1.5359015701626571970219277395307219559*10^-10, -(2.5276251634656448110488642861697581281*10^-11), 1.5096920828239108679033677120960016650*10^-12}; Daubechies[i_/; OddQ[i] || i < 4] := Message[Daubechies::order] (* Using Bezout's theorem and the results of Daubechies to generate the list of filter coefficients in the order {c0,c1,c2,c3,c4,...} *) P[n_, y_] := Sum[Binomial[n-1+k,k] y^k, {k,0,n-1}] GenerateCoefficients[n_, prec_:100] := Module[{poly, r, small, z, l}, poly = P[n/2,1/2 - 1/(4z) - z/4] // Factor; r = z /. N[Solve[poly == 0, z], prec]; small = Select[r, Abs[#] < 1 &]; poly = (z+1)^(n/2) Times @@ (z - small); l = CoefficientList[poly,z] // Reverse; l / Sqrt[l.l] ] /; If[OddQ[n] || n < 4, Message[Daubechies::order], True] (* --------------FORWARD WAVELET TRANSFORM--------------*) (* Define the high and low pass quadrature mirror filters *) QMFL[basis_] := QMFL[basis] = basis; QMFH[basis_] := QMFH[basis] = Reverse[basis] Table[ (-1)^(i+1),{i,1,Length[basis]}]; (* Define a procedure for extending the data vector in such a way that it is compatible with the basis length *) Extension[v_,bas_] := Table[v[[Mod[i-1,Length[v]]+1]], {i,1,Length[v] + Length[bas] - 2}]; (* The intermediate wavelet transform is applied iteratively to the real space vector or part thereof *) Intermediate[data_,m_,basis_] := Module[{vect, vectcomp, l = Length[basis], L, H, vl = Length[data]/(2^m)}, vect = Take[data,vl]; vectcomp = Drop[data,vl]; vect = Extension[vect,basis]; L = Table[QMFL[basis].Take[vect,{1+i,i+l}],{i,0, Length[vect] - l,2}]; H = Table[QMFH[basis].Take[vect,{1+i,i+l}],{i,0, Length[vect] - l,2}]; vect = L ~Join~ H ~Join~ vectcomp ]; Warning::basis = "length of basis is not correct." Wavelet::error = "Vector length is not dyadic." (* Wavelet definition *) Wavelet[data_, basis_:Daubechies[4]] := Block[{n = -1}, Which[OddQ[Length[basis]], Message[Warning::basis], IntegerQ[Log[2,Length[data]]], (1/N[Sqrt[Length[data]]])* Nest[(++n; Intermediate[#,n,basis])&, data, Log[2,Length[data]]], True,Message[Wavelet::error]] ]; (*----------------INVERSE WAVELET TRANSFORM-------------*) (* Define the inverse quadrature mirror filters *) InverseQMF[band_,basis_] := Block[{l = Length[basis],oddelem,evenelem,revodd,reveven,qmf}, oddelem = Table[basis[[i]],{i,1,l,2}]; evenelem = Table[basis[[i]],{i,2,l,2}]; revodd = Reverse[oddelem]; reveven = Reverse[evenelem]; If[TrueQ[band == l], qmf = Flatten[Table[{revodd[[i]],evenelem[[i]]}, {i,1,Length[revodd]}]], qmf = Flatten[Table[{reveven[[i]],-oddelem[[i]]}, {i,1,Length[reveven]}]]] ]; (* Define a procedure which matches the length of the transform vector to the length of the basis *) InverseExtension[v_,bas_] := Table[v[[Mod[Length[v]+i- Length[bas]+1,Length[v]]+1]], {i,1,Length[v] + Length[bas] - 2}]; (* Intermediate inverse transform definition *) InverseIntermediate[data_,m_,basis_] := Module[{v1, v2, v1comp, vl = 2^(m+1),l = Length[basis], L, H}, v1 = Take[data,vl]; v1comp = Drop[data,vl]; v2 = Flatten[Table[{v1[[i]],v1[[i+vl/2]]}, {i,1,vl/2}]]; v1 = InverseExtension[v2,basis]; L = Table[InverseQMF[l,basis].Take[v1,{1+i,i+l}], {i,0,Length[v1] - l,2}]; H = Table[InverseQMF[h,basis].Take[v1,{1+i,i+l}], {i,0,Length[v1] - l,2}]; v1 = Flatten[Table[{L[[i]],H[[i]]}, {i,1,Length[L]}]] ~Join~ v1comp ]; InverseWavelet::error = "Vector length is not dyadic." (* Inverse wavelet transform definition *) InverseWavelet[data_,basis_:Daubechies[4]] := Block[{n = -1}, Which[OddQ[Length[basis]], Message[Warning::basis], IntegerQ[Log[2,Length[data]]], N[Sqrt[Length[data]]]* Nest[(++n; InverseIntermediate[#,n,basis])&, data, Log[2,Length[data]]], True,Message[InverseWavelet::error] ] ]; (*------------------GRAPHICAL OUTPUT-----------------*) (* Re-arrange the transform space vector into the appropriate form for viewing on a spectral density plot *) PictFormat[data_] := Module[{l = Length[data], t1, t2}, t2 = Table[Take[data,{2^i + 1,2^(i+1)}][[j]], {i,1,Log[2,l]-1},{j,1,2^i},{l/(2^i)}]; t1 = {Flatten[Table[{Take[data,1]},{l}]]} ~Join~ {Flatten[Table[{Take[data,{2,2}]},{l}]]} ~Join~ Table[Flatten[t2[[i]]],{i,1,Log[2,(l/2)]}] ]; scaleticks[n_] := Table[{i+1/2, i},{i,-1,n}]; posticks[n_,m_] := Table[m i,{i,0,n/m}]; (* SpectralDensityPlot definition *) SpectralDensityPlot[list_?VectorQ, numticks_:4, f_:Identity] := Block[{dims,pos,scales}, dims = Dimensions[PictFormat[list]]; pos = Last[dims]; scales = First[dims]; ListDensityPlot[f[PictFormat[list]], Mesh -> False, MeshRange -> {{1,pos},{-1,scales-1}}, FrameTicks -> {posticks[pos,pos/numticks], scaleticks[scales-2]}, Axes->True,AxesLabel->{"position","scale"}] ]; End[]; (* "WaveletTransform`Private`" *) SetAttributes[Daubechies,ReadProtected]; SetAttributes[GenerateCoefficients,ReadProtected]; SetAttributes[Wavelet,ReadProtected]; SetAttributes[InverseWavelet,ReadProtected]; SetAttributes[SpectralDensityPlot,ReadProtected]; Protect[Daubechies,GenerateCoefficients,Wavelet, InverseWavelet,SpectralDensityPlot]; EndPackage[]; (* "WaveletTransform`" *)