Java Array Multiply multiplyP(int[] x)

Here you can find the source of multiplyP(int[] x)

Description

multiply P

License

Open Source License

Declaration

static void multiplyP(int[] x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static void multiplyP(int[] x) {
        boolean lsb = (x[3] & 1) != 0;
        shiftRight(x);//from ww  w.j a v  a  2  s  .  c o  m
        if (lsb) {
            // R = new int[]{ 0xe1000000, 0, 0, 0 };
            //            xor(v, R);
            x[0] ^= 0xe1000000;
        }
    }

    static void multiplyP(int[] x, int[] output) {
        boolean lsb = (x[3] & 1) != 0;
        shiftRight(x, output);
        if (lsb) {
            output[0] ^= 0xe1000000;
        }
    }

    static void shiftRight(byte[] block) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i] & 0xff;
            block[i] = (byte) ((b >>> 1) | bit);
            if (++i == 16) {
                break;
            }
            bit = (b & 1) << 7;
        }
    }

    static void shiftRight(byte[] block, byte[] output) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i] & 0xff;
            output[i] = (byte) ((b >>> 1) | bit);
            if (++i == 16) {
                break;
            }
            bit = (b & 1) << 7;
        }
    }

    static void shiftRight(int[] block) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i];
            block[i] = (b >>> 1) | bit;
            if (++i == 4) {
                break;
            }
            bit = b << 31;
        }
    }

    static void shiftRight(int[] block, int[] output) {
        int i = 0;
        int bit = 0;
        for (;;) {
            int b = block[i];
            output[i] = (b >>> 1) | bit;
            if (++i == 4) {
                break;
            }
            bit = b << 31;
        }
    }
}

Related

  1. multiplycst(int k, double[] t)
  2. multiplyElementwise(double[] a, int[] b)
  3. multiplyHarmonics(float[] powerSpectrumInOut, int nHarmonics)
  4. multiplyInPlace(double[] img, double val)
  5. multiplyInto(double[] out, double[] a, double[] b)
  6. multiplyP(int[] x)
  7. multiplyP(int[] x)
  8. multiplyP(int[] x)
  9. multiplyP8(int[] x)