Class ConjugateGradientEx1

java.lang.Object
com.imsl.test.example.math.ConjugateGradientEx1
All Implemented Interfaces:
ConjugateGradient.Function

public class ConjugateGradientEx1 extends Object implements ConjugateGradient.Function

Solves a positive definite linear system using the conjugate gradient method.

The solution to a positive definite linear system is found. The coefficient matrix is stored as a full matrix. The system is \(Ax = b\) where $$ A=\begin{bmatrix} 1.0 & -3.0 & 2.0 \\ -3.0 & 10.0 & -5.0 \\ 2.0 & -5.0 & 6.0 \end{bmatrix} $$

and \( b = (27.0, -78.0, 64.0)^T\)

See Also:
  • Constructor Details

    • ConjugateGradientEx1

      public ConjugateGradientEx1()
  • Method Details

    • amultp

      public void amultp(double[] p, double[] z)
      Description copied from interface: ConjugateGradient.Function
      A user-supplied function which computes z=Ap.
      Specified by:
      amultp in interface ConjugateGradient.Function
      Parameters:
      p - an input double vector of length dimension of A.
      z - an output double vector containing the matrix-vector product Ap.
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception