org.eclipse.january.dataset

## Class BroadcastUtils

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

-     public final class BroadcastUtils
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BroadcastUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static List<int[]>` | `broadcastShapes(int[]... shapes)` Take in shapes and broadcast them to same rank
    `static List<int[]>` | `broadcastShapesToMax(int[] maxShape, int[]... shapes)` Take in shapes and broadcast them to maximum shape
    `static int[][]` | `calculateBroadcastShapes(int[] oldShape, int size, int... newShape)` Calculate shapes for broadcasting
    `static Dataset[]` | `convertAndBroadcast(Object... objects)` Converts and broadcast all objects as datasets of same shape
    `static int[]` | `createBroadcastStrides(Dataset a, int[] broadcastShape)` Create a stride array from a dataset to a broadcast shape
    `static int[]` | `createBroadcastStrides(int isize, int[] oShape, int[] oStride, int[] broadcastShape)` Create a stride array from a dataset to a broadcast shape
    `static int[]` | `padShape(int[] shape, int padding)` Pad shape by prefixing with ones

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

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

- - ### Constructor Detail

    - #### BroadcastUtils

          public BroadcastUtils()

  - ### Method Detail

    - #### calculateBroadcastShapes

          public static int[][] calculateBroadcastShapes(int[] oldShape,
                                         int size,
                                         int... newShape)

      Calculate shapes for broadcasting
      Parameters:
        `oldShape` -
        `size` -
        `newShape` -
      Returns:
        broadcasted shape and full new shape or null if it cannot be done

    - #### padShape

          public static int[] padShape(int[] shape,
                       int padding)

      Pad shape by prefixing with ones
      Parameters:
        `shape` -
        `padding` -
      Returns:
        new shape or old shape if padding is zero

    - #### broadcastShapes

          public static List<int[]> broadcastShapes(int[]... shapes)

      Take in shapes and broadcast them to same rank
      Parameters:
        `shapes` -
      Returns:
        list of broadcasted shapes plus the first entry is the maximum shape

    - #### broadcastShapesToMax

          public static List<int[]> broadcastShapesToMax(int[] maxShape,
                                         int[]... shapes)

      Take in shapes and broadcast them to maximum shape
      Parameters:
        `maxShape` -
        `shapes` -
      Returns:
        list of broadcasted shapes

    - #### createBroadcastStrides

          public static int[] createBroadcastStrides(Dataset a,
                                     int[] broadcastShape)

      Create a stride array from a dataset to a broadcast shape
      Parameters:
        `a` - dataset
        `broadcastShape` -
      Returns:
        stride array

    - #### createBroadcastStrides

          public static int[] createBroadcastStrides(int isize,
                                     int[] oShape,
                                     int[] oStride,
                                     int[] broadcastShape)

      Create a stride array from a dataset to a broadcast shape
      Parameters:
        `isize` -
        `oShape` - original shape
        `oStride` - original stride
        `broadcastShape` -
      Returns:
        stride array

    - #### convertAndBroadcast

          public static Dataset[] convertAndBroadcast(Object... objects)

      Converts and broadcast all objects as datasets of same shape
      Parameters:
        `objects` -
      Returns:
        all as broadcasted to same shape

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