📄 matrix.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Mon Sep 11 14:37:20 EDT 2000 --><TITLE>: Class Matrix</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../Jama/LUDecomposition.html"><B>PREV CLASS</B></A> <A HREF="../Jama/QRDecomposition.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Matrix.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">Jama</FONT><BR>Class Matrix</H2><PRE>java.lang.Object | +--<B>Jama.Matrix</B></PRE><HR><DL><DT>public class <B>Matrix</B><DT>extends java.lang.Object<DT>implements java.lang.Cloneable, java.io.Serializable</DL><P>Jama = Java Matrix class.<P>The Java Matrix Class provides the fundamental operations of numericallinear algebra. Various constructors create Matrices from two dimensionalarrays of double precision floating point numbers. Various "gets" and"sets" provide access to submatrices and matrix elements. Several methods implement basic matrix arithmetic, including matrix addition andmultiplication, matrix norms, and element-by-element array operations.Methods for reading and printing matrices are also included. All theoperations in this version of the Matrix Class involve real matrices.Complex matrices may be handled in a future version.<P>Five fundamental matrix decompositions, which consist of pairs or triplesof matrices, permutation vectors, and the like, produce results in fivedecomposition classes. These decompositions are accessed by the Matrixclass to compute solutions of simultaneous linear equations, determinants,inverses and other matrix functions. The five decompositions are:<P><UL><LI>Cholesky Decomposition of symmetric, positive definite matrices.<LI>LU Decomposition of rectangular matrices.<LI>QR Decomposition of rectangular matrices.<LI>Singular Value Decomposition of rectangular matrices.<LI>Eigenvalue Decomposition of both symmetric and nonsymmetric square matrices.</UL><DL><DT><B>Example of use:</B></DT><P><DD>Solve a linear system A x = b and compute the residual norm, ||b - A x||.<P><PRE>double[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};Matrix A = new Matrix(vals);Matrix b = Matrix.random(3,1);Matrix x = A.solve(b);Matrix r = A.times(x).minus(b);double rnorm = r.normInf();</PRE></DD></DL><P><DL><DT><B>See Also: </B><DD><A HREF="../serialized-form.html#Jama.Matrix">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../Jama/Matrix.html#Matrix(double[][])">Matrix</A></B>(double[][] A)</CODE><BR> Construct a matrix from a 2-D array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../Jama/Matrix.html#Matrix(double[][], int, int)">Matrix</A></B>(double[][] A, int m, int n)</CODE><BR> Construct a matrix quickly without checking arguments.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../Jama/Matrix.html#Matrix(double[], int)">Matrix</A></B>(double[] vals, int m)</CODE><BR> Construct a matrix from a one-dimensional packed array</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../Jama/Matrix.html#Matrix(int, int)">Matrix</A></B>(int m, int n)</CODE><BR> Construct an m-by-n matrix of zeros.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../Jama/Matrix.html#Matrix(int, int, double)">Matrix</A></B>(int m, int n, double s)</CODE><BR> Construct an m-by-n constant matrix.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#arrayLeftDivide(Jama.Matrix)">arrayLeftDivide</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> Element-by-element left division, C = A.\B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#arrayLeftDivideEquals(Jama.Matrix)">arrayLeftDivideEquals</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> Element-by-element left division in place, A = A.\B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#arrayRightDivide(Jama.Matrix)">arrayRightDivide</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> Element-by-element right division, C = A./B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#arrayRightDivideEquals(Jama.Matrix)">arrayRightDivideEquals</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> Element-by-element right division in place, A = A./B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#arrayTimes(Jama.Matrix)">arrayTimes</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> Element-by-element multiplication, C = A.*B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#arrayTimesEquals(Jama.Matrix)">arrayTimesEquals</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> Element-by-element multiplication in place, A = A.*B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/CholeskyDecomposition.html">CholeskyDecomposition</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#chol()">chol</A></B>()</CODE><BR> Cholesky Decomposition</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.Object</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#clone()">clone</A></B>()</CODE><BR> Clone the Matrix object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#cond()">cond</A></B>()</CODE><BR> Matrix condition (2 norm)</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#constructWithCopy(double[][])">constructWithCopy</A></B>(double[][] A)</CODE><BR> Construct a matrix from a copy of a 2-D array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#copy()">copy</A></B>()</CODE><BR> Make a deep copy of a matrix</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#det()">det</A></B>()</CODE><BR> Matrix determinant</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/EigenvalueDecomposition.html">EigenvalueDecomposition</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#eig()">eig</A></B>()</CODE><BR> Eigenvalue Decomposition</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#get(int, int)">get</A></B>(int i, int j)</CODE><BR> Get a single element.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double[][]</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getArray()">getArray</A></B>()</CODE><BR> Access the internal two-dimensional array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double[][]</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getArrayCopy()">getArrayCopy</A></B>()</CODE><BR> Copy the internal two-dimensional array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getColumnDimension()">getColumnDimension</A></B>()</CODE><BR> Get column dimension.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double[]</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getColumnPackedCopy()">getColumnPackedCopy</A></B>()</CODE><BR> Make a one-dimensional column packed copy of the internal array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getMatrix(int[], int[])">getMatrix</A></B>(int[] r, int[] c)</CODE><BR> Get a submatrix.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getMatrix(int[], int, int)">getMatrix</A></B>(int[] r, int j0, int j1)</CODE><BR> Get a submatrix.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getMatrix(int, int, int[])">getMatrix</A></B>(int i0, int i1, int[] c)</CODE><BR> Get a submatrix.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getMatrix(int, int, int, int)">getMatrix</A></B>(int i0, int i1, int j0, int j1)</CODE><BR> Get a submatrix.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getRowDimension()">getRowDimension</A></B>()</CODE><BR> Get row dimension.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double[]</CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#getRowPackedCopy()">getRowPackedCopy</A></B>()</CODE><BR> Make a one-dimensional row packed copy of the internal array.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#identity(int, int)">identity</A></B>(int m, int n)</CODE><BR> Generate identity matrix</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#inverse()">inverse</A></B>()</CODE><BR> Matrix inverse or pseudoinverse</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/LUDecomposition.html">LUDecomposition</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#lu()">lu</A></B>()</CODE><BR> LU Decomposition</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#minus(Jama.Matrix)">minus</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR> C = A - B</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../Jama/Matrix.html">Matrix</A></CODE></FONT></TD><TD><CODE><B><A HREF="../Jama/Matrix.html#minusEquals(Jama.Matrix)">minusEquals</A></B>(<A HREF="../Jama/Matrix.html">Matrix</A> B)</CODE><BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -