Java Matrix Transpose transposeValue(long[] valSet, int DEPTH)

Here you can find the source of transposeValue(long[] valSet, int DEPTH)

Description

Transpose the value from long[DIM] to long[DEPTH].

License

Open Source License

Parameter

Parameter Description
valSet vector
DEPTH total number of bits, usually 64

Return

Transposed value

Declaration

public static long[] transposeValue(long[] valSet, int DEPTH) 

Method Source Code

//package com.java2s;
/*/*from   w ww .  ja  v  a  2s.  c om*/
 * Copyright 2011-2016 ETH Zurich. All Rights Reserved.
 *
 * This software is the proprietary information of ETH Zurich.
 * Use is subject to license terms.
 */

public class Main {
    /**
     * Transpose the value from long[DIM] to long[DEPTH].
     * Transposition occurs such that high-order bits end up in the first value of 'tv'.
     * Value from DIM=0 end up as highest order bits in 'tv'.
     * 0001,
     * 0010, 
     * 0011
     * becomes
     * 000, 000, 011, 101
     * 
     * @param valSet vector
     * @param DEPTH total number of bits, usually 64 
     * @return Transposed value
     */
    public static long[] transposeValue(long[] valSet, int DEPTH) {
        long[] tv = new long[DEPTH];
        long valMask = 1L << (DEPTH - 1);
        int rightShift = DEPTH - 1;
        for (int j = 0; j < DEPTH; j++) {
            long pos = 0;
            for (long v : valSet) {
                pos <<= 1;
                //set pos-bit if bit is set in value
                //               if ((valMask & v) != 0) {
                //                   pos |= 1L;
                //               }
                pos |= (valMask & v) >>> rightShift;
            }
            tv[j] = pos;
            valMask >>>= 1;
            rightShift--;
        }
        return tv;
    }
}

Related

  1. transposeMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset)
  2. transposeMatrix3x3(float[] result, float[] m)
  3. transposematrixmultiply(final double[][] A, final double[] b)
  4. transposeQuad(final double[][] src, int n)
  5. transposeSquareMatrix(T[][] matrixT)