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

📄 nm11.htm

📁 非常好用的用C编写的矩阵类,可在不同编译器下编译使用.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
Alternatively, with the PC compilers, its pretty quick just to load all the files in the
interactive environments by pointing and clicking. </P>
<P>Use the large or win32 console model when you are using a PC. Do not
<I>outline</I> inline functions. You may need to increase the stack size on 
older operating systems or compilers. </P>
<P>Your source files that access the newmat will need to #include one or more
of the following files. </P>
<TABLE WIDTH="100%" CELLPADDING="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<TR>
<TD VALIGN="TOP">include.h</TD>
<TD>to access just the compiler options</TD>
</TR>
<TR>
<TD VALIGN="TOP">newmat.h</TD>
<TD>to access just the main matrix library (includes include.h)</TD>
</TR>
<TR>
<TD VALIGN="TOP">newmatap.h</TD>
<TD>to access the advanced matrix routines such as Cholesky decomposition, QR
triangularisation etc (includes newmat.h)</TD>
</TR>
<TR>
<TD VALIGN="TOP">newmatio.h</TD>
<TD>to access the <A HREF="#output">output</A> routines (includes newmat.h) You
can use this only with compilers that support the standard input/output
routines including manipulators</TD>
</TR>
<TR>
<TD VALIGN="TOP">newmatnl.h</TD>
<TD>to access the non-linear optimisation routines (includes newmat.h)</TD>
</TR>
</TABLE>
<P>See the section on <A HREF="#custom">customising</A> to see how to edit
include.h for your environment and the section on <A
HREF="#compiler">compilers</A> for any special problems with the compiler you
are using.</P>
<H2><A NAME="make"></A>2.2 Make files</H2>
<P CLASS="small"><A HREF="#custom">next</A> - <A HREF="#custom">skip</A> -
<A HREF="#starting">up</A> - <A HREF="#top">start</A></P>
<P>I have included <I>make</I> files for compiling my test and example programs for CC, Borland 5.5, 5.6, Microsoft VC++6, 
7, Open Watcom, Intel and Gnu compilers. You 
can generate make files for a number of other compilers with my
<a href="genmake.htm">genmake</a> utility. <i>Make</i> files provide
a way of compiling your programs  without using the IDE that comes with
PC compilers. See the <A HREF="#files">files section</A> for details.</P>
<H3>PC</H3>
<P>I include  make files for Borland 5.5, 5.6 and Microsoft VC++6 or 7. With the 
Borland compiler you will need to edit it to show where 
you have stored your Borland compiler. For make files for other compilers use my
<a href="genmake.htm">genmake</a> utility. To compile my test and example 
programs use Borland 5.5 (Builder 5) use</P>
<pre>   make -f nm_b55.mak</pre>
<p>or with Borland 5.6 (Builder 6) use</p>
<pre>   make -f nm_b56.mak</pre>
<P>or with Microsoft VC++ 6 or 7 use</P>
<pre>   nmake -f nm_m6.mak</pre>
<P>There are some more notes in the
<a href="genmake.htm">genmake</a> documentation about using these make files.</P>
<H3>Unix</H3>
<P>The <I>make</I> file for the Unix CC compilers link a .cxx file to each .cpp
file since some of these compilers do not recognise .cpp as a legitimate
extension for a C++ file. I suggest you delete this part of the <I>make</I>
file and, if necessary, rename the .cpp files to something your compiler
recognises. </P>
<P>My <I>make</I> file for Gnu GCC on Unix systems is for use with
<TT>gmake</TT> rather than <TT>make</TT>. I assume your compiler recognises the
.cpp extension. Ordinary <TT>make</TT> works with it on the Sun did not the
Silicon Graphics or HP machines when I had access to them. On Linux use <TT>make</TT>. </P>
<P>My make file for the CC compilers works with the ordinary make. </P>
<P>To compile everything with the CC compiler use </P>
<PRE>   make -f nm_cc.mak
</PRE>

<P>or for the gnu compiler use </P>
<PRE>   make -f nm_gnu.mak
</PRE>

<P>On some computers you will need to use <tt>gmake</tt> rather than <tt>make</tt>.</P>

