Package pal.misc

Class Utils

java.lang.Object
pal.misc.Utils

public class Utils extends Object
Provides some miscellaneous methods.
Version:
$Id: Utils.java,v 1.25 2004/08/02 05:22:04 matt Exp $
Author:
Matthew Goode
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final int
    argmax(double[] array)
    Deprecated. 
    static final int
    argmax(int[] array)
    Deprecated. 
    Creates an interface between a parameterised object to allow it to act as a multivariate minimum.
    static final void
    copy(double[][] source, double[][] dest)
    Copies all of source into dest - assumes dest to be large enough
    static final int
    getArgmax(double[] array)
    Find the maximum "argument" (of a double array)
    static final int
    getArgmax(int[] array)
    Find the maximum "argument"
    static final boolean[][]
    getCopy(boolean[][] array)
    Clones an array of booleans
    static final byte[]
    getCopy(byte[] array)
    Clones an array of bytes
    static final byte[][]
    getCopy(byte[][] array)
    Clones an array of bytes
    static final double[]
    getCopy(double[] array)
    Clones an array of doubles
    static final double[][]
    getCopy(double[][] array)
    Clones an array of doubles
    static final double[][][]
    getCopy(double[][][] array)
    Clones an array of doubles
    static final double[]
    getCopy(double[] array, int start)
    Clones an array of doubles from index start (inclusive) to end
    static final double[]
    getCopy(double[] array, int start, int end)
    Clones an array of doubles from index start (inclusive) to index end (exclusive)
    static final int[]
    getCopy(int[] array)
    Clones an array of ints
    static final int[][]
    getCopy(int[][] matrix)
    Clones a matrix of ints
    static final int[]
    getCopy(int[] array, int startingIndex)
    Clones an array of ints
    static final String[]
    getCopy(String[] array)
    Clones an array of Strings
    static final double
    getMax(double[] array)
    Calculate the max of an array
    static final double
    getMax(double[] array, int start, int end)
    Calculate the max of an array
    static final double
    getMean(double[] array)
    Calculate the mean value of an array
    static final double
    getMin(double[] array)
    Calculate the min of an array
    static final double
    getSum(double[] array)
    Calculate the total of an array
    static final boolean
    isContains(String[] set, String query)
    Test if a string occurs within a set
    static final String
    toString(double[] array)
    A simple toString method for an array of doubles.
    static final String
    toString(double[][] array)
    A simple toString method for an array of doubles.
    static final String
    toString(double[] array, int number)
    A simple toString method for an array of doubles.
    static final String
    toString(int[] array)
    A simple toString method for an array of ints.
    static final String
    toString(int[][] array)
    A simple toString method for an array of ints.
    static final String
    toString(int[] array, int number)
     
    static final String
    toString(Object[] array)
    A simple toString method for an array of doubles.
    static final String
    toString(Object[] array, int number)
    A simple toString method for an array of objects.
    static final String
    toString(Object[] array, String divider)
    A simple toString method for an array of objects.
    static final String
    toString(Object[] array, String divider, int number)
    A simple toString method for an array of objects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • isContains

      public static final boolean isContains(String[] set, String query)
      Test if a string occurs within a set
      Parameters:
      set - the set of strings
      query - the query string
      Returns:
      true if the query string is in the set (as determined by object equality)
    • getCopy

      public static final double[] getCopy(double[] array)
      Clones an array of doubles
      Returns:
      null if input is null, otherwise return complete copy.
    • getSum

      public static final double getSum(double[] array)
      Calculate the total of an array
      Parameters:
      array - The array to sum up
      Returns:
      the sum of all the elements
    • getMax

      public static final double getMax(double[] array)
      Calculate the max of an array
      Parameters:
      array - The array to check
      Returns:
      the max of all the elements
    • getMax

      public static final double getMax(double[] array, int start, int end)
      Calculate the max of an array
      Parameters:
      array - The array to check
      start - the first index to check
      end - the index after the last index to check
      Returns:
      the max of all the elements
    • getMin

      public static final double getMin(double[] array)
      Calculate the min of an array
      Parameters:
      array - The array to check
      Returns:
      the min of all the elements
    • getMean

      public static final double getMean(double[] array)
      Calculate the mean value of an array
      Parameters:
      array - the values
      Returns:
      the average
    • getCopy

      public static final double[] getCopy(double[] array, int start, int end)
      Clones an array of doubles from index start (inclusive) to index end (exclusive)
      Returns:
      null if input is null
    • getCopy

      public static final double[] getCopy(double[] array, int start)
      Clones an array of doubles from index start (inclusive) to end
      Returns:
      null if input is null
    • getCopy

      public static final byte[] getCopy(byte[] array)
      Clones an array of bytes
      Parameters:
      array - the bytes to copy
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final String[] getCopy(String[] array)
      Clones an array of Strings
      Parameters:
      array - the strings to copy
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final double[][] getCopy(double[][] array)
      Clones an array of doubles
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final int[][] getCopy(int[][] matrix)
      Clones a matrix of ints
      Parameters:
      matrix - the matrix to clone
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final double[][][] getCopy(double[][][] array)
      Clones an array of doubles
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final byte[][] getCopy(byte[][] array)
      Clones an array of bytes
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final boolean[][] getCopy(boolean[][] array)
      Clones an array of booleans
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final int[] getCopy(int[] array)
      Clones an array of ints
      Returns:
      null if input is null, otherwise return complete copy.
    • getCopy

      public static final int[] getCopy(int[] array, int startingIndex)
      Clones an array of ints
      Parameters:
      startingIndex - , starts copying from this index
      Returns:
      null if input is null, otherwise return complete copy.
    • copy

      public static final void copy(double[][] source, double[][] dest)
      Copies all of source into dest - assumes dest to be large enough
    • toString

      public static final String toString(double[] array, int number)
      A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value
      Parameters:
      number - number of elements to process starting from first element
    • toString

      public static final String toString(Object[] array, int number)
      A simple toString method for an array of objects. No fancy formating. Puts spaces between each value
      Parameters:
      number - number of elements to process starting from first element
    • toString

      public static final String toString(Object[] array, String divider)
      A simple toString method for an array of objects. No fancy formating. Puts user defined string between each value
      Parameters:
      number - number of elements to process starting from first element
    • toString

      public static final String toString(Object[] array, String divider, int number)
      A simple toString method for an array of objects. No fancy formating. Puts user defined string between each value
      Parameters:
      number - number of elements to process starting from first element
    • toString

      public static final String toString(Object[] array)
      A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value
    • toString

      public static final String toString(double[] array)
      A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value
    • toString

      public static final String toString(int[] array)
      A simple toString method for an array of ints. No fancy formating. Puts spaces between each value
    • toString

      public static final String toString(int[] array, int number)
    • toString

      public static final String toString(double[][] array)
      A simple toString method for an array of doubles. No fancy formating. Puts spaces between each value
    • toString

      public static final String toString(int[][] array)
      A simple toString method for an array of ints. No fancy formating. Puts spaces between each value
    • argmax

      public static final int argmax(int[] array)
      Deprecated.
      See Also:
      • invalid reference
        getArgmax()
    • getArgmax

      public static final int getArgmax(int[] array)
      Find the maximum "argument"
      Parameters:
      array - The array to examine
      Returns:
      the element of the array with the maximum value
    • argmax

      public static final int argmax(double[] array)
      Deprecated.
      See Also:
      • invalid reference
        getArgmax()
    • getArgmax

      public static final int getArgmax(double[] array)
      Find the maximum "argument" (of a double array)
      Parameters:
      array - The array to examine
      Returns:
      the element of the array with the maximum value
    • combineMultivariateFunction

      public static final MultivariateFunction combineMultivariateFunction(MultivariateFunction base, Parameterized[] additionalParameters)
      Creates an interface between a parameterised object to allow it to act as a multivariate minimum.