Package linalg.util

Class LinAlgArrayUtils

java.lang.Object
linalg.util.LinAlgArrayUtils

public class LinAlgArrayUtils extends Object
Contains some utility functions to manipulate arrays.
  • Method Details

    • random

      public static CNumber[][] random​(int rows, int cols, double min, double max, boolean... magnitude_flag)
    • random

      public static CNumber[][] random​(int rows, int cols)
    • random

      public static CNumber[][] random​(int rows, int cols, double mag)
    • randomComplex

      public static CNumber[][] randomComplex​(int rows, int cols)
    • randn

      public static CNumber[][] randn​(int rows, int cols, boolean complex)
    • printArr

      public static void printArr​(CNumber[][] arr)
    • printArr

      public static void printArr​(CNumber[] arr)
    • getDims

      public static String getDims​(CNumber[][] arr)
    • zeros

      public static CNumber[][] zeros​(int rows, int cols)
    • abs

      public static CNumber[] abs​(CNumber[] arr)
    • flatten

      public static CNumber[] flatten​(CNumber[][] arr)
    • getSection

      public static CNumber[][] getSection​(CNumber[][] data, int rowStart, int rowEnd, int colStart, int colEnd)
    • contains

      public static boolean contains​(int[] arr, int value)
    • extend2D

      public static CNumber[][] extend2D​(CNumber[] arr, int axis)
      Extends a 1D array to 2D along a specified axis.
      Parameters:
      arr - - array to extend
      axis - - axis along which to extend.

      If axis is 0 then a new dimension will be added along the rows and the entires of arr will become the column entries. This results in a 1xarr.length 2D array.

      If axis is 1, then a new dimension will be added along the columns and the antries of arr will become the row entries. This results in a arr.lengthx1 2D array.
      Returns:
      Array extended to 2D
    • extend2D

      public static CNumber[][] extend2D​(double[] arr, int axis)
      Extends a 1D array to 2D along a specified axis.
      Parameters:
      arr - - array to extend
      axis - - axis along which to extend.

      If axis is 0 then a new dimension will be added along the rows and the entires of arr will become the column entries. This results in a 1xarr.length 2D array.

      If axis is 1, then a new dimension will be added along the columns and the antries of arr will become the row entries. This results in a arr.lengthx1 2D array.
      Returns:
      Array extended to 2D
    • extend2D

      public static CNumber[][] extend2D​(int[] arr, int axis)
      Extends a 1D array to 2D along a specified axis.
      Parameters:
      arr - - array to extend
      axis - - axis along which to extend.

      If axis is 0 then a new dimension will be added along the rows and the entires of arr will become the column entries. This results in a 1xarr.length 2D array.

      If axis is 1, then a new dimension will be added along the columns and the antries of arr will become the row entries. This results in a arr.lengthx1 2D array.
      Returns:
      Array extended to 2D
    • norm

      public static CNumber norm​(CNumber[] arr)
      Computes norm of an array as if it was a vector.
      Returns:
      Norm of array
    • group

      public static CNumber[] group​(CNumber[] values)