📄 nm11.htm
字号:
<!DOCTYPE HTML PUBLIC "-//SoftQuad Software//DTD HoTMetaL PRO 5.0::19981217::extensions to HTML 4.0//EN" "hmpro5.dtd">
<HTML>
<HEAD>
<meta http-equiv="Content-Language" content="en-nz">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<TITLE>Newmat11 documentation</TITLE>
<link rel="stylesheet" type="text/css" href="rbd.css">
<link REL="SHORTCUT ICON" HREF="favicon.ico">
</HEAD>
<BODY>
<H1><A NAME="top"></A>Documentation for newmat11, a matrix library in C++</H1>
<P CLASS="small"><A HREF="#intro">next</A> - <A HREF="#top">skip</A> -
<A HREF="ol_doc.htm">up</A> - <A HREF="#top">start</A><BR>
<A HREF="ol_doc.htm">return to online documentation page</A></P>
<P><B>Copyright (C) 2005: R B Davies</B></P>
<P><i>22 April, 2006</i>.</P>
<TABLE WIDTH=100%>
<TR>
<TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%"> <A HREF="#intro">1.
Introduction</A><BR>
<A HREF="#starting">2. Getting started</A><BR>
<A HREF="#refer">3. Reference manual</A><br>
<A HREF="#error">4.
Error messages</A></TD>
<TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%">
<A HREF="#design">5. Design of the library</A><br>
<a href="#function">6. Function summary</a><br>
<a href="#changes">7. Change History</a><br>
<a href="#problem">8. Problem report form</a></TD>
</TR>
</TABLE>
<p> </p>
<P>This is the <I>how to use</I> documentation for <I>newmat</I> plus some
background information on its design. </P>
<P>There is additional support material on my <A HREF="#where">web site</A>.
</P>
<P CLASS="small">Navigation: This page is arranged in sections,
sub-sections and sub-sub-sections; four cross-references are given at the top
of these. <I>Next</I> takes you through the sections, sub-sections and
sub-sub-sections in order. <I>Skip</I> goes to the next section, sub-section or
sub-sub-section at the same level in the hierarchy as the section, sub-section
or sub-sub-section that you are currently reading. <I>Up</I> takes you up one
level in the hierarchy and <I>start</I> gets you back here.</P>
<P><B>Please read the sections on <A HREF="#custom">customising</A> and
<a href="#compiler">compilers</a> before
attempting to compile <i>newmat</i>.</B> </P>
<H2><A NAME="intro"></A>1. Introduction</H2>
<P CLASS="small"><A HREF="#use">next</A> - <A HREF="#starting">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="#use">1.1
Conditions of use</A><BR>
<A HREF="#descript">1.2 Description</A><BR>
<A HREF="#which">1.3 Is this the library for you?</A><BR>
<A HREF="#other">1.4 Other matrix libraries</A></TD>
<TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%"> <A HREF="#where">1.5
Where to find this library</A><BR>
<A HREF="#author">1.6 How to contact the author</A><BR>
<A HREF="#sources">1.7 References</A></TD>
</TR>
</TABLE>
<H2><A NAME="use"></A>1.1 Conditions of use</H2>
<P CLASS="small"><A HREF="#descript">next</A> - <A HREF="#descript">skip</A> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A></P>
<hr>
<p>I place no restrictions on the use of <i>newmat</i> except that I take no liability for any problems that may arise from its use,
distribution or other dealings with it.<p>
<p>
You can use it in your commercial projects (as well as your non-commercial
projects).<p>
<p>
You can make and distribute modified or merged versions. You can
include parts of it in your own software.<p>
<p>
If you distribute modified or merged versions, please make it clear
which parts are mine and which parts are modified.<p>
<p>
For a substantially modified version, simply note that it is, in
part, derived from my software. A comment in the code will be
sufficient.<p>
<p>
The software is provided <i>as is</i>, without warranty of any kind.<p>
<p>
Please understand that there may still be bugs and errors. Use at
your own risk. I (Robert Davies) take no responsibility for any errors
or omissions in this package or for any misfortune that may befall you
or others as a result of your use, distribution or other dealings with it.<HR>
<P>Please report bugs to me at <B>robert at statsresearch.co.nz</B>
[replace <b>at</b> by you-know-what-character in the email address].</P>
<P>When reporting a bug please tell me which C++ compiler you are using, and
what version. Also give me details of your computer. And tell me which version
of <I>newmat</I> (e.g. newmat03 or newmat04) you are using and its date. Note any changes
you have made to my code. If at all possible give me a piece of code
illustrating the bug. See the <A HREF="#problem">problem report form</A>. </P>
<P><I>Please do report bugs to me.</I> </P>
<H2><A NAME="descript"></A>1.2 General description
</H2>
<P CLASS="small"><A HREF="#which">next</A> - <A HREF="#which">skip</A> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A></P>
<P>The package is intended for scientists and engineers who need to manipulate
a variety of types of matrices using standard matrix operations. Emphasis is on
the kind of operations needed in statistical calculations such as least
squares, linear equation solve and eigenvalues. </P>
<P>It supports matrix types </P>
<BLOCKQUOTE>
<TABLE WIDTH="80%" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<TR>
<TD>Matrix</TD>
<TD>rectangular matrix</TD>
</TR>
<TR>
<TD>SquareMatrix</TD>
<TD>square matrix</TD>
</TR>
<TR>
<TD>nricMatrix</TD>
<TD>for use with <I>Numerical Recipes in C</I> programs</TD>
</TR>
<TR>
<TD>UpperTriangularMatrix</TD>
<TD> </TD>
</TR>
<TR>
<TD>LowerTriangularMatrix</TD>
<TD> </TD>
</TR>
<TR>
<TD>DiagonalMatrix</TD>
<TD> </TD>
</TR>
<TR>
<TD>SymmetricMatrix</TD>
<TD> </TD>
</TR>
<TR>
<TD>BandMatrix</TD>
<TD> </TD>
</TR>
<TR>
<TD>UpperBandMatrix</TD>
<TD>upper triangular band matrix</TD>
</TR>
<TR>
<TD>LowerBandMatrix</TD>
<TD>lower triangular band matrix</TD>
</TR>
<TR>
<TD>SymmetricBandMatrix</TD>
<TD> </TD>
</TR>
<TR>
<TD>RowVector</TD>
<TD>derived from Matrix</TD>
</TR>
<TR>
<TD>ColumnVector</TD>
<TD>derived from Matrix</TD>
</TR>
<TR>
<TD>IdentityMatrix</TD>
<TD>diagonal matrix, elements have same value</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
<P>Only one element type (float or double) is supported. </P>
<P>The package includes the operations <TT>*</TT>, <TT>+</TT>, <TT>-</TT>,
Kronecker product, Schur product, concatenation, inverse, transpose, conversion between types, submatrix,
determinant, Cholesky decomposition, QR decomposition, singular value
decomposition, eigenvalues of a symmetric matrix, sorting, fast Fourier
transform, printing and an interface with <I>Numerical Recipes in C</I>. </P>
<P>It is intended for matrices in the range 10 x 10 to the maximum size your
machine will accommodate in a single array. The number of elements in an array
cannot exceed the maximum size of an <I>int</I>. The package will work for very
small matrices but becomes rather inefficient. Some of the factorisation
functions are not (yet) optimised for paged memory and so become inefficient
when used with very large matrices. </P>
<P>A <I>lazy evaluation</I> approach to evaluating matrix expressions is used
to improve efficiency and reduce the use of temporary storage. </P>
<P>I have tested versions of the package on variety of compilers and platforms
including Borland, Gnu, Microsoft and Sun. For more details
see the section on <A HREF="#compiler">compilers</A>. </P>
<H2><A NAME="which"></A>1.3 Is this the library for
you?</H2>
<P CLASS="small"><A HREF="#other">next</A> - <A HREF="#other">skip</A> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A></P>
<P>Do you</P>
<UL>
<LI>understand <TT>*</TT> to mean matrix multiply and not element by element
multiply </LI>
<LI>need matrix operators such as <TT>*</TT> and <TT>+</TT> defined as
operators so you can write things like <TT> X = A * (B + C);</TT></LI>
<LI>need a variety of types of matrices (but not sparse)</LI>
<LI>need only one element type (float or double)</LI>
<LI>work with matrices in the range 10 x 10 up to what can be stored in memory
</LI>
<LI>tolerate a moderately large but not huge package</LI>
<LI>need high quality but not necessarily the latest numerical methods. </LI>
</UL>
<P>Then <I>newmat</I> may be the right matrix library for you. </P>
<H2><A NAME="other"></A>1.4 Other matrix libraries
</H2>
<P CLASS="small"><A HREF="#where">next</A> - <A HREF="#where">skip</A> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A></P>
<P>For details of other C++ matrix libraries look at
<a href="http://www.robertnz.net/cpp_site.html">http://www.robertnz.net/cpp_site.html</a>.
Look at the section <I>lists of libraries</I> which gives the locations of
several very comprehensive lists of matrix and other C++ libraries and at the
section <I>source code</I>. Or just search on <a href="http://www.google.com">Google</a>.</P>
<H2><A NAME="where"></A>1.5 Where to find this
library</H2>
<P CLASS="small"><A HREF="#author">next</A> - <A HREF="#author">skip</A> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A> </P>
<UL>
<LI><a href="http://www.robertnz.net">http://www.robertnz.net</a></LI>
</UL>
<H2><A NAME="author"></A>1.6 How to contact the
author</H2>
<P CLASS="small"><a href="#sources">next</a> - <a href="#sources">skip</a> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A></P>
<PRE> Robert Davies
16 Gloucester Street
Wilton
Wellington
New Zealand
<I>Internet:</I> robert <b>at</b> statsresearch.co.nz</PRE>
[replace <b>at</b> by you-know-what.]
<H2><A NAME="sources"></A>1.7 References</H2>
<P CLASS="small"><A HREF="#starting">next</A> - <A HREF="#starting">skip</A> -
<A HREF="#intro">up</A> - <A HREF="#top">start</A></P>
<UL>
<LI>The matrix LU decomposition is from Golub, G.H. & Van Loan, C.F.
(1996), <I>Matrix Computations</I>, published by Johns Hopkins University
Press. </LI>
<LI>Part of the matrix inverse/solve routine is adapted from Press, Flannery,
Teukolsky, Vetterling (1988), <I>Numerical Recipes in C</I>, published by the
Cambridge University Press. </LI>
<LI>Many of the advanced matrix routines are adapted from routines in Wilkinson
and Reinsch (1971), <I>Handbook for Automatic Computation, Vol II, Linear
Algebra</I> published by Springer Verlag. </LI>
<LI>The fast Fourier transform is adapted from Carl de Boor (1980), <I>Siam J
Sci Stat Comput</I>, pp173-8 and the fast trigonometric transforms from Charles
Van Loan (1992) in <I>Computational frameworks for the fast Fourier
transform</I> published by SIAM. </LI>
<LI>The sort function is derived from Sedgewick, Robert (1992), <I>Algorithms
in C++</I> published by Addison Wesley. </LI>
</UL>
<P>For references about <I>Newmat</I> see </P>
<UL>
<LI>Davies, R.B. (1994) Writing a matrix package in C++. In OON-SKI'94: The
second annual object-oriented numerics conference, pp 207-213. Rogue Wave
Software, Corvallis. </LI>
<LI>Eddelbuttel, Dirk (1996) Object-oriented econometrics: matrix programming
in C++ using GCC and Newmat. Journal of Applied Econometrics, Vol 11, No 2, pp
199-209. </LI>
</UL>
<H2><A NAME="starting"></A>2. Getting started</H2>
<P CLASS="small"><A HREF="#overview">next</A> - <A HREF="#refer">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="#overview">2.1 Overview</A><BR>
<A HREF="#make">2.2 Make files</A><BR>
<A HREF="#custom">2.3 Customising</A><BR>
<A HREF="#compiler">2.4 Compilers</A><BR>
<a HREF="#update">2.5 Updating from previous versions</a><br>
<a HREF="#except_1">2.6 Catching exceptions</a></TD>
<TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%"> <A
HREF="#example">2.7 Examples</A><BR>
<A HREF="#testing">2.8 Testing</A><BR>
<A HREF="#bugs">2.9 Bugs</A><BR>
<a href="#problemareas">2.10 Problem areas</a><BR>
<A HREF="#files">2.11 Files in newmat11</A><BR>
</TD>
</TR>
</TABLE>
<H2><A NAME="overview"></A>2.1 Overview</H2>
<P CLASS="small"><A HREF="#make">next</A> - <A HREF="#make">skip</A> -
<A HREF="#starting">up</A> - <A HREF="#top">start</A></P>
<P>I use .h as the suffix of definition files and .cpp as the suffix of C++
source files. </P>
<P>You will need to compile all the *.cpp files listed as program files in the
<A HREF="#files">files section</A> to get the complete package. Ideally you
should store the resulting object files as a library. The tmt*.cpp files are
used for <A HREF="#testing">testing</A>, example.cpp is an <A
HREF="#example">example</A> and sl_ex.cpp, nl_ex.cpp and garch.cpp are examples
of the <A HREF="#nonlin">non-linear</A> solve and optimisation routines. A
demonstration and test of the exception mechanism is in test_exc.cpp. </P>
<P>I include a number of <I>make</I> files for compiling the example and the
test package. See the section on <A HREF="#make">make files</A> for details.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -