## Installing and using the Matlab interfaces

To use the Matlab interfaces, the C library must be built according to the instructions on this page. The Matlab interfaces require C and Matlab mex compilers. It is also required to link with CFITSIO and HEALPIX libraries to support for the Healpix spherical harmonic transform as well as the FITS input-output routines.

#### Compiling

Makefiles are provided to build the code. However the locations of **SSHT**, **FFTW** and optionally **CFITSIO** and **HEALPIX** must be specified by defining the symbols in Bash/Shell. Alternatively you may declare them explicitely in the first section of the makefile. The compilers and their options may also be changed in the Makefile.

Once you have set the Makefile up for your system,
the C library and the Matlab interfaces for **S2LET** may be compiled by running:

>> make matlab

To tidy up all temporary files and objects run:

>> make tidy

To remove all compiled files and programs run:

>> make clean

## Source code documentation

**S2LET** ships with source documentation that is
generated by doxygen for C and by m2html for Matlab. The Matlab documention is available here. Also, all
Matlab routines are self documenting and that documentation can be accessed through the help command in
Matlab, as discussed below.

## Testing and using the interfaces

Once the Matlab interface is built, you must have **both**
`s2let/src/main/matlab`

and `ssht/src/matlab`

in your path in order to run the Matlab functions.
A number of Matlab functions and demos illustrating their use are
provided.

#### Functions

A list of the high-level Matlab functions, with brief descriptions, is given here:

##### Axisymmetric wavelet transform

s2let_transform_axisym_analysis_mw Compute exact axisymmetric wavelet transform of a signal on the sphere (MW sampling). s2let_transform_axisym_synthesis_mw Exactly reconstuct a signal on the sphere from its axisymmetric wavelets (MW sampling). s2let_transform_axisym_analysis_hpx Compute exact axisymmetric wavelet transform of a signal on the sphere (Healpix sampling). s2let_transform_axisym_synthesis_hpx Exactly reconstuct a signal on the sphere from its axisymmetric wavelets (Healpix sampling).

##### Spin directional wavelet transform

s2let_transform_analysis_lm2wav Compute forward (spin) directional wavelet transform, input in harmonic space, output in wavelet space (MW sampling). s2let_transform_analysis_mw Compute forward (spin) directional wavelet transform, output in pixel space (MW sampling). s2let_transform_synthesis_lm2wav Compute inverse (spin) directional wavelet transform, input in harmonic space, output in wavelet space (MW sampling). s2let_transform_synthesis_mw Compute inverse (spin) directional wavelet transform, output in pixel space (MW sampling).

##### Radon transform and Ridgelet transform

s2let_radon_transform Compute forward (spin) radon transform in harmonic space. s2let_radon_inverse Compute inverse (spin) radon transform in harmonic space. s2let_ridgelet_analysis Compute forward (spin) ridgelet transform (MW sampling). s2let_ridgelet_synthesis Compute inverse (spin) ridgelet transform (MW sampling).

##### Curvelet transform

s2let_transform_curvelet_analysis_lm2lmn Compute forward (spin) curvelet transform, input in harmonic space, output in Wigner space (MW sampling). s2let_transform_curvelet_analysis_lm2cur Compute forward (spin) curvelet transform, input in harmonic space, output in curvelet space (MW sampling). s2let_transform_curvelet_analysis_px2cur Compute forward (spin) curvelet transform, input in pixel space, output in curvelet space (MW sampling). s2let_transform_curvelet_synthesis_lmn2lm Compute inverse (spin) curvelet transform, input in Wigner space, output in harmonic space (MW sampling). s2let_transform_curvelet_synthesis_cur2lm Compute inverse (spin) curvelet transform, input in curvelet space, output in harmonic space (MW sampling). s2let_transform_curvelet_synthesis_cur2px Compute inverse (spin) curvelet transform, input in curvelet space, output in pixel space (MW sampling).

##### Construction and exactness check for scale-discretised wavelets

s2let_bandlimit Return the bandlimit of a specific wavelet scale j. s2let_elmin Return the lowest harmonic index l supported by the given wavelet scale. s2let_jmax Return the maximum scale for a wavelet transform. s2let_compute_scal Compute a rotated scaling function. s2let_compute_wav Compute a rotated wavelet. s2let_ridgelet_compute_wav Compute ridgelets and scaling functions. s2let_axisym_tiling Compute the tiling of axisymmetric wavelets in harmonic space. s2let_check_axisym_tiling Check exactness (i.e. identity resolution) of axisymmetric wavelets in the harmonic tiling. s2let_wavelet_tiling Compute the tiling of the (spin) directional wavelets in harmonic space. s2let_check_tiling Check exactness of (spin) directional wavelets in the harmonic tiling. s2let_curvelet_tiling Compute the (spin) curvelet tiling in harmonic space. s2let_check_cur_tiling Check exactness of (spin) curvelets in the harmonic tiling. s2let_curvelet_transform_test_lm2lmn_lmn2lm Check exactness of the scalar and spin curvelet transform, from harmonic space to Wigner space and vice versa. s2let_curvelet_transform_test_lm2cur_cur2lm Check exactness of the scalar and spin curvelet transform, from harmonic space to curvelet space and vice versa. s2let_curvelet_transform_test_px2cur_cur2px Check exactness of the scalar and spin curvelet transform, from pixel space to curvelet space and vice versa.

