Skip to main content
Log in

A MATLAB Suite for Second Generation Wavelets on an Interval and the Corresponding Adaptive Grid

  • Published:
Acta Applicandae Mathematicae Aims and scope Submit manuscript

Abstract

A collection of Matlab routines for the second generation wavelet transformation and inverse wavelet transformation on the space \(\mathcal{L}_{2}([a,b])\) is presented. These wavelet transforms are further used for computing the wavelet function and scaling function values (\(\psi (x)\) and \(\phi (x)\) respectively). At the end a procedure for generating an adaptive grid using second generation wavelet is provided. In the collection of the Matlab routines, we are providing three Matlab functions namely, Reconstruction_testing.m, AdaptiveGrid_standard_testing.m and AdaptiveGrid_modified_testing.m for directly testing the results claimed in the paper.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8

Similar content being viewed by others

References

  1. Arora, S., Brar, Y., Kumar, S.: Haar wavelet matrices for the numerical solutions of differential equations. Int. J. Comput. Appl. 97, 33–36 (2014)

    Google Scholar 

  2. Auscher, P.: Compactly supported wavelets and boundary conditions. J. Funct. Anal. 111, 29–43 (1993)

    MathSciNet  MATH  Google Scholar 

  3. Bacry, E., Mallat, S., Papanicolau, G.: Wavelet based space-time adaptive numerical method for partial differential equations. Math. Model. Num. Anal. 26, 793–834 (1992)

    MathSciNet  MATH  Google Scholar 

  4. Bertoluzza, S., Maday, Y., Ravel, J.: A dynamically adaptive wavelet method for solving partial differential equations. Comput. Methods Appl. Mech. Eng. 116, 293–299 (1994)

    MathSciNet  MATH  Google Scholar 

  5. Cohen, A., Daubechies, I., Feauveau, J.C.: Biorthogonal bases of compactly supported wavelets. Commun. Pure Appl. Math. 45, 485–560 (1992)

    MathSciNet  MATH  Google Scholar 

  6. Coifman, R.R., Maggioni, M.: Diffusion wavelets. Appl. Comput. Harmon. Anal. 21, 53–94 (2006)

    MathSciNet  MATH  Google Scholar 

  7. Dahmen, W.: Wavelet and multiscale methods for operator equations. Acta Numer. 6, 55–228 (1997)

    MathSciNet  MATH  Google Scholar 

  8. Dahmen, W., Kunoth, A., Urban, K.: A wavelet Galerkin method for Stokes equations. Computing 56, 259–301 (1996)

    MathSciNet  MATH  Google Scholar 

  9. Dahmen, W., Urban, K., Vorloeper, J.: Adaptive Wavelet Methods: Basic Concepts and Applications to the Stokes Problem pp. 39–80. World Scientific, Singapore (2002)

    MATH  Google Scholar 

  10. Daubechies, I.: Orthonormal bases of compactly supported wavelets. Commun. Pure Appl. Math. 41, 909–996 (1988)

    MathSciNet  MATH  Google Scholar 

  11. Daubechies, I.: Ten Lectures on Wavelets. SIAM, Philadelphia (1992)

    MATH  Google Scholar 

  12. Dianfeng, Lu., Tadashi, O., Lin, Z.: Treatment of boundary conditions in the application of wavelet-Galerkin method to an SH wave problem. Int. J. Soc. Mater. Eng. 5, 15–25 (1997)

    Google Scholar 

  13. Donoho, D.L.: Interpolating wavelet transforms. Tech. Rep. 408, Department of Statistics, Stanford University (1992)

  14. Ebeida, M.S., Davis, R.L., Freund, R.W.: A new fast hybrid adaptive grid generation technique for arbitrary two-dimensional domains. Int. J. Numer. Methods Eng. 84, 305–329 (2010)

    MathSciNet  MATH  Google Scholar 

  15. Eiseman, P.R.: Adaptive grid generation. Comput. Methods Appl. Math. 64, 321–376 (1987)

    MathSciNet  MATH  Google Scholar 

  16. Frohlich, J., Schneider, K.: An adaptive wavelet Galerkin algorithm for one-dimensional and two-dimensional flame computations. Eur. J. Mech. B, Fluids 13, 439–471 (1994)

    MathSciNet  MATH  Google Scholar 

  17. Frohlich, J., Schneider, K.: An adaptive wavelet-vaguelette algorithm for the solution of PDEs. J. Comput. Phys. 130, 90–174 (1997)

    MathSciNet  MATH  Google Scholar 

  18. Gabriel, F., Periaswamy, S., Sweldens, W., Aldroubi, A., Laine, A.F.: Wavelet applications in signal and image processing IV. In: Proceedings of SPIE (1996)

    Google Scholar 

  19. Gagnon, L., Lina, J.M.: Symmetrical Daubechies wavelets and numerical solution of NLS equations. J. Phys. A, Math. Gen. 27, 8207–8230 (1994)

    MATH  Google Scholar 

  20. Goyal, K., Mehra, M.: An adaptive meshfree diffusion wavelet method for PDEs on the sphere. J. Comput. Phys. 272, 747–771 (2014)

    MathSciNet  MATH  Google Scholar 

  21. Goyal, K., Mehra, M.: An adaptive mesh free spectral graph wavelet method for partial differential equations. Appl. Numer. Math. 113, 168–185 (2016)

    MATH  Google Scholar 

  22. Hammond, D.K., Vandergheynst, P., Gribonval, R.: Wavelets on graphs via spectral graph theory. Appl. Comput. Harmon. Anal. 30, 129–150 (2011)

    MathSciNet  MATH  Google Scholar 

  23. Hesthaven, J.S., Jameson, L.: A wavelet-optimized adaptive multi-domain method. J. Comput. Phys. 145, 280–296 (1998)

    MathSciNet  MATH  Google Scholar 

  24. Jameson, L.: On the wavelet-optimized finite difference method. Technical Report NASA CR-191601: ICASE Report No. 94–9, (1994)

  25. Jameson, L.: Wavelet based grid generation. Technical Report NASA CR-201609: ICASE Report No. 96–59, (1996)

  26. Jameson, L.: A wavelet-optimized, very high order adaptive grid and numerical method. SIAM J. Sci. Comput. 19, 1980–2013 (1998)

    MathSciNet  MATH  Google Scholar 

  27. Jiwari, R.: A Haar wavelet quasilinearization approach for numerical simulation of Burger’s equation. Comput. Phys. Commun. 183, 2413–2423 (2012)

    MathSciNet  MATH  Google Scholar 

  28. Khodier, A.M.M., Hassan, A.Y.: Oone-dimensional adaptive grid generation. Int. J. Math. Math. Sci. 20, 577–584 (1997)

    MATH  Google Scholar 

  29. Maday, Y., Perrier, V., Ravel, J.C.: Dynamical adaptivity using wavelets basis for the approximation of partial differential equations. C. R. Acad. Sci. 312, 405–410 (1991)

    MATH  Google Scholar 

  30. Maday, Y., Perrier, V., Ravel, J.C.: Adaptivite dynamique sur bases dondelettes pour lapproximation dequations aux de rivees partielles. C. R. Acad. Sci. Paris 312, 405–410 (1991)

    Google Scholar 

  31. Mallat, S.: Multiresolution approximation and orthonormal wavelet basis of \(L^{2}(R)\). Trans. Am. Math. Soc. 315, 69–87 (1989)

    MATH  Google Scholar 

  32. Mehra, M., Goyal, K.: Algorithm 929: a wavelet differentiation matrix suite. ACM Trans. Math. Softw. 39, 27:1–27:28 (2013)

    MATH  Google Scholar 

  33. Mehra, M., Kevlahan, N.K.R.: An adaptive wavelet collocation method for the solution of partial differential equations on the sphere. J. Comput. Phys. 227, 5610–5632 (2008)

    MathSciNet  MATH  Google Scholar 

  34. Mehra, M., Kevlahan, N.K.R.: An adaptive multilevel wavelet solver for elliptic equations on an optimal spherical geodesic grid. SIAM J. Sci. Comput. 30, 3073–3086 (2008)

    MathSciNet  MATH  Google Scholar 

  35. Mehra, M., Kumar, B.V.R.: Time-accurate solution of advection diffusion problems by wavelet-Taylor-Galerkin method. Commun. Numer. Methods Eng. 21, 313–326 (2005)

    MathSciNet  MATH  Google Scholar 

  36. Mehra, M., Patel, K.S.: Algorithm 986: a suite of compact finite difference schemes. ACM Trans. Math. Softw. 44, 1–23 (2017)

    MathSciNet  MATH  Google Scholar 

  37. Nielsen, O.M.: Wavelets in scientific computing. Ph.D. thesis, Technical University of Denmark, Lyngby (1998)

  38. Paolucci, S., Zikoski, Z., Wirasaet, D.: WAMR: an adaptive wavelet method for the simulation of compressible reacting flow. Part I. Accuracy and efficiency of algorithm. J. Comput. Phys. 272, 814–841 (2014)

    MATH  Google Scholar 

  39. Pie, Z.L., Fu, L.Y., Yu, G.X., Zhang, L.X.: A wavelet-optimized adaptive grid method for finite-difference simulation of wave propagation. Bull. Seismol. Soc. Am. 99, 302–313 (2009)

    Google Scholar 

  40. Prusa, Z., Snndergaard, P.L., Rajmic, P.: Discrete wavelet transforms in the large time-frequency analysis toolbox for Matlab/GNU octave. ACM Trans. Math. Softw. 42, 1–23 (2016)

    MathSciNet  MATH  Google Scholar 

  41. Schroder, P., Sweldens, W.: Wavelets in computer graphics. Proc. IEEE 84, 615–625 (1996)

    Google Scholar 

  42. Sharma, D., Goyal, K.: Second-generation wavelet optimized finite difference method (SGWOFD) for solution of Burger’s equation with different boundary conditions. Int. J. Wavelets Multiresolut. Inf. 16, 1–29 (2018)

    MathSciNet  MATH  Google Scholar 

  43. Sharma, D., Goyal, K.: Spectral graph wavelet optimized finite difference method for solution of Burger’s equation with different boundary conditions. J. Differ. Equ. Appl. 25, 373–395 (2019)

    MathSciNet  MATH  Google Scholar 

  44. Sharma, D., Singla, R.K., Goyal, K.: An adaptive grid based curvelet optimized solution for non-linear Schrodinger equation. Int. J. Mod. Phys. C (2019). https://doi.org/10.1142/S0129183119501018

    Article  Google Scholar 

  45. Sweldens, W.: The lifting scheme: a construction of second generation wavelets. SIAM J. Math. Anal. 29, 511–546 (1998)

    MathSciNet  MATH  Google Scholar 

  46. Sweldens, W., Schroder, P.: Building your own wavelets at home. In: Klees, R., Haagmans, R. (eds.) Wavelets in the Geosciences. Lecture Notes in Earth Sciences Springer, Berlin (2000)

    MATH  Google Scholar 

  47. Sweledens, W.: The lifting scheme: a custom design construction of biorthogonal wavelets. Appl. Comput. Harmon. Anal. 3, 485–560 (1996)

    MathSciNet  Google Scholar 

  48. Ulzibayar, V., Zhanlav, T., huluunbaatar, O.C.: Higher order accurate numerical solution of Burger’s equation. Int. J. Math. Sci. 33, 2051–5995 (2013)

    Google Scholar 

  49. Vasilyev, O.V., Bowman, C.: Second-generation wavelet collocation method for the solution of partial differential equations. J. Comput. Phys. 165, 660–693 (2000)

    MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

