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 x0 = x[0], x1 = x[1];
        long y0 = y[0], y1 = y[1];
        long z0 = 0, z1 = 0, z2 = 0;

        for (int j = 0; j < 64; ++j) {
            long m0 = -(x0 & 1L);
            x0 >>>= 1;/* w w  w .  j a va2  s  .c  om*/
            z0 ^= (y0 & m0);
            z1 ^= (y1 & m0);

            long m1 = -(x1 & 1L);
            x1 >>>= 1;
            z1 ^= (y0 & m1);
            z2 ^= (y1 & m1);

            long c = y1 >> 63;
            y1 = (y1 << 1) | (y0 >>> 63);
            y0 = (y0 << 1) ^ (c & 0x87L);
        }

        z0 ^= z2 ^ (z2 << 1) ^ (z2 << 2) ^ (z2 << 7);
        z1 ^= (z2 >>> 63) ^ (z2 >>> 62) ^ (z2 >>> 57);

        z[0] = z0;
        z[1] = z1;
    }
}

Related

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