Construction of the representation of the multiplication by a coefficient from a fine scale to a coarse scale
in two dimension for the Legendre Multiwavelet Basis.

restart:
with(linalg):
LePath:="./":
LeName:=Legendre:
Datafile:=cat(LePath,"Data",LeName,".m"):
SaveFile:=cat(LePath,"Coeffs",LeName,".m"):

> MatJ:=matrix(4,4):
MatJ[1,1]:=H0[1,1]:MatJ[1,2]:=H0[1,2]:MatJ[1,3]:=H1[1,1]:MatJ[1,4]:=H1[1,2]:
MatJ[2,1]:=H0[2,1]:MatJ[2,2]:=H0[2,2]:MatJ[2,3]:=H1[2,1]:MatJ[2,4]:=H1[2,2]:
MatJ[3,1]:=G0[1,1]:MatJ[3,2]:=G0[1,2]:MatJ[3,3]:=G1[1,1]:MatJ[3,4]:=G1[1,2]:
MatJ[4,1]:=G0[2,1]:MatJ[4,2]:=G0[2,2]:MatJ[4,3]:=G1[2,1]:MatJ[4,4]:=G1[2,2]:
print(MatJ);

Construction of the two dimensional wavelet base by tensor products
MatJ is the inter scale identity matrix
CoarScale contains the 16 wavelets.

FineScaleX:=matrix(4,1,[f||0(x),f||1(x),f||0(x-1),f||1(x-1)]):
CoarScaleX:=simplify(multiply(MatJ,FineScaleX)):
FineScaleY:=matrix(4,1,[g||0(y),g||1(y),g||0(y-1),g||1(y-1)]):
CoarScaleY:=simplify(multiply(MatJ,FineScaleY)):

> CoarScale:=matrix(16,1):
CoarScale[1,1] :=CoarScaleX[1,1] *CoarScaleY[1,1]:
CoarScale[2,1] :=CoarScaleX[1,1] *CoarScaleY[2,1]:
CoarScale[3,1] :=CoarScaleX[2,1] *CoarScaleY[1,1]:
CoarScale[4,1] :=CoarScaleX[2,1] *CoarScaleY[2,1]:
CoarScale[5,1] :=CoarScaleX[1,1] *CoarScaleY[3,1]:
CoarScale[6,1] :=CoarScaleX[1,1] *CoarScaleY[4,1]:
CoarScale[7,1] :=CoarScaleX[2,1] *CoarScaleY[3,1]:
CoarScale[8,1] :=CoarScaleX[2,1] *CoarScaleY[4,1]:
CoarScale[9,1] :=CoarScaleX[3,1] *CoarScaleY[1,1]:
CoarScale[10,1] :=CoarScaleX[3,1] *CoarScaleY[2,1]:
CoarScale[11,1] :=CoarScaleX[4,1] *CoarScaleY[1,1]:
CoarScale[12,1] :=CoarScaleX[4,1] *CoarScaleY[2,1]:
CoarScale[13,1] :=CoarScaleX[3,1] *CoarScaleY[3,1]:
CoarScale[14,1] :=CoarScaleX[3,1] *CoarScaleY[4,1]:
CoarScale[15,1] :=CoarScaleX[4,1] *CoarScaleY[3,1]:
CoarScale[16,1] :=CoarScaleX[4,1] *CoarScaleY[4,1]:
print(CoarScale):

Introducing coefficients, Ca,Cb,Cc,Cd in their geographical location:
Ca | Cb
---------

Cc | Cd
The values are first introduced on the fine scale (the functions f0(x) representing
F0 and at that scale)

M01:=matrix(16,1,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]):
for i from 1 to 16 do
for k from 0 to 1 do for l from 0 to 1 do
M01[i,1]:=M01[i,1]+
coeff(coeff(CoarScale[i,1],f||k(x) ), g||l(y))*f||k(x) *g||l(y) *Ca+
coeff(coeff(CoarScale[i,1],f||k(x-1)), g||l(y))*f||k(x-1)*g||l(y) *Cb+
coeff(coeff(CoarScale[i,1],f||k(x) ),g||l(y-1))*f||k(x) *g||l(y-1)*Cc+
coeff(coeff(CoarScale[i,1],f||k(x-1)),g||l(y-1))*f||k(x-1)*g||l(y-1)*Cd
od od od;

We then return to coarse scale notations, F and Y (noted S and P)

Invsc:=simplify(multiply(inverse(MatJ),
matrix(4,1,[S0(x),S1(x),P0(x),P1(x)]))):
f0(x):=Invsc[1,1]:
f1(x):=Invsc[2,1]:
f0(x-1):=Invsc[3,1]:
f1(x-1):=Invsc[4,1]:
Invsc:=simplify(multiply(inverse(MatJ),
matrix(4,1,[S0(y),S1(y),P0(y),P1(y)]))):
g0(y):=Invsc[1,1]:
g1(y):=Invsc[2,1]:
g0(y-1):=Invsc[3,1]:
g1(y-1):=Invsc[4,1]:
for k from 0 to 0 do for i from 1 to 16 do
CoarScale[i,1]:=simplify(Scale[i,1]);
M01[i,1]:=simplify(M01[i,1]) od; od;
print(CoarScale,M01);

The "translation" matrix TransM contains the data, with the ordering convention

F0 (x)* F0 (y), F0 (x)* F1 (y), F1 (x)* F0 (y), F1 (x)* F1 (y),
F0 (x)* Y0 (y), F0 (x)* Y1 (y), F1 (x)* Y0 (y), F1 (x)* Y1 (y),
Y0 (x)* F0 (y), Y0 (x)* F1 (y), Y1 (x)* F0 (y), Y1 (x)* F1 (y),
Y0 (x)* Y0 (y), Y0 (x)* Y1 (y), Y1 (x)* Y0 (y), Y1 (x)* Y1 (y),

TransM:=matrix(16,16);
for i from 1 to 16 do
for k from 0 to 1 do
for l from 0 to 1 do
TransM[i,2*k+l+1] := coeff(coeff(M01[i,1],S||k(x)),S||l(y));
TransM[i,2*k+l+5] := coeff(coeff(M01[i,1],S||k(x)),P||l(y));
TransM[i,2*k+l+9] := coeff(coeff(M01[i,1],P||k(x)),S||l(y));
TransM[i,2*k+l+13]:= coeff(coeff(M01[i,1],P||k(x)),P||l(y));
od od od;
TransM:=transpose(TransM):
print(TransM);

We then represent the Data (Ca,Cb,Cc,Cd) using Haar Wavelet Coefficients,
leading to the new translation matrix NTM

HaarTypeCoef:=matrix(4,4,
[1/4,1/4,1/4,1/4,
1/4,1/4,-1/4,-1/4,
1/4,-1/4,1/4,-1/4,
1/4,-1/4,-1/4,1/4]):IHTC:=inverse(HaarTypeCoef):
#print(HaarTypeCoef,IHTC);
HTC:=multiply(IHTC,vector(4,[a1,a2,a3,a4]));

H1:={Ca=HTC[1]}:
H2:={Cb=HTC[2]}:
H3:={Cc=HTC[3]}:
H4:={Cd=HTC[4]}:
NTM:=simplify(TransM,H1):
NTM:=simplify(NTM,H2):
NTM:=simplify(NTM,H3):
NTM:=simplify(NTM,H4):
NTM:=simplify(NTM);

The result is saved in SaveFile, defined in the introduction.

save NTM, SaveFile;

>