    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one or more
    003     * contributor license agreements.  See the NOTICE file distributed with
    004     * this work for additional information regarding copyright ownership.
    005     * The ASF licenses this file to You under the Apache License, Version 2.0
    006     * (the "License"); you may not use this file except in compliance with
    007     * the License.  You may obtain a copy of the License at
    008     *
    009     *      http://www.apache.org/licenses/LICENSE-2.0
    010     *
    011     * Unless required by applicable law or agreed to in writing, software
    012     * distributed under the License is distributed on an "AS IS" BASIS,
    013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014     * See the License for the specific language governing permissions and
    015     * limitations under the License.
    016     */
    017
    018    package org.apache.commons.math.linear;
    019
    020
    021    /**
    022     * An interface to classes that implement an algorithm to calculate the
    023     * LU-decomposition of a real matrix.
    024     * <p>The LU-decomposition of matrix A is a set of three matrices: P, L and U
    025     * such that P&times;A = L&times;U. P is a rows permutation matrix that is used
    026     * to rearrange the rows of A before so that it can be decomposed. L is a lower
    027     * triangular matrix with unit diagonal terms and U is an upper triangular matrix.</p>
    028     * <p>This interface is based on the class with similar name from the
    029     * <a href="http://math.nist.gov/javanumerics/jama/">JAMA</a> library.</p>
    030     * <ul>
    031     *   <li>a {@link #getP() getP} method has been added,</li>
    032     *   <li>the <code>det</code> method has been renamed as {@link #getDeterminant()
    033     *   getDeterminant},</li>
    034     *   <li>the <code>getDoublePivot</code> method has been removed (but the int based
    035     *   {@link #getPivot() getPivot} method has been kept),</li>
    036     *   <li>the <code>solve</code> and <code>isNonSingular</code> methods have been replaced
    037     *   by a {@link #getSolver() getSolver} method and the equivalent methods provided by
    038     *   the returned {@link DecompositionSolver}.</li>
    039     * </ul>
    040     *
    041     * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
    042     * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
    043     * @version $Revision: 826627 $ $Date: 2009-10-19 12:27:47 +0200 (lun. 19 oct. 2009) $
    044     * @since 2.0
    045     */
    046    public interface LUDecomposition {
    047
    048        /**
    049         * Returns the matrix L of the decomposition.
    050         * <p>L is an lower-triangular matrix</p>
    051         * @return the L matrix (or null if decomposed matrix is singular)
    052         */
    053        RealMatrix getL();
    054
    055        /**
    056         * Returns the matrix U of the decomposition.
    057         * <p>U is an upper-triangular matrix</p>
    058         * @return the U matrix (or null if decomposed matrix is singular)
    059         */
    060        RealMatrix getU();
    061
    062        /**
    063         * Returns the P rows permutation matrix.
    064         * <p>P is a sparse matrix with exactly one element set to 1.0 in
    065         * each row and each column, all other elements being set to 0.0.</p>
    066         * <p>The positions of the 1 elements are given by the {@link #getPivot()
    067         * pivot permutation vector}.</p>
    068         * @return the P rows permutation matrix (or null if decomposed matrix is singular)
    069         * @see #getPivot()
    070         */
    071        RealMatrix getP();
    072
    073        /**
    074         * Returns the pivot permutation vector.
    075         * @return the pivot permutation vector
    076         * @see #getP()
    077         */
    078        int[] getPivot();
    079
    080        /**
    081         * Return the determinant of the matrix
    082         * @return determinant of the matrix
    083         */
    084        double getDeterminant();
    085
    086        /**
    087         * Get a solver for finding the A &times; X = B solution in exact linear sense.
    088         * @return a solver
    089         */
    090        DecompositionSolver getSolver();
    091
    092    }