edu.mines.jtk.lapack.DMatrixQrd Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edu-mines-jtk Show documentation
Show all versions of edu-mines-jtk Show documentation
Java packages for science and engineering
/****************************************************************************
Copyright 2005, Colorado School of Mines and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
package edu.mines.jtk.lapack;
import org.netlib.blas.BLAS;
import org.netlib.lapack.LAPACK;
import static edu.mines.jtk.util.ArrayMath.*;
import edu.mines.jtk.util.Check;
/**
* QR decomposition of a matrix A.
* For an m-by-n matrix A, with m>=n, the QR decomposition is A = Q*R,
* where Q is an m-by-n orthogonal matrix, and R is an n-by-n upper-triangular
* matrix.
*
* The QR decomposition is constructed even if the matrix A is rank
* deficient. However, the primary use of the QR decomposition is for
* least-squares solutions of non-square systems of linear equations,
* and such solutions are feasible only if the matrix A is of full rank.
* @author Dave Hale, Colorado School of Mines
* @version 2005.12.14
*/
public class DMatrixQrd {
/**
* Constructs a QR decomposition for the specified matrix A.
* @param a the m-by-n matrix A with m>=n.
*/
public DMatrixQrd(DMatrix a) {
Check.argument(a.getM()>=a.getN(),"m >= n");
_m = a.getM();
_n = a.getN();
_k = min(_m,_n); // same as n, but might not be if we allow m