Java Array Multiply multiply(long[] x, long[] y, long[] z)

Here you can find the source of multiply(long[] x, long[] y, long[] z)

Description

multiply

License

Open Source License

Declaration

public static void multiply(long[] x, long[] y, long[] z) 

Method Source Code

//package com.java2s;

public class Main {
    public static void multiply(long[] x, long[] y, long[] z) {
        long y0 = y[0], y1 = y[1], y2 = y[2], y3 = y[3];
        long y4 = y[4], y5 = y[5], y6 = y[6], y7 = y[7];
        long z0 = 0, z1 = 0, z2 = 0, z3 = 0;
        long z4 = 0, z5 = 0, z6 = 0, z7 = 0;
        long z8 = 0;

        for (int i = 0; i < 8; i += 2) {
            long x0 = x[i], x1 = x[i + 1];

            for (int j = 0; j < 64; ++j) {
                long m0 = -(x0 & 1L);
                x0 >>>= 1;//w  ww  .  j ava  2 s  .co  m
                z0 ^= (y0 & m0);
                z1 ^= (y1 & m0);
                z2 ^= (y2 & m0);
                z3 ^= (y3 & m0);
                z4 ^= (y4 & m0);
                z5 ^= (y5 & m0);
                z6 ^= (y6 & m0);
                z7 ^= (y7 & m0);

                long m1 = -(x1 & 1L);
                x1 >>>= 1;
                z1 ^= (y0 & m1);
                z2 ^= (y1 & m1);
                z3 ^= (y2 & m1);
                z4 ^= (y3 & m1);
                z5 ^= (y4 & m1);
                z6 ^= (y5 & m1);
                z7 ^= (y6 & m1);
                z8 ^= (y7 & m1);

                long c = y7 >> 63;
                y7 = (y7 << 1) | (y6 >>> 63);
                y6 = (y6 << 1) | (y5 >>> 63);
                y5 = (y5 << 1) | (y4 >>> 63);
                y4 = (y4 << 1) | (y3 >>> 63);
                y3 = (y3 << 1) | (y2 >>> 63);
                y2 = (y2 << 1) | (y1 >>> 63);
                y1 = (y1 << 1) | (y0 >>> 63);
                y0 = (y0 << 1) ^ (c & 0x125L);
            }

            long y8 = y7;
            y7 = y6;
            y6 = y5;
            y5 = y4;
            y4 = y3;
            y3 = y2;
            y2 = y1;
            y1 = y0 ^ (y8 >>> 62) ^ (y8 >>> 59) ^ (y8 >>> 56);
            y0 = y8 ^ (y8 << 2) ^ (y8 << 5) ^ (y8 << 8);
        }

        z0 ^= z8 ^ (z8 << 2) ^ (z8 << 5) ^ (z8 << 8);
        z1 ^= (z8 >>> 62) ^ (z8 >>> 59) ^ (z8 >>> 56);

        z[0] = z0;
        z[1] = z1;
        z[2] = z2;
        z[3] = z3;
        z[4] = z4;
        z[5] = z5;
        z[6] = z6;
        z[7] = z7;
    }
}

Related

  1. multiply(float[] in, float f)
  2. multiply(float[] mat, float[] mat2, float[] dest)
  3. multiply(float[] v, double factor)
  4. multiply(float[] v1, float[] v2)
  5. multiply(long[] x, long[] y, long[] z)
  6. multiply(long[] x, long[] y, long[] z)
  7. multiply(String[] strings, String placeholder, String[] replacements)
  8. multiplyAndSum(double[] r1, double[] r2)
  9. multiplyAndSum(final double[] d, final double scale)