org.eclipse.january.dataset

## Class DTypeUtils

- java.lang.Object
- - org.eclipse.january.dataset.DTypeUtils

-     public class DTypeUtils
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static org.slf4j.Logger` | `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DTypeUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Object` | `fromDoublesToBiggestPrimitives(double[] x, int dtype)`
    `static Number` | `fromDoubleToBiggestNumber(double x, int dtype)`
    `static int` | `getBestDType(int atype, int btype)` Find dataset type that best fits given types The best type takes into account complex and array datasets
    `static int` | `getBestFloatDType(Class<? extends Object> cls)` Find floating point dataset type that best fits given class The best type takes into account complex and array datasets
    `static int` | `getBestFloatDType(int otype)` Find floating point dataset type that best fits given types.
    `static int` | `getDType(Class<? extends Dataset> clazz)`
    `static int` | `getDType(ILazyDataset d)` Get dataset type from given dataset
    `static int` | `getDTypeFromClass(Class<? extends Object> cls)` Get dataset type from an element class
    `static int` | `getDTypeFromClass(Class<? extends Object> cls, int isize)` Get dataset type from an element class
    `static int` | `getDTypeFromObject(Object obj)` Get dataset type from an object.
    `static String` | `getDTypeName(Dataset a)`
    `static String` | `getDTypeName(ILazyDataset a)`
    `static String` | `getDTypeName(int dtype, int itemSize)`
    `static int` | `getElementalDType(int otype)`
    `static Class<?>` | `getElementClass(int dtype)`
    `static int` | `getElementsPerItem(int dtype)`
    `static int` | `getItemBytes(int dtype)`
    `static int` | `getItemBytes(int dtype, int isize)`
    `static int` | `getLargestDType(int otype)` The largest dataset type suitable for a summation of around a few thousand items without changing from the "kind" of dataset
    `static int` | `getLength(Object b)`
    `static boolean` | `isClassSupportedAsElement(Class<? extends Object> comp)`
    `static boolean` | `isDTypeComplex(int dtype)`
    `static boolean` | `isDTypeElemental(int dtype)`
    `static boolean` | `isDTypeFloating(int dtype)`
    `static boolean` | `isDTypeInteger(int dtype)`
    `static boolean` | `isDTypeNumerical(int dtype)`
    `static boolean` | `toBoolean(Object b)`
    `static byte[]` | `toByteArray(Object b, int itemSize)`
    `static double[]` | `toDoubleArray(Object b, int itemSize)`
    `static float[]` | `toFloatArray(Object b, int itemSize)`
    `static double` | `toImag(Object b)`
    `static int[]` | `toIntegerArray(Object b, int itemSize)`
    `static long` | `toLong(double d)`
    `static long` | `toLong(float d)`
    `static long` | `toLong(Object b)`
    `static long[]` | `toLongArray(Object b, int itemSize)`
    `static double` | `toReal(Object b)`
    `static short[]` | `toShortArray(Object b, int itemSize)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected static final org.slf4j.Logger logger

  - ### Constructor Detail

    - #### DTypeUtils

          public DTypeUtils()

  - ### Method Detail

    - #### getDTypeName

          public static String getDTypeName(Dataset a)

      Parameters:
        `a` -
      Returns:
        name of dataset type

    - #### getDTypeName

          public static String getDTypeName(ILazyDataset a)

      Parameters:
        `a` -
      Returns:
        name of dataset type

    - #### getDTypeName

          public static String getDTypeName(int dtype,
                            int itemSize)

      Parameters:
        `dtype` -
        `itemSize` -
      Returns:
        name of dataset type

    - #### getDType

          public static int getDType(Class<? extends Dataset> clazz)

      Parameters:
        `clazz` - dataset class
      Returns:
        dataset type for dataset class

    - #### isDTypeElemental

          public static boolean isDTypeElemental(int dtype)

    - #### isDTypeInteger

          public static boolean isDTypeInteger(int dtype)

    - #### isDTypeFloating

          public static boolean isDTypeFloating(int dtype)

    - #### isDTypeComplex

          public static boolean isDTypeComplex(int dtype)

    - #### isDTypeNumerical

          public static boolean isDTypeNumerical(int dtype)

      Parameters:
        `dtype` -
      Returns:
        true if dataset type is numerical, i.e. a dataset contains numbers

    - #### getBestDType

          public static int getBestDType(int atype,
                         int btype)

      Find dataset type that best fits given types The best type takes into account complex and array datasets
      Parameters:
        `atype` - first dataset type
        `btype` - second dataset type
      Returns:
        best dataset type

    - #### getBestFloatDType

          public static int getBestFloatDType(int otype)

      Find floating point dataset type that best fits given types. The best type takes into account complex and array datasets
      Parameters:
        `otype` - old dataset type
      Returns:
        best dataset type

    - #### getBestFloatDType

          public static int getBestFloatDType(Class<? extends Object> cls)

      Find floating point dataset type that best fits given class The best type takes into account complex and array datasets
      Parameters:
        `cls` - of an item or element
      Returns:
        best dataset type

    - #### getDTypeFromClass

          public static int getDTypeFromClass(Class<? extends Object> cls)

      Get dataset type from an element class
      Parameters:
        `cls` - element class
      Returns:
        dataset type

    - #### getDTypeFromClass

          public static int getDTypeFromClass(Class<? extends Object> cls,
                              int isize)

      Get dataset type from an element class
      Parameters:
        `cls` - element class
      Returns:
        dataset type

    - #### getDTypeFromObject

          public static int getDTypeFromObject(Object obj)

      Get dataset type from an object. The following are supported: Java Number objects, Apache common math Complex objects, Java arrays and lists
      Parameters:
        `obj` -
      Returns:
        dataset type

    - #### getDType

          public static int getDType(ILazyDataset d)

      Get dataset type from given dataset
      Parameters:
        `d` -
      Returns:
        dataset type

    - #### getLargestDType

          public static int getLargestDType(int otype)

      The largest dataset type suitable for a summation of around a few thousand items without changing from the "kind" of dataset
      Parameters:
        `otype` -
      Returns:
        largest dataset type available for given dataset type

    - #### getElementalDType

          public static int getElementalDType(int otype)

      Parameters:
        `otype` -
      Returns:
        elemental dataset type available for given dataset type

    - #### isClassSupportedAsElement

          public static boolean isClassSupportedAsElement(Class<? extends Object> comp)

      Parameters:
        `comp` -
      Returns:
        true if supported

    - #### getElementsPerItem

          public static int getElementsPerItem(int dtype)

      Parameters:
        `dtype` -
      Returns:
        number of elements per item

    - #### getItemBytes

          public static int getItemBytes(int dtype)

      Parameters:
        `dtype` -
      Returns:
        length of single item in bytes

    - #### getItemBytes

          public static int getItemBytes(int dtype,
                         int isize)

      Parameters:
        `dtype` -
        `isize` - number of elements in an item
      Returns:
        length of single item in bytes

    - #### toBoolean

          public static boolean toBoolean(Object b)

    - #### toLong

          public static final long toLong(double d)

      Parameters:
        `d` -
      Returns:
        returns a long or 0 if d is NaN or infinite
      Since:
        2.1

    - #### toLong

          public static final long toLong(float d)

      Parameters:
        `d` -
      Returns:
        returns a long or 0 if d is NaN or infinite
      Since:
        2.1

    - #### toLong

          public static long toLong(Object b)

    - #### toReal

          public static double toReal(Object b)

    - #### toImag

          public static double toImag(Object b)

    - #### toDoubleArray

          public static double[] toDoubleArray(Object b,
                               int itemSize)

    - #### toFloatArray

          public static float[] toFloatArray(Object b,
                             int itemSize)

    - #### toLongArray

          public static long[] toLongArray(Object b,
                           int itemSize)

    - #### toIntegerArray

          public static int[] toIntegerArray(Object b,
                             int itemSize)

    - #### toShortArray

          public static short[] toShortArray(Object b,
                             int itemSize)

    - #### toByteArray

          public static byte[] toByteArray(Object b,
                           int itemSize)

    - #### fromDoublesToBiggestPrimitives

          public static Object fromDoublesToBiggestPrimitives(double[] x,
                                              int dtype)

    - #### fromDoubleToBiggestNumber

          public static Number fromDoubleToBiggestNumber(double x,
                                         int dtype)

      Parameters:
        `x` -
        `dtype` -
      Returns:
        biggest native primitive if integer (should test for 64bit?)

    - #### getLength

          public static final int getLength(Object b)

      Parameters:
        `b` -
      Returns:
        length of object

    - #### getElementClass

          public static Class<?> getElementClass(int dtype)

      Parameters:
        `dtype` -
      Returns:
        (boxed) class of constituent element

Copyright © 2014–2018 Eclipse Foundation. All rights reserved.