Package de.gsi.math

Class ArrayConversion


  • public final class ArrayConversion
    extends java.lang.Object
    This utility class converts arrays of frequently used java primitives into other the requested primitive type. For the time being only 'Number' primitives are implemented, e.g. double array to float array etc. NOTE: USE WITH CARE! Keep in mind that these routines are based on creating new arrays and copying the old data. Consider re-implementing the analysis routines where necessary. Also, apologies for the largely redundant code: this is due to the lack of java template mechanism (generics) handling of primitive types. A hoorray to C++ templates!
    Author:
    rstein
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getByteArray​(byte[] in)
      returns a type-converted copy of the input vector
      static byte[] getByteArray​(double[] in)
      returns a type-converted copy of the input vector
      static byte[] getByteArray​(float[] in)
      returns a type-converted copy of the input vector
      static byte[] getByteArray​(int[] in)
      returns a type-converted copy of the input vector
      static byte[] getByteArray​(long[] in)
      returns a type-converted copy of the input vector
      static byte[] getByteArray​(short[] in)
      returns a type-converted copy of the input vector
      static double[][] getDouble2DArray​(float[][] in)
      returns a type-converted copy of the input matrix
      static double[] getDoubleArray​(byte[] in)
      returns a type-converted copy of the input vector
      static double[] getDoubleArray​(double[] in)
      returns a type-converted copy of the input vector
      static double[] getDoubleArray​(float[] in)
      returns a type-converted copy of the input vector
      static double[] getDoubleArray​(int[] in)
      returns a type-converted copy of the input vector
      static double[] getDoubleArray​(long[] in)
      returns a type-converted copy of the input vector
      static double[] getDoubleArray​(short[] in)
      returns a type-converted copy of the input vector
      static float[][] getFloat2DArray​(double[][] in)
      returns a type-converted copy of the input matrix
      static float[] getFloatArray​(byte[] in)
      returns a type-converted copy of the input vector
      static float[] getFloatArray​(double[] in)
      returns a type-converted copy of the input vector
      static float[] getFloatArray​(float[] in)
      returns a type-converted copy of the input vector
      static float[] getFloatArray​(int[] in)
      returns a type-converted copy of the input vector
      static float[] getFloatArray​(long[] in)
      returns a type-converted copy of the input vector
      static float[] getFloatArray​(short[] in)
      returns a type-converted copy of the input vector
      static int[] getIntegerArray​(byte[] in)
      returns a type-converted copy of the input vector
      static int[] getIntegerArray​(double[] in)
      returns a type-converted copy of the input vector
      static int[] getIntegerArray​(float[] in)
      returns a type-converted copy of the input vector
      static int[] getIntegerArray​(int[] in)
      returns a type-converted copy of the input vector
      static int[] getIntegerArray​(long[] in)
      returns a type-converted copy of the input vector
      static int[] getIntegerArray​(short[] in)
      returns a type-converted copy of the input vector
      static long[] getLongArray​(byte[] in)
      returns a type-converted copy of the input vector
      static long[] getLongArray​(double[] in)
      returns a type-converted copy of the input vector
      static long[] getLongArray​(float[] in)
      returns a type-converted copy of the input vector
      static long[] getLongArray​(int[] in)
      returns a type-converted copy of the input vector
      static long[] getLongArray​(long[] in)
      returns a type-converted copy of the input vector
      static long[] getLongArray​(short[] in)
      returns a type-converted copy of the input vector
      static short[] getShortArray​(byte[] in)
      returns a type-converted copy of the input vector
      static short[] getShortArray​(double[] in)
      returns a type-converted copy of the input vector
      static short[] getShortArray​(float[] in)
      returns a type-converted copy of the input vector
      static short[] getShortArray​(int[] in)
      returns a type-converted copy of the input vector
      static short[] getShortArray​(long[] in)
      returns a type-converted copy of the input vector
      static short[] getShortArray​(short[] in)
      returns a type-converted copy of the input vector
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getByteArray

        public static byte[] getByteArray​(byte[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a byte array
        Returns:
        a byte array containing the values of in
      • getByteArray

        public static byte[] getByteArray​(double[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a double array
        Returns:
        a byte array containing the values of in
      • getByteArray

        public static byte[] getByteArray​(float[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a float array
        Returns:
        a byte array containing the values of in
      • getByteArray

        public static byte[] getByteArray​(int[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a integer array
        Returns:
        a byte array containing the values of in
      • getByteArray

        public static byte[] getByteArray​(long[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a long integer array
        Returns:
        a byte array containing the values of in
      • getByteArray

        public static byte[] getByteArray​(short[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a short integer array
        Returns:
        a byte array containing the values of in
      • getDouble2DArray

        public static double[][] getDouble2DArray​(float[][] in)
        returns a type-converted copy of the input matrix
        Parameters:
        in - a float 2D array
        Returns:
        a double 2D array containing the values of in
      • getDoubleArray

        public static double[] getDoubleArray​(byte[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - an byte array
        Returns:
        a double array containing the values of in
      • getDoubleArray

        public static double[] getDoubleArray​(double[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a double array
        Returns:
        a double array containing the values of in
      • getDoubleArray

        public static double[] getDoubleArray​(float[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a float array
        Returns:
        a double array containing the values of in
      • getDoubleArray

        public static double[] getDoubleArray​(int[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - an integer array
        Returns:
        a double array containing the values of in
      • getDoubleArray

        public static double[] getDoubleArray​(long[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a long integer array
        Returns:
        a double array containing the values of in
      • getDoubleArray

        public static double[] getDoubleArray​(short[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - an short integer array
        Returns:
        a double array containing the values of in
      • getFloat2DArray

        public static float[][] getFloat2DArray​(double[][] in)
        returns a type-converted copy of the input matrix
        Parameters:
        in - a double 2D array
        Returns:
        a float 2D array containing the values of in
      • getFloatArray

        public static float[] getFloatArray​(byte[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a byte array
        Returns:
        a float array containing the values of in
      • getFloatArray

        public static float[] getFloatArray​(double[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a double array
        Returns:
        a float array containing the values of in
      • getFloatArray

        public static float[] getFloatArray​(float[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a float array
        Returns:
        a float array containing the values of in
      • getFloatArray

        public static float[] getFloatArray​(int[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a integer array
        Returns:
        a float array containing the values of in
      • getFloatArray

        public static float[] getFloatArray​(long[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a long integer array
        Returns:
        a float array containing the values of in
      • getFloatArray

        public static float[] getFloatArray​(short[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a short integer array
        Returns:
        a float array containing the values of in
      • getIntegerArray

        public static int[] getIntegerArray​(byte[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a byte array
        Returns:
        a integer array containing the values of in
      • getIntegerArray

        public static int[] getIntegerArray​(double[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a double array
        Returns:
        a integer array containing the values of in
      • getIntegerArray

        public static int[] getIntegerArray​(float[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a float array
        Returns:
        a integer array containing the values of in
      • getIntegerArray

        public static int[] getIntegerArray​(int[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a integer array
        Returns:
        a integer array containing the values of in
      • getIntegerArray

        public static int[] getIntegerArray​(long[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a long integer array
        Returns:
        a integer array containing the values of in
      • getIntegerArray

        public static int[] getIntegerArray​(short[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a short integer array
        Returns:
        a integer array containing the values of in
      • getLongArray

        public static long[] getLongArray​(byte[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a byte array
        Returns:
        a long integer array containing the values of in
      • getLongArray

        public static long[] getLongArray​(double[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a double array
        Returns:
        a long integer array containing the values of in
      • getLongArray

        public static long[] getLongArray​(float[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a float array
        Returns:
        a long integer array containing the values of in
      • getLongArray

        public static long[] getLongArray​(int[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a integer array
        Returns:
        a long integer array containing the values of in
      • getLongArray

        public static long[] getLongArray​(long[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a long integer array
        Returns:
        a long integer array containing the values of in
      • getLongArray

        public static long[] getLongArray​(short[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a short integer array
        Returns:
        a long integer array containing the values of in
      • getShortArray

        public static short[] getShortArray​(byte[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a short integer array
        Returns:
        a short integer array containing the values of in
      • getShortArray

        public static short[] getShortArray​(double[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a double array
        Returns:
        a short integer array containing the values of in
      • getShortArray

        public static short[] getShortArray​(float[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a float array
        Returns:
        a short integer array containing the values of in
      • getShortArray

        public static short[] getShortArray​(int[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a integer array
        Returns:
        a short integer array containing the values of in
      • getShortArray

        public static short[] getShortArray​(long[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a long integer array
        Returns:
        a short integer array containing the values of in
      • getShortArray

        public static short[] getShortArray​(short[] in)
        returns a type-converted copy of the input vector
        Parameters:
        in - a short integer array
        Returns:
        a short integer array containing the values of in