⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nm10.htm

📁 各种矩阵算法库。支持UpperTriangularMatrix,LowerTriangularMatrix, DiagonalMatrix, SymmetricMatrix, BandMatrix,U
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<TR><TD width="25%"><B>Make files</B></TD><TD width="25%">nm_gnu.mak</TD><TD width="50%">make file for Gnu G++</TD></TR><TR><TD width="25%">&nbsp;</TD><TD width="25%">nm_cc.mak</TD><TD width="50%">make file for AT&amp;T, Sun and HPUX</TD></TR><TR><TD width="25%">&nbsp;</TD><TD width="25%">nm_b55.mak</TD><TD width="50%">make file for Borland C++ 5.5</TD></TR><TR><TD width="25%">&nbsp;</TD><TD width="25%">newmat.lfl</TD><TD width="50%">library file list for use with <a href="genemake.htm">genemake</a></TD></TR><TR><TD width="25%">&nbsp;</TD><TD width="25%">nm_targ.txt</TD><TD width="50%">target file list for use with <a href="genemake.htm">genemake</a></TD></TR></TABLE><H2><A NAME="problem"></A>2.11 Problem report form</H2><P CLASS="small"><A HREF="#refer">next</A> - <A HREF="#refer">skip</A> -<A HREF="#starting">up</A> - <A HREF="#top">start</A></P><P>Copy and paste this to your editor; fill it out and email to<B>robert@statsresearch.co.nz</B> </P><P>But first look in my web page http://webnz.com/robert/ to see if the bug hasalready been reported. </P><PRE> Version: ............... newmat10 beta (28 July 2001) Your email address: .... Today's date: .......... Your machine: .......... Operating system: ...... Compiler &amp; version: .... Compiler options   (eg GUI or console)... Describe the problem - attach examples if possible:-----------------------------------------------------------</PRE><H2><A NAME="refer"></A>3. Reference manual</H2><P CLASS="small"><A HREF="#constr">next</A> - <A HREF="#error">skip</A> -<A HREF="#top">up</A> - <A HREF="#top">start</A></P><TABLE WIDTH="100%"><TR><TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%"> <A HREF="#constr">3.1Constructors </A><BR><A HREF="#elements">3.2 Accessing elements </A><BR><A HREF="#copy">3.3 Assignment and copying </A><BR><A HREF="#entering">3.4 Entering values </A><BR><A HREF="#unary">3.5 Unary operations </A><BR><A HREF="#binary">3.6 Binary operations </A><BR><A HREF="#matscal">3.7 Matrix and scalar ops </A><BR><A HREF="#scalar1">3.8 Scalar functions - size &amp; shape </A><BR><A HREF="#scalar2">3.9 Scalar functions - maximum &amp; minimum </A><BR><A HREF="#scalar3">3.10 Scalar functions - numerical </A><BR><A HREF="#submat">3.11 Submatrices </A><BR><A HREF="#dimen">3.12 Change dimension </A><BR><A HREF="#ch_type">3.13 Change type </A><BR><A HREF="#solve">3.14 Multiple matrix solve </A><BR><A HREF="#memory">3.15 Memory management </A><BR><A HREF="#efficien">3.16 Efficiency </A></TD><TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%">  <AHREF="#output">3.17 Output </A><BR><A HREF="#unspec">3.18 Accessing unspecified type </A><BR><A HREF="#cholesky">3.19 Cholesky decomposition </A><BR><A HREF="#qr">3.20 QR decomposition </A><BR><A HREF="#svd">3.21 Singular value decomposition </A><BR><A HREF="#evalues">3.22 Eigenvalue decomposition </A><BR><A HREF="#sorting">3.23 Sorting </A><BR><A HREF="#fft">3.24 Fast Fourier transform </A><BR><A HREF="#trigtran">3.25 Fast trigonometric transforms </A><BR><A HREF="#nric">3.26 Numerical recipes in C </A><BR><A HREF="#except">3.27 Exceptions </A><BR><A HREF="#cleanup">3.28 Cleanup following exception </A><BR><A HREF="#nonlin">3.29 Non-linear applications </A><BR><A HREF="#stl">3.30 Standard template library </A><BR><A HREF="#namesp">3.31 Namespace </A></TD></TR></TABLE><H2><A NAME="constr"></A>3.1 Constructors</H2><P CLASS="small"><A HREF="#elements">next</A> - <A HREF="#elements">skip</A> -<A HREF="#refer">up</A> - <A HREF="#top">start</A></P><P>To construct an <I>m</I> x <I>n</I> matrix, <TT>A</TT>, (<I>m</I> and<I>n</I> are integers) use </P><PRE>    Matrix A(m,n);</PRE><P>The UpperTriangularMatrix, LowerTriangularMatrix, SymmetricMatrix andDiagonalMatrix types are square. To construct an <I>n</I> x <I>n</I> matrixuse, for example </P><PRE>    UpperTriangularMatrix UT(n);    LowerTriangularMatrix LT(n);    SymmetricMatrix S(n);    DiagonalMatrix D(n);</PRE><P>Band matrices need to include bandwidth information in their constructors. </P><PRE>    BandMatrix BM(n, lower, upper);    UpperBandMatrix UB(n, upper);    LowerBandMatrix LB(n, lower);    SymmetricBandMatrix SB(n, lower);</PRE><P>The integers <I>upper</I> and <I>lower</I> are the number of non-zerodiagonals above and below the diagonal (<I>excluding</I> the diagonal)respectively. </P><P>The RowVector and ColumnVector types take just one argument in theirconstructors: </P><PRE>    RowVector RV(n);    ColumnVector CV(n);</PRE><P><b>These constructors do <EM>not</EM> initialise the elements of the matrices.</b>To set all the elements to zero use, for example, </P><PRE>    Matrix A(m, n); A = 0.0;</PRE><P>You can also construct vectors and matrices without specifying thedimension. For example </P><PRE>    Matrix A;</PRE><P>In this case the dimension must be set by an <A HREF="#copy">assignmentstatement</A> or a <A HREF="#dimen">re-dimension statement</A>. </P><P>You can also use a constructor to set a matrix equal to another matrix ormatrix expression. </P><PRE>    Matrix A = UT;    Matrix A = UT * LT;</PRE><P>Only conversions that don't lose information are supported - eg you cannotconvert an upper triangular matrix into a diagonal matrix using =. </P><H2><A NAME="elements"></A>3.2 Accessing elements </H2><P CLASS="small"><A HREF="#copy">next</A> - <A HREF="#copy">skip</A> -<A HREF="#refer">up</A> - <A HREF="#top">start</A></P><P>Elements are accessed by expressions of the form <TT>A(i,j)</TT> where<I>i</I> and <I>j</I> run from 1 to the appropriate dimension. Access elementsof vectors with just one argument. Diagonal matrices can accept one or twosubscripts. </P><P>This is different from the earliest version of the package in which thesubscripts ran from 0 to one less than the appropriate dimension. Use<TT>A.element(i,j)</TT> if you want this earlier convention. </P><P><TT>A(i,j)</TT> and <TT>A.element(i,j)</TT> can appear on either side of an= sign. </P><P>If you activate the <TT>#define SETUP_C_SUBSCRIPTS</TT> in<TT>include.h</TT> you can also access elements using the traditional C stylenotation. That is <TT>A[i][j]</TT> for matrices (except diagonal) and<TT>V[i]</TT> for vectors and diagonal matrices. The subscripts start at zero(i.e. like element) and there is <I>no</I> range checking. Because of thepossibility of confusing <TT>V(i)</TT> and <TT>V[i]</TT>, I suggest you do<I>not</I> activate this option unless you really want to use it. </P><P>Symmetric matrices are stored as lower triangular matrices. It is importantto remember this if you are using the <TT>A[i][j]</TT> method of accessingelements. Make sure the first subscript is greater than or equal to the secondsubscript. However, if you are using the <TT>A(i,j)</TT> method the programwill swap <TT>i</TT> and <TT>j</TT> if necessary; so it doesn't matter if youthink of the storage as being in the upper triangle (but it <I>does</I> matterin some other situations such as when <A HREF="#entering">entering</A> data). </P><H2><A NAME="copy"></A>3.3 Assignment and copying</H2><P CLASS="small"><A HREF="#entering">next</A> - <A HREF="#entering">skip</A> -<A HREF="#refer">up</A> - <A HREF="#top">start</A></P><P>The operator <TT>=</TT> is used for copying matrices, converting matrices,or evaluating expressions. For example </P><PRE>    A = B;  A = L;  A = L * U;</PRE><P>Only conversions that don't lose information are supported. The dimensionsof the matrix on the left hand side are adjusted to those of the matrix orexpression on the right hand side. Elements on the right hand side which arenot present on the left hand side are set to zero. </P><P>The operator <TT>&lt;&lt;</TT> can be used in place of <TT>=</TT> where itis permissible for information to be lost. </P><P>For example </P><PRE>    SymmetricMatrix S; Matrix A;    ......    S &lt;&lt; A.t() * A;</PRE><P>is acceptable whereas </P><PRE>    S = A.t() * A;                            // error</PRE><P>will cause a runtime error since the package does not (yet?) recognise<TT>A.t()*A</TT> as symmetric. </P><P>Note that you can <I>not</I> use <TT>&lt;&lt;</TT> with constructors. Forexample </P><PRE>    SymmetricMatrix S &lt;&lt; A.t() * A;           // error</PRE><P>does <I>not</I> work. </P><P>Also note that <TT>&lt;&lt;</TT> cannot be used to load values from a fullmatrix into a band matrix, since it will be unable to determine the bandwidthof the band matrix. </P><P>A third copy routine is used in a similar role to <TT>=</TT>. Use </P><PRE>    A.Inject(D);</PRE><P>to copy the elements of <TT>D</TT> to the corresponding elements of<TT>A</TT> but leave the elements of <TT>A</TT> unchanged if there is nocorresponding element of <TT>D</TT> (the <TT>=</TT> operator would set them to0). This is useful, for example, for setting the diagonal elements of a matrixwithout disturbing the rest of the matrix. Unlike <TT>=</TT> and<TT>&lt;&lt;</TT>, Inject does not reset the dimensions of <TT>A</TT>, whichmust match those of <TT>D</TT>. Inject does <I>not</I> test for no loss ofinformation. </P><P>You cannot replace <TT>D</TT> by a matrix expression. The effect of<TT>Inject(D)</TT> depends on the type of <TT>D</TT>. If <TT>D</TT> is anexpression it might not be obvious to the user what type it would have. So Ithought it best to disallow expressions. </P><P>Inject can be used for loading values from a regular matrix into a bandmatrix. (Don't forget to zero any elements of the left hand side that will notbe set by the loading operation). </P><P>Both <TT>&lt;&lt;</TT> and Inject can be used with submatrix expressions onthe left hand side. See the section on <A HREF="#submat">submatrices</A>. </P><P>To set the elements of a matrix to a scalar use operator <TT>=</TT> </P><PRE>    Real r; int m,n;    ......    Matrix A(m,n); A = r;</PRE><H2><A NAME="entering"></A>3.4 Entering values</H2><P CLASS="small"><A HREF="#unary">next</A> - <A HREF="#unary">skip</A> -<A HREF="#refer">up</A> - <A HREF="#top">start</A></P><P>You can load the elements of a matrix from an array: </P><PRE>    Matrix A(3,2);    Real a[] = { 11,12,21,22,31,33 };    A &lt;&lt; a;</PRE><P>This construction does <I>not</I> check that the numbers of elements matchcorrectly. This version of <TT>&lt;&lt;</TT> can be used with submatrices onthe left hand side. It is not defined for band matrices. </P><P>Alternatively you can enter short lists using a sequence of numbersseparated by <TT>&lt;&lt;</TT> . </P><PRE>    Matrix A(3,2);    A &lt;&lt; 11 &lt;&lt; 12      &lt;&lt; 21 &lt;&lt; 22      &lt;&lt; 31 &lt;&lt; 32;</PRE><P>This does check for the correct total number of entries, although themessage for there being insufficient numbers in the list may be delayed untilthe end of the block or the next use of this construction. This does <I>not</I>work for band matrices or for long lists. It does work for submatrices if thesubmatrix is a single complete row. For example </P><PRE>    Matrix A(3,2);    A.Row(1) &lt;&lt; 11 &lt;&lt; 12;    A.Row(2) &lt;&lt; 21 &lt;&lt; 22;    A.Row(3) &lt;&lt; 31 &lt;&lt; 32;</PRE><P>Load only values that are actually stored in the matrix. For example </P><PRE>    SymmetricMatrix S(2);    S.Row(1) &lt;&lt; 11;    S.Row(2) &lt;&lt; 21 &lt;&lt; 22;</PRE><P>Try to restrict this way of loading data to numbers. You can includeexpressions, but these must not call a function which includes the sameconstruction. </P><P>Remember that matrices are stored by rows and that symmetric matrices arestored as <I> lower</I> triangular matrices when using these methods to enterdata. </P><H2><A NAME="unary"></A>3.5 Unary operators</H2><P CLASS="small"><A HREF="#binary">next</A> - <A HREF="#binary">skip</A> -<A HREF="#refer">up</A> - <A HREF="#top">start</A></P><P>The package supports unary operations </P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -