Package HAL

Class Util


  • public final class Util
    extends java.lang.Object
    A collection of helpful static utility functions recommended import: import static Util.*
    • Constructor Summary

      Constructors 
      Constructor Description
      Util()  
    • Method Summary

      Modifier and Type Method Description
      static void AlongLineAction​(double x1, double y1, double x2, double y2, Coords2DAction Action)
      executes the provided action function using as argument the coordinates of all squares along the line between (x1,y1) and (x2,y2)
      static int[] AlongLineCoords​(double x1, double y1, double x2, double y2)
      Returns a coordinates array of all squares along the line between (x1,y1) and (x2,y2)
      static int AlongLineCoords​(double x1, double y1, double x2, double y2, int[] returnCoords)
      puts into Coords all squares along the line between (x1,y1) and (x2,y2)
      static <T> T[] Append​(T[] arr, T appendMe)
      Returns a new array that is the first array with the appendMe object appended to the end of it
      static double[] ArrayListToArrayDouble​(java.util.ArrayList<java.lang.Double> in)  
      static int[] ArrayListToArrayInt​(java.util.ArrayList<java.lang.Integer> in)  
      static <T> T[] ArrayListToArrayObject​(java.util.ArrayList<T> in)  
      static java.lang.String[] ArrayListToArrayString​(java.util.ArrayList<java.lang.String> in)  
      static double ArrayMax​(double[] arr)
      gets the max value from an array
      static int ArrayMax​(int[] arr)
      gets the max value from an array
      static double ArrayMean​(double[] a)
      returns the mean value of the provided array
      static double ArrayMean​(int[] a)
      returns the mean value of the provided array
      static double ArrayMean​(long[] a)
      returns the mean value of the provided array
      static double ArrayMin​(double[] arr)
      gets the min value from an array
      static int ArrayMin​(int[] arr)
      gets the min value from an array
      static double ArraySquaredSum​(double[] arr)
      sums the array
      static double ArrayStdDev​(double[] a)
      returns the standard deviation value of the provided array
      static double ArrayStdDev​(int[] a)
      returns the standard deviation value of the provided array
      static double ArrayStdDev​(long[] a)
      returns the standard deviation value of the provided array
      static double ArraySum​(double[] arr)
      sums the array
      static int ArraySum​(int[] arr)
      sums the array
      static long ArraySum​(long[] arr)
      sums the array
      static java.lang.String ArrToString​(double[] arr, java.lang.String delim)
      prints an array using delim to separate the entries
      static java.lang.String ArrToString​(double[] arr, java.lang.String delim, int start, int end)
      prints an array using delim to separate the entries, beginning at index start and ending at index end
      static java.lang.String ArrToString​(float[] arr, java.lang.String delim)
      prints an array using delim to separate the entries
      static java.lang.String ArrToString​(float[] arr, java.lang.String delim, int start, int end)
      prints an array using delim to separate the entries, beginning at index start and ending at index end
      static java.lang.String ArrToString​(int[] arr, java.lang.String delim)
      prints an array using delim to separate the entries
      static java.lang.String ArrToString​(int[] arr, java.lang.String delim, int start, int end)
      prints an array using delim to separate the entries, beginning at index start and ending at index end
      static java.lang.String ArrToString​(long[] arr, java.lang.String delim)
      prints an array using delim to separate the entries
      static java.lang.String ArrToString​(long[] arr, java.lang.String delim, int start, int end)
      prints an array using delim to separate the entries, beginning at index start and ending at index end
      static java.lang.String ArrToString​(java.lang.String[] arr, java.lang.String delim)
      prints an array using delim to separate the entries
      static java.lang.String ArrToString​(java.lang.String[] arr, java.lang.String delim, int start, int end)
      prints an array using delim to separate the entries, beginning at index start and ending at index end
      static <T> java.lang.String ArrToString​(java.util.ArrayList<java.lang.String> arr, java.lang.String delim)
      prints an array to a string, using the .toString function, and separating entries with the delim argument
      static <T> java.lang.String ArrToString​(java.util.ArrayList<java.lang.String> arr, java.lang.String delim, int start, int end)
      prints an array between start and end indices to a string, using the .toString function, and separating entries with the delim argument
      static <T> java.lang.String ArrToString​(T[] arr, java.lang.String delim)
      prints an array to a string, using the .toString function, and separating entries with the delim argument
      static <T> java.lang.String ArrToString​(T[] arr, java.lang.String delim, int start, int end)
      prints an array between start and end indices to a string, using the .toString function, and separating entries with the delim argument
      static java.lang.String AwaitInput()  
      static double BinomialDistPDF​(long n, double p, long k)  
      static double Bound​(double val, double min, double max)
      returns the original value bounded by min and max inclusive
      static float Bound​(float val, double min, double max)
      returns the original value bounded by min and max inclusive
      static int Bound​(int val, int min, int max)
      returns the original value bounded by min and max inclusive
      static long Bound​(long val, long min, long max)
      returns the original value bounded by min and max inclusive
      static int CategorialColor​(int index)
      returns a color from the d3 category20 color set based on the index argument
      static int[] CategoricalColors​(int startIndex, int endIndex)  
      static int CbCrPlaneColor​(double x, double y)
      generates an RGB color from the CbCr plane with x,y coordinates assumed to be from 0 to 1
      static int[] CircleHood​(boolean includeOrigin, double radius)
      generates a neighborhood with the set of all coordinates in the circle with center 0,0 and the given radius.
      static double CircleOverlapArea​(double radii, double centerDist)
      finds the area of overlap between 2 circles of equal radii
      static double CircleOverlapArea​(double r1, double r2, double centerDist)  
      static int ColorMap​(double val, double min, double max, int minColor, int maxColor)
      interpoloates value from min to max to between any pair of colors
      static int ColorMap​(double val, int minColor, int maxColor)
      interpoloates value from 0 to 1 to between any pair of colors
      static int ColorMap2D​(double valx, double valy, int bottomLeft, int bottomRight, int topLeft, int topRight)
      interpoloates coordinate pairs from 0 to 1 to between a box with any 4 corner colors
      static java.lang.String ColorString​(int color)
      returns the RGBA components of the color as a string
      static void ColorToHSB​(int color, float[] ret)
      puts the HSB components [hue, saturation, brightness] of the RGB color into the ret array
      static <T> T[] Concat​(T[] first, T[] second)
      Returns a new array that is the first array with the second concatenated to the end of it
      static double DispWrap​(double p1, double p2, double dim)
      computes the minimum distance between p1 and p2, using wraparound if it is shorter
      static double Dist​(double x1, double y1, double x2, double y2)
      gets the euclidean distance between (x1,y1) and (x2,y2)
      static double Dist​(double x1, double y1, double z1, double x2, double y2, double z2)
      gets the euclidean distance between (x1,y1,z1) and (x2,y2,z2)
      static double Dist​(double x1, double y1, double x2, double y2, double xDim, double yDim, boolean wrapX, boolean wrapY)
      gets the euclidean distance between (x1,y1) and (x2,y2), assuming boundaries 0,xDim and 0,yDim, and wraparound as given in the arguments
      static double Dist​(double x1, double y1, double z1, double x2, double y2, double z2, int xDim, int yDim, int zDim, boolean wrapX, boolean wrapY, boolean wrapZ)
      gets the euclidean distance between (x1,y1,z1) and (x2,y2,z2), assuming boundaries (0,xDim),(0,yDim), and (0,zDim) and wraparound as given in the arguments
      static double DistSquared​(double[] p1, double[] p2)
      returns the distance squared between the two position provided in any number of dimensions
      static double DistSquared​(double x1, double y1, double x2, double y2)
      similar to dist above, but returns the distance squared
      static double DistSquared​(double x1, double y1, double z1, double x2, double y2, double z2)
      similar to dist above, but returns the distance squared
      static double DistSquared​(double x1, double y1, double x2, double y2, double xDim, double yDim, boolean wrapX, boolean wrapY)
      similar to dist above, but returns the distance squared
      static double DistSquared​(double x1, double y1, double z1, double x2, double y2, double z2, int xDim, int yDim, int zDim, boolean wrapX, boolean wrapY, boolean wrapZ)
      similar to dist above, but returns the distance squared
      static long Factorial​(long n)
      Factorial of a positive integer, uses FactorialSplit
      static int FlipBit​(int v, int i)
      returns a version of the int v with the bit at index i flipped
      static long FlipBit​(long v, int i)
      returns a version of the long v with the bit at index i flipped
      static double GaussianPDF​(double pos)  
      static double GaussianPDF​(double mean, double std, double pos)  
      static float[] GenCirclePoints​(float rad, int nCorners)
      returns the evenly spaced coordinates along the edge of a circle in 2D, centered on (0,0)
      static int[] GenHood1D​(int[] coords)
      generates a 1D neighborhood from a set of coordinates, with space for the results of mapping
      static int[] GenHood2D​(int[] coords)
      generates a 2D neighborhood from a set of coordinates, with space for the results of mapping
      static int[] GenHood3D​(int[] coords)
      generates a 3D neighborhood from a set of coordinates, with space for the results of mapping
      static int[] GenIndicesArray​(int nEntries)
      returns an array of indices starting with 0 and ending with nEntries-1
      static double GetAlpha​(int color)
      returns the Alpha component value of the color as an integer from 0 to 1
      static int GetAlpha256​(int color)
      returns the Alpha component value of the color as an integer from 0 to 255
      static boolean GetBit​(int v, int i)
      gets the value from a single bit of an int32
      static boolean GetBit​(long v, int i)
      gets the value from a single bit of an long64
      static double GetBlue​(int color)
      returns the Blue component value of the color as an integer from 0 to 1
      static int GetBlue256​(int color)
      returns the Blue component value of the color as an integer from 0 to 255
      static double GetGreen​(int color)
      returns the Green component value of the color as an integer from 0 to 1
      static int GetGreen256​(int color)
      returns the Green component value of the color as an integer from 0 to 255
      static double GetRed​(int color)
      returns the Red component value of the color as an integer from 0 to 1
      static int GetRed256​(int color)
      returns the Red component value of the color as an integer from 0 to 255
      static int HeatMapBGR​(double val)
      returns a color int by mapping values from 0 to 1 with a heatmap with colors black, blue, light blue, cyan, white
      static int HeatMapBGR​(double val, double min, double max)
      returns a color int by mapping values from min to max with a heatmap with colors black, blue, light blue, cyan, white
      static int HeatMapBRG​(double val)
      returns a color int by mapping values from 0 to 1 with a heatmap with colors black, blue, purple, pink, white
      static int HeatMapBRG​(double val, double min, double max)
      returns a color int by mapping values from min to max with a heatmap with colors black, blue, purple, pink, white
      static int HeatMapGBR​(double val)
      returns a color int by mapping values from 0 to 1 with a heatmap with colors black, green, greenblue, cyan, white
      static int HeatMapGBR​(double val, double min, double max)
      returns a color int by mapping values from min to max with a heatmap with colors black, green, greenblue, cyan, white
      static int HeatMapGRB​(double val)
      returns a color int by mapping values from 0 to 1 with a heatmap with colors black, green, lime, yellow, white
      static int HeatMapGRB​(double val, double min, double max)
      returns a color int by mapping values from min to max with a heatmap with colors black, green, lime, yellow, white
      static int HeatMapJet​(double val)  
      static int HeatMapJet​(double val, double min, double max)  
      static int HeatMapRBG​(double val)
      returns a color int by mapping values from 0 to 1 with a heatmap with colors black, red, pink, magenta, white
      static int HeatMapRBG​(double val, double min, double max)
      returns a color int by mapping values from min to max with a heatmap with colors black, red, pink, magenta, white
      static int HeatMapRGB​(double val)
      returns a color int by mapping values from 0 to 1 with a heatmap with colors black, red, orange, yellow, white
      static int HeatMapRGB​(double val, double min, double max)
      returns a color int by mapping values from min to max with a heatmap with colors black, red, orange, yellow, white
      static int[] HexHoodEvenY​(boolean includeOrigin)
      Returns the coordinates defining the Hexagonal neighborhood for even yDim coordinates centered on (0,0)
      static int[] HexHoodOddY​(boolean includeOrigin)
      Returns the coordinates defining the Hexagonal neighborhood for odd yDim coordinates centered on (0,0)
      static double HillEqn​(double conc, double dissociationRate, double hillCoef)  
      static int HSBColor​(double hue, double saturation, double brightness)
      generates a color int based on the HSB color space
      static int HsLuvColor​(double x, double y)  
      static boolean InDim​(double Val, double Dim)
      returns whether the input value is between 0 and the dimension value
      static boolean InDim​(int Val, int Dim)
      returns whether the input value is between 0 and the dimension value
      static boolean InfiniteLinesIntersection2D​(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double[] retCoords)
      gets the point at which the line from (x1,y1) to (x2,y2) intersects with the line from (x3,y3) and (x4,y4) and puts the coordinates in retCoords.
      static double Interpolate​(double val, double min, double max)
      interpolates value from 0 to 1 to be between min and max
      static double Interpolate2D​(double x, double y, double bottomLeft, double bottomRight, double topLeft, double topRight)
      interpolates value from 0 to 1 to be between min and max
      static double Interpolate2DNoBound​(double x, double y, double bottomLeft, double bottomRight, double topLeft, double topRight)  
      static double InterpolateLinear​(double x, double startX, double endX, double startY, double endY)  
      static double InterpolateNoBound​(double val, double min, double max)  
      static <T,​O extends T>
      boolean
      IsMethodOverridden​(java.lang.Class<O> derived, java.lang.String methodName)  
      static boolean IsMethodOverridden​(java.lang.Class derived, java.lang.Class base, java.lang.String methodName)  
      static boolean IsPath​(java.lang.String path)  
      static <T extends SerializableModel>
      T
      LoadState​(byte[] state)
      Loads a model form a byte array created with SaveState.
      static <T extends SerializableModel>
      T
      LoadState​(java.lang.String stateBytesFile)
      Loads a model from a file created with SaveState.
      static int Log2​(int n)  
      static long Log2​(long n)  
      static boolean MakeDirs​(java.lang.String path)
      creates directories to ensure that the path argument exists
      static void MatrixToCSV​(double[][] mat, java.lang.String filePath)  
      static void MatrixToCSV​(int[][] mat, java.lang.String filePath)  
      static void MatrixToCSV​(long[][] mat, java.lang.String filePath)  
      static double[] MatVecMul​(double[] mat, double[] vec, double[] out)  
      static void MemoryUsageInfo​(long[] ret)  
      static java.lang.String MemoryUsageStr()
      gets information about the memory usage and max memory allocated for the program
      static double MichaelisMenten​(double conc, double maxRate, double halfRateConc)
      uses the Michaelis Menten equation to compute the reaction rate for a given substrate concentration
      static int[] MooreHood​(boolean includeOrigin)
      Returns the coordinates defining the Moore neighborhood centered on (0,0)
      static int[] MooreHood3D​(boolean includeOrigin)  
      static void MultiThread​(int nRuns, int nThreads, ParallelFunction RunFun)
      Creates a thread pool and launches a total of nRun threads, with nThreads running simultaneously at a time.
      static void MultiThread​(int nRuns, ParallelFunction RunFun)
      does the same thing as MultiThread above, but generates a number of threads equal to the number of available processors
      static long NchooseK​(long n, long k)  
      static double Norm​(double[] vals)
      returns the norm or "length" of the vector array
      static double Norm​(double v1, double v2)
      returns the norm or "length" of the vector (v1,v2)
      static double Norm​(double v1, double v2, double v3)
      returns the norm or "length" of the vector (v1,v2,v3)
      static double Norm​(double v1, double v2, double v3, double v4)
      returns the norm or "length" of the vector (v1,v2,v3,v4)
      static void Normalize​(double[] vals)
      normalizes the vector array in place so that its norm is 1
      static double NormSquared​(double[] vals)
      returns the norm or "length" of the vector array squared
      static double NormSquared​(double v1, double v2)
      returns the norm or "length" of the vector (v1,v2) squared
      static double NormSquared​(double v1, double v2, double v3)
      returns the norm or "length" of the vector (v1,v2,v3) squared
      static double NormSquared​(double v1, double v2, double v3, double v4)
      returns the norm or "length" of the vector (v1,v2,v3,v4) squared
      static double PhToProtons​(double ph)
      converts pH to proton concentration
      static double PoissonProb​(int sampleSize, double avg)
      Samples a Poisson distribution
      static double ProbScale​(double prob, double duration)
      adjusts probability that an event will occur in 1 unit of time to the probability that the event will occur at least once over the duration
      static double ProtonsToPh​(double protonConc)
      converts proton concentration to pH
      static java.lang.String PWD()
      gets the current working directory as a string
      static double[] Py4jDoublesIn​(byte[] in)  
      static double[][] Py4jDoublesIn​(byte[] in, int nRows)  
      static java.util.ArrayList<double[]> Py4jDoublesInAsArrayList​(byte[] in, int nRows)  
      static byte[] Py4jDoublesOut​(double[] doubles)  
      static byte[] Py4jDoublesOut​(double[][] doubles)  
      static byte[] Py4jDoublesOut​(java.util.ArrayList<double[]> doubles)  
      static <T extends Sortable>
      void
      QuickSort​(T sortMe, boolean greatestToLeast)
      Runs quicksort on an object that implements Sortable
      static int[] RectangleHood​(boolean includeOrigin, int radX, int radY)
      Returns the coordinates of all squares whose centers lie within a rectangle of the provided radius, centered on (0,0)
      static double Rescale​(double val, double oldMin, double oldMax, double newMin, double newMax)
      rescales the value from being between oldMin and oldMax to being between newMin and newMax
      static int RGB​(double r, double g, double b)
      returns a color integer based on the RGB components passed in.
      static int RGB256​(int r, int g, int b)
      returns a color integer based on the RGB components passed in.
      static int RGBA​(double r, double g, double b, double a)
      returns a color integer based on the RGBA components passed in.
      static int RGBA256​(int r, int g, int b, int a)
      returns a color integer based on the RGB components passed in.
      static byte[] SaveState​(SerializableModel model)
      Saves a model state to a byte array and returns it.
      static void SaveState​(SerializableModel model, java.lang.String stateFileName)
      Saves a model state to a file with the name specified.
      static double Scale0to1​(double val, double min, double max)
      returns where the value is from min to max as a number from 0 to 1
      static double ScaleMinToMax​(double val, double min, double max)
      interpolates value from 0 to 1 to be between min and max
      static int SetAlpha​(int color, double a)
      returns a new color integer based on the input color but with the alpha component changed to the r argument
      static int SetAlpha256​(int color, int a)
      returns a new color integer based on the input color but with the alpha component changed to the r argument
      static int SetBit​(int v, int i, boolean val)
      returns a version of the int v with the bit at position i set to val
      static long SetBit​(long v, int i, boolean val)
      returns a version of the long v with the bit at position i set to val
      static int SetBlue​(int color, double b)
      returns a new color integer based on the input color but with the blue component changed to the r argument
      static int SetBlue256​(int color, int b)
      returns a new color integer based on the input color but with the blue component changed to the r argument
      static int SetGreen​(int color, double g)
      returns a new color integer based on the input color but with the green component changed to the r argument
      static int SetGreen256​(int color, int g)
      returns a new color integer based on the input color but with the green component changed to the r argument
      static int SetRed​(int color, double r)
      returns a new color integer based on the input color but with the red component changed to the r argument
      static int SetRed256​(int color, int r)
      returns a new color integer based on the input color but with the red component changed to the r argument
      static double Sigmoid​(double val, double stretch)
      transforms val with a sigmoid curve with a minCap of 0, a maxCap of 1, and an inflectionX value of 0
      static double Sigmoid​(double val, double stretch, double inflectionX, double minCap, double maxCap)
      transforms val with a sigmoid curve with the given properties
      static void Sort​(IsEntry1Before2 Compare, SwapEntries Swap, int length)  
      static int SubsetIndices​(int[] hood, int lenToCheck, IndexBool EvalFun)
      subsets a set of indices such that all indices evaluate to true under the EvalFun
      static double SumTo1​(double[] vals)
      sets the values in the array such that they sum to 1
      static double SumTo1​(double[] vals, int start, int end)
      sets the values in the array such that they sum to 1, using only the numbers between start and end
      static java.lang.String TimeStamp()
      returns a timestamp of the form "yyyy_MM_dd_HH_mm_ss" as a string
      static int[] TriangleHoodDifParity​(boolean includeOrigin)
      Returns the coordinates defining the Triangular neighborhood for even xDim, odd yDim or oddx, even yDim.
      static int[] TriangleHoodSameParity​(boolean includeOrigin)
      Returns the coordinates defining the Triangular neighborhood for even xDim, even yDim or oddx, odd yDim.
      static int[] VonNeumannHood​(boolean includeOrigin)
      Returns the coordinates defining the Von Neumann neighborhood centered on (0,0)
      static int[] VonNeumannHood3D​(boolean includeOrigin)
      Returns the coordinates defining the Von Neumann neighborhood centered on (0,0,0)
      static double Wrap​(double val, double max)
      returns value with wraparound between 0 and max
      static int Wrap​(int val, int max)
      returns value with wraparound between 0 and max
      static int YCbCrColor​(double y, double cb, double cr)
      generates an RGB color from the YCbCr color space
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RED

        public static final int RED
      • GREEN

        public static final int GREEN
      • BLUE

        public static final int BLUE
      • BLACK

        public static final int BLACK
      • WHITE

        public static final int WHITE
      • YELLOW

        public static final int YELLOW
      • CYAN

        public static final int CYAN
      • MAGENTA

        public static final int MAGENTA
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • RGB

        public static int RGB​(double r,
                              double g,
                              double b)
        returns a color integer based on the RGB components passed in. color values should be scaled from 0 to 1
      • RGBA

        public static int RGBA​(double r,
                               double g,
                               double b,
                               double a)
        returns a color integer based on the RGBA components passed in. color values should be scaled from 0 to 1. the alpha value is used with the AddAlphaGrid UIGrid function to blend colors together from multiple grids
      • RGB256

        public static int RGB256​(int r,
                                 int g,
                                 int b)
        returns a color integer based on the RGB components passed in. color values should be scaled from 0 to 255.
      • RGBA256

        public static int RGBA256​(int r,
                                  int g,
                                  int b,
                                  int a)
        returns a color integer based on the RGB components passed in. color values should be scaled from 0 to 255. the alpha value is used with the AddAlphaGrid UIGrid function to blend colors together from multiple grids
      • GetRed256

        public static int GetRed256​(int color)
        returns the Red component value of the color as an integer from 0 to 255
      • GetGreen256

        public static int GetGreen256​(int color)
        returns the Green component value of the color as an integer from 0 to 255
      • GetBlue256

        public static int GetBlue256​(int color)
        returns the Blue component value of the color as an integer from 0 to 255
      • GetAlpha256

        public static int GetAlpha256​(int color)
        returns the Alpha component value of the color as an integer from 0 to 255
      • GetRed

        public static double GetRed​(int color)
        returns the Red component value of the color as an integer from 0 to 1
      • GetGreen

        public static double GetGreen​(int color)
        returns the Green component value of the color as an integer from 0 to 1
      • GetBlue

        public static double GetBlue​(int color)
        returns the Blue component value of the color as an integer from 0 to 1
      • GetAlpha

        public static double GetAlpha​(int color)
        returns the Alpha component value of the color as an integer from 0 to 1
      • SetRed

        public static int SetRed​(int color,
                                 double r)
        returns a new color integer based on the input color but with the red component changed to the r argument
      • SetGreen

        public static int SetGreen​(int color,
                                   double g)
        returns a new color integer based on the input color but with the green component changed to the r argument
      • SetBlue

        public static int SetBlue​(int color,
                                  double b)
        returns a new color integer based on the input color but with the blue component changed to the r argument
      • SetAlpha

        public static int SetAlpha​(int color,
                                   double a)
        returns a new color integer based on the input color but with the alpha component changed to the r argument
      • SetRed256

        public static int SetRed256​(int color,
                                    int r)
        returns a new color integer based on the input color but with the red component changed to the r argument
      • SetGreen256

        public static int SetGreen256​(int color,
                                      int g)
        returns a new color integer based on the input color but with the green component changed to the r argument
      • SetBlue256

        public static int SetBlue256​(int color,
                                     int b)
        returns a new color integer based on the input color but with the blue component changed to the r argument
      • SetAlpha256

        public static int SetAlpha256​(int color,
                                      int a)
        returns a new color integer based on the input color but with the alpha component changed to the r argument
      • CategoricalColors

        public static int[] CategoricalColors​(int startIndex,
                                              int endIndex)
      • CategorialColor

        public static int CategorialColor​(int index)
        returns a color from the d3 category20 color set based on the index argument
      • HeatMapRGB

        public static int HeatMapRGB​(double val)
        returns a color int by mapping values from 0 to 1 with a heatmap with colors black, red, orange, yellow, white
      • HeatMapRBG

        public static int HeatMapRBG​(double val)
        returns a color int by mapping values from 0 to 1 with a heatmap with colors black, red, pink, magenta, white
      • HeatMapGRB

        public static int HeatMapGRB​(double val)
        returns a color int by mapping values from 0 to 1 with a heatmap with colors black, green, lime, yellow, white
      • HeatMapGBR

        public static int HeatMapGBR​(double val)
        returns a color int by mapping values from 0 to 1 with a heatmap with colors black, green, greenblue, cyan, white
      • HeatMapBRG

        public static int HeatMapBRG​(double val)
        returns a color int by mapping values from 0 to 1 with a heatmap with colors black, blue, purple, pink, white
      • HeatMapBGR

        public static int HeatMapBGR​(double val)
        returns a color int by mapping values from 0 to 1 with a heatmap with colors black, blue, light blue, cyan, white
      • HeatMapRGB

        public static int HeatMapRGB​(double val,
                                     double min,
                                     double max)
        returns a color int by mapping values from min to max with a heatmap with colors black, red, orange, yellow, white
      • HeatMapRBG

        public static int HeatMapRBG​(double val,
                                     double min,
                                     double max)
        returns a color int by mapping values from min to max with a heatmap with colors black, red, pink, magenta, white
      • HeatMapGRB

        public static int HeatMapGRB​(double val,
                                     double min,
                                     double max)
        returns a color int by mapping values from min to max with a heatmap with colors black, green, lime, yellow, white
      • HeatMapGBR

        public static int HeatMapGBR​(double val,
                                     double min,
                                     double max)
        returns a color int by mapping values from min to max with a heatmap with colors black, green, greenblue, cyan, white
      • HeatMapBRG

        public static int HeatMapBRG​(double val,
                                     double min,
                                     double max)
        returns a color int by mapping values from min to max with a heatmap with colors black, blue, purple, pink, white
      • HeatMapBGR

        public static int HeatMapBGR​(double val,
                                     double min,
                                     double max)
        returns a color int by mapping values from min to max with a heatmap with colors black, blue, light blue, cyan, white
      • HeatMapJet

        public static int HeatMapJet​(double val)
      • HeatMapJet

        public static int HeatMapJet​(double val,
                                     double min,
                                     double max)
      • ColorMap

        public static int ColorMap​(double val,
                                   int minColor,
                                   int maxColor)
        interpoloates value from 0 to 1 to between any pair of colors
      • ColorMap

        public static int ColorMap​(double val,
                                   double min,
                                   double max,
                                   int minColor,
                                   int maxColor)
        interpoloates value from min to max to between any pair of colors
      • ColorMap2D

        public static int ColorMap2D​(double valx,
                                     double valy,
                                     int bottomLeft,
                                     int bottomRight,
                                     int topLeft,
                                     int topRight)
        interpoloates coordinate pairs from 0 to 1 to between a box with any 4 corner colors
      • ColorString

        public static java.lang.String ColorString​(int color)
        returns the RGBA components of the color as a string
      • HSBColor

        public static int HSBColor​(double hue,
                                   double saturation,
                                   double brightness)
        generates a color int based on the HSB color space
      • ColorToHSB

        public static void ColorToHSB​(int color,
                                      float[] ret)
        puts the HSB components [hue, saturation, brightness] of the RGB color into the ret array
      • YCbCrColor

        public static int YCbCrColor​(double y,
                                     double cb,
                                     double cr)
        generates an RGB color from the YCbCr color space
      • CbCrPlaneColor

        public static int CbCrPlaneColor​(double x,
                                         double y)
        generates an RGB color from the CbCr plane with x,y coordinates assumed to be from 0 to 1
      • HsLuvColor

        public static int HsLuvColor​(double x,
                                     double y)
      • ArrayMax

        public static double ArrayMax​(double[] arr)
        gets the max value from an array
      • ArrayMax

        public static int ArrayMax​(int[] arr)
        gets the max value from an array
      • ArrayMin

        public static double ArrayMin​(double[] arr)
        gets the min value from an array
      • ArrayMin

        public static int ArrayMin​(int[] arr)
        gets the min value from an array
      • ArraySum

        public static double ArraySum​(double[] arr)
        sums the array
      • ArraySquaredSum

        public static double ArraySquaredSum​(double[] arr)
        sums the array
      • ArraySum

        public static int ArraySum​(int[] arr)
        sums the array
      • ArraySum

        public static long ArraySum​(long[] arr)
        sums the array
      • ArrayMean

        public static double ArrayMean​(double[] a)
        returns the mean value of the provided array
      • ArrayStdDev

        public static double ArrayStdDev​(double[] a)
        returns the standard deviation value of the provided array
      • ArrayMean

        public static double ArrayMean​(int[] a)
        returns the mean value of the provided array
      • ArrayStdDev

        public static double ArrayStdDev​(int[] a)
        returns the standard deviation value of the provided array
      • ArrayMean

        public static double ArrayMean​(long[] a)
        returns the mean value of the provided array
      • ArrayStdDev

        public static double ArrayStdDev​(long[] a)
        returns the standard deviation value of the provided array
      • ArrToString

        public static <T> java.lang.String ArrToString​(java.util.ArrayList<java.lang.String> arr,
                                                       java.lang.String delim)
        prints an array to a string, using the .toString function, and separating entries with the delim argument
      • ArrToString

        public static <T> java.lang.String ArrToString​(java.util.ArrayList<java.lang.String> arr,
                                                       java.lang.String delim,
                                                       int start,
                                                       int end)
        prints an array between start and end indices to a string, using the .toString function, and separating entries with the delim argument
      • ArrToString

        public static <T> java.lang.String ArrToString​(T[] arr,
                                                       java.lang.String delim)
        prints an array to a string, using the .toString function, and separating entries with the delim argument
      • ArrToString

        public static <T> java.lang.String ArrToString​(T[] arr,
                                                       java.lang.String delim,
                                                       int start,
                                                       int end)
        prints an array between start and end indices to a string, using the .toString function, and separating entries with the delim argument
      • ArrayListToArrayDouble

        public static double[] ArrayListToArrayDouble​(java.util.ArrayList<java.lang.Double> in)
      • ArrayListToArrayInt

        public static int[] ArrayListToArrayInt​(java.util.ArrayList<java.lang.Integer> in)
      • ArrayListToArrayObject

        public static <T> T[] ArrayListToArrayObject​(java.util.ArrayList<T> in)
      • ArrayListToArrayString

        public static java.lang.String[] ArrayListToArrayString​(java.util.ArrayList<java.lang.String> in)
      • InterpolateLinear

        public static double InterpolateLinear​(double x,
                                               double startX,
                                               double endX,
                                               double startY,
                                               double endY)
      • Interpolate

        public static double Interpolate​(double val,
                                         double min,
                                         double max)
        interpolates value from 0 to 1 to be between min and max
      • InterpolateNoBound

        public static double InterpolateNoBound​(double val,
                                                double min,
                                                double max)
      • Interpolate2D

        public static double Interpolate2D​(double x,
                                           double y,
                                           double bottomLeft,
                                           double bottomRight,
                                           double topLeft,
                                           double topRight)
        interpolates value from 0 to 1 to be between min and max
      • Interpolate2DNoBound

        public static double Interpolate2DNoBound​(double x,
                                                  double y,
                                                  double bottomLeft,
                                                  double bottomRight,
                                                  double topLeft,
                                                  double topRight)
      • GetBit

        public static boolean GetBit​(int v,
                                     int i)
        gets the value from a single bit of an int32
      • GetBit

        public static boolean GetBit​(long v,
                                     int i)
        gets the value from a single bit of an long64
      • FlipBit

        public static int FlipBit​(int v,
                                  int i)
        returns a version of the int v with the bit at index i flipped
      • FlipBit

        public static long FlipBit​(long v,
                                   int i)
        returns a version of the long v with the bit at index i flipped
      • SetBit

        public static int SetBit​(int v,
                                 int i,
                                 boolean val)
        returns a version of the int v with the bit at position i set to val
      • SetBit

        public static long SetBit​(long v,
                                  int i,
                                  boolean val)
        returns a version of the long v with the bit at position i set to val
      • ArrToString

        public static java.lang.String ArrToString​(double[] arr,
                                                   java.lang.String delim)
        prints an array using delim to separate the entries
      • ArrToString

        public static java.lang.String ArrToString​(double[] arr,
                                                   java.lang.String delim,
                                                   int start,
                                                   int end)
        prints an array using delim to separate the entries, beginning at index start and ending at index end
      • ArrToString

        public static java.lang.String ArrToString​(float[] arr,
                                                   java.lang.String delim)
        prints an array using delim to separate the entries
      • ArrToString

        public static java.lang.String ArrToString​(float[] arr,
                                                   java.lang.String delim,
                                                   int start,
                                                   int end)
        prints an array using delim to separate the entries, beginning at index start and ending at index end
      • ArrToString

        public static java.lang.String ArrToString​(int[] arr,
                                                   java.lang.String delim)
        prints an array using delim to separate the entries
      • ArrToString

        public static java.lang.String ArrToString​(int[] arr,
                                                   java.lang.String delim,
                                                   int start,
                                                   int end)
        prints an array using delim to separate the entries, beginning at index start and ending at index end
      • ArrToString

        public static java.lang.String ArrToString​(long[] arr,
                                                   java.lang.String delim)
        prints an array using delim to separate the entries
      • ArrToString

        public static java.lang.String ArrToString​(long[] arr,
                                                   java.lang.String delim,
                                                   int start,
                                                   int end)
        prints an array using delim to separate the entries, beginning at index start and ending at index end
      • ArrToString

        public static java.lang.String ArrToString​(java.lang.String[] arr,
                                                   java.lang.String delim,
                                                   int start,
                                                   int end)
        prints an array using delim to separate the entries, beginning at index start and ending at index end
      • ArrToString

        public static java.lang.String ArrToString​(java.lang.String[] arr,
                                                   java.lang.String delim)
        prints an array using delim to separate the entries
      • Concat

        public static <T> T[] Concat​(T[] first,
                                     T[] second)
        Returns a new array that is the first array with the second concatenated to the end of it
      • Append

        public static <T> T[] Append​(T[] arr,
                                     T appendMe)
        Returns a new array that is the first array with the appendMe object appended to the end of it
      • GenIndicesArray

        public static int[] GenIndicesArray​(int nEntries)
        returns an array of indices starting with 0 and ending with nEntries-1
      • VonNeumannHood

        public static int[] VonNeumannHood​(boolean includeOrigin)
        Returns the coordinates defining the Von Neumann neighborhood centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim...]
      • MooreHood

        public static int[] MooreHood​(boolean includeOrigin)
        Returns the coordinates defining the Moore neighborhood centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim,...]
      • HexHoodEvenY

        public static int[] HexHoodEvenY​(boolean includeOrigin)
        Returns the coordinates defining the Hexagonal neighborhood for even yDim coordinates centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim,...]
      • HexHoodOddY

        public static int[] HexHoodOddY​(boolean includeOrigin)
        Returns the coordinates defining the Hexagonal neighborhood for odd yDim coordinates centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim,...]
      • TriangleHoodSameParity

        public static int[] TriangleHoodSameParity​(boolean includeOrigin)
        Returns the coordinates defining the Triangular neighborhood for even xDim, even yDim or oddx, odd yDim. centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim,...]
      • TriangleHoodDifParity

        public static int[] TriangleHoodDifParity​(boolean includeOrigin)
        Returns the coordinates defining the Triangular neighborhood for even xDim, odd yDim or oddx, even yDim. centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim,...]
      • VonNeumannHood3D

        public static int[] VonNeumannHood3D​(boolean includeOrigin)
        Returns the coordinates defining the Von Neumann neighborhood centered on (0,0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0,0)
        Returns:
        coordinates returned as an array of the form [xDim,yDim,z,xDim,yDim,z,...]
      • MooreHood3D

        public static int[] MooreHood3D​(boolean includeOrigin)
      • AlongLineCoords

        public static int[] AlongLineCoords​(double x1,
                                            double y1,
                                            double x2,
                                            double y2)
        Returns a coordinates array of all squares along the line between (x1,y1) and (x2,y2)
      • AlongLineCoords

        public static int AlongLineCoords​(double x1,
                                          double y1,
                                          double x2,
                                          double y2,
                                          int[] returnCoords)
        puts into Coords all squares along the line between (x1,y1) and (x2,y2)
      • AlongLineAction

        public static void AlongLineAction​(double x1,
                                           double y1,
                                           double x2,
                                           double y2,
                                           Coords2DAction Action)
        executes the provided action function using as argument the coordinates of all squares along the line between (x1,y1) and (x2,y2)
      • CircleHood

        public static int[] CircleHood​(boolean includeOrigin,
                                       double radius)
        generates a neighborhood with the set of all coordinates in the circle with center 0,0 and the given radius.
      • RectangleHood

        public static int[] RectangleHood​(boolean includeOrigin,
                                          int radX,
                                          int radY)
        Returns the coordinates of all squares whose centers lie within a rectangle of the provided radius, centered on (0,0)
        Parameters:
        includeOrigin - defines whether to include the origin (0,0)
        radX - the radius of the rectangle in the xDim direction
        radY - the radius of the rectangle in the yDim direction
        Returns:
        coordinates returned as an array of the form [xDim,yDim,xDim,yDim,...]
      • GenHood1D

        public static int[] GenHood1D​(int[] coords)
        generates a 1D neighborhood from a set of coordinates, with space for the results of mapping
      • GenHood2D

        public static int[] GenHood2D​(int[] coords)
        generates a 2D neighborhood from a set of coordinates, with space for the results of mapping
      • GenHood3D

        public static int[] GenHood3D​(int[] coords)
        generates a 3D neighborhood from a set of coordinates, with space for the results of mapping
      • Log2

        public static long Log2​(long n)
      • Log2

        public static int Log2​(int n)
      • Factorial

        public static long Factorial​(long n)
        Factorial of a positive integer, uses FactorialSplit
        Parameters:
        n - 0 or a natural number
        Returns:
        Factorial of toFact. Factorial(0) is 1 possibly refactor with lround(exp(lgamma(n+1)))
      • NchooseK

        public static long NchooseK​(long n,
                                    long k)
      • BinomialDistPDF

        public static double BinomialDistPDF​(long n,
                                             double p,
                                             long k)
      • PoissonProb

        public static double PoissonProb​(int sampleSize,
                                         double avg)
        Samples a Poisson distribution
        Parameters:
        sampleSize - How many times the event happens
        avg - The average number of times the event happens
        Returns:
        the probability of toSamp many events
      • GaussianPDF

        public static double GaussianPDF​(double pos)
      • GaussianPDF

        public static double GaussianPDF​(double mean,
                                         double std,
                                         double pos)
      • Sigmoid

        public static double Sigmoid​(double val,
                                     double stretch,
                                     double inflectionX,
                                     double minCap,
                                     double maxCap)
        transforms val with a sigmoid curve with the given properties
        Parameters:
        val - the input value
        stretch - linearly scales the sigmoid curve in the x dimension, the default is 1
        inflectionX - the point at which the slope changes sign
        minCap - the minimum return value of the sigmoid function
        maxCap - the maximum return value of the sigmoid function
      • Sigmoid

        public static double Sigmoid​(double val,
                                     double stretch)
        transforms val with a sigmoid curve with a minCap of 0, a maxCap of 1, and an inflectionX value of 0
        Parameters:
        val - the input value
        stretch - linearly scales the sigmoid curve in the x dimension, the default is 1
      • SumTo1

        public static double SumTo1​(double[] vals)
        sets the values in the array such that they sum to 1
      • SumTo1

        public static double SumTo1​(double[] vals,
                                    int start,
                                    int end)
        sets the values in the array such that they sum to 1, using only the numbers between start and end
      • MakeDirs

        public static boolean MakeDirs​(java.lang.String path)
        creates directories to ensure that the path argument exists
      • IsPath

        public static boolean IsPath​(java.lang.String path)
      • MichaelisMenten

        public static double MichaelisMenten​(double conc,
                                             double maxRate,
                                             double halfRateConc)
        uses the Michaelis Menten equation to compute the reaction rate for a given substrate concentration
        Parameters:
        conc - concentration of the reaction limiting substrate
        maxRate - reaction rate given maximum concentration
        halfRateConc - substrate concentration at which the reaction rate is 1/2 the maximum
        Returns:
        the reaction rate at the given substrate concentration
      • HillEqn

        public static double HillEqn​(double conc,
                                     double dissociationRate,
                                     double hillCoef)
      • Dist

        public static double Dist​(double x1,
                                  double y1,
                                  double x2,
                                  double y2)
        gets the euclidean distance between (x1,y1) and (x2,y2)
      • Dist

        public static double Dist​(double x1,
                                  double y1,
                                  double x2,
                                  double y2,
                                  double xDim,
                                  double yDim,
                                  boolean wrapX,
                                  boolean wrapY)
        gets the euclidean distance between (x1,y1) and (x2,y2), assuming boundaries 0,xDim and 0,yDim, and wraparound as given in the arguments
      • Dist

        public static double Dist​(double x1,
                                  double y1,
                                  double z1,
                                  double x2,
                                  double y2,
                                  double z2)
        gets the euclidean distance between (x1,y1,z1) and (x2,y2,z2)
      • Dist

        public static double Dist​(double x1,
                                  double y1,
                                  double z1,
                                  double x2,
                                  double y2,
                                  double z2,
                                  int xDim,
                                  int yDim,
                                  int zDim,
                                  boolean wrapX,
                                  boolean wrapY,
                                  boolean wrapZ)
        gets the euclidean distance between (x1,y1,z1) and (x2,y2,z2), assuming boundaries (0,xDim),(0,yDim), and (0,zDim) and wraparound as given in the arguments
      • DistSquared

        public static double DistSquared​(double x1,
                                         double y1,
                                         double x2,
                                         double y2)
        similar to dist above, but returns the distance squared
      • DistSquared

        public static double DistSquared​(double x1,
                                         double y1,
                                         double x2,
                                         double y2,
                                         double xDim,
                                         double yDim,
                                         boolean wrapX,
                                         boolean wrapY)
        similar to dist above, but returns the distance squared
      • DistSquared

        public static double DistSquared​(double x1,
                                         double y1,
                                         double z1,
                                         double x2,
                                         double y2,
                                         double z2)
        similar to dist above, but returns the distance squared
      • DistSquared

        public static double DistSquared​(double x1,
                                         double y1,
                                         double z1,
                                         double x2,
                                         double y2,
                                         double z2,
                                         int xDim,
                                         int yDim,
                                         int zDim,
                                         boolean wrapX,
                                         boolean wrapY,
                                         boolean wrapZ)
        similar to dist above, but returns the distance squared
      • DistSquared

        public static double DistSquared​(double[] p1,
                                         double[] p2)
        returns the distance squared between the two position provided in any number of dimensions
        Parameters:
        p1 - the coordinates of the first position
        p2 - the coordinates of the second position
        Returns:
        the distance squared between the first and second position
      • Norm

        public static double Norm​(double v1,
                                  double v2)
        returns the norm or "length" of the vector (v1,v2)
      • Norm

        public static double Norm​(double v1,
                                  double v2,
                                  double v3)
        returns the norm or "length" of the vector (v1,v2,v3)
      • Norm

        public static double Norm​(double v1,
                                  double v2,
                                  double v3,
                                  double v4)
        returns the norm or "length" of the vector (v1,v2,v3,v4)
      • Norm

        public static double Norm​(double[] vals)
        returns the norm or "length" of the vector array
      • Normalize

        public static void Normalize​(double[] vals)
        normalizes the vector array in place so that its norm is 1
      • NormSquared

        public static double NormSquared​(double v1,
                                         double v2)
        returns the norm or "length" of the vector (v1,v2) squared
      • NormSquared

        public static double NormSquared​(double v1,
                                         double v2,
                                         double v3)
        returns the norm or "length" of the vector (v1,v2,v3) squared
      • NormSquared

        public static double NormSquared​(double v1,
                                         double v2,
                                         double v3,
                                         double v4)
        returns the norm or "length" of the vector (v1,v2,v3,v4) squared
      • NormSquared

        public static double NormSquared​(double[] vals)
        returns the norm or "length" of the vector array squared
      • InfiniteLinesIntersection2D

        public static boolean InfiniteLinesIntersection2D​(double x1,
                                                          double y1,
                                                          double x2,
                                                          double y2,
                                                          double x3,
                                                          double y3,
                                                          double x4,
                                                          double y4,
                                                          double[] retCoords)
        gets the point at which the line from (x1,y1) to (x2,y2) intersects with the line from (x3,y3) and (x4,y4) and puts the coordinates in retCoords. returns whether the lines intersect
      • GenCirclePoints

        public static float[] GenCirclePoints​(float rad,
                                              int nCorners)
        returns the evenly spaced coordinates along the edge of a circle in 2D, centered on (0,0)
      • DispWrap

        public static double DispWrap​(double p1,
                                      double p2,
                                      double dim)
        computes the minimum distance between p1 and p2, using wraparound if it is shorter
        Parameters:
        p1 -
        p2 -
        dim -
        Returns:
      • Bound

        public static double Bound​(double val,
                                   double min,
                                   double max)
        returns the original value bounded by min and max inclusive
      • Bound

        public static long Bound​(long val,
                                 long min,
                                 long max)
        returns the original value bounded by min and max inclusive
      • Bound

        public static int Bound​(int val,
                                int min,
                                int max)
        returns the original value bounded by min and max inclusive
      • Bound

        public static float Bound​(float val,
                                  double min,
                                  double max)
        returns the original value bounded by min and max inclusive
      • ScaleMinToMax

        public static double ScaleMinToMax​(double val,
                                           double min,
                                           double max)
        interpolates value from 0 to 1 to be between min and max
      • Scale0to1

        public static double Scale0to1​(double val,
                                       double min,
                                       double max)
        returns where the value is from min to max as a number from 0 to 1
      • Rescale

        public static double Rescale​(double val,
                                     double oldMin,
                                     double oldMax,
                                     double newMin,
                                     double newMax)
        rescales the value from being between oldMin and oldMax to being between newMin and newMax
      • Wrap

        public static int Wrap​(int val,
                               int max)
        returns value with wraparound between 0 and max
      • Wrap

        public static double Wrap​(double val,
                                  double max)
        returns value with wraparound between 0 and max
      • ProtonsToPh

        public static double ProtonsToPh​(double protonConc)
        converts proton concentration to pH
      • PhToProtons

        public static double PhToProtons​(double ph)
        converts pH to proton concentration
      • ProbScale

        public static double ProbScale​(double prob,
                                       double duration)
        adjusts probability that an event will occur in 1 unit of time to the probability that the event will occur at least once over the duration
        Parameters:
        prob - probability that an event occurs in 1 unit of time
        duration - duration in units of time over which event may occur
        Returns:
        the probability that the event will occur at least once over the duration
      • TimeStamp

        public static java.lang.String TimeStamp()
        returns a timestamp of the form "yyyy_MM_dd_HH_mm_ss" as a string
      • PWD

        public static java.lang.String PWD()
        gets the current working directory as a string
      • MemoryUsageStr

        public static java.lang.String MemoryUsageStr()
        gets information about the memory usage and max memory allocated for the program
      • MemoryUsageInfo

        public static void MemoryUsageInfo​(long[] ret)
      • QuickSort

        public static <T extends Sortable> void QuickSort​(T sortMe,
                                                          boolean greatestToLeast)
        Runs quicksort on an object that implements Sortable
        Parameters:
        sortMe - the object to be sorted
        greatestToLeast - if true, sorting will be form greatest to least, otherwise will be least to greatest
      • InDim

        public static boolean InDim​(int Val,
                                    int Dim)
        returns whether the input value is between 0 and the dimension value
      • InDim

        public static boolean InDim​(double Val,
                                    double Dim)
        returns whether the input value is between 0 and the dimension value
      • SubsetIndices

        public static int SubsetIndices​(int[] hood,
                                        int lenToCheck,
                                        IndexBool EvalFun)
        subsets a set of indices such that all indices evaluate to true under the EvalFun
        Parameters:
        hood - a neighborhood or set of indices
        lenToCheck - the number of indices to subset
        EvalFun - function should return true for all indices to keep
      • CircleOverlapArea

        public static double CircleOverlapArea​(double radii,
                                               double centerDist)
        finds the area of overlap between 2 circles of equal radii
      • CircleOverlapArea

        public static double CircleOverlapArea​(double r1,
                                               double r2,
                                               double centerDist)
      • MultiThread

        public static void MultiThread​(int nRuns,
                                       int nThreads,
                                       ParallelFunction RunFun)
        Creates a thread pool and launches a total of nRun threads, with nThreads running simultaneously at a time. the RunFun that is passed in must be a void function that takes an integer argument. when the function is called, this integer will be the index of that particular run in the lineup. This can be used to assign the result of many runs to a single array, for example, if the array is written to once by each RunFun at its run index. If you want to run many simulations simultaneously, this function is for you.
      • MultiThread

        public static void MultiThread​(int nRuns,
                                       ParallelFunction RunFun)
        does the same thing as MultiThread above, but generates a number of threads equal to the number of available processors
        Parameters:
        nRuns -
        RunFun -
      • SaveState

        public static byte[] SaveState​(SerializableModel model)
        Saves a model state to a byte array and returns it. The model must implement the SerializableModel interface
      • AwaitInput

        public static java.lang.String AwaitInput()
      • SaveState

        public static void SaveState​(SerializableModel model,
                                     java.lang.String stateFileName)
        Saves a model state to a file with the name specified. creates a new file or overwrites one if the file already exists. The model must implement the SerializableModel interface
      • LoadState

        public static <T extends SerializableModel> T LoadState​(java.lang.String stateBytesFile)
        Loads a model from a file created with SaveState. The model must implement the SerializableModel interface
      • LoadState

        public static <T extends SerializableModel> T LoadState​(byte[] state)
        Loads a model form a byte array created with SaveState. The model must implement the SerializableModel interface
      • IsMethodOverridden

        public static boolean IsMethodOverridden​(java.lang.Class derived,
                                                 java.lang.Class base,
                                                 java.lang.String methodName)
      • IsMethodOverridden

        public static <T,​O extends T> boolean IsMethodOverridden​(java.lang.Class<O> derived,
                                                                       java.lang.String methodName)
      • MatVecMul

        public static double[] MatVecMul​(double[] mat,
                                         double[] vec,
                                         double[] out)
      • MatrixToCSV

        public static void MatrixToCSV​(double[][] mat,
                                       java.lang.String filePath)
      • MatrixToCSV

        public static void MatrixToCSV​(long[][] mat,
                                       java.lang.String filePath)
      • MatrixToCSV

        public static void MatrixToCSV​(int[][] mat,
                                       java.lang.String filePath)
      • Py4jDoublesOut

        public static byte[] Py4jDoublesOut​(double[] doubles)
      • Py4jDoublesOut

        public static byte[] Py4jDoublesOut​(double[][] doubles)
      • Py4jDoublesOut

        public static byte[] Py4jDoublesOut​(java.util.ArrayList<double[]> doubles)
      • Py4jDoublesInAsArrayList

        public static java.util.ArrayList<double[]> Py4jDoublesInAsArrayList​(byte[] in,
                                                                             int nRows)
      • Py4jDoublesIn

        public static double[][] Py4jDoublesIn​(byte[] in,
                                               int nRows)
      • Py4jDoublesIn

        public static double[] Py4jDoublesIn​(byte[] in)