# Wavelets for preconditioning in MATLAB

I have been trying to understand the Wavelet transform in order to use it as a precondioner for ill-conditioned linear problems of the form $$A\vec{x}=\vec{b}$$.

I have come across this paper that is attempting to do the aforementioned. The paper lays out an algorithm in which I must compute $$\tilde{A} = RAR^T$$ where $$R$$ is defined as:$$D = \begin{bmatrix}H_0^N \\ H_1^N\end{bmatrix} ⊗ \begin{bmatrix}H_0^N \\ H_1^N\end{bmatrix}, \quad R = \begin{bmatrix}(G_0^N)^T \\ (G_1^N)^T\end{bmatrix}^T ⊗ \begin{bmatrix}(G_0^N)^T \\ (G_1^N)^T\end{bmatrix}^T,$$ where in turn $$H$$ and $$G$$ are defined as:$$\begin{gather*} H_i^{\frac{N}{2^m}} ≜ {\small\begin{bmatrix} h_i[0] & h_i[\frac{N}{2^m} - 1] & h_i[\frac{N}{2^m} - 2] & h_i[\frac{N}{2^m} - 3] & \cdots & \cdots & h_i[2] & h_i[1]\\ h_i[2] & h_i[1] & h_i[0] & h_i[\frac{N}{2^m} - 1] & \cdots & \cdots & h_i[4] & h_i[3]\\ h_i[4] & h_i[3] & h_i[2] & h_i[1] & \cdots & \cdots & h_i[6] & h_i[5]\\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ h[\frac{N}{2^m} - 2] & h[\frac{N}{2^m} - 3] & h[\frac{N}{2^m} - 4] & h[\frac{N}{2^m} - 5] & \cdots & \cdots & h_i[0] & h[\frac{N}{2^m} - 1] \end{bmatrix}},\\ G_i^{\frac{N}{2^m}} ≜ {\small\begin{bmatrix} g_i[0] & g_i[1] & g_i[2] & g_i[3] & \cdots & \cdots & g_i[\frac{N}{2^m} - 2] & g_i[\frac{N}{2^m} - 1]\\ g_i[\frac{N}{2^m} - 2] & g_i[\frac{N}{2^m} - 1] & g_i[0] & g_i[1] & \cdots & \cdots & g_i[\frac{N}{2^m} - 4] & g_i[\frac{N}{2^m} - 3]\\ g_i[\frac{N}{2^m} - 4] & g_i[\frac{N}{2^m} - 3] & g_i[\frac{N}{2^m} - 2] & g_i[\frac{N}{2^m} - 1] & \cdots & \cdots & g_i[\frac{N}{2^m} - 6] & g_i[\frac{N}{2^m} - 5]\\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ g_i[2] & g_i[3] & g_i[4] & g_i[5] & \cdots & \cdots & g_i[0] & g_i[1] \end{bmatrix}^T}. \end{gather*}$$

My question is: how do I calculate $$R$$ in MATLAB in order to compute $$\tilde{A} = RAR^{T}$$? Is there a predefined function? I understand that MATLAB has dwt and dwt2, but these functions provide me with the results and not the matrix $$R$$.