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 018package org.apache.commons.math3.linear; 019 020import org.apache.commons.math3.FieldElement; 021 022 023/** 024 * Interface handling decomposition algorithms that can solve A × X = B. 025 * <p>Decomposition algorithms decompose an A matrix has a product of several specific 026 * matrices from which they can solve A × X = B in least squares sense: they find X 027 * such that ||A × X - B|| is minimal.</p> 028 * <p>Some solvers like {@link FieldLUDecomposition} can only find the solution for 029 * square matrices and when the solution is an exact linear solution, i.e. when 030 * ||A × X - B|| is exactly 0. Other solvers can also find solutions 031 * with non-square matrix A and with non-null minimal norm. If an exact linear 032 * solution exists it is also the minimal norm solution.</p> 033 * 034 * @param <T> the type of the field elements 035 * @since 2.0 036 */ 037public interface FieldDecompositionSolver<T extends FieldElement<T>> { 038 039 /** Solve the linear equation A × X = B for matrices A. 040 * <p>The A matrix is implicit, it is provided by the underlying 041 * decomposition algorithm.</p> 042 * @param b right-hand side of the equation A × X = B 043 * @return a vector X that minimizes the two norm of A × X - B 044 * @throws org.apache.commons.math3.exception.DimensionMismatchException 045 * if the matrices dimensions do not match. 046 * @throws SingularMatrixException 047 * if the decomposed matrix is singular. 048 */ 049 FieldVector<T> solve(final FieldVector<T> b); 050 051 /** Solve the linear equation A × X = B for matrices A. 052 * <p>The A matrix is implicit, it is provided by the underlying 053 * decomposition algorithm.</p> 054 * @param b right-hand side of the equation A × X = B 055 * @return a matrix X that minimizes the two norm of A × X - B 056 * @throws org.apache.commons.math3.exception.DimensionMismatchException 057 * if the matrices dimensions do not match. 058 * @throws SingularMatrixException 059 * if the decomposed matrix is singular. 060 */ 061 FieldMatrix<T> solve(final FieldMatrix<T> b); 062 063 /** 064 * Check if the decomposed matrix is non-singular. 065 * @return true if the decomposed matrix is non-singular 066 */ 067 boolean isNonSingular(); 068 069 /** Get the inverse (or pseudo-inverse) of the decomposed matrix. 070 * @return inverse matrix 071 * @throws SingularMatrixException 072 * if the decomposed matrix is singular. 073 */ 074 FieldMatrix<T> getInverse(); 075}