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    import org.apache.commons.math.FieldElement;
021    
022    /**
023     * An interface to classes that implement an algorithm to calculate the
024     * LU-decomposition of a real matrix.
025     * <p>The LU-decomposition of matrix A is a set of three matrices: P, L and U
026     * such that P&times;A = L&times;U. P is a rows permutation matrix that is used
027     * to rearrange the rows of A before so that it can be decomposed. L is a lower
028     * triangular matrix with unit diagonal terms and U is an upper triangular matrix.</p>
029     * <p>This interface is based on the class with similar name from the
030     * <a href="http://math.nist.gov/javanumerics/jama/">JAMA</a> library.</p>
031     * <ul>
032     *   <li>a {@link #getP() getP} method has been added,</li>
033     *   <li>the <code>det</code> method has been renamed as {@link #getDeterminant()
034     *   getDeterminant},</li>
035     *   <li>the <code>getDoublePivot</code> method has been removed (but the int based
036     *   {@link #getPivot() getPivot} method has been kept),</li>
037     *   <li>the <code>solve</code> and <code>isNonSingular</code> methods have been replaced
038     *   by a {@link #getSolver() getSolver} method and the equivalent methods provided by
039     *   the returned {@link DecompositionSolver}.</li>
040     * </ul>
041     *
042     * @param <T> the type of the field elements
043     * @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
044     * @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
045     * @version $Revision: 826627 $ $Date: 2009-10-19 12:27:47 +0200 (lun. 19 oct. 2009) $
046     * @since 2.0
047     */
048    public interface FieldLUDecomposition<T extends FieldElement<T>> {
049    
050        /**
051         * Returns the matrix L of the decomposition.
052         * <p>L is an lower-triangular matrix</p>
053         * @return the L matrix (or null if decomposed matrix is singular)
054         */
055        FieldMatrix<T> getL();
056    
057        /**
058         * Returns the matrix U of the decomposition.
059         * <p>U is an upper-triangular matrix</p>
060         * @return the U matrix (or null if decomposed matrix is singular)
061         */
062        FieldMatrix<T> getU();
063    
064        /**
065         * Returns the P rows permutation matrix.
066         * <p>P is a sparse matrix with exactly one element set to 1.0 in
067         * each row and each column, all other elements being set to 0.0.</p>
068         * <p>The positions of the 1 elements are given by the {@link #getPivot()
069         * pivot permutation vector}.</p>
070         * @return the P rows permutation matrix (or null if decomposed matrix is singular)
071         * @see #getPivot()
072         */
073        FieldMatrix<T> getP();
074    
075        /**
076         * Returns the pivot permutation vector.
077         * @return the pivot permutation vector
078         * @see #getP()
079         */
080        int[] getPivot();
081    
082        /**
083         * Return the determinant of the matrix
084         * @return determinant of the matrix
085         */
086        T getDeterminant();
087    
088        /**
089         * Get a solver for finding the A &times; X = B solution in exact linear sense.
090         * @return a solver
091         */
092        FieldDecompositionSolver<T> getSolver();
093    
094    }