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
18package org.apache.commons.math.linear;
19
20
21/**
22 * An interface to classes that implement an algorithm to calculate the
23 * LU-decomposition of a real matrix.
24 * <p>The LU-decomposition of matrix A is a set of three matrices: P, L and U
25 * such that P&times;A = L&times;U. P is a rows permutation matrix that is used
26 * to rearrange the rows of A before so that it can be decomposed. L is a lower
27 * triangular matrix with unit diagonal terms and U is an upper triangular matrix.</p>
28 * <p>This interface is based on the class with similar name from the
29 * <a href="http://math.nist.gov/javanumerics/jama/">JAMA</a> library.</p>
30 * <ul>
31 *   <li>a {@link #getP() getP} method has been added,</li>
32 *   <li>the <code>det</code> method has been renamed as {@link #getDeterminant()
33 *   getDeterminant},</li>
34 *   <li>the <code>getDoublePivot</code> method has been removed (but the int based
35 *   {@link #getPivot() getPivot} method has been kept),</li>
36 *   <li>the <code>solve</code> and <code>isNonSingular</code> methods have been replaced
37 *   by a {@link #getSolver() getSolver} method and the equivalent methods provided by
38 *   the returned {@link DecompositionSolver}.</li>
39 * </ul>
40 *
41 * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
42 * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
43 * @version $Revision: 826627 $ $Date: 2009-10-19 12:27:47 +0200 (lun. 19 oct. 2009) $
44 * @since 2.0
45 */
46public interface LUDecomposition {
47
48    /**
49     * Returns the matrix L of the decomposition.
50     * <p>L is an lower-triangular matrix</p>
51     * @return the L matrix (or null if decomposed matrix is singular)
52     */
53    RealMatrix getL();
54
55    /**
56     * Returns the matrix U of the decomposition.
57     * <p>U is an upper-triangular matrix</p>
58     * @return the U matrix (or null if decomposed matrix is singular)
59     */
60    RealMatrix getU();
61
62    /**
63     * Returns the P rows permutation matrix.
64     * <p>P is a sparse matrix with exactly one element set to 1.0 in
65     * each row and each column, all other elements being set to 0.0.</p>
66     * <p>The positions of the 1 elements are given by the {@link #getPivot()
67     * pivot permutation vector}.</p>
68     * @return the P rows permutation matrix (or null if decomposed matrix is singular)
69     * @see #getPivot()
70     */
71    RealMatrix getP();
72
73    /**
74     * Returns the pivot permutation vector.
75     * @return the pivot permutation vector
76     * @see #getP()
77     */
78    int[] getPivot();
79
80    /**
81     * Return the determinant of the matrix
82     * @return determinant of the matrix
83     */
84    double getDeterminant();
85
86    /**
87     * Get a solver for finding the A &times; X = B solution in exact linear sense.
88     * @return a solver
89     */
90    DecompositionSolver getSolver();
91
92}
93