Documentation of 'smile.math.Array2D' Java class
Array2D
smile.math

Class Array2D



  • public class Array2D
    extends java.lang.Object
    2-dimensional array of doubles. Java doesn't have real multidimensional arrays. They are just array of arrays, which are not friendly to modern CPU due to frequent cache miss. The extra (multiple times) array index checking also significantly reduces the performance. This class solves these pain points by storing data in a single 1D array of doubles in row major order. Note that this class is simple by design, as a replacement of double[][] in case of row by row access. For advanced matrix computation, please use Matrix.
    See Also:
    Matrix
    • Constructor Detail

      • Array2D

        public Array2D(double[][] A)
        Constructor.
        Parameters:
        A - the array of matrix.
      • Array2D

        public Array2D(int rows,
                       int cols)
        Constructor of all-zero matrix.
      • Array2D

        public Array2D(int rows,
                       int cols,
                       double value)
        Constructor. Fill the matrix with given value.
      • Array2D

        public Array2D(int rows,
                       int cols,
                       double[] value)
        Constructor.
        Parameters:
        value - the array of matrix values arranged in row major format
    • Method Detail

      • nrows

        public int nrows()
      • ncols

        public int ncols()
      • apply

        public double apply(int i,
                            int j)
        Returns A(i, j). Useful in Scala.
      • get

        public double get(int i,
                          int j)
        Returns A(i, j).
      • set

        public double set(int i,
                          int j,
                          double x)
        Sets A(i, j).
      • add

        public double add(int i,
                          int j,
                          double x)
      • sub

        public double sub(int i,
                          int j,
                          double x)
      • mul

        public double mul(int i,
                          int j,
                          double x)
      • div

        public double div(int i,
                          int j,
                          double x)
      • add

        public Array2D add(double x)
      • sub

        public Array2D sub(double x)
      • mul

        public Array2D mul(double x)
      • div

        public Array2D div(double x)
      • replaceNaN

        public Array2D replaceNaN(double x)
      • sum

        public double sum()

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.