The DCT (discrete cosine transform) is defined as the matrix
First we factorize the matrix into a product of sparse matrices using the function MatrixDecompositionByPermIrredSymmetry from AREP. The matrix is analyzed for symmetry and decomposed (explanation of the procedure). We start with the transpose of the DCT, usually called DCT, type III, and transpose the result.
gap> M := DCT_III(8);The function MatrixDecompositionByPermIrredSymmetry returns an AMat, a recursive data structure for representing sparse structured matrix products. Click here to see, what A looks like.
gap> A := MatrixDecompositionByPermIrredSymmetry(M);
gap> A := TransposedAMat(A);
Next we want to create a SPL program from the AMat A. First, A is translated into an SPL object, an interim data structure to represent SPL programs within GAP. Second, the SPL object is exported to a file as an SPL program.
gap> T := SPLAMat(A);The file tmp.spl now contains an SPL program representing the sparse matrix factorization computed above.
gap> T := PrepareForExportingSPL(T);
gap> ExportSPL("tmp.spl", T);
The SPL compiler translates the SPL program into a FORTRAN progam performing different optimizations. The option "-R" creates a program for real input vectors.
spl -R tmp.spl > tmp.fSee, how tmp.f looks like.
Any standard FORTRAN compiler can be used to compile tmp.f:
f77 -c tmp.f