The first author is grateful to Science & Engineering Research Board (SERB) for the grant MTR/2017/000619 to support this research work and TIET for seed grant. The second author would like to thank Council of Scientific and Industrial Research, New Delhi, India for providing financial support under Senior Research Fellowship scheme with file no. 09/677(0038)/2019-EMR-I.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Deepika Sharma.

Additional information

Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendix: List of Matlab Programs

Appendix: List of Matlab Programs

  1. 1.

    Split.m (dependency: none).

    The function Split.m performs the lazy wavelet transform and separates the even and odd entries of the vector u with suitable multiplication of constants. The calling command for this function is

    figure r

    where u is the vector on which the lazy wavelet transform is to be performed, index is the corresponding vector of indices, lambda and lambda_index are the vectors containing the odd entries and the corresponding indices respectively, gamma and gamma_index are the vectors containing the even entries and the corresponding indices respectively. The implementation goes as follows:

    length_u= length(u); if mod(length_u,2)==0     lambda= zeros(1,length_u/2);     lambda_index=zeros(1,length_u/2);     gamma=zeros(1,length_u/2);     gamma_index=zeros(1,length_u/2); else     lambda=zeros(1,(length_u+1)/2);     lambda_index=zeros(1,(length_u+1)/2);     gamma=zeros(1,(length_u-1)/2);     gamma_index=zeros(1,(length_u-1)/2); end for i=1:length_u     if mod(i,2)==0         gamma(1,i/2)=u(i);         gamma_index(1,i/2)=index(i);     else         lambda(1,(i+1)/2)=u(i);         lambda_index(1,(i+1)/2)=index(i);     end end lambda=(1/sqrt(2))*lambda; gamma=sqrt(2)*gamma;

  2. 2.

    Neville_algo.m (dependency(dependency: none).

    The function Neville_algo.m implements the Neville’s algorithm for interpolation. The main commands are:

    [yi] = Neville_algo(x, y, xi) n = length(x); for k = 1:length(xi)    xd = [];    for i = 1:n       xd(i) = abs(x(i) - xi(k));    end    [xds,i] = sort(xd);    x = x(i);    y = y(i);    P = zeros(n,n);    P(:,1) = y(:);    for i = 1:n-1       for j = 1:(n-i)          P(j,i+1) = ((xi(k)-x(j))*P(j+1,i) + (x(j+i)-xi(k))*P(j,i))                     /(x(j+i)-x(j));       end    end    yi(k) = P(1,n); end

  3. 3.

    Prediction_coefficients_interval.m (dependency: Neville_algo.m).

    This function computes the prediction coefficients for the second generation wavelets. The calling command for this function is

    figure s

    where N is an even number denoting the number of dual vanishing moments and coeff gives the prediction coefficients. The main commands used in this function are the following:

    m=N+1; Prediction_coefficients=zeros(m,N); k1=0:N-1; k2=-0.5:N-0.5; for i=1:N     tmp1=zeros(1,N);     tmp1(i)=1;     for  j=1:m         [yi, ypi, P, D] = Neville_algo(k1, tmp1,k2(j));         Prediction_coefficients(j,i)=yi;     end end

  4. 4.

    Contribution.m (dependency: Prediction_coefficients_interval.m).

    This function computes the matrix containing the information about the indicies of the lambdas which are used to predict gammas and the matrix containing the amount by which the lambdas have predicted gammas. The calling command for this function is

    figure t

    where N is an even number denoting the number of dual vanishing moments, length_lambda_input is the length of lambdas at a particular level, Contri_count gives the matrix containing the information about the indicies of the lambdas which are used to predict gammas, Contri_amount gives the matrix containing the amount by which the lambdas have predicted gammas. The main commands used in this function are the following:

    Prediction_coefficients_matrix=Prediction_coefficients_interval(N);     if mod(length_lambda_input,2)==0         L_tmp=length_lambda_input;     else         L_tmp=length_lambda_input-1;     end     Contri_count =zeros(L_tmp/2,N);     Contri_amount=zeros(L_tmp/2,N);     Case_number=zeros(L_tmp/2,1);     for tmp6=2:2:L_tmp         if ((tmp6-(N-1))>=1 && (tmp6+(N-1))<=length_lambda_input)             Case_number(tmp6/2,1)=N/2;         end     end     tmp7=find(Case_number);     tmp8=tmp7(1);     tmp9=tmp7(end);     for tmp10=1:tmp8-1         Case_number(tmp10,1)=tmp10;     end     for tmp11=tmp9+1:L_tmp/2         Case_number(tmp11,1)=N/2+tmp11-tmp9;     end     for tmp12=1:N         for tmp13=2:2:L_tmp             if(Case_number(tmp13/2,1)==tmp12)                 for tmp14=1:tmp12                     Contri_count(tmp13/2,tmp14)=tmp13-(2*tmp12-1)+2*(tmp14-1);                 end                 for tmp15=1:N-tmp12                     Contri_count(tmp13/2,tmp12+tmp15)=tmp13+2*tmp15-1;                 end             end         end     end     for tmp16=1:N         for tmp17=2:2:L_tmp             if (Case_number(tmp17/2,1)==tmp16)                 Contri_amount(tmp17/2,:)=                 Prediction_coefficients_matrix(tmp16+1,:);             end         end     end

  5. 5.

    Update_coefficients_interval.m (dependency: Prediction_coefficients_interval.m).

    The function Update_coefficients_interval.m computes the update coefficients for the second generation wavelets on intervals as explained in section 3 of the accompanied paper. The calling command for this function is

    figure u

    where L is the length of the original signal, N is number of dual vanishing moments, tN is number of primal vanishing moments, Ini_mom gives a matrix of initial moments, Coeff_matrix gives a matrix containing update coefficients corresponding to gamma, Update_moments gives a matrix containing updated moments, Contri_count gives the matrix containing the information about the indicies of the lambdas which are used to predict gammas and Contri_amount gives the matrix containing the amount by which the lambdas have predicted gammas. The implementation goes as follows:

    L=input('Enter the length of the signal.'); N=input('Enter the number of dual vanishing moments.'); tN=input('Enter the number of primal vanishing moments.'); depth=input('Enter the depth for wavelet transform.'); Coeff_Assi=zeros(depth+1,L); Coeff_Assi(1,:)=1; for tmp1=1:L     if mod(tmp1,2)==1         Coeff_Assi(2,tmp1)=1;     else         Coeff_Assi(2,tmp1)=2;     end end Ini_mom=zeros(tN,L); Ini_mom(1,:)=1; for tmp2=2:tN     Ini_mom(tmp2,:)=(1:L).^(tmp2-1); end if mod(L,2)==0     L_tmp=L; else     L_tmp=L-1; end Contri_count =zeros(L_tmp/2,N); Contri_amount=zeros(L_tmp/2,N);     Case_number=zeros(L_tmp/2,1);     for tmp6=2:2:L_tmp         if ((tmp6-(N-1))>=1 && (tmp6+(N-1))<=L)             Case_number(tmp6/2,1)=N/2;         end     end     tmp7=find(Case_number);     tmp8=tmp7(1);     tmp9=tmp7(end);     for tmp10=1:tmp8-1         Case_number(tmp10,1)=tmp10;     end     for tmp11=tmp9+1:L_tmp/2         Case_number(tmp11,1)=N/2+tmp11-tmp9;     end     for tmp12=1:N         for tmp13=2:2:L_tmp             if(Case_number(tmp13/2,1)==tmp12)                 for tmp14=1:tmp12                     Contri_count(tmp13/2,tmp14)=tmp13-(2*tmp12-1)+2*(tmp14-1);                 end                 for tmp15=1:N-tmp12                     Contri_count(tmp13/2,tmp12+tmp15)=tmp13+2*tmp15-1;                 end             end         end     end Prediction_coefficients_matrix=Prediction_coefficients_interval(N);    %(N+1)xN matrix for tmp16=1:N     for tmp17=2:2:L_tmp         if (Case_number(tmp17/2,1)==tmp16)             Contri_amount(tmp17/2,:)=Prediction_coefficients_matrix(tmp16+1,:);         end     end end if mod(L,2)==0     L_tmp1=L-1; else     L_tmp1=L; end for tmp18=1:2:L_tmp1     [tmp19_row, tmp19_col] =find(Contri_count==tmp18);     gamma_effected=2*tmp19_row;     length_gamma_effected=length(gamma_effected);     for tmp20=1:tN         for tmp21=1:length_gamma_effected             Ini_mom(tmp20,tmp18)=Ini_mom(tmp20,tmp18)+              Contri_amount(tmp19_row(tmp21),              tmp19_col(tmp21))*Ini_mom(tmp20, gamma_effected(tmp21));         end     end end Coeff_matrix=zeros(L_tmp/2,N); for tmp21=2:2:L_tmp     Left_matrix=zeros(tN,N);     right_vec=zeros(tN,1);     for tmp22=1:tN         for tmp23=1:N             Left_matrix(tmp22,tmp23)=             Ini_mom(tmp22,Contri_count(tmp21/2,tmp23));         end         right_vec(tmp22)=Ini_mom(tmp22,tmp21);     end     tmp23=Left_matrix\right_vec;     Coeff_matrix(tmp21/2,:)=tmp23'; end

  6. 6.

    Wavelet_transform.m (dependency: Split.m, Prediction_coefficients_interval.m,

    Update_coefficients_interval.m ).

    The function Wavelet_transform.m performs the second generation wavelet transform on the interval. The calling command for this function is

    figure v

    where f is the function on which wavelet transform is performed, index is the corresponding vector of indices, N is an even number denoting the number of dual vanishing moments, tN is an even number denoting the number of primal vanishing moments, depth determines the numbers of levels upto which the wavelet transform has to be performed. The main commands used in this function are the following:

    length_f=length(f); Prediction_coefficients_matrix=Prediction_coefficients_interval(N); max_NtN=max(N,tN); max_depth_possible=floor(log2((length_f-1)/(max_NtN-1))); if depth>max_depth_possible     error('Maximum depth possible is %f',max_depth_possible ); end Wavelet_transform_matrix=zeros(depth+1,length_f); Wavelet_transform_index=zeros(depth+1,length_f); Wavelet_transform_matrix(1,:)=f; Wavelet_transform_index(1,:)=index; lambda_input=f; index_input=index; Ini_mom=zeros(tN,length_f); Ini_mom(1,:)=1; for tmp2=2:tN     Ini_mom(tmp2,:)=index.^(tmp2-1); end for j=1:depth     [ lambda_tmp, gamma_tmp, lambda_index_tmp, gamma_index_tmp ] =      Split( lambda_input , index_input);     length_lambda_input=length(lambda_input);     if mod(length_lambda_input,2)==0         L_tmp=length_lambda_input;     else         L_tmp=length_lambda_input-1;     end     Contri_count =zeros(L_tmp/2,N);     Contri_amount=zeros(L_tmp/2,N);     Case_number=zeros(L_tmp/2,1);     for tmp6=2:2:L_tmp         if ((tmp6-(N-1))>=1 && (tmp6+(N-1))<=L_tmp)             Case_number(tmp6/2,1)=N/2;         end     end     tmp7=find(Case_number);     tmp8=tmp7(1);     tmp9=tmp7(end);     for tmp10=1:tmp8-1         Case_number(tmp10,1)=tmp10;     end     for tmp11=tmp9+1:L_tmp/2         Case_number(tmp11,1)=N/2+tmp11-tmp9;     end     for tmp12=1:N         for tmp13=2:2:L_tmp             if(Case_number(tmp13/2,1)==tmp12)                 for tmp14=1:tmp12                     Contri_count(tmp13/2,tmp14)=tmp13-(2*tmp12-1)+2*(tmp14-1);                 end                 for tmp15=1:N-tmp12                     Contri_count(tmp13/2,tmp12+tmp15)=tmp13+2*tmp15-1;                 end             end         end     end     for tmp16=1:N         for tmp17=2:2:L_tmp             if (Case_number(tmp17/2,1)==tmp16)                 Contri_amount(tmp17/2,:)=                 Prediction_coefficients_matrix(tmp16+1,:);             end         end     end     gamma_tmp_length=length(gamma_tmp);     for tmp18=1:gamma_tmp_length         for tmp19=1:N             gamma_tmp(tmp18)=gamma_tmp(tmp18)-Contri_amount(tmp18,tmp19)*             lambda_tmp((Contri_count(tmp18,tmp19)+1)/2);         end     end     [Coeff_matrix, Update_moments] =     Update_coefficients_interval1(length_lambda_input, Ini_mom, N,tN);     lambda_tmp_length=length(lambda_tmp);     for tmp20=1:lambda_tmp_length         tmp20_to_original=2*tmp20-1;         [tmp20_row, tmp20_col]=find(Contri_count==tmp20_to_original);         for tmp21=1:length(tmp20_row)                 lambda_tmp(tmp20)=lambda_tmp(tmp20)+                 Coeff_matrix(tmp20_row(tmp21),                 tmp20_col(tmp21))*gamma_tmp(tmp20_row(tmp21));         end     end     Wavelet_transform_matrix(j+1,1:length(lambda_tmp))=lambda_tmp;     Wavelet_transform_matrix(j+1,length(lambda_tmp)+1:length(lambda_input))=        gamma_tmp;     Wavelet_transform_index(j+1,1:length(lambda_tmp))=lambda_index_tmp;     Wavelet_transform_index(j+1,length(lambda_tmp)+1:length(lambda_input))=        gamma_index_tmp;     lambda_input=lambda_tmp;     index_input=lambda_index_tmp;     Ini_mom=zeros(tN, length(lambda_tmp));     for tmp22=1:length(lambda_tmp)         Ini_mom(:,tmp22)=Update_moments(:,2*tmp22-1);     end end end

  7. 7.

    Wavelet_transform_inverse.m (dependency: Contribution.m,

    Update_coefficients_interval.m, Update_coefficients_interval.m).

    The function Wavelet_transform_inverse.m performs the inverse second generation wavelet transform on the interval. The calling command for this function is

    figure w

    where Wavelet_transform_matrix, Wavelet_transform_index are the outputs of Wavelettransform.m, N is an even number denoting the number of dual vanishing moments, tN is an even number denoting the number of primal vanishing moments and f is the reconstructed function. The main commands used in this function are the following:

    depth=size(Wavelet_transform_matrix,1)-1; length_f=size(Wavelet_transform_matrix,2); index=1:length_f; dk=floor((length(nonzeros(Wavelet_transform_matrix(depth+1,:)))+1)/2); dk1=length(nonzeros(Wavelet_transform_matrix(depth+1,:))); lambda_tmp=Wavelet_transform_matrix(depth+1,1:dk);  for tmp24=dk+1:dk1      gamma_tmp(tmp24-dk)=Wavelet_transform_matrix(depth+1,tmp24);  end [D1, D]= Contribution(length(nonzeros(Wavelet_transform_index(depth+1,:))),N); Moments=cell(depth,1); Contribution_A=cell(depth,1); Contribution_C=cell(depth,1); Ini_mom=zeros(tN,length_f); Ini_mom(1,:)=1; for tmp2=2:tN     Ini_mom(tmp2,:)=index.^(tmp2-1); end Moments{1,1}=Ini_mom; for tmp=2:depth     tmp1=length(nonzeros(Wavelet_transform_index(tmp,:)));     [Coeff_matrix, Update_moments,Contri_count, Contri_amount] =     Update_coefficients_interval(tmp1, Ini_mom, N,tN);     Ini_mom=zeros(tN, length(nonzeros(Wavelet_transform_index(tmp+1,:))));     for tmp22=1:length(nonzeros(Wavelet_transform_index(tmp+1,:)))         Ini_mom(:,tmp22)=Update_moments(:,2*tmp22-1);     end     Moments{tmp,1}=Ini_mom;     Contribution_A{tmp,1}=Contri_amount;     Contribution_C{tmp,1}=Contri_count; end for tmp=depth+1:-1:2         [Coeff_matrix, Update_moments,Contri_count, Contri_amount]=             Update_coefficients_interval              (length(nonzeros(Wavelet_transform_index(tmp,:))),              Moments{tmp-1,1}, N,tN);         lambda_tmp_length=length(lambda_tmp);         for tmp20=1:lambda_tmp_length             tmp20_to_original=2*tmp20-1;             [tmp20_row, tmp20_col]=find(Contri_count==tmp20_to_original);             for tmp21=1:length(tmp20_row)                 lambda_tmp(tmp20)=lambda_tmp(tmp20)-                 Coeff_matrix(tmp20_row(tmp21),tmp20_col(tmp21))*                  gamma_tmp(tmp20_row(tmp21));             end         end          gamma_tmp_length=length(gamma_tmp);             for tmp18=1:gamma_tmp_length                 for tmp19=1:N                     gamma_tmp(tmp18)=gamma_tmp(tmp18)+                     D(tmp18,tmp19)*lambda_tmp((D1(tmp18,tmp19)+1)/2);                 end             end         lambda_tmp=sqrt(2)*lambda_tmp;         gamma_tmp=(1/sqrt(2))*gamma_tmp;         for i=2:2:2*length(gamma_tmp)             tmpd(i)=gamma_tmp(i/2);         end         for i=1:2:2*length(lambda_tmp)-1             tmpd(i)=lambda_tmp((i+1)/2);         end         lambda_tmp=tmpd;         dk=floor((length(nonzeros(Wavelet_transform_matrix(tmp-1,:)))+1)/2);         dk1=length(nonzeros(Wavelet_transform_matrix(tmp-1,:)));             for tmp24=dk+1:dk1             gamma_tmp(tmp24-dk)=Wavelet_transform_matrix(tmp-1,tmp24);             end         [D1, D]= Contribution(length(nonzeros                  (Wavelet_transform_index(tmp-1,:))),N);

  8. 8.

    Reconstruction.m (dependency: Wavelet_transform.m, Wavelet_transform_inverse.m).

    The function Reconstruction.m gives the error when the function \(f\) is reconstructed using second generation wavelet transform. It also plots the original given function \(f\) in blue and the reconstructed function in red. The calling command for this function is

    figure x

    where x is the grid, f is the function value, N is an even number denoting the number of dual vanishing moments, tN is an even number denoting the number of primal vanishing moments, depth determines the levels upto which the wavelet transform is to be performed and error gives the reconstruction error. The main commands used in this function are the following:

    index=1:length(x); [C,L,Wavelet_transform_matrix, Wavelet_transform_index] = Wavelet_transform(f,N,tN,depth,index); [f_reconstructed]=Wavelet_transform_inverse(Wavelet_transform_matrix, Wavelet_transform_index,N,tN); error=norm(f-f_reconstructed); figure; plot(x,f,'LineWidth',3); hold on; plot(x,f_reconstructed,'ro'); legend('original function','reconstructed function') grid on;

  9. 9.

    AdaptiveGrid_SGW_modified.m (dependency: Wavelet_transform.m).

    The function AdaptiveGrid_SGW_modified.m constructs an adaptive grid in \(1D\) for second generation wavelet by using the modified adaptation technique. The calling command for this function is

    figure y

    where u is the function value, x is the initial grid, n denotes the number of points to be inserted, epsilon is threshold value, N1 is number of dual vanishing moments, tN is number of primal vanishing moments, depth gives the levels upto which the wavelet transform is to be performed and xc is new grid. The main commands used in this function are the following:

    N=length(x); index=1:length(x); [C,L,Wavelet_transform_matrix, Wavelet_transform_index] = Wavelet_transform(u,N1,tN,depth,index); d=zeros(size(x)); lx=length(x); for tmp1=1:depth     for i=ceil(lx/2)+1:lx         d(Wavelet_transform_index(tmp1+1,i))=         Wavelet_transform_matrix(tmp1+1,i);     end     lx=ceil(lx/2); end xc=x; for i=1:N     if abs(d(i))>=epsilon;         len_int= (x(i)-x(i-1))/2;         dis= len_int/(n+1);         a= zeros(1,2*n);         for j=1:n             a(j)=x(i)-(j-(n+1))*dis;         end         for j=n+1:2*n             a(j)=x(i)-(j-n)*dis;         end         a1=setdiff(a,x);         size(xc)         size(a1)         xc=[xc; a1'];     end end     if abs(d(N))>=epsilon;          len_int= (x(N)-x(N-1))/2;     dis= len_int/(n+1);     a= zeros(1,n);     for j=1:n         a(j)=x(N)-(j)*dis;     end     a1=setdiff(a,x);     xc=[xc; a1'];     end xc=sort(xc); points = zeros(size(xc)); figure; plot(x,u,xc,points,'or','linewidth',2);

  10. 10.

    AdaptiveGrid_SGW_standard.m (dependency: Wavelet_transform.m).

    The function AdaptiveGrid_SGW_standard.m constructs an adaptive grid for a function by using the standard adaptation technique. The calling command for this function is

    figure z

    where u is the function value, x is the initial grid, epsilon is threshold value, N1 is number of dual vanishing moments, tN is number of primal vanishing moments, depth gives the levels upto which the wavelet transform is to be performed and x_new is new grid. The main commands used in this function are the following:

    N= length(x); index=1:length(x); [C,L,Wavelet_transform_matrix, Wavelet_transform_index] = Wavelet_transform(u,N1,tN,depth,index); d=zeros(size(x)); lx=length(x); for tmp1=1:depth     for i=ceil(lx/2)+1:lx         d(Wavelet_transform_index(tmp1+1,i))=         Wavelet_transform_matrix(tmp1+1,i);     end     lx=ceil(lx/2); end y= zeros(1,N); for i=1:N     if(abs(d(i))>=epsilon)         y(i)=1;     end end x_new=[x(1)]; for i=2:length(x)-1     if y(i)==1         x_new=[x_new;x(i)];     end end x_new=[x_new;x(end)]; points = zeros(size(x_new)); figure; plot(x,u,x_new,points,'or','linewidth',2);

  11. 11.

    Reconstruction_testing.m (dependency: Wavelet_transform.m,

    Wavelet_transform_inverse.m).

    The function Reconstruction_testing.m tests the reconstruction error for the second generation wavelet. It gives the error when the function f is reconstructed using second generation wavelet transform. It also plots the original given function f in blue and the reconstructed function in red. The calling command for this function is

    figure aa

    where num takes the values 1, 2 and 3. num=1 means the testing is done for sawtooth function, num=2 means the testing is done for sine function with a discontinuity, num=3 means the testing is done for \(f(x)=-\tanh ((x+x0)/(2*nu))+\exp (-64^{2}*(x-x0).^{2}); x0=1/3;nu=10^{-3}\) and err gives the reconstruction error. The main commands used in this function are the following:

    N=2; tN=2; depth=5; if num==1   x=linspace(0,1,100);   u=zeros(size(x));   for i=1:length(x)     if (x(i)<0.8)         u(i)=x(i);     else         u(i)=x(i)-1;     end   end   [err]=Reconstruction(x,u,N,tN,depth); elseif num==2      x=linspace(0,1,100);      u=zeros(size(x));      for i=1:length(x)          u(i)=sin(2*pi*x(i))+exp(-10^4*(x(i)-0.5)^2);      end      [err]=Reconstruction(x,u,N,tN,depth); elseif num==3     x=linspace(0,1,100);     u=zeros(size(x));     x0=1/3;     nu=10^-3;     for i=1:length(x)         u(i)=-tanh((x(i)+x0)/(2*nu))+exp(-64^2*(x(i)-x0).^2);     end     [err]=Reconstruction(x,u,N,tN,depth); else     error('permissible values of num are 1,2 and 3' ); end

  12. 12.

    AdaptiveGrid_modified_testing.m (dependency: Wavelet_transform.m).

    The function AdaptiveGrid_modified_testing.m plots the given function f and the corresponding adaptive grid using modified adaptation technique. The implementation goes as follows:

    N1=2; tN=2; depth=2; n=2; if num==1   x=linspace(0,1,70)';   u=zeros(size(x));   epsilon=0.7;   for i=1:length(x)     if (x(i)<0.8)         u(i)=x(i);     else         u(i)=x(i)-1;     end   end   [xc] = AdaptiveGrid_SGW_modified(x,u,n,epsilon,N1,tN,depth); elseif num==2      x=linspace(0,1,70)';      u=zeros(size(x));      epsilon=0.7;      for i=1:length(x)          u(i)=sin(2*pi*x(i))+exp(-10^4*(x(i)-0.5)^2);      end      [xc] = AdaptiveGrid_SGW_modified(x,u,n,epsilon,N1,tN,depth); elseif num==3     x=linspace(-1,1,70)';     u=zeros(size(x));     epsilon=0.9;     x0=1/3;     nu=10^-3;     for i=1:length(x)         u(i)=-tanh((x(i)+x0)/(2*nu))+exp(-64^2*(x(i)-x0).^2);     end     [xc] = AdaptiveGrid_SGW_modified(x,u,n,epsilon,N1,tN,depth);     ylim([-2,2]); else     error('permissible values of num are 1,2 and 3' ); end

  13. 13.

    AdaptiveGrid_standard_testing.m (dependency: Wavelet_transform.m).

    The function AdaptiveGrid_SGW_standard.m plots the given function f and the corresponding adaptive grid using standard adaptation technique. The implementation goes as follows:

    N1=2; tN=2; depth=2; if num==1   x=linspace(0,1,100)';   u=zeros(size(x));   epsilon=0.2;   for i=1:length(x)     if (x(i)<0.8)         u(i)=x(i);     else         u(i)=x(i)-1;     end   end   [x_new] = AdaptiveGrid_SGW_standard(x,u,epsilon,N1,tN,depth); elseif num==2      x=linspace(0,1,100)';      u=zeros(size(x));      epsilon=0.7;      for i=1:length(x)          u(i)=sin(2*pi*x(i))+exp(-10^4*(x(i)-0.5)^2);      end      [x_new] = AdaptiveGrid_SGW_standard(x,u,epsilon,N1,tN,depth); elseif num==3     x=linspace(-1,1,100)';     u=zeros(size(x));     epsilon=0.75;     x0=1/3;     nu=10^-3;     for i=1:length(x)         u(i)=-tanh((x(i)+x0)/(2*nu))+exp(-64^2*(x(i)-x0).^2);     end     [x_new] = AdaptiveGrid_SGW_standard(x,u,epsilon,N1,tN,depth);     ylim([-2,2]); else     error('permissible values of num are 1,2 and 3' ); end

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Goyal, K., Sharma, D. A MATLAB Suite for Second Generation Wavelets on an Interval and the Corresponding Adaptive Grid. Acta Appl Math 169, 279–321 (2020). https://doi.org/10.1007/s10440-019-00299-5

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10440-019-00299-5

Keywords

Navigation