org.eclipse.january.dataset

## Class DTypeUtils

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

-     public class DTypeUtils
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DTypeUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated 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 dtype)` Find floating point dataset type that best fits given types.
    `static String` | `getDatasetName(Class<? extends Dataset> clazz, int itemSize)`
    `static String` | `getDatasetName(Dataset a)`
    `static String` | `getDatasetName(ILazyDataset a)`
    `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 itemSize)` 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 dtype)`
    `static Class<?>` | `getElementClass(int dtype)`
    `static int` | `getElementsPerItem(int dtype)`
    `static Class<? extends Dataset>` | `getInterface(int dtype)`
    `static int` | `getItemBytes(int dtype)`
    `static int` | `getItemBytes(int dtype, int isize)`
    `static Class<? extends Dataset>` | `getLargestDataset(Class<? extends Dataset> clazz)` The largest dataset class suitable for a summation of around a few thousand items without changing from the "kind" of dataset
    `static int` | `getLargestDType(int dtype)` 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> clazz)` Deprecated. Use `InterfaceUtils.isElementSupported(Class)`
    `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`

- - ### Constructor Detail

    - #### DTypeUtils

          public DTypeUtils()

  - ### Method Detail

    - #### getDTypeName

          public static String getDTypeName(Dataset a)

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

    - #### getDTypeName

          public static String getDTypeName(ILazyDataset a)

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

    - #### getDTypeName

          public static String getDTypeName(int dtype,
                                            int itemSize)

      Parameters:
        `dtype` - dataset type
        `itemSize` - item size
      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)

      Parameters:
        `dtype` - dataset type
      Returns:
        true if each dataset item has single element

    - #### isDTypeInteger

          public static boolean isDTypeInteger(int dtype)

      Parameters:
        `dtype` - dataset type
      Returns:
        true if dataset elements are integers

    - #### isDTypeFloating

          public static boolean isDTypeFloating(int dtype)

      Parameters:
        `dtype` - dataset type
      Returns:
        true if dataset elements are floats

    - #### isDTypeComplex

          public static boolean isDTypeComplex(int dtype)

      Parameters:
        `dtype` - dataset type
      Returns:
        true if each dataset itema are complex

    - #### isDTypeNumerical

          public static boolean isDTypeNumerical(int dtype)

      Parameters:
        `dtype` - dataset type
      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 dtype)

      Find floating point dataset type that best fits given types. The best type takes into account complex and array datasets
      Parameters:
        `dtype` - 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 itemSize)

      Get dataset type from an element class
      Parameters:
        `cls` - element class
        `itemSize` - item size
      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` - input
      Returns:
        dataset type

    - #### getDType

          public static int getDType(ILazyDataset d)

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

    - #### getLargestDType

          public static int getLargestDType(int dtype)

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

    - #### getLargestDataset

          public static Class<? extends Dataset> getLargestDataset(Class<? extends Dataset> clazz)

      The largest dataset class suitable for a summation of around a few thousand items without changing from the "kind" of dataset
      Parameters:
        `clazz` - dataset sub-interface
      Returns:
        largest dataset class available for given dataset class
      Since:
        2.3

    - #### getElementalDType

          public static int getElementalDType(int dtype)

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

    - #### getElementsPerItem

          public static int getElementsPerItem(int dtype)

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

    - #### getItemBytes

          public static int getItemBytes(int dtype)

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

    - #### getItemBytes

          public static int getItemBytes(int dtype,
                                         int isize)

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

    - #### toBoolean

          public static boolean toBoolean(Object b)

      Parameters:
        `b` - input
      Returns:
        converted boolean

    - #### toLong

          public static final long toLong(double d)

      Parameters:
        `d` - value
      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` - value
      Returns:
        returns a long or 0 if d is NaN or infinite
      Since:
        2.1

    - #### toLong

          public static long toLong(Object b)

      Parameters:
        `b` - input
      Returns:
        converted long

    - #### toReal

          public static double toReal(Object b)

      Parameters:
        `b` - input
      Returns:
        real part of input

    - #### toImag

          public static double toImag(Object b)

      Parameters:
        `b` - input
      Returns:
        imaginary part of input

    - #### toDoubleArray

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

      Parameters:
        `b` - input
        `itemSize` - item size
      Returns:
        converted doubles

    - #### toFloatArray

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

      Parameters:
        `b` - input
        `itemSize` - item size
      Returns:
        converted floats

    - #### toLongArray

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

      Parameters:
        `b` - input
        `itemSize` - item size
      Returns:
        converted longs

    - #### toIntegerArray

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

      Parameters:
        `b` - input
        `itemSize` - item size
      Returns:
        converted integers

    - #### toShortArray

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

      Parameters:
        `b` - input
        `itemSize` - item size
      Returns:
        converted shorts

    - #### toByteArray

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

      Parameters:
        `b` - input
        `itemSize` - item size
      Returns:
        converted bytes

    - #### fromDoublesToBiggestPrimitives

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

      Parameters:
        `x` - input
        `dtype` - dataset type primitive array
      Returns:
        array of biggest primitives

    - #### getElementClass

          public static Class<?> getElementClass(int dtype)

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

    - #### getInterface

          public static Class<? extends Dataset> getInterface(int dtype)

      Parameters:
        `dtype` - dataset type
      Returns:
        dataset interface can be null
      Since:
        2.3

    - #### fromDoubleToBiggestNumber

          public static Number fromDoubleToBiggestNumber(double x,
                                                         int dtype)

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

    - #### isClassSupportedAsElement

          @Deprecated
          public static boolean isClassSupportedAsElement(Class<? extends Object> clazz)

      Deprecated. Use `InterfaceUtils.isElementSupported(Class)`
      Parameters:
        `clazz` - element class
      Returns:
        true if supported

    - #### getLength

          public static final int getLength(Object b)

      Parameters:
        `b` - input
      Returns:
        length of object

    - #### getDatasetName

          public static String getDatasetName(Dataset a)

      Parameters:
        `a` - input
      Returns:
        name of dataset interface
      Since:
        2.3

    - #### getDatasetName

          public static String getDatasetName(ILazyDataset a)

      Parameters:
        `a` - input
      Returns:
        name of dataset interface
      Since:
        2.3

    - #### getDatasetName

          public static String getDatasetName(Class<? extends Dataset> clazz,
                                              int itemSize)

      Parameters:
        `clazz` - dataset interface
        `itemSize` - item size
      Returns:
        name of dataset interface
      Since:
        2.3

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