View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.math.linear;
19  
20  import org.apache.commons.math.FieldElement;
21  
22  /**
23   * An interface to classes that implement an algorithm to calculate the 
24   * LU-decomposition of a real matrix.
25   * <p>The LU-decomposition of matrix A is a set of three matrices: P, L and U
26   * such that P&times;A = L&times;U. P is a rows permutation matrix that is used
27   * to rearrange the rows of A before so that it can be decomposed. L is a lower
28   * triangular matrix with unit diagonal terms and U is an upper triangular matrix.</p>
29   * <p>This interface is based on the class with similar name from the now defunct
30   * <a href="http://math.nist.gov/javanumerics/jama/">JAMA</a> library.</p>
31   * <ul>
32   *   <li>a {@link #getP() getP} method has been added,</li>
33   *   <li>the <code>det</code> method has been renamed as {@link #getDeterminant()
34   *   getDeterminant},</li>
35   *   <li>the <code>getDoublePivot</code> method has been removed (but the int based
36   *   {@link #getPivot() getPivot} method has been kept),</li>
37   *   <li>the <code>solve</code> and <code>isNonSingular</code> methods have been replaced
38   *   by a {@link #getSolver() getSolver} method and the equivalent methods provided by
39   *   the returned {@link DecompositionSolver}.</li>
40   * </ul>
41   *   
42   * @param <T> the type of the field elements
43   * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
44   * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
45   * @version $Revision: 781122 $ $Date: 2009-06-02 14:53:23 -0400 (Tue, 02 Jun 2009) $
46   * @since 2.0
47   */
48  public interface FieldLUDecomposition<T extends FieldElement<T>> {
49  
50      /**
51       * Returns the matrix L of the decomposition. 
52       * <p>L is an lower-triangular matrix</p>
53       * @return the L matrix (or null if decomposed matrix is singular)
54       */
55      FieldMatrix<T> getL();
56  
57      /**
58       * Returns the matrix U of the decomposition. 
59       * <p>U is an upper-triangular matrix</p>
60       * @return the U matrix (or null if decomposed matrix is singular)
61       */
62      FieldMatrix<T> getU();
63  
64      /**
65       * Returns the P rows permutation matrix.
66       * <p>P is a sparse matrix with exactly one element set to 1.0 in
67       * each row and each column, all other elements being set to 0.0.</p>
68       * <p>The positions of the 1 elements are given by the {@link #getPivot()
69       * pivot permutation vector}.</p>
70       * @return the P rows permutation matrix (or null if decomposed matrix is singular)
71       * @see #getPivot()
72       */
73      FieldMatrix<T> getP();
74  
75      /**
76       * Returns the pivot permutation vector.
77       * @return the pivot permutation vector
78       * @see #getP()
79       */
80      int[] getPivot();
81  
82      /**
83       * Return the determinant of the matrix
84       * @return determinant of the matrix
85       */
86      T getDeterminant();
87  
88      /**
89       * Get a solver for finding the A &times; X = B solution in exact linear sense.
90       * @return a solver
91       */
92      FieldDecompositionSolver<T> getSolver();
93  
94  }