Rename bit-shuffing routines

This commit is contained in:
Takeshi YAMAMURO 2017-01-26 14:47:44 +09:00
parent 9d5bb7b8e5
commit 8b038c8ed4
5 changed files with 84 additions and 84 deletions

View File

@ -55,7 +55,7 @@ public class BitShuffle
* @throws SnappyError when the input is not a direct buffer
* @throws IllegalArgumentException when the input length is not a multiple of the given type size
*/
public static int bitShuffle(ByteBuffer input, BitShuffleType type, ByteBuffer shuffled) throws IOException {
public static int shuffle(ByteBuffer input, BitShuffleType type, ByteBuffer shuffled) throws IOException {
if (!input.isDirect()) {
throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "input is not a direct buffer");
}
@ -74,7 +74,7 @@ public class BitShuffle
if (shuffled.remaining() < uLen) {
throw new IllegalArgumentException("not enough space for output");
}
int numProcessed = impl.bitShuffleInDirectBuffer(input, uPos, typeSize, uLen, shuffled, shuffled.position());
int numProcessed = impl.shuffleDirectBuffer(input, uPos, typeSize, uLen, shuffled, shuffled.position());
assert(numProcessed == uLen);
// pos limit
@ -90,9 +90,9 @@ public class BitShuffle
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] bitShuffle(short[] input) throws IOException {
public static byte[] shuffle(short[] input) throws IOException {
byte[] output = new byte[input.length * 2];
int numProcessed = impl.bitShuffle(input, 0, 2, input.length * 2, output, 0);
int numProcessed = impl.shuffle(input, 0, 2, input.length * 2, output, 0);
assert(numProcessed == input.length * 2);
return output;
}
@ -104,9 +104,9 @@ public class BitShuffle
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] bitShuffle(int[] input) throws IOException {
public static byte[] shuffle(int[] input) throws IOException {
byte[] output = new byte[input.length * 4];
int numProcessed = impl.bitShuffle(input, 0, 4, input.length * 4, output, 0);
int numProcessed = impl.shuffle(input, 0, 4, input.length * 4, output, 0);
assert(numProcessed == input.length * 4);
return output;
}
@ -118,9 +118,9 @@ public class BitShuffle
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] bitShuffle(long[] input) throws IOException {
public static byte[] shuffle(long[] input) throws IOException {
byte[] output = new byte[input.length * 8];
int numProcessed = impl.bitShuffle(input, 0, 8, input.length * 8, output, 0);
int numProcessed = impl.shuffle(input, 0, 8, input.length * 8, output, 0);
assert(numProcessed == input.length * 8);
return output;
}
@ -132,9 +132,9 @@ public class BitShuffle
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] bitShuffle(float[] input) throws IOException {
public static byte[] shuffle(float[] input) throws IOException {
byte[] output = new byte[input.length * 4];
int numProcessed = impl.bitShuffle(input, 0, 4, input.length * 4, output, 0);
int numProcessed = impl.shuffle(input, 0, 4, input.length * 4, output, 0);
assert(numProcessed == input.length * 4);
return output;
}
@ -146,9 +146,9 @@ public class BitShuffle
* @return bit-shuffled byte array
* @throws IOException
*/
public static byte[] bitShuffle(double[] input) throws IOException {
public static byte[] shuffle(double[] input) throws IOException {
byte[] output = new byte[input.length * 8];
int numProcessed = impl.bitShuffle(input, 0, 8, input.length * 8, output, 0);
int numProcessed = impl.shuffle(input, 0, 8, input.length * 8, output, 0);
assert(numProcessed == input.length * 8);
return output;
}
@ -165,7 +165,7 @@ public class BitShuffle
* @throws SnappyError when the input is not a direct buffer
* @throws IllegalArgumentException when the length of input shuffled data is not a multiple of the given type size
*/
public static int bitUnShuffle(ByteBuffer shuffled, BitShuffleType type, ByteBuffer output) throws IOException {
public static int unshuffle(ByteBuffer shuffled, BitShuffleType type, ByteBuffer output) throws IOException {
if (!shuffled.isDirect()) {
throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "input is not a direct buffer");
}
@ -184,7 +184,7 @@ public class BitShuffle
if (output.remaining() < uLen) {
throw new IllegalArgumentException("not enough space for output");
}
int numProcessed = impl.bitUnShuffleInDirectBuffer(shuffled, uPos, typeSize, uLen, output, shuffled.position());
int numProcessed = impl.unshuffleDirectBuffer(shuffled, uPos, typeSize, uLen, output, shuffled.position());
assert(numProcessed == uLen);
// pos limit
@ -200,9 +200,9 @@ public class BitShuffle
* @return a short array
* @throws IOException
*/
public static short[] bitUnShuffleShortArray(byte[] input) throws IOException {
public static short[] unshuffleShortArray(byte[] input) throws IOException {
short[] output = new short[input.length / 2];
int numProcessed = impl.bitUnShuffle(input, 0, 2, input.length, output, 0);
int numProcessed = impl.unshuffle(input, 0, 2, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
@ -214,9 +214,9 @@ public class BitShuffle
* @return an int array
* @throws IOException
*/
public static int[] bitUnShuffleIntArray(byte[] input) throws IOException {
public static int[] unshuffleIntArray(byte[] input) throws IOException {
int[] output = new int[input.length / 4];
int numProcessed = impl.bitUnShuffle(input, 0, 4, input.length, output, 0);
int numProcessed = impl.unshuffle(input, 0, 4, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
@ -228,9 +228,9 @@ public class BitShuffle
* @return a long array
* @throws IOException
*/
public static long[] bitUnShuffleLongArray(byte[] input) throws IOException {
public static long[] unshuffleLongArray(byte[] input) throws IOException {
long[] output = new long[input.length / 8];
int numProcessed = impl.bitUnShuffle(input, 0, 8, input.length, output, 0);
int numProcessed = impl.unshuffle(input, 0, 8, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
@ -242,9 +242,9 @@ public class BitShuffle
* @return an float array
* @throws IOException
*/
public static float[] bitUnShuffleFloatArray(byte[] input) throws IOException {
public static float[] unshuffleFloatArray(byte[] input) throws IOException {
float[] output = new float[input.length / 4];
int numProcessed = impl.bitUnShuffle(input, 0, 4, input.length, output, 0);
int numProcessed = impl.unshuffle(input, 0, 4, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}
@ -256,9 +256,9 @@ public class BitShuffle
* @return a double array
* @throws IOException
*/
public static double[] bitUnShuffleDoubleArray(byte[] input) throws IOException {
public static double[] unshuffleDoubleArray(byte[] input) throws IOException {
double[] output = new double[input.length / 8];
int numProcessed = impl.bitUnShuffle(input, 0, 8, input.length, output, 0);
int numProcessed = impl.unshuffle(input, 0, 8, input.length, output, 0);
assert(numProcessed == input.length);
return output;
}

View File

@ -29,10 +29,10 @@ inline void throw_exception(JNIEnv *env, jobject self, int errorCode)
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitShuffle
* Method: shuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitShuffle
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffle
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
@ -60,10 +60,10 @@ JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitShuffle
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitShuffleInDirectBuffer
* Method: shuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitShuffleInDirectBuffer
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffleDirectBuffer
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* inputBuffer = (char*) env->GetDirectBufferAddress(input);
@ -81,10 +81,10 @@ JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitShuffleInDirec
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitUnShuffle
* Method: unshuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitUnShuffle
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffle
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* in = (char*) env->GetPrimitiveArrayCritical((jarray) input, 0);
@ -112,10 +112,10 @@ JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitUnShuffle
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitUnShuffleInDirectBuffer
* Method: unshuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitUnShuffleInDirectBuffer
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffleDirectBuffer
(JNIEnv * env, jobject self, jobject input, jint inputOffset, jint typeSize, jint length, jobject output, jint outputOffset)
{
char* inputBuffer = (char*) env->GetDirectBufferAddress(input);

View File

@ -9,34 +9,34 @@ extern "C" {
#endif
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitShuffle
* Method: shuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitShuffle
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffle
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitShuffleInDirectBuffer
* Method: shuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitShuffleInDirectBuffer
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_shuffleDirectBuffer
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitUnShuffle
* Method: unshuffle
* Signature: (Ljava/lang/Object;IIILjava/lang/Object;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitUnShuffle
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffle
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
/*
* Class: org_xerial_snappy_BitShuffleNative
* Method: bitUnShuffleInDirectBuffer
* Method: unshuffleDirectBuffer
* Signature: (Ljava/nio/ByteBuffer;IIILjava/nio/ByteBuffer;I)I
*/
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_bitUnShuffleInDirectBuffer
JNIEXPORT jint JNICALL Java_org_xerial_snappy_BitShuffleNative_unshuffleDirectBuffer
(JNIEnv *, jobject, jobject, jint, jint, jint, jobject, jint);
#ifdef __cplusplus

View File

@ -46,15 +46,15 @@ public class BitShuffleNative
// A quick benchmark result can be found in a gist below;
// https://gist.github.com/maropu/01103215df34b317a7a7
// ------------------------------------------------------------------------
public native int bitShuffle(Object input, int inputOffset, int typeSize, int byteLength, Object output, int outputOffset)
public native int shuffle(Object input, int inputOffset, int typeSize, int byteLength, Object output, int outputOffset)
throws IOException;
public native int bitShuffleInDirectBuffer(ByteBuffer input, int inputOffset, int typeSize, int byteLength, ByteBuffer output, int outputOffset)
public native int shuffleDirectBuffer(ByteBuffer input, int inputOffset, int typeSize, int byteLength, ByteBuffer output, int outputOffset)
throws IOException;
public native int bitUnShuffle(Object input, int inputOffset, int typeSize, int byteLength, Object output, int outputOffset)
public native int unshuffle(Object input, int inputOffset, int typeSize, int byteLength, Object output, int outputOffset)
throws IOException;
public native int bitUnShuffleInDirectBuffer(ByteBuffer input, int inputOffset, int typeSize, int byteLength, ByteBuffer output, int outputOffset)
public native int unshuffleDirectBuffer(ByteBuffer input, int inputOffset, int typeSize, int byteLength, ByteBuffer output, int outputOffset)
throws IOException;
}

View File

@ -40,9 +40,9 @@ public class BitShuffleTest {
ByteBuffer heapBuf = ByteBuffer.allocate(64);
ByteBuffer directBuf = ByteBuffer.allocateDirect(64);
// Tests for BitShuffle.bitShuffle()
// Tests for BitShuffle.shuffle()
try {
BitShuffle.bitShuffle(heapBuf, BitShuffleType.BYTE, directBuf);
BitShuffle.shuffle(heapBuf, BitShuffleType.BYTE, directBuf);
fail("no expected exception happened");
}
catch (SnappyError e) {
@ -50,7 +50,7 @@ public class BitShuffleTest {
Assert.assertTrue(e.getMessage().contains("input is not a direct buffer"));
}
try {
BitShuffle.bitShuffle(directBuf, BitShuffleType.BYTE, heapBuf);
BitShuffle.shuffle(directBuf, BitShuffleType.BYTE, heapBuf);
fail("no expected exception happened");
}
catch (SnappyError e) {
@ -58,9 +58,9 @@ public class BitShuffleTest {
Assert.assertTrue(e.getMessage().contains("destination is not a direct buffer"));
}
// Then, tests for BitShuffle.bitUnShuffle()
// Then, tests for BitShuffle.unshuffle()
try {
BitShuffle.bitUnShuffle(heapBuf, BitShuffleType.BYTE, directBuf);
BitShuffle.unshuffle(heapBuf, BitShuffleType.BYTE, directBuf);
fail("no expected exception happened");
}
catch (SnappyError e) {
@ -68,7 +68,7 @@ public class BitShuffleTest {
Assert.assertTrue(e.getMessage().contains("input is not a direct buffer"));
}
try {
BitShuffle.bitUnShuffle(directBuf, BitShuffleType.BYTE, heapBuf);
BitShuffle.unshuffle(directBuf, BitShuffleType.BYTE, heapBuf);
fail("no expected exception happened");
}
catch (SnappyError e) {
@ -85,13 +85,13 @@ public class BitShuffleTest {
ByteBuffer outputBuf = ByteBuffer.allocateDirect(8);
try {
BitShuffle.bitShuffle(inputBuf, BitShuffleType.INT, outputBuf);
BitShuffle.shuffle(inputBuf, BitShuffleType.INT, outputBuf);
fail("no expected exception happened");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().startsWith("input length must be a multiple of the given type size"));
}
try {
BitShuffle.bitUnShuffle(inputBuf, BitShuffleType.INT, outputBuf);
BitShuffle.unshuffle(inputBuf, BitShuffleType.INT, outputBuf);
fail("no expected exception happened");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().startsWith("length of input shuffled data must be a multiple of the given type size"));
@ -105,13 +105,13 @@ public class BitShuffleTest {
ByteBuffer outputBuf = ByteBuffer.allocateDirect(3);
try {
BitShuffle.bitShuffle(inputBuf, BitShuffleType.INT, outputBuf);
BitShuffle.shuffle(inputBuf, BitShuffleType.INT, outputBuf);
fail("no expected exception happened");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().equals("not enough space for output"));
}
try {
BitShuffle.bitUnShuffle(inputBuf, BitShuffleType.INT, outputBuf);
BitShuffle.unshuffle(inputBuf, BitShuffleType.INT, outputBuf);
fail("no expected exception happened");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().equals("not enough space for output"));
@ -119,7 +119,7 @@ public class BitShuffleTest {
}
@Test
public void bitShuffleInDirectLongArray()
public void shuffleDirectLongArray()
throws Exception
{
ByteBuffer testData = ByteBuffer.allocateDirect(48);
@ -131,9 +131,9 @@ public class BitShuffleTest {
testData.putLong(43251531412342342L);
testData.putLong(23423422342L);
testData.flip();
BitShuffle.bitShuffle(testData, BitShuffleType.LONG, shuffled);
BitShuffle.shuffle(testData, BitShuffleType.LONG, shuffled);
ByteBuffer result = ByteBuffer.allocateDirect(48);
BitShuffle.bitUnShuffle(shuffled, BitShuffleType.LONG, result);
BitShuffle.unshuffle(shuffled, BitShuffleType.LONG, result);
assertEquals(2L, result.getLong());
assertEquals(3L, result.getLong());
assertEquals(15L, result.getLong());
@ -143,7 +143,7 @@ public class BitShuffleTest {
}
@Test
public void bitShuffleInDirectShortArray()
public void shuffleDirectShortArray()
throws Exception
{
ByteBuffer testData = ByteBuffer.allocateDirect(18);
@ -158,9 +158,9 @@ public class BitShuffleTest {
testData.putShort(Short.MAX_VALUE);
testData.putShort((short) -1);
testData.flip();
BitShuffle.bitShuffle(testData, BitShuffleType.SHORT, shuffled);
BitShuffle.shuffle(testData, BitShuffleType.SHORT, shuffled);
ByteBuffer result = ByteBuffer.allocateDirect(18);
BitShuffle.bitUnShuffle(shuffled, BitShuffleType.SHORT, result);
BitShuffle.unshuffle(shuffled, BitShuffleType.SHORT, result);
assertEquals(432, result.getShort());
assertEquals(-32267, result.getShort());
assertEquals(1, result.getShort());
@ -173,7 +173,7 @@ public class BitShuffleTest {
}
@Test
public void bitShuffleInDirectIntArray()
public void shuffleDirectIntArray()
throws Exception
{
ByteBuffer testData = ByteBuffer.allocateDirect(48);
@ -191,9 +191,9 @@ public class BitShuffleTest {
testData.putInt(3424);
testData.putInt(43);
testData.flip();
BitShuffle.bitShuffle(testData, BitShuffleType.INT, shuffled);
BitShuffle.shuffle(testData, BitShuffleType.INT, shuffled);
ByteBuffer result = ByteBuffer.allocateDirect(48);
BitShuffle.bitUnShuffle(shuffled, BitShuffleType.INT, result);
BitShuffle.unshuffle(shuffled, BitShuffleType.INT, result);
assertEquals(432, result.getInt());
assertEquals(-32267, result.getInt());
assertEquals(1, result.getInt());
@ -209,7 +209,7 @@ public class BitShuffleTest {
}
@Test
public void bitShuffleInDirectFloatArray()
public void shuffleDirectFloatArray()
throws Exception
{
ByteBuffer testData = ByteBuffer.allocateDirect(36);
@ -224,9 +224,9 @@ public class BitShuffleTest {
testData.putFloat(-0.1f);
testData.putFloat(Integer.MIN_VALUE);
testData.flip();
BitShuffle.bitShuffle(testData, BitShuffleType.FLOAT, shuffled);
BitShuffle.shuffle(testData, BitShuffleType.FLOAT, shuffled);
ByteBuffer result = ByteBuffer.allocateDirect(36);
BitShuffle.bitUnShuffle(shuffled, BitShuffleType.FLOAT, result);
BitShuffle.unshuffle(shuffled, BitShuffleType.FLOAT, result);
assertEquals(100.0f, result.getFloat(), 0.0000001f);
assertEquals(0.5f, result.getFloat(), 0.0000001f);
assertEquals(-0.1f, result.getFloat(), 0.0000001f);
@ -239,7 +239,7 @@ public class BitShuffleTest {
}
@Test
public void bitShuffleInDirectDoubleArray()
public void shuffleDirectDoubleArray()
throws Exception
{
ByteBuffer testData = ByteBuffer.allocateDirect(72);
@ -254,9 +254,9 @@ public class BitShuffleTest {
testData.putDouble(-0.1);
testData.putDouble(Integer.MIN_VALUE);
testData.flip();
BitShuffle.bitShuffle(testData, BitShuffleType.DOUBLE, shuffled);
BitShuffle.shuffle(testData, BitShuffleType.DOUBLE, shuffled);
ByteBuffer result = ByteBuffer.allocateDirect(72);
BitShuffle.bitUnShuffle(shuffled, BitShuffleType.DOUBLE, result);
BitShuffle.unshuffle(shuffled, BitShuffleType.DOUBLE, result);
assertEquals(100.0, result.getDouble(), 0.0000001);
assertEquals(0.5, result.getDouble(), 0.0000001);
assertEquals(-0.1, result.getDouble(), 0.0000001);
@ -269,52 +269,52 @@ public class BitShuffleTest {
}
@Test
public void bitShuffleLongArray()
public void shuffleLongArray()
throws Exception
{
long[] data = new long[] {2, 3, 15, 4234, 43251531412342342L, 23423422342L};
byte[] shuffledData = BitShuffle.bitShuffle(data);
long[] result = BitShuffle.bitUnShuffleLongArray(shuffledData);
byte[] shuffledData = BitShuffle.shuffle(data);
long[] result = BitShuffle.unshuffleLongArray(shuffledData);
assertArrayEquals(data, result);
}
@Test
public void bitShuffleShortArray()
public void shuffleShortArray()
throws Exception
{
short[] data = new short[] {432, -32267, 1, 3, 34, 43, 34, Short.MAX_VALUE, -1};
byte[] shuffledData = BitShuffle.bitShuffle(data);
short[] result = BitShuffle.bitUnShuffleShortArray(shuffledData);
byte[] shuffledData = BitShuffle.shuffle(data);
short[] result = BitShuffle.unshuffleShortArray(shuffledData);
assertArrayEquals(data, result);
}
@Test
public void bitShuffleIntArray()
public void shuffleIntArray()
throws Exception
{
int[] data = new int[] {432, -32267, 1, 3, 34, 43, 34, Short.MAX_VALUE, -1, Integer.MAX_VALUE, 3424, 43};
byte[] shuffledData = BitShuffle.bitShuffle(data);
int[] result = BitShuffle.bitUnShuffleIntArray(shuffledData);
byte[] shuffledData = BitShuffle.shuffle(data);
int[] result = BitShuffle.unshuffleIntArray(shuffledData);
assertArrayEquals(data, result);
}
@Test
public void bitShuffleFloatArray()
public void shuffleFloatArray()
throws Exception
{
float[] data = new float[] {100.0f, 0.5f, -0.1f, 30.3f, Float.MIN_NORMAL, Float.MAX_EXPONENT, Float.MAX_VALUE, -0.1f, Integer.MIN_VALUE};
byte[] shuffledData = BitShuffle.bitShuffle(data);
float[] result = BitShuffle.bitUnShuffleFloatArray(shuffledData);
byte[] shuffledData = BitShuffle.shuffle(data);
float[] result = BitShuffle.unshuffleFloatArray(shuffledData);
assertArrayEquals(data, result, 0.0000001f);
}
@Test
public void bitShuffleDoubleArray()
public void shuffleDoubleArray()
throws Exception
{
double[] data = new double[] {100.0f, 0.5f, -0.1f, 30.3f, Float.MIN_NORMAL, Float.MAX_EXPONENT, Float.MAX_VALUE, -0.1f, Integer.MIN_VALUE};
byte[] shuffledData = BitShuffle.bitShuffle(data);
double[] result = BitShuffle.bitUnShuffleDoubleArray(shuffledData);
byte[] shuffledData = BitShuffle.shuffle(data);
double[] result = BitShuffle.unshuffleDoubleArray(shuffledData);
assertArrayEquals(data, result, 0.0000001f);
}
}