math
Class Util

java.lang.Object
  extended by math.Util

public class Util
extends java.lang.Object

This contains various static utility functions that are useful for nifti files.

Author:
eider

Constructor Summary
Util()
           
 
Method Summary
static short[] sign(byte[] unsigned)
          Turn an unsigned byte[] into a signed short[].
static long[] sign(int[] unsigned)
          Turn an unsigned int[] into a signed long[].
static double[] sign(long[] unsigned)
          Turn an unsigned long[] into a signed double[].
static java.lang.Object sign(java.lang.Object unsigned)
          Take a byte[], short[], int[] or long[] and call the appropriate sign function.
static char[] sign(short[] unsigned)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

sign

public static short[] sign(byte[] unsigned)
Turn an unsigned byte[] into a signed short[]. This is necessary because Java doesn't really support unsigned bytes, ints or longs, but some file formats do. When this returns, the file type will by ImageData.TYPE_SHORT

Parameters:
-
Returns:

sign

public static char[] sign(short[] unsigned)

sign

public static long[] sign(int[] unsigned)
Turn an unsigned int[] into a signed long[]. This is necessary because Java doesn't really support unsigned bytes, ints or longs, but some file formats do. When this returns, the file type will by ImageData.TYPE_LONG

Parameters:
-
Returns:

sign

public static double[] sign(long[] unsigned)
Turn an unsigned long[] into a signed double[]. This is necessary because Java doesn't really support unsigned bytes, ints or longs, but some file formats do. We will lose some of the details that are provided, but java doesn't have a native integer format that is longer than long. The only other option really is to use an Object like BigInteger. However, this would cause a lot of overhead. If you need all of the information in a long, do a custom BigInteger. It may require writing your own ImageData class. When this returns, the file type will by ImageData.TYPE_DOUBLE

Parameters:
-
Returns:
See Also:
,

sign

public static java.lang.Object sign(java.lang.Object unsigned)
Take a byte[], short[], int[] or long[] and call the appropriate sign function. Return the next type up. As a convenience, if char[] is the input, it just returns that array as it is the only unsigned type.

Parameters:
unsigned -
Returns:
Throws:
java.lang.IllegalArgumentException - if the type is not a 1d array of integer primitives.