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

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

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

MatJ:=matrix(2,2,[H0,H1,G0,G1]);
FineScaleX:=matrix(2,1,[f||0(x),f||0(x-1)]):
CoarScaleX:=simplify(multiply(MatJ,FineScaleX)):
FineScaleY:=matrix(2,1,[g||0(y),g||0(y-1)]):
CoarScaleY:=simplify(multiply(MatJ,FineScaleY)):
CoarScale:=matrix(4,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]:
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 function f0(x) representing
F at that scale)

M01:=matrix(4,1,[0,0,0,0]):
for i from 1 to 4 do
for k from 0 to 0 do for l from 0 to 0 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;
# print(CoarScale,M01);

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

Invsc:=simplify(multiply(inverse(MatJ),
matrix(2,1,[S(x),P(x)]))):
f0(x):=Invsc[1,1]:
f0(x-1):=Invsc[2,1]:
Invsc:=simplify(multiply(inverse(MatJ),
matrix(2,1,[S(y),P(y)]))):
g0(y):=Invsc[1,1]:
g0(y-1):=Invsc[2,1]:
for k from 0 to 0 do for i from 1 to 4 do
CoarScale[i,1]:=simplify(CoarScale[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
F (x)* F (y), F (x)* Y (y), Y (x)* F (y), Y (x)* Y (y)

TransM:=matrix(4,4):
for i from 1 to 4 do
for k from 0 to 0 do
TransM[i,1]:=coeff(coeff(M01[i,1],S(x)),S(y));
TransM[i,2]:=coeff(coeff(M01[i,1],S(x)),P(y));
TransM[i,3]:=coeff(coeff(M01[i,1],P(x)),S(y));
TransM[i,4]:=coeff(coeff(M01[i,1],P(x)),P(y));
od od;
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])):
# Legendre
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;

>