Supercompilation of double interpretation

index.htm - Russian text 

scp2int.zip - archived directory. 

In a title I am not original - it was for the Refal-supercompiler. I think, that here it too suits. The operations above complex numbers are interpreted through operations above matrixes, and the operations above matrixes are interpreted by the package Jama.

Andrei Klimov very figuratively has commented on on essence of the given paragraph:

A way of combination of two another's packages here is offered. The obtained acceleration - 200 times - costs of the expended gains.

The packages are used

If the package for operation with real matrixes pecialization on square matrixes of a size 2 sorts {{a, b}, {-b, a)}, we shall receive the package for operation with complex numbers. I shall utillize the known simple fact, that the set of the indicated matrixes is isomorphous to set of complex numbers.

I have selected an example with matrixes and complex numbers in view of its simplicity. I think, that the common enough technology of usage of the supercompiler here is demonstrated

In set of real matrixes of a size 2 on 2 there is a subset, isomorphous set of complex numbers. It consists of matrixes of sort {{a, b}, {-b, a}}.

As I had only experimental purpose, I have made so.

Has taken the ready package for operation with complex numbers in in operations of addition, subtraction, multiplyings and divisions has made uniform replacement. For example, fragment

public Complex
    add (Complex z) {
        return  cart(re + z.re, im + z.im);
    }//end add(Complex)

Has exchanged with a fragment

public Complex
    add (Complex z) {

    Matrix zzz1 = new Matrix(2,2);
    Matrix zzz2 = new Matrix(2,2);
 
    zzz1.set(0,0,re);
    zzz1.set(0,1,im);
    zzz1.set(1,0,-im);
    zzz1.set(1,1,re);

    zzz2.set(0,0,z.re);
    zzz2.set(0,1,z.im);
    zzz2.set(1,0,-z.im);
    zzz2.set(1,1,z.re);

    Matrix zzz = zzz1.plus(zzz2);

    return  cart(zzz.get(0,0), zzz.get(0,1));

    }//end add(Complex)

(Has made first, that has come in a head, probably, it is possible and in another way and easier).

Then has taken an example Happy Tickets

In the directory happytickets all is placed necessary for start-up to account of the source programs.

In the directory mycomplex the indicated replacement of complex numbers by matrixes is made.

In the table the execution times in seconds of both programs before supercompilation and after supercompilation are located

  before scpj after scpj Acceleration
HappyTickets 9.07 1.09 8.32
MyComplex 167.7 1.17 143

The numbers in the table are clear enough. After supercompilation the almost identical programs are received. In the program MyComplex permanently there is a "superfluous" operation, therefore time of its fulfilment in some times is more, therefore and the coefficient of acceleration is more.

This example is a typical example of usage of the supercompiler of Java hereafter. It is possible consciously to program "non-optimumly", and the supercompiler will remove all superfluous and will construct the good program.

In this example in one case the package for complex numbers, in the friend - completely illogical application of matrixes was used. After supercompilation was received same.