<P>There is a line in the make file for CC <TT>rm -f $*.cxx</TT>. Some systems
won't accept this line and you will need to delete it. In this case, if you
have a bad compile and you are using my scheme for linking .cxx files, you will
need to delete the .cxx file link generated by that compile before you can do
the next one. </P>
<H2><A NAME="custom"></A>2.3 Customising</H2>
<P CLASS="small"><A HREF="#compiler">next</A> - <A HREF="#compiler">skip</A> -
<A HREF="#starting">up</A> - <A HREF="#top">start</A></P>
<P>The file <I>include.h</I> sets a variety of options including several
compiler dependent options. You may need to edit include.h to get the options
you require. If you are using a compiler different from one I have worked with
you may have to set up a new section in include.h appropriate for your
compiler. </P>
<P>Borland, Turbo, Gnu, Microsoft and Watcom are recognised automatically. If
none of these are recognised a default set of options is used. These are fine
for AT&amp;T, HPUX and Sun C++. If you using a compiler I don't know about you
may have to write a new set of options. </P>
<P>There is an option in include.h for selecting whether you use compiler
supported exceptions, simulated exceptions, or disable exceptions. I now set
<I> compiler supported exceptions</I> as the default. Use the option for
compiler supported exceptions <I>if and only if</I> you have set the option on
your compiler to recognise exceptions. Disabling exceptions sometimes helps
with compilers that are incompatible with my exception simulation scheme. </P>
<P>Activate the appropriate statement to make the element type <i>float</i> or 
<i>double</i>. I suggest you leave it at <i>double</i>.</P>
<P>The option <A HREF="#testing">DO_FREE_CHECK</A> is used for tracking memory
leaks and normally should not be activated. </P>
<P>Activate SETUP_C_SUBSCRIPTS if you want to use traditional C style
<A HREF="#elements">element access</A>. Note that this does <I>not</I> change
the starting point for indices when you are using round brackets for accessing
elements or selecting submatrices. It does enable you to use C style square
brackets. This also activates additional constructors for Matrix, ColumnVector 
and RowVector to simplify use with <i>Numerical Recipes in C++</i>.</P>
<P>Activate <TT>#define use_namespace</TT> if you want to use <A
HREF="#namesp">namespaces</A>. Do this only if you are sure your compiler
supports namespaces. If you do turn this option on, be prepared to turn it off
again if the compiler reports inaccessible variables or the linker reports
missing links. </P>
<P>Activate <TT>#define _STANDARD_</TT> to use the standard names for the
included files and to find the floating point precision data using the floating
point standard. This will work only with the most recent compilers. </P>
<P>If you haven't defined <TT>_STANDARD_</TT> and are using a compiler that
<I>include.h</I> does not recognise and you want to pick up the floating point
precision data from <I>float.h</I> then activate <TT>#define use_float_h</TT>.
Otherwise the floating point precision data will be accessed from
<I>values.h</I>. You may need to do this with computers from Digital, in
particular. </P>
<H2><A NAME="compiler"></A>2.4 Compilers</H2>
<P CLASS="small"><A HREF="#atandt">next</A> - <A HREF="#update">skip</A> -
<A HREF="#starting">up</A> - <A HREF="#top">start</A></P>
<TABLE WIDTH="100%">
<TR>
<TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%">
<A HREF="#atandt">2.4.1 AT&amp;T </A><BR>
<A HREF="#borland">2.4.2 Borland </A><BR>
<A HREF="#gcc">2.4.3 Gnu G++ </A><BR>
<A HREF="#hpux">2.4.4 HPUX </A> </TD>
<TD VALIGN="TOP" ALIGN="LEFT" WIDTH="50%">
<A HREF="#intel">2.4.5 Intel </A><BR>
<A HREF="#microso">2.4.6 Microsoft </A><BR>
<A HREF="#sun">2.4.7 Sun </A><BR>
<A HREF="#watcom">2.4.8 Watcom </A></TD>
</TR>
</TABLE>
<P>I have tested this library on a number of compilers. Here are the levels of
success and any special considerations. In most cases I have chosen code that
works under all the compilers I have access to, but I have had to include some
specific work-arounds for some compilers. For the newest PC versions,  I use a Pentium 
4 computer running windows XP or Linux
(Red Hat workstation version). The older compilers are tested on older computers. The Unix versions are on a Sun Sparc
station. Thanks to Victoria University for access to the Sparc. </P>
<P>I have set up a block of code for each of the compilers in include.h. Turbo,
Borland, Gnu, Microsoft and Watcom are recognised automatically. There is a
default option that works for AT&amp;T, Sun C++ and HPUX. So you don't
have to make any changes for these compilers. Otherwise you may have to build
your own set of options in include.h. </P>
<H2><A NAME="atandt"></A>2.4.1 AT&amp;T</H2>
<P CLASS="small"><A HREF="#borland">next</A> - <A HREF="#borland">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<P>The AT&amp;T compiler used to be available on a wide variety of Unix
workstations. I don't know if anyone still uses it. However the AT&amp;T options are 
the default if your compiler is not recognised.</P>
<P>AT&amp;T C++ 2.1; 3.0.1 on a Sun: Previous versions worked on these
compilers, which I no longer have access to. </P>
<P>In AT&amp;T 2.1 you may get an error when you use an expression for the
single argument when constructing a Vector or DiagonalMatrix or one of the
Triangular Matrices. You need to evaluate the expression separately. </P>
<H2><A NAME="borland"></A>2.4.2 Borland</H2>
<P CLASS="small"><A HREF="#gcc">next</A> - <A HREF="#gcc">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<H3>Newer compilers</H3>
<P><b>Borland Builder version 6:</b> My tests have been on the <i>personal</i> 
version. See the notes for version 5. If you are 
compiling with a make file you can use <i>nm_b56.mak</i> as a model. You can set 
the <i>newmat</i> options to use namespace and the standard library. If you are 
compiling a GUI program you may need to comment out the line defining <i>
TypeDefException</i> in <i>include.h. </i>I don't believe exceptions work 
completely correctly in either version 5 or version 6. However, this does not 
seem to be a problem with my use of them in <i>newmat</i>.</P>
<P><B>Borland Builder version 5:</B> This works fine in console mode and no
special editing of the source codes is required. I haven't tested it in GUI
mode. You can set the <i>newmat</i> options to use namespace and the standard library. <b> You
should turn <I>off</I> the Borland option to use pre-compiled headers.</b> There 
are notes on compiling with the IDE on my <a href="#where">website</a>. 
Alternatively you can use the <i>nm_b55.mak</i> make file<i>.</i></P>
<P><B>Borland Builder version 4</B>: I have successfully used this on older 
versions of newmat using the
console wizard (menu item file/new - select new tab). Use compiler
exceptions. Suppose you are compiling my test program <I>tmt</I>. Rename my
<I>main()</I> function in <I>tmt.cpp</I> to <I>my_main()</I>. Rename
<I>tmt.cpp</I> to <I>tmt_main.cpp</I>. Borland will generate a new file
<I>tmt.cpp</I> containing their <I>main()</I> function. Put the line <TT>int
my_main();</TT> above this function and put <TT>return my_main();</TT> into the
body of <I>main()</I>.</P>
<P><B>Borland compiler version 5.5</B>: this is the free C++ compiler available
from Borland's web site. I suggest you use
the compiler supported exceptions and turn on <I>standard</I> in include.h. You
can use the make file <i>nm_b55.mak</i> after editing to correct the file locations for
your system.</P>
<H3>Older compilers</H3>
<P><B>Borland C++  5.02</B>: Use the large or 32 bit flat model. If you are not debugging, turn off the 
options that collect debugging information. Use my simulated exceptions.</P>
<P>When running my test program under ms-dos you may run out of memory. Either
compile the test routine to run under <I>easywin</I> or use simulated exceptions 
rather than the built in exceptions. </P>
<P>If you can, upgrade to windows 95 or window NT and use the 32 bit console
model. </P>
<P>If you are using the 16 bit large model, don't forget to keep all matrices
less than 64K bytes in length (90x90 for a rectangular matrix if you are using
<TT>double</TT> as your element type). Otherwise your program will crash
without warning or explanation. You will need to break the <A
HREF="#testing">tmt</A> set of test files into several parts to get the program 
to fit into your computer and run without stack overflow. </P>
<P>You can generate make files for versions 5  with my <a href="genmake.htm">
genmake</a> utility.</P>
<P><b>Borland C++ 3 and 4</b>.</P>
<P>The program will compile in version 3.1 if you enable the <i>simulated booleans</i> 
- comment <i>out</i> the line <tt>#define bool_LIB 0</tt> in <i>include.h</i> 
and use the <i>simulated exceptions</i>. The main test program is too large to run 
unless you break it up into several parts. I haven't tried it under version 4.</P>
<H2><A NAME="gcc"></A>2.4.3 Gnu G++</H2>
<P CLASS="small"><A HREF="#hpux">next</A> - <A HREF="#hpux">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<P><B>Gnu G++  3.4 (Linux), 3.3 (Sun):</B> These work OK. If you are using a much earlier version
see if you can upgrade. It&nbsp; used to work with 2.95 and 2.96 but I don't 
have access to these now. You can't use <i>standard</i> with the 2.9X 
versions. The namespace option worked with 2.96 on Linux but not with 2.95 on 
the Sun. Standard is automatically turned on with the 3.X.</P>
<P>This version of Newmat is not compatible with versions 2.6 or earlier.</P>
<H2><A NAME="hpux"></A>2.4.4 HP-UX</H2>
<P CLASS="small"><A HREF="#intel">next</A> - <A HREF="#intel">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<P>HP 9000 series HP-UX. I no longer have access to this compiler. Newmat09
worked without problems with the simulated exceptions; haven't tried the
built-in exceptions. </P>
<P>With recent versions of the compiler you may get warning messages like
<TT>Unsafe cast between pointers/references to incomplete classes</TT>. At
present, I think these can be ignored. </P>

