#!/usr/bin/perl -w

print "DCT:\n";

foreach $f (0..7) {
    my @c = map cos(($_+0.5)*3.1415926535*$f/8), 0..7;
    my $ss = 0;
    for(@c) { $ss += $_*$_; }
    for(@c) { printf " %6.3f", $_ * sqrt(8/$ss); }
    print "\n";
}

print "\nHCT:\n";

@h = (
    [qw( 1   1   1   1   1   1   1   1)],
    [qw(12  10   6   3  -3  -6 -10 -12)],
    [qw( 4   1  -1  -4  -4  -1   1   4)],
    [qw(10  -3 -12  -6   6  12   3 -10)],
    [qw( 1  -1  -1   1   1  -1  -1   1)],
    [qw( 6 -12   3  10 -10  -3  12  -6)],
    [qw( 1  -2   2  -1  -1   2  -2   1)],
    [qw( 3  -6  10 -12  12 -10   6  -3)]
);

foreach $f (0..7) {
    my @c = @{$h[$f]};
    my $ss = 0;
    for(@c) { $ss += $_*$_; }
    for(@c) { printf " %6.3f", $_ * sqrt(8/$ss); }
    print "\n";
}