##### Plotting functions

s2let_plot_sphere Plot wavelet kernels of different scales on multiple spheres. s2let_plot_wavs Plot B-splines, needlets and scale-discretised wavelets. s2let_plot_curvelet_on_sphere Plot curvelet kernels, axis aligned to the North pole, at different wavelet scales, on multiple spheres. s2let_plot_curvelet_parametric Plot curvelets parametrically. s2let_hpx_plot_mollweide Plot a Healpix map (ring ordered) using Mollweide projection. s2let_plot_mollweide Plot wavelet coefficients at different scales j using multiple Mollweide projections.

##### Miscellaneous

s2let_hpx_read_real_map Read a Healpix map (ring ordered) from a FITS file s2let_hpx_write_real_map Write a Healpix map (ring ordered) to a FITS file. s2let_hpx_read_real_spin_maps Read a Healpix spin maps (ring ordered) from a FITS file. s2let_hpx_write_real_spin_maps Write a Healpix spin maps (ring ordered) from a FITS file. s2let_hpx_alm2map Interface to the Fortran function alm2map in Healpix (ring ordered, inverse spherical harmonic transform). s2let_hpx_map2alm Interface to the Fortran function map2alm in Healpix (ring ordered, forward spherical harmonic transform). s2let_hpx_alm2map_spin Interface to the Fortran function alm2map_spin in Healpix (ring ordered, inverse spin spherical harmonic transform). s2let_hpx_map2alm_spin Interface to the Fortran function map2alm_spin in Healpix (ring ordered, forward spin spherical harmonic transform). s2let_axisym_hpx_analysis Compute axiysymmetric wavelet transform of a Healpix map (ring ordered). s2let_axisym_hpx_synthesis Reconstuct a Healpix map (ring ordered) on the sphere from its axiysymmetric wavelets. s2let_hpx_sampling_ring Compute the Healpix (ring ordered) sampling nodes (thetas, phis). s2let_hpx2mw Convert a Healpix map into a MW map. s2let_mw2hpx Convert a MW map into a Healpix map. s2let_mw_read_real_map Read a MW map from a FITS file. s2let_mw_write_real_map Write a MW map to a FITS file. s2let_smoothing Return a smoothed map.

To access the documentation for each function in Matlab, simply run:

>> help <function>

where `<function>`

is the function name.

#### Demos

A number of demos are provided to illustrate the use of the Matlab interface.

s2let_fulltest Run and test all functionalities of the wavelet transform (MW sampling). s2let_fulltest_curvelet Run and test all functionalities of the curvelet transform (MW sampling). s2let_hpxtest Run and test all functionalties of the wavelet transform (Healpix sampling). s2let_demo1 Compute and plot axisymmetric wavelet coefficients of the Earth topographic data (full and multi-resolution, MW sampling). s2let_demo2 Plot axisymmetric wavelet kernels corresponding to some set of parameters. s2let_demo3 Compute and plot axisymmetric wavelets of a random CMB simulation (Healpix sampling). s2let_demo4 Compute and plot directioanl wavelet coefficients of the Earth topographic data (MW sampling). s2let_demo5 Plot (spin) directional wavelet kernels corresponding to some set of parameters. s2let_demo6 Compute and plot directional wavelet coefficients of the WMAP CMB polarisation data (Healpix sampling). s2let_demo7_curvelet_Plot_Funcs_and_Tiling Plot (spin) curvelet kernels corresponding to some set of parameters. s2let_demo8_curvelet_Mollweide_EarthTopography Compute and plot curvelet coefficients of the Earth topographic data (MW sampling). s2let_demo_ridgelet_plot Plot ridgelet kernels corresponding to some set of parameters. s2let_demo_covariance Compute and compare the theoretical covariance and the empirical covariance for several sets of harmonic coefficients using directional wavelet transform. s2let_demo_curvelet_covariance Compute and compare the theoretical covariance and the empirical covariance for several sets of harmonic coefficients using curvelet transform. s2let_demo_ridgelet_evaluate Evaluate timing and numerical accuracy of the ridgelet transform. s2let_demo_curvelet_evaluate_performance Evaluate timing and numerical accuracy of the curvelet transform. s2let_plot_denoising_demo Plot the noisy and denoised polarisation maps.

To access the documentation for each demo in Matlab, simply run:

>> help <demo>

where `<demo>`

is the demo name.