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

📄 nm10.htm

📁 matrix library for linux and windos
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<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.3, 4.0, 4.1:</B> These work OK. If you are using a much earlier version see if you can upgrade. Standard is automatically turned on with 3.X.</P><P>If you are using 2.6 or earlier remember to edit include.h to activate myBoolean class. In 2.6.?, <TT>fabs(*X++)</TT> causes a problem. You may need to write youown non-inlined version.&nbsp; </P><P>For versions earlier than 2.6.0 you must enable the optionsTEMPS_DESTROYED_QUICKLY and TEMPS_DESTROYED_QUICKLY_R. You can't useexpressions like <TT>Matrix(X*Y)</TT> in the middle of an expression and<TT>(Matrix)(X*Y)</TT> is unreliable. If you write a function returning amatrix, you MUST use the <A HREF="#memory">ReturnMatrix</A> method described inthis documentation. This is because g++ destroys temporaries occurring in anexpression too soon for the two stage way of evaluating expressions that newmatuses. You will have problems with versions of Gnu earlier than 2.3.1. </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. Newmat09worked without problems with the simulated exceptions; haven't tried thebuilt-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>. Atpresent, I think these can be ignored. </P><P>Here are comments I made in 1997. </P><P>I have tried the library on two versions of HP-UX. (I don't know the versionnumbers, the older is a clone of AT&amp;T 3, the newer is HP's version withexceptions). Both worked after the modifications described in this section. </P><P>With the older version of the compiler I needed to edit the math.h libraryfile to remove a duplicate definition of abs. </P><P>With the newer version you can set the +eh option to enable exceptions andactivate the UseExceptions option in include.h. If you are using my make file,you will need to replace CC with CC +eh where ever CC occurs. I recommend thatyou do not do this and either disable exceptions or use my simulatedexceptions. I get core dumps when I use the built-in exceptions and suspectthey are not sufficiently debugged as yet. </P><P>If you are using my simulated exceptions you may get a mass of errormessages from the linker about __EH_JMPBUF_TEMP. In this case get file setjmp.h(in directory /usr/include/CC ?) and put extern in front of the line </P><PRE>   jmp_buf * __EH_JMPBUF_TEMP;</PRE><P>The file setjmp.h is accessed in my file myexcept.h. You may want to changethe #include statement to access your edited copy of setjmp.h. </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 9 C++ compilers for Windows and for Linux. Standard is automatically switched on for the Linux version and for the Windows version if you are emulating VC++ 7 or higher.</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 workMicrosoft's IDE.</P><P><b>Microsoft Visual C++ 8:</b> I have tested the <i>express</i> version using my make file run the compiler.</P><P><b>Microsoft Visual C++ 7, 7.1:</b> This works OK. Note that all my tests have been in console mode. The standard option is on by default but I am still a bit wary about the namespace option.</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 <i>may</i> be able touse the namespace and standard options but I suggest not using namespace. If you want to work under MFCyou may need to <TT>#include &quot;stdafx.h&quot;</TT> at the beginning of each .cpp file. </P><P><B>Microsoft Visual C++ 5</B>: I have tried this in console mode and itseems to work satisfactorily. There may be a problem with <AHREF="#namesp">namespace</A> (fixed by Service Pack 3?). <B>Turn optimisationoff</B>. Use the compiler supported exceptions. Ifyou want to work under MFC&nbsp;you may need to <TT>#include &quot;stdafx.h&quot;</TT> at thebeginning of each .cpp file.</P><H3>Older versions</H3><P>Microsoft Visual C++ 2.0: This used to work OK. I haven't tried it with recent versions of newmat.</P><P>You must <TT>#define TEMPS_DESTROYED_QUICKLY</TT> owing to a bug in version7 (at least) of MSC. There are some notes in the file <TT>include.h</TT> onchanges to run under version 7. I haven't tried newmat10 on version 7. </P><P>Microsoft Visual C++ 1.51. Disable exceptions, comment out the line ininclude.h <TT>#define TEMPS_DESTROYED_QUICKLY_R</TT>. In <TT>tmt.cpp</TT>,comment out the <TT>Try</TT> and <TT>CatchAll</TT> lines at the beginning of<TT>main()</TT> and the line <TT>trymati()</TT>. You can use the makefile<TT>ms.mak</TT>. You will probably need to break the <A HREF="#testing">tmt</A>test files into two parts to get the program to link. </P><P>If you can, upgrade to windows 95, 98 or window NT and use the 32 bitconsole model. </P><P>If you are using the 16 bit large model, don't forget to keep all matricesless 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 crashwithout warning or explanation. You may need to break the <AHREF="#testing">tmt</A> set of test files into two parts to get the program tofit into your computer. </P><P>Microsoft Visual C++ 4: I haven't tried this - a correspondent reports: Iuse Microsoft Visual C++ Version 4. there is only one minor problem. In allfiles you must include <TT>#include &quot;stdafx.h&quot;</TT> (presumably ifyou are using MFC). This file contains essential information for VC++. Leave itout and you get <I>Unexpected end of file</I>. </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++:</B> The current version works fine with compiler supported exceptions. <B>Sun C++ (version5):</B> There seems to be a problem with exceptions. If you use my simulatedexceptions the non-linear optimisation programs hang. If you use the compilersupported 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 C++:</B> this works fine.</P><H2><A NAME="update"></A>2.5 Updating from previousversions</H2><P CLASS="small"><A HREF="#example">next</A> - <A HREF="#example">skip</A> -<A HREF="#starting">up</A> - <A HREF="#top">start</A></P><P><B>Newmat10</B> includes new <A HREF="#scalar2">maxima, minima</A>,<A HREF="#scalar3">determinant, dot product and Frobenius norm</A> functions, afaster <A HREF="#fft">FFT</A>, revised <A HREF="#make">make</A> files for GCCand CC compilers, several corrections, new <A HREF="#dimen">ReSize</A> function, <a href="#constr">IdentityMatrix</a> and <a href="#binary">Kronecker Product</a>. Singular values from <a href="#svd">SVD</a> are sorted. The program files include a new file, <TT>newfft.cpp</TT>, so youwill need to include this in the list of files in your IDE and make files. There is also a new test file tmtm.cpp.<A HREF="#pointer">Pointer arithmetic</A> now mostly meets requirements ofstandard. You can use <A HREF="#entering">&lt;&lt;</A> to load data into rowsof a matrix. The <A HREF="#custom">default options</A> in include.h have beenchanged. If you are updating from a beta version of newmat09 look through thenext section as there were some late changes to newmat09. </P><P>If you are upgrading from <B>newmat08</B> note the following:</P><UL><LI>Boolean, TRUE, FALSE are now bool, true, false. See<A HREF="#custom">customising</A> if your compiler supports the bool class.</LI><LI>ReDimension is now <A HREF="#dimen">ReSize</A>.  </LI><LI>The <A HREF="#except">simulated exception</A> package hasbeen updated. </LI><LI>Operators <TT>==</TT>, <TT>!=</TT>, <TT>+=</TT>,<TT>-=</TT>, <TT>*=</TT>, <TT>|=</TT>, <TT>&amp;=</TT> are now supported as<A HREF="#binary">binary</A> matrix operators. </LI><LI><TT>A+=f</TT>, <TT>A-=f</TT>, <TT>A*=f</TT>, <TT>A/=f</TT>,<TT>f+A</TT>, <TT>f-A</TT>, <TT>f*A</TT> are supported for <A HREF="#matscal">Amatrix, f scalar</A>. </LI><LI><A HREF="#trigtran">Fast trigonometric transforms</A>.</LI><LI><A HREF="#unary">Reverse</A> function for reversing order ofelements in a vector or matrix. </LI><LI><A HREF="#scalar3">IsSingular</A> function. </LI><LI>An option is included for defining <AHREF="#namesp">namespaces</A>. </LI><LI>Dummy inequality operators are defined for compatibilitywith the STL. </LI><LI>The row/column classes in newmat3.cpp have been modified toimprove efficiency and correct an invalid use of pointer arithmetic. Most userswon't be using these classes explicitly; if you are, please contact me fordetails of the changes. </LI><LI>Matrix LU decomposition rewritten (faster for large arrays).</LI><LI>The sort function rewritten (faster). </LI><LI>The documentation files newmata.txt and newmatb.txt havebeen amalgamated and both are included in the hypertext version. </LI><LI>Some of the <A HREF="#make">make</A> files reorganisedagain. </LI></UL><P>If you are upgrading from <B>newmat07</B> note the following:</P><UL><LI>.cxx files are now .cpp files. Some versions of won't accept.cpp. The <I>make</I> files for Gnu and AT&amp;T link the .cpp files to .cxxfiles before compilation and delete the links after compilation.  </LI><LI>An <A HREF="#custom">option</A> in include.h allows you touse compiler supported exceptions, simulated exceptions or disable exceptions.Edit the file include.h to select one of these three options. Don't simulateexceptions if you have set your compiler's option to implement exceptions.</LI><LI>New <A HREF="#qr">QR decomposition</A> functions.  </LI><LI>A <A HREF="#nonlin">non-linear least squares</A> class.</LI><LI>No need to explicitly set the AT&amp;T option in include.h.</LI><LI><A HREF="#binary">Concatenation and elementwisemultiplication</A>. </LI><LI>A new <A HREF="#unspec">GenericMatrix</A> class.  </LI><LI><A HREF="#scalar3">Sum</A> function. </LI><LI>Some of the <A HREF="#make">make</A> files reorganised.</LI></UL><P>If you are upgrading from <B>newmat06</B> note the following:</P><UL><LI>If you are using &lt;&lt; to load a Real into a submatrixchange this to =. </LI></UL><P>If you are upgrading from <B>newmat03</B> or <B>newmat04</B>note the following </P><UL><LI>.hxx files are now .h files </LI><LI>real changed to Real </LI><LI>BOOL changed to Boolean </LI><LI>CopyToMatrix changed to AsMatrix, etc </LI><LI>real(A) changed to A.AsScalar() </LI></UL><P>The current version is quite a bit longer that newmat04, soif you are almost out of space with newmat04, don't throw newmat04 away untilyou have checked your program will work under this version. </P><P>See the <A HREF="#changes">change history</A> for other changes. </P><h2><a name="except_1"></a>2.6 Catching exceptions</h2><P>This section applies particularly to people using <i>compiler supported</i>exceptions rather than my <i>simulated</i> exceptions. </P><P>If newmat detects an error it will throw an exception. It is important thatyou catch this exception and print the error message. Otherwise you will get anunhelpful message like <i>abnormal termination</i>. I suggest you set up yourmain program like&nbsp; </P><pre>#define WANT_STREAM             // or #include &lt;iostream&gt;#include &quot;include.h&quot;            // or #include &quot;newmat.h&quot;#include &quot;myexcept.h&quot;main(){   try   {      ... your program here   }   // catch exceptions thrown by my programs   catch(Exception) { cout &lt;&lt; Exception::what() &lt;&lt; endl; }   // catch exceptions thrown by other people's programs   catch(...) { cout &lt;&lt; &quot;exception caught in main program&quot; &lt;&lt; endl; }   return 0;}</pre><P>If you are using a GUI version rather a console version of the program youwill need to replace the <i>cout </i>statements by windows pop-up messages.</P><P>If you are using my simulated exceptions or have set the disable exceptionsoption in <i>include.h</i> then uncaught exceptions automatically print theerror message generated by the exception so you can ignore this section.Alternatively use <i>Try</i>, <i>Catch</i> and <i>CatchAll</i> in place of <i>try</i>, <i>catch</i>and <i>catch(...)</i> in the preceding code. It is probably a good idea to dothis if you are using a GUI version of the program as opposed to a consoleversion as the <i>cout </i>statement used in newmat's <i>Terminate</i> functionmay be ignored in a GUI version.</P><P>See the <a href="#except">section on exceptions</a> for more information onthe exception structure. </P><H2><A NAME="example"></A>2.7 Example</H2><P CLASS="small"><A HREF="#testing">next</A> - <A HREF="#testing">skip</A> -<A HREF="#starting">up</A> - <A HREF="#top">start</A></P><P>An example is given in <TT>example.cpp</TT>. This gives a simple linearregression example using five different algorithms. The correct output is givenin <TT>example.txt</TT>. The program carries out a rough check that no memoryis left allocated on the heap when it terminates. See the section on<A HREF="#testing">testing</A> for a comment on the reliability of this check(generally it doesn't work with the newer compilers) and the use of theDO_FREE_CHECK option. </P><P>I include a variety of make files. To compile the example use a command like</P><pre>   gmake -f nm_gnu.mak example              (Gnu G++)   gmake -f nm_cc.mak example               (AT&amp;T, HPUX, Sun)   make -f nm_b55.mak example.exe           (Borland C++ 5.5)</pre><p>You can generate make make files for a number of other compilers with my<a href="genmake.htm">genmake</a> utility.</p><P>To compile all the example and test files use a command like </P><PRE>   gmake -f nm_gnu.mak                      (Gnu G++)</PRE><P>  The example uses io manipulators. It will not work with acompiler that does not support the standard io manipulators. </P><P>Other example files are <TT>nl_ex.cpp</TT> and <TT>garch.cpp</TT> fordemonstrating the non-linear fitting routines, <TT>sl_ex</TT> for demonstratingthe solve function and <TT>test_exc</TT> for demonstrating the exceptions. </P><H2><A NAME="testing"></A>2.8 Testing</H2><P CLASS="small"><A HREF="#bugs">next</A> - <A HREF="#bugs">skip</A> -<A HREF="#starting">up</A> - <A HREF="#top">start</A></P><P>The library package contains a comprehensive test program in the form of aseries of files with names of the form tmt?.cxx. The files consist of a largenumber of matrix formulae all of which evaluate to zero (except the first onewhich is used to check that we are detecting non-zero matrices). The printoutshould state that it has found just one non-zero matrix. </P><P>The test program should be run with <I>Real</I> typedefed to <I>double</I>rather than <I>float</I> in <A HREF="#custom">include.h</A>. </P><P>Make sure the <A HREF="#elements">C subscripts</A> are enabled if you wantto test these. </P><P>If you are carrying out some form of bounds checking, for example, withBorland's <I>CodeGuard</I>, then disable the testing of the <A

⌨️ 快捷键说明

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