Bug list and notes

Last updated 22 December 2016

To online documentation page

To home page

Newmat10, newmat11

The syntax for the code for entering values into a matrix is incompatible with the current version of the C++ standard: "you must not throw an exception from a destructor". This is fixed in newmat10 with the fix for newmat11 to come.


In G++ version 4.4 and probably other compilers remove // from the beginning of the line

   //#define _STANDARD_ // using standard library 

in include.h.

String Manipulation Library and programs that use this (newran03, genmake)

This won't compile under G++ version 4.4. You get an error message that 'EOF' is not recognised. Insert a line

   #include <cstdio>

in str.cpp.

Gnuplot interface

Reported by a user: there is a conflict between my Gnuplot interface and Gnuplot 4.4 under Linux. In gnuplot.cpp you need to replace lines like

   { String S = String("lines ") + Colour; return S; }


   { String S = String("lines lc ") + Colour; return S; }

and lines like

   { String S = String("points ") + Colour + String(" ") + Shape; return S; }


   { String S = String("points lc ") + Colour + String(" ps ") + Shape; return S; }

There are 10 lines to be fixed.

String Manipulation Library

It has been pointed out to me that my string manipulation library differs from the standard library in its handling of String(const char* s, uint n). I take the length of the string as the minimum of strlen(s) and n whereas I should take it as n.  This means that, according to the standard if strlen(s) is less than n then the constructed String will be of length n and will include the 0 byte that concluded the string starting at s. There are similar differences in the corresponding assign, append, insert, replace, find and compare functions.

Newmat10 and Newmat11 - LnMinimum and LnMaximum

These are calculated in precisio.h and are used for checking whether exp(x) will overflow or underflow. They are not calculated correctly by some compilers. LnMinimum is never used in Newmat and LnMaximum is used only for checking whether an overflow will occur before the value of a determinant is calculated. You can see if there is a problem with your compiler by running the example program nm_ex3.cpp included with newmat11.

Borland C++ 2006

Activate the line #define ios_format_flags ios::fmtflags in include.h.

Gnu G++ and 64 bits

The random number generator that I use to generate test data in newmat11 doesn't work correctly under some circumstances with the 64 bit option of G++. This causes a crash in the tmt9.cpp test program. This issue also affects the multiply-with-carry generator in newran03. Contact me if you need the fix. Hopefully fixed in 20 July, 2008 versions.

Gnu G++ 4.1.0

There is an incompatibility in some of my libraries including Newmat with Gnu G++ 4.1.0 that comes with Fedora 5 Linux. I'll load updates soon, email if you need them now - hopefully all fixed now (23 April, 2006).

Microsoft VC++ in GUI mode

You may find a problem with any of my C++ libraries due to the use of cout in myexcept.cpp. You need to comment out the line #define WANT_STREAM and the insides of void Tracer::PrintTrace() and write a pop-up window to deliver an error message and then to exit to replace the contents of void Terminate().  It seems possible to get subtle and hard to track problems if you don't do this.

Newmat11 on Visual C++ Toolkit 2003

This is from a user.

Visual C++ Toolkit 2003 is available for free at <http://msdn.microsoft.com/visualc/vctoolkit2003/>. Because this toolkit does not include the nmake or lib commands, you need to download nmake from the MS Knowledge Base at <http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084> and change the "lib" command in NM_M6.MAK to "link -lib". Then, newmat11 beta builds with "nmake -f nm_m6.mak", and I've used newmat without any problems.

Newmat11 on DJGPP

This is from a user.

DJGPP is a version of GCC for DOS and Windows that is available for free at <http://www.delorie.com/djgpp/getting.html>. Download the files:
Unzip all the files into C:\DJGPP, set environment variable DJGPP=C:\DJGPP\djgpp.env, and add C:\DJGPP\bin to the PATH environment variable. Change the "g++" command in NM_GNU.MAK to "gxx". Then, newmat11 beta builds with "make -f nm_gnu.mak", and I've used newmat without any problems with gcc 4.0.1 and gcc 3.4.4 using DJGPP, and with gcc 3.1 on Solaris.

Newran03 seed

If you are using the Mother uniform generator don't set the seed = 0.5, fixed 28 September, 2005.

Newmat conflict with some Windows include files

This is a user report. At least one file you include (windows.h, windef.h?) when you are compiling Windows programs #define max and min. This causes conflicts with my precision.h under VC++ 7. See http://www.codecomments.com/archive373-2005-4-450048.html for solutions.

MatrixType in newmat10 and newmat11

In section 3.8 the documentation says: "MatrixType mt = A.Type() returns the type of a matrix. Use (char*)mt to get a string (UT, LT, Rect, Sym, Diag, Band, UB, LB, Crout, BndLU) showing the type (Vector types are returned as Rect)." That should read mt.Value() rather than (char*)mt.

Missing boolean.h file

Some combinations of my libraries, when compiled with my make files will give an error message, missing boolean.h file. The simplest fix is to download newmat10 and copy boolean.h from its files. I think this should be fixed now.

Intel C++ compiler, version 8.1 for Linux for 32 bit processors

If you are using my make files or make files generated by my genmake program you need to replace the first line in the make file by

CXX = icpc


Microsoft Visual C++ version 7.1 and Newmat

A user reports a problem with

LinearEquationSolver::LinearEquationSolver(const BaseMatrix& bm)
   : gm( ( ((BaseMatrix&)bm).Evaluate() )->MakeSolver() )

in newmat8.cpp. Replace this with

LinearEquationSolver::LinearEquationSolver(const BaseMatrix& bm)
   gm = ( ((BaseMatrix&)bm).Evaluate() )->MakeSolver();

Newmat - float version.

If you have selected the option #define USING_FLOAT in include.h, statements like

Matrix A(2,2); A << 3.4 << 2.1 << 4.5 << 5.1;

will not work. Instead use

Matrix A(2,2); A << 3.4f << 2.1f << 4.5f << 5.1f;

Even if you make this change throughout the tmt set of test files, tmt will not run to completion on a computer that uses 32 bits for type float since 32 bits does not provide enough precision for some of the tests.

The problem with input using << is fixed in the 19 June 2004, version.

Microsoft Visual C++ version 7.1 (the version that comes with .NET 2003)

Activate the line #define _STANDARD_ in include.h.

There is a conflict with my format program that comes with my string library and newran03. Delete the lines

friend OstreamWithFormat operator<<(ostream& osx, const Format& fx)
   { return OstreamWithFormat(osx, fx); }
in format.h and insert the lines
inline OstreamWithFormat operator<<(ostream& osx, const Format& fx)
   { return OstreamWithFormat(osx, fx); }
at the end of format.h just above #ifdef use_namespace.

Problem with format.h fixed in 19 June, 2004 version.

Newmat conflict with GCC 3.4

In the definition of class GetSubMatrix in newmat.h, you may need to move the copy constructor  (i.e. the 3 lines including and following GetSubMatrix(const GetSubMatrix& g)) to the public part of the class definition. Hopefully fixed in March 28, 2004 version. Fixed in newmat10B, 1 January, 2005.

SymmetricBandMatrix problem.

SymmetricBandMatrix SBM; Matrix M = SBM; will crash. It's OK if SBM has be given a non-zero size. Fixed in the December 29, 2003 version of Newmat 11.

Intel C++ compiler, versions 7 and 8, for Linux.

Please see http://newweb.ices.utexas.edu/misc/ctype.c when trying compile my programs (or anyone else's) under Redhat 9 Linux with the Intel C++ compiler, version 7.

There was a problem with exceptions with the Intel C++ compiler for Linux, version 8. Fixed in the version of the compiler released at the end of January, 2004.

Newmat11 with Intel version 7 or Visual C++ version 7

There is a problem when namespace option is set. Also a user found an incompatibility with Visual C++ 7 with Matrix A; ... A = 10 + A; possibly due to Microsoft's implementation of namespace. I haven't been able to reproduce this on my system. Hopefully both of these are fixed in the November 18, 2003 version of Newmat.

Newmat with Sun CC

The SVD routine fails if the option -fns = yes is set. It works correctly if -fns = no (the default).

Newmat is picking up an incorrect value for the minimum non-zero floating point value from value.h. The work-around is to activate (i.e. remove // from the beginning of the line) either of the lines

   #define _STANDARD_ 


   #define use_float_h 

near the beginning of include.h.


Problem with Release function in all versions of Newmat

The following program causes an invalid pointer to be accessed (Hopefully, fixed in April 28, 2003 version of Newmat11).

   Matrix M = something;
   Matrix M1 = M;
   Matrix X = M;      // M is not in a valid state.

While the last line would be an unusual thing to do there are situations where it would be reasonable for M to be accessed and which would lead to the invalid pointer access.

Workaround is to do


before the last statement.

Borland Builder 5 & 6 and returning a matrix from a function in Newmat11 (& Newmat10A?).

I have an inline member function returning a matrix as its function value. If I throw an exception after running this function I may get a "Memory could not be read"  application error. Everything is fine if I use the ReturnMatrix construct. Builder seems to be generating an extra destruct call. This appears to be a bug in Borland Builder 5 and 6 and is not present in the other compilers I have tested. I have put a demonstration example of the bug at the end of this file.

Kronecker Product

There is a bug in the Kronecker Product (KP) function in newmat10 and newmat11. This occurs in KP(A, B) where A is diagonal or band and B is not square (fixed in October 2002 versions of newmat10A and newmat11).

Newmat make file for Gnu G++ on Mac OS 10.1.5

You may need to change the line

   $(AR) cr $@ $(newmat_lobj)


   $(AR) -r $@ $(newmat_lobj)

(fixed in October 2002 versions of newmat 10A and 11?).

Multi-threading and Newmat

I have not tested Newmat or any of my other libraries in a multi-threaded environment and do not know how to do this.

One correspondent says there are problems with random crashing, possibly due to mishandling of virtual destructs, with Newmat on a two processor system when compiled with VC++6 and VC++.NET.

I have tried to make Newmat thread-safe but there are a couple of issues that I know about:

Some of my other libraries - such as the String library - are not thread-safe and are unlikely ever to be thread safe.

Newmat and Microsoft VC++6

If you are setting the Standard option in include.h also include the line

   #include <limits>

in include.h.

Also replace fstream.h by fstream at the beginning of garch.cpp. (automatic in October 2002 versions of newmat10A and newmat11).

Newmat and Borland Builder 6

There is a problem with compiling Newmat10 with Borland C Builder 6. I have put a beta version of newmat11 on the website. You should use this with Borland C Builder 6.

Newran02 and Microsoft Visual C++ 6

You get slightly different answers from Newran02 under MS Visual C++ when optimisation is on. This is probably due to round-off error being different under optimisation and is more of a nuisance than a problem.

Newmat10 and Gnu G++ 3 or Intel 5 for Linux

You get a compilation error in newmat9.cpp. I suggest you comment out the statement s.flags(f);.

Or try putting this line in include.h:

   #define _Ios_Fmtflags ios::fmtflags // for Gnu 3 and Intel for Linux

Fixed in the October 2002 versions of newmat10A and newmat11.

Abnormal termination and exceptions

If you are using the compiler's built-in exceptions make sure you you are able to catch any exceptions thrown by my libraries. Otherwise you are likely to get a very unhelpful message like abnormal termination if any of my functions throw an exception. I suggest you make your main program look like

   #define WANT_STREAM             // or #include <iostream>
   #include "include.h"            // or #include "newmat.h"
   #include "myexcept.h"

         ... your program here
      // catch exceptions thrown by my programs
      catch(Exception) { cout << Exception::what() << endl; }
      // catch exceptions thrown by other people's programs
      catch(...) { cout << "exception caught in main program" << endl; }
      return 0;

If you are using a GUI version rather a console version of the program you will need to replace the cout statements by windows pop-up messages.

If you are using my simulated exceptions or have set the disable exceptions option in include.h then uncaught exceptions automatically print the error message generated by the exception so you can ignore this note. Otherwise use Try, Catch and CatchAll in place of try, catch and catch(...) in this example. (You might want do this if you are using a GUI version of the program as opposed to a console version as cout statement used in newmat's Terminate function may be ignored in a GUI version and this construction avoids calling the Terminate function).

MS Visual C++ 5

If you are using this in Release mode with any of my programs turn off the optimisation. This is noted in the documentation for newmat09, but you may have missed it. In MS Developer Studio go to Project - Settings - C/C++ and set Optimizations to default. This problem seems to be fixed in version 6.

Having problems with compiling and linking?  See my page on compiling with Visual C++.

MS Visual C++ 6

Install service pack 2 or higher if you want to use namespace. Preferably install the latest service pack.

Having problems with compiling and linking?  See my page on compiling with Visual C++.

Borland C++ version 5.5, Borland Builder 4,5

Turn off the Borland option to use pre-compiled headers.

Having problems with compiling and linking?  See my page on compiling with Borland Builder 5.

Codewarrior, Intel for Linux and maybe others

Some compilers do not have a file values.h but do have float.h. Newmat uses one of these files for determining the precision of arithmetic of your computer. This will be a problem if your compiler is not recognised by the options in include.h. If your compiler is not recognised by one of the options in include.h and you get a message that the compiler can't find values.h then activate the line

   #define use_float_h                   // use float.h for precision data

in include.h. Alternatively you might try activating the standard library by activating the line

   #define _STANDARD_                    // using standard library

MINGW-32 port of GCC.

 You may need to modify gnu.mak. Include a line AR = ar near the beginning and delete the -lm option.

Gnuplot interface

This doesn't work with recent versions of gnuplot for windows. You need to use a forward slash to separate the parts of a file name (or 4 back slashes) when you define TemporaryDirectory and in the definition of the FILE SEPARATOR in gnuplot.cpp. Fixed in July 2001 version.

String library and Gnuplot interface

This applies to Borland users and maybe to others. Make sure the string library appears before the gnuplot interface library in the list files in the IDE. Otherwise you will get a runtime error when the program closes. Hopefully this is fixed in the August 1998 version of the string library.

Automatic differentiation library

The second derivative of Real-x was wrongly calculated. Corrected in the 1 August, 1999 version.


To online documentation page

To home page


Notes relevant to Newmat09 and beta versions of Newmat10

Don't read this - upgrade to the latest version of newmat10!

LowerBandMatrix ReSize

Applying ReSize to a LowerBandMatrix fails (fixed in 17 January, 2002 version).

Submatrices of symmetric matrices

The following code throws an exception

   SymmetricMatrix A(10,10);
   A = something
   SymmetricMatrix B(20,20);
   B.SubMatrix(1,10,1,10) = A;

Replace the last line with

   B.SubMatrix(1,10,1,10) << A;

(Fixed in release version of newmat10).

SVD routine

The current version of newmat does not sort the singular values in the SVD routine - fixed in 7 Dec. 2001 version of newmat10.

Newmat10 data entry

The construction

    Matrix A(2,2);
    A.Row(1) << 11 << 12;
    A.Row(2) << 21 << 22;

works only with square matrices - fixed in 7 Dec. 2001 version of newmat10.

Also note that if the first entry in the list on the left hand side is 0 you should enter it as 0.0 - fixed in 7 Dec. 2001 version of newmat10.

Gnu G++ 3.01


   #ifndef _Ios_Fmtflags
   #define _Ios_Fmtflags long

at the beginning of newmat9.cpp and in line 4 of ostream& operator<<(ostream&s, const GeneralMatrix& X) replace long f = s.flags(); by _Ios_Fmtflags f = s.flags();

 Fixed in 7 Dec. 2001 version of newmat10?

Gnu G++ under Windows and newmat

Function Jacobi in newmat causes a crash under gcc version 2.95.3-5 under cygwin. The problem is the return statement from inside the main loop. Use a break and with a boolean to show that convergence has been achieved.

There seems to be a problem with gcc under cygwin when heap usage exceeds about 256 megabytes. Attempts to exceed this heap size causes your program to crash.

MS Visual C++ 6

With newmat10 (before December, 2000 version) you may need to edit tmtb.cpp, line 45 to

   ReturnMatrix TestClass::Sum() { return Matrix(A + B).ForReturn(); }

Borland C++ version 5.5, Borland Builder 4,5

Version 5.5 is the free C++ compiler available from Borland's web site. These comments apply particularly to newmat10 but may be relevant to others of my programs. If you are using newmat09 I suggest you switch to newmat10. Make sure you have the latest version. Some of these comments also apply to Borland Builder versions 4 and 5.

If you are using Borland Builder version 4 and are compiling in console mode using the Borland IDE and the console wizard see the special instructions in the newmat10 documentation under Getting started/Compiler performance/Borland.

If you are using Borland Builder version 5 turn off the Borland option to use pre-compiled headers.


VC6++ in debug mode (probably also affects other compilers and Newmat09) may crash when an exception is thrown. Edit function void GeneralMatrix::Eq(const BaseMatrix& X, MatrixType mt) by adding statement store = 0; after the statements storage = 0; Fixed in January, 18, 2001 version.



Please make sure your version is dated September, 1997. Some people are still using an earlier beta version. Look for the date at the beginning of newmat.txt. But I suggest you update to the newmat10 as this has a number of fixes and improvements.

Vectors with zero length

The following code throws an exception

   RowVector RV1; RowVector RV2; RV2 = RV1;

with a similar problem with column vectors. If this a problem replace the default constructors for RowVector and ColumnVector in newmat.h with

   RowVector() { nrows = 1; }
   ColumnVector() { ncols = 1; }

Codewarrior and maybe others. Some compilers do not have a file values.h but do have float.h. Newmat uses one of these files for determining the precision of arithmetic of your computer. This will be a problem if your compiler is not recognised by the options in include.h. If your compiler is not recognised by one of the options in include.h and you get a message that the compiler can't find values.h then include a new section in include.h:

   #ifdef use_float_h // use float.h for precision values
   #include <stdlib.h>
   #ifdef WANT_STREAM
   #include <iostream.h>
   #include <iomanip.h>
   #ifdef WANT_MATH
   #include <float.h>
   #include <math.h>

and #define use_float_h at the beginning of include.h.

Standard template library and newmat09. As noted in the documentation do not use my simulated exceptions if you want to store matrices in the standard template library containers. Also make sure that the DO_FREE_CHECK option is not activated.

EGCS 1.1. A user reports that this does not work with my eigenvalue class (although 1.03 did work). But another user reports no problems (with either 1.03 or 1.1b). It works in my tests in the version that comes with Linux (Red Hat 6). EGCS is the experimental offshoot of GCC so perhaps you shouldn't expect everything to work.

GenericMatrix: The following lines may fail.

   GenericMatrix GM;
   ... put some values in GM
   Matrix M1; M1 = GM;                    // may give wrong answers or crash program
   Matrix M2 = GM;                        // may give wrong answers or crash program

This will be fixed in the next version, meanwhile you can use

   Matrix M1; M1 = GM + 0;                // works correctly
   Matrix M2 = GM + 0;                    // works correctly

Gnu GCC users: I have put a revised version of newmat.h on the ftp site. With this version newmat09 will compile with GCC 2.7.2 with optimisation turned on. Thanks to Bernd Wuebben for showing me what needed to be done. Bernd has made a number of other suggestions for getting rid of warning messages under -Wall which I will incorporate in a later version. Warning: if you are using a beta version of newmat09 you will need to update to the September, 1997 version to use this update.

FFT: There is an error in fft.cpp. Lines 198-205 should be

   int after = 1; int before = n; int next = 0; bool inzee = true;
   int now = 0; int b1;             // initialised to keep gnu happy
      for (;;)
	 if (next < nextmx) now = prime[next];

The current version seems to work with all the compilers I have access to but this certainly can't be guaranteed.

DCT_II and DST_II: The definitions in the documentation should be

   v[k] = SUM { u[j] cos (pi (j+1/2)k/m) }
   v[k] = SUM { u[j] sin (pi (j-1/2)k/m) }

Complex: The matrix in the last section in the documentation should be

    /  X   Y \
    \ -Y   X / 

GCC 2.95 users: You may need to set the compiler option


You may need to edit line 148 in newmat.h

   static int nTypes() { return 9; }    // number of different types
                                        // exclude Ct, US, BC

LogAndSign: In some versions of the documentation this is referred to as LogandSign.


To online documentation page

To home page


Compiler notes

These are further notes on compiler bug described above

Borland Builder 5 and 6

The following program shows Builder trying to delete a non-existent object.  

// example illustrating problem with Borland compilers

#include <iostream.h>

class my_exception

// Simple class with constructor, default constructor, copy
// constructor and operator=

class CV
   int ID;
   CV(int id);                   // create object with given ID
   CV();                         // create object with ID = 10
   CV(const CV& cv);             // copy constructor, increase ID by 100 
   void operator=(const CV& cv); // operator=, increase ID by 1000 

CV::CV(int id) : ID(id)
   cout << "CV created with id = " << ID << "\n";

   ID = 10;
   cout << "CV created with default id = " << ID << "\n";

CV::CV(const CV& cv)
   ID = cv.ID + 100;
   cout << "CV created by cc with new id = " << ID << "\n";

void CV::operator=(const CV& cv)
   ID = cv.ID + 1000;

   cout << "CV destroyed with id = " << ID << "\n";

// class SS; stores a CV
// can recover this CV with inline function get_X

class SS
   CV X;
   CV get_X() const { return X; }              //<----

int main()
      CV cv1(2);
      SS ss;
      cout << "Call get_X\n";
      CV Z1 = ss.get_X();
      cout << "Throw exception\n";
      throw my_exception();                     //<----
      CV cv4(4);
   catch(...) { cout << "Catch exception\n"; }
   return 0;

The output looks like this

CV created with id = 2
CV created with default id = 10
Call get_X
CV created by cc with new id = 110
Throw exception
CV destroyed with id = 4206616
CV destroyed with id = 110
CV destroyed with id = 10
CV destroyed with id = 2
Catch exception

The 6th line shouldn't be there.

The problem seems to be due to an interaction between the inline statement in the SS object and the exception throw in the main program.

I have the problem with both Borland Builder 5 and 6. I am compiling a console program either in release mode or debug mode (but with the disable inline option not set). With some variations of the program the extra destruct call will cause the program to crash, in others execution will continue as in the current example.

The problem does not occur with other compilers that I have tested this on.


To online documentation page

To home page