Java Square Calculate square2Index(long square)

Here you can find the source of square2Index(long square)

Description

square Index

License

Open Source License

Declaration

public static byte square2Index(long square) 

Method Source Code

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

public class Main {
    public static final byte[] bitTable = { 63, 30, 3, 32, 25, 41, 22, 33,
            15, 50, 42, 13, 11, 53, 19, 34, 61, 29, 2, 51, 21, 43, 45, 10,
            18, 47, 1, 54, 9, 57, 0, 35, 62, 31, 40, 4, 49, 5, 52, 26, 60,
            6, 23, 44, 46, 27, 56, 16, 7, 39, 48, 24, 59, 14, 12, 55, 38,
            28, 58, 20, 37, 17, 36, 8 };

    public static byte square2Index(long square) {
        long b = square ^ (square - 1);
        int fold = (int) (b ^ (b >>> 32));
        return bitTable[(fold * 0x783a9b23) >>> 26];
    }//from  www . java  2 s  .  co  m
}

Related

  1. square2array(byte[][] square)
  2. squareArea(final double side)
  3. squared(int x)
  4. squaredError(double[] vector1, double[] vector2)
  5. squaredLoss(double[] x, double[] y, double w_0, double w_1)