<h2><a name="intel"></a>2.4.5 Intel</h2>
<P CLASS="small"><A HREF="#microso">next</A> - <A HREF="#microso">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>

<P>Newmat works correctly with the Intel versions 5 and 8 C++ compiler for Windows and for 
version 8 for Linux. (Not tested for the other versions). Standard is 
automatically turned on for the Linux versions and with the Windows versions&nbsp; 
if it is emulating Visual C++ 7 or above. Note that the Intel compiler for 
Linux is <i>free</i> for non-commercial use. (One of the versions of 8.1 gave a 
warning message every time I had something like
<tt>Real x; ... if (x==0.0) ...</tt>, which was often. This is now seems to be fixed.)</P>

<H2><A NAME="microso"></A>2.4.6 Microsoft</H2>
<P CLASS="small"><A HREF="#sun">next</A> - <A HREF="#sun">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<H3>Newer versions</H3>
<P>See my <A HREF="#where">web site</A> for instructions how to work
Microsoft's IDE.<B></B></P>
<P><b>Microsoft Visual C++ 7, 7.1, 8:</b> These works OK. All my tests have 
been in console mode. You can turn on my namespace option. Standard is turned on 
by default for these versions. </P>
<P><B>Microsoft Visual C++ 6</B>: <b>Get the latest service pack</b>. I have tried this 
in console mode and it seems to work satisfactorily. Use the compiler supported exceptions. You may be able to
use the namespace and standard options. If you want to work under MFC
you may need to <TT>#include &quot;stdafx.h&quot;</TT> at the beginning of each .cpp file 
(or turn off precompiled headers). </P>
<P><B>Microsoft Visual C++ 5</B>: I have tried this in console mode on previous 
versions of Newmat. It
seems to work satisfactorily. There may be a problem with <A
HREF="#namesp">namespace</A> (fixed by Service Pack 3?). <B>Turn optimisation
off</B>. Use the compiler supported exceptions. If
you want to work under MFC&nbsp;
you may need to <TT>#include &quot;stdafx.h&quot;</TT> at the
beginning of each .cpp file (or turn off precompiled headers).</P>
<H3>Older versions</H3>
<p>I doubt whether these will work.</p>
<H2><A NAME="sun"></A>2.4.7 Sun</H2>
<P CLASS="small"><A HREF="#watcom">next</A> - <A HREF="#watcom">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<P><B>Sun C++ (version 7):</B> This seems to work fine with 
compiler supported exceptions. <B>Sun C++ (version
5):</B> There was a problem with exceptions. If you use my simulated
exceptions the non-linear optimisation programs hang. If you use the compiler
supported exceptions my tmt and test_exc programs crash. You should
<I>disable</I> exceptions.</P>
<H2><A NAME="watcom"></A>2.4.8 Watcom</H2>
<P CLASS="small"><A HREF="#update">next</A> - <A HREF="#update">skip</A> -
<A HREF="#compiler">up</A> - <A HREF="#top">start</A></P>
<P><b>Open Watcom (version 1.3):</b> this works. Do <i>not</i> set the standard 
option in <tt>include.h</tt>.</P>
<P><B>Watcom C++ (version 10a):</B> this used to work, I don't know if it works 
now. </P>
<H2><A NAME="update"></A>2.5 Updating from previous
versions</H2>
<P CLASS="small"><a href="#except_1">next</a> - <a href="#except_1">skip</a> -
<A HREF="#starting">up</A> - <A HREF="#top">start</A></P>
<P><b>Newmat11 </b>- if you are upgrading from earlier versions note the 
following:</P>
<ul>
  <li>The class <i>Exception</i> in <i>myexcept.h</i> has been replaced by <i>
  BaseException</i> and a <b>typedef</b> statement included so programs that use 
  the <i>Exception</i> class will still work. If the <i>Exception</i> class was 

⌨️ 快捷键说明

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