Class ErrorMessages

java.lang.Object
org.flag4j.util.ErrorMessages

public final class ErrorMessages extends Object
Contains error messages for common errors which may occur.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    equalShapeErrMsg(Shape shape1, Shape shape2)
    Gets an error message for two tensors with mismatching shapes.
    static String
    getArrayHasLengthErr(int expLength, int actLength, String arrayName)
    Gets an error message for when an array does not have the expected length.
    static String
    Gets an error message for arrays which were expected to be the same length.
    static String
    getAxisErr(int axis)
    Gets an error message for a disallowed axis.
    static String
    getAxisErr(int axis, int... allowedAxes)
    Gets an error message for a disallowed axis.
    static String
    getGreaterEqErr(double threshold, double value)
    Gets an error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    static String
    getIndicesRankErr(int numIndices, int rank)
    Gets an error message for a tensor being indexed with a number of indices not equal to the rank of the tensor.
    static String
    getLessEqErr(double threshold, double value)
    Gets an error message for a value which was expected to be less than of equal to a specified threshold but wasn't.
    static String
    getNamedGreaterEqErr(double threshold, double value, String name)
    Gets an error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    static String
    getNamedLessEqErr(double threshold, double value, String name)
    Gets an error message for a value which was expected to be less than of equal to a specified threshold but wasn't.
    static String
    getNamedLessEqErr(BigInteger threshold, double value, String name)
    Gets an error message for a value which was expected to be less than of equal to a specified threshold but wasn't.
    static String
    getNegValueErr(double value)
    Gets an error message for a negative value when a non-negative was expected.
    static String
    getNonPosErr(double value)
    Gets an error message for a non-positive value when a positive, non-zero value was expected.
    static String
    getRangeErr(double value, double lowerBound, double upperBound, String paramName)
    Gets an error message for a value which is not within the expected range.
    static String
    Gets an error message for two shapes which cannot be broadcast together.
    static String
    Gets an error message for a shape which was expected to be square but was not
    static String
    Gets an error message for arrays which do not have the same total number of data.
    static String
    Gets an error message for an attempted instantiation of a utility class.
    static String
    Gets an error message for an attempted instantiation of a utility class.
    static String
    matMultShapeErrMsg(Shape shape1, Shape shape2)
    Gets an error message for two matrices with shapes not conducive with matrix multiplication.
    static String
    negativeDimErrMsg(int[] dims)
    Gets an error message for an attempted construction of a tensor with a negative dimension.
    static String
    shapeEntriesError(Shape shape, int numEntries)
    Gets an error message for a shape which cannot hold a specified number of data.
    static String
    shapeRankErr(int actRank, int expRank)
    Gets an error message for an incorrect shape.

    Methods inherited from class java.lang.Object

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

    • equalShapeErrMsg

      public static String equalShapeErrMsg(Shape shape1, Shape shape2)
      Gets an error message for two tensors with mismatching shapes.
      Parameters:
      shape1 - The shape of the first tensor.
      shape2 - The shape of the second tensor.
      Returns:
      An error message for tensors with mismatching shapes.
    • matMultShapeErrMsg

      public static String matMultShapeErrMsg(Shape shape1, Shape shape2)
      Gets an error message for two matrices with shapes not conducive with matrix multiplication.
      Parameters:
      shape1 - The shape of the first matrix.
      shape2 - The shape of the second matrix.
      Returns:
      An error message for matrices with shapes not conducive with matrix multiplication.
    • negativeDimErrMsg

      public static String negativeDimErrMsg(int[] dims)
      Gets an error message for an attempted construction of a tensor with a negative dimension.
      Parameters:
      dims - Shape of the tensor.
      Returns:
      An error message for negative dimension.
    • getUtilityClassErrMsg

      public static String getUtilityClassErrMsg()
      Gets an error message for an attempted instantiation of a utility class.
      Returns:
      An error message for the attempted instantiation of a utility class.
    • getUtilityClassErrMsg

      public static String getUtilityClassErrMsg(Class cls)
      Gets an error message for an attempted instantiation of a utility class.
      Parameters:
      cls - Class which was attempted to be instantiated.
      Returns:
      An error message for the attempted instantiation of a utility class.
    • getNegValueErr

      public static String getNegValueErr(double value)
      Gets an error message for a negative value when a non-negative was expected.
      Parameters:
      value - Negative value.
      Returns:
      An error message for a negative value.
    • getNonPosErr

      public static String getNonPosErr(double value)
      Gets an error message for a non-positive value when a positive, non-zero value was expected.
      Parameters:
      value - Non-positive value.
      Returns:
      An error message for a Non-positive value.
    • getAxisErr

      public static String getAxisErr(int axis, int... allowedAxes)
      Gets an error message for a disallowed axis.
      Parameters:
      axis - Negative value.
      allowedAxes - An array containing allowed axes.
      Returns:
      An error message for a disallowed axis.
    • getAxisErr

      public static String getAxisErr(int axis)
      Gets an error message for a disallowed axis.
      Parameters:
      axis - Negative value.
      Returns:
      An error message for a disallowed axis.
    • shapeRankErr

      public static String shapeRankErr(int actRank, int expRank)
      Gets an error message for an incorrect shape.
      Parameters:
      actRank - Actual rank of the shape.
      expRank - Expected rank of the shape.
      Returns:
      An error message for a shape object with wrong shape.
    • shapeEntriesError

      public static String shapeEntriesError(Shape shape, int numEntries)
      Gets an error message for a shape which cannot hold a specified number of data.
      Parameters:
      shape - Shape.
      numEntries - Number of data to hold.
      Returns:
      An error message for a shape which cannot hold a specified number of data.
    • getArrayLengthsMismatchErr

      public static String getArrayLengthsMismatchErr(int... lengths)
      Gets an error message for arrays which were expected to be the same length.
      Parameters:
      lengths - Lengths of arrays.
      Returns:
      An error message for arrays which were expected to be the same length.
    • getIndicesRankErr

      public static String getIndicesRankErr(int numIndices, int rank)
      Gets an error message for a tensor being indexed with a number of indices not equal to the rank of the tensor.
      Parameters:
      numIndices - Number of indices.
      rank - Rank of the tensor.
      Returns:
      An error message for a tensor being indexed with a number if indices not equal ot the rank of the tensor.
    • getShapeTotalEntriesErr

      public static String getShapeTotalEntriesErr(Shape shape1, Shape shape2)
      Gets an error message for two shapes which cannot be broadcast together.
      Parameters:
      shape1 - First shape.
      shape2 - Second shape.
      Returns:
      An error message for two shapes which cannot be broadcast together.
    • getTotalEntriesErr

      public static String getTotalEntriesErr()
      Gets an error message for arrays which do not have the same total number of data.
      Returns:
      An error message for arrays which do not have the same total number of data.
    • getGreaterEqErr

      public static String getGreaterEqErr(double threshold, double value)
      Gets an error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
      Parameters:
      threshold - Threshold value.
      value - Value expected to be greater than or equal to the threshold value.
      Returns:
      An error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    • getNamedGreaterEqErr

      public static String getNamedGreaterEqErr(double threshold, double value, String name)
      Gets an error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
      Parameters:
      threshold - Threshold value.
      value - Value expected to be greater than or equal to the threshold value.
      Returns:
      An error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    • getLessEqErr

      public static String getLessEqErr(double threshold, double value)
      Gets an error message for a value which was expected to be less than of equal to a specified threshold but wasn't.
      Parameters:
      threshold - Threshold value.
      value - Value expected to be less than or equal to the threshold value.
      Returns:
      An error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    • getNamedLessEqErr

      public static String getNamedLessEqErr(double threshold, double value, String name)
      Gets an error message for a value which was expected to be less than of equal to a specified threshold but wasn't.
      Parameters:
      threshold - Threshold value.
      value - Value expected to be less than or equal to the threshold value.
      Returns:
      An error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    • getNamedLessEqErr

      public static String getNamedLessEqErr(BigInteger threshold, double value, String name)
      Gets an error message for a value which was expected to be less than of equal to a specified threshold but wasn't.
      Parameters:
      threshold - Threshold value.
      value - Value expected to be less than or equal to the threshold value.
      Returns:
      An error message for a value which was expected to be greater than of equal to a specified threshold but wasn't.
    • getSquareShapeErr

      public static String getSquareShapeErr(Shape shape)
      Gets an error message for a shape which was expected to be square but was not
      Parameters:
      shape - Shape of the tensor.
      Returns:
      An error message for a shape which was expected to be square but was not
    • getRangeErr

      public static String getRangeErr(double value, double lowerBound, double upperBound, String paramName)
      Gets an error message for a value which is not within the expected range.
      Parameters:
      value - Value of interest.
      lowerBound - Lower bound of expected range.
      upperBound - Upper bound of expected range.
      paramName - Name of the parameter which has the specified value.
      Returns:
      An error message for the parameter being out of the expected range.
    • getArrayHasLengthErr

      public static String getArrayHasLengthErr(int expLength, int actLength, String arrayName)
      Gets an error message for when an array does not have the expected length.
      Parameters:
      expLength - Expected length of the array.
      actLength - Actual length of the array.
      arrayName - Name of the array parameter. May be null if no name is desired.
      Returns:
      An error message for when an array does not have the expected length.