BigInteger Die meiste Zeit optimierte Multiplikation

Hallo, ich möchte 2 große ganze Zahlen auf eine möglichst zeitnahe und optimierte Weise multiplizieren. Ich verwende derzeit den Karatsuba-Algorithmus. Kann mir jemand einen optimierten Weg vorschlagen oder algo, es zu tun.

Vielen Dank

public static BigInteger karatsuba(BigInteger x, BigInteger y) {

        // cutoff to brute force
        int N = Math.max(x.bitLength(), y.bitLength());
        System.out.println(N);
        if (N <= 2000) return x.multiply(y);                // optimize this parameter

        // number of bits divided by 2, rounded up
        N = (N / 2) + (N % 2);

        // x = a + 2^N b,   y = c + 2^N d
        BigInteger b = x.shiftRight(N);
        BigInteger a = x.subtract(b.shiftLeft(N));
        BigInteger d = y.shiftRight(N);
        BigInteger c = y.subtract(d.shiftLeft(N));

        // compute sub-expressions
        BigInteger ac    = karatsuba(a, c);
        BigInteger bd    = karatsuba(b, d);
        BigInteger abcd  = karatsuba(a.add(b), c.add(d));

        return ac.add(abcd.subtract(ac).subtract(bd).shiftLeft(N)).add(bd.shiftLeft(2*N));
    }

Antworten auf die Frage(2)

Ihre Antwort auf die Frage