Module ojalgo

Class Equation

    • Field Detail

      • index

        public final int index
        The row index of the original body matrix, [A].
      • myBody

        private final BasicArray<?> myBody
        The (nonzero) elements of this equation/row
      • myPivot

        private double myPivot
      • myRHS

        private double myRHS
    • Constructor Detail

      • Equation

        Equation​(BasicArray<?> body,
                 int pivot,
                 double rhs)
    • Method Detail

      • dense

        public static Equation dense​(int pivot,
                                     int cols)
      • dense

        public static <N extends java.lang.Comparable<N>> Equation dense​(int pivot,
                                                                         int cols,
                                                                         DenseArray.Factory<N,​?> factory)
      • denseSystem

        public static java.util.List<Equation> denseSystem​(int rows,
                                                           int cols)
      • denseSystem

        public static <N extends java.lang.Comparable<N>> java.util.List<Equation> denseSystem​(int rows,
                                                                                               int cols,
                                                                                               DenseArray.Factory<N,​?> factory)
      • of

        public static Equation of​(double rhs,
                                  int pivot,
                                  double... body)
      • sparse

        public static Equation sparse​(int pivot,
                                      int cols)
      • sparse

        public static Equation sparse​(int pivot,
                                      int cols,
                                      int numberOfNonzeros)
      • sparse

        public static <N extends java.lang.Comparable<N>> Equation sparse​(int pivot,
                                                                          int cols,
                                                                          PlainArray.Factory<N,​?> factory)
      • sparse

        public static <N extends java.lang.Comparable<N>> Equation sparse​(int pivot,
                                                                          int cols,
                                                                          PlainArray.Factory<N,​?> factory,
                                                                          int numberOfNonzeros)
      • sparseSystem

        public static java.util.List<Equation> sparseSystem​(int rows,
                                                            int cols)
      • sparseSystem

        public static java.util.List<Equation> sparseSystem​(int rows,
                                                            int cols,
                                                            int numberOfNonzeros)
      • sparseSystem

        public static <N extends java.lang.Comparable<N>> java.util.List<Equation> sparseSystem​(int rows,
                                                                                                int cols,
                                                                                                PlainArray.Factory<N,​?> factory)
      • sparseSystem

        public static <N extends java.lang.Comparable<N>> java.util.List<Equation> sparseSystem​(int rows,
                                                                                                int cols,
                                                                                                PlainArray.Factory<N,​?> factory,
                                                                                                int numberOfNonzeros)
      • add

        public void add​(int ind,
                        double addend)
        Specified by:
        add in interface Mutate1D.Modifiable<java.lang.Double>
      • add

        public void add​(long ind,
                        java.lang.Comparable<?> addend)
        Specified by:
        add in interface Mutate1D.Modifiable<java.lang.Double>
      • adjust

        public <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> double adjust​(T x,
                                                                                                            double relaxation)
        Will perform a (relaxed) GaussSeidel update.

        This call will not work if the pivot (the element at index) is zero!

        Parameters:
        x - The current solution (one element will be updated)
        relaxation - Typically 1.0 but could be anything (Most likely should be between 0.0 and 2.0).
        Returns:
        The error in this equation
      • compareTo

        public int compareTo​(Equation other)
        Specified by:
        compareTo in interface java.lang.Comparable<Equation>
      • count

        public long count()
        Description copied from interface: Structure1D
        The total number of elements in this structure.

        You only need to implement this method if the structure can contain more than Integer.MAX_VALUE elements.

        Specified by:
        count in interface Structure1D
      • dot

        public double dot​(Access1D<?> vector)
        Description copied from interface: Access1D
        Will calculate and return the dot product of this 1D-structure and another input 1D-vector.
        Specified by:
        dot in interface Access1D<java.lang.Double>
        Parameters:
        vector - Another 1D-structure
        Returns:
        The dot product
      • dotLower

        public double dotLower​(Access1D<?> x)
        Efficiently compute sum_{j < pivot} a_{ij} * x_j (excludes the pivot). Uses direct sparse iteration when available to avoid O(n) random access scans.
      • dotUpper

        public double dotUpper​(Access1D<?> x)
        Efficiently compute sum_{j > pivot} a_{ij} * x_j (excludes the pivot). Uses direct sparse iteration when available to avoid O(n) random access scans.
      • doubleValue

        public double doubleValue​(int ind)
        Specified by:
        doubleValue in interface Access1D<java.lang.Double>
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • get

        public java.lang.Double get​(long ind)
        Specified by:
        get in interface Access1D<java.lang.Double>
      • getCoefficients

        public double[] getCoefficients()
      • getPivot

        public double getPivot()
        Returns:
        The element at index
      • getRHS

        public double getRHS()
        Returns:
        The equation RHS
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • initialise

        public <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> void initialise​(T x)
        Initialises the solution vector's element at index to the value that would solve this equation if the RHS was zero and all other elements in the solution vector unchanged.
        Type Parameters:
        T - The solution vector type
        Parameters:
        x - The solution vector to be initialised
      • set

        public void set​(long ind,
                        java.lang.Comparable<?> value)
      • set

        public void set​(long ind,
                        double value)
      • setRHS

        public void setRHS​(double rhs)
      • size

        public int size()
        Description copied from interface: Structure1D
        The total number of elements in this structure.
        Specified by:
        size in interface Structure1D
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • calculate

        private <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> double calculate​(T x,
                                                                                                                double rhs,
                                                                                                                double relaxation)