home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!usc!news!benton.prepress.com!bob
- From: bob@prepress.com (Robert Crowe)
- Newsgroups: comp.sys.sgi
- Subject: Re: matrix class in C++
- Message-ID: <1992Nov18.235738.12736@prepress.com>
- Date: 18 Nov 92 23:57:38 GMT
- Article-I.D.: prepress.1992Nov18.235738.12736
- References: <34113@adm.brl.mil> <1992Nov17.050752.14929@odin.corp.sgi.com>
- Organization: Pre-Press Technologies, Carlsbad Ca.
- Lines: 292
-
- In article <1992Nov17.050752.14929@odin.corp.sgi.com> ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz) writes:
- >In article <34113@adm.brl.mil>, rose@baby.swmed.utexas.edu (Rose Oguz) writes:
- >|> I haven't seen any mention of a matrix class in C++. I have no information
- >|> that tells me that there should be. I just assume that matrices/2D arrays
- >|> are commonly used and there would a class definition. All I have found is
- >|> a complex class and a vector class. Any chance that I missed the matrix
- >|> class?
- >|>
- >|> Rose
- >|>
- >
- >Nope, there isn't one. Some people out there may have written some but there
- >isn't one that comes with the C++ compiler. The Vector and Complex classes
- >are just traditional C++ classes that were created by AT&T to demonstrate
- >classes as much as anything else. It is pretty obvious how a Complex class
- >can be used to demonstrate overloading of operators such as operator+().
- >Notice that the term "vector" is use more in a data structure sense by the
- >Vector classes than in the sense of a vector used in linear algebra. I think
- >the name was chosen to avoid confusion with intrinsic "array" structures.
- >
- >Writing your own Matrix class was left as an exercise to the user by
- >Stroustrup and company.
- >
-
- There is in fact a package called newmat, which is a matrix package
- written in c++. I believe it has been posted to one of the sources
- newsgroups, but I'm not certain which one. Instructions for obtaining
- follow below.
-
- Following is the top portion of the documentation that comes with the
- package. I didn't include the whole thing because it is quite lengthy,
- and contains details that the average net-reader won't be interested in.
-
-
- Please note that I have nothing to do with the production of this
- package, I just use it occasionally.
-
- P.S. Im not sure if this is from the most recent version of newmat.
- I think the current rev is 04, not 03.
-
-
- --------- Top portion of newmat.txt follows -----------
- //$$ newmat.txt Documentation file
-
-
- Documentation for newmat03, an experimental matrix package in C++.
- ==================================================================
-
-
- MATRIX PACKAGE 25 November, 1991
-
- Copyright (C) 1991: R B Davies and DSIR
-
- Permission is granted to use but not to sell.
-
-
- Contents
- ========
-
- General description
- Is this the package you need?
- Changes
- Where you can get a copy of this package
- Compiler performance
- Example
- Detailed documentation
- Customising
- Constructors
- Elements of matrices
- Matrix copy
- Unary operators
- Binary operators
- Combination of a matrix and scalar
- Scalar functions of matrices
- Submatrix operations
- Change dimensions
- Change type
- Multiple matrix solve
- Memory management
- Output
- Accessing matrices of unspecified type
- Cholesky decomposition
- Householder triangularisation
- Singular Value Decomposition
- Eigenvalues
- Sorting
- Fast Fourier Transform
- Interface to Numerical Recipes in C
- List of files
- Notes on the design of the package
- What this is package for
- What size of matrices?
- Allow matrix expressions?
- Which matrix types?
- What element types?
- Naming convention
- Row and Column index ranges
- Structure of matrix objects
- Data storage - one block or several
- Data storage - by row or by column or other
- Storage of symmetric matrices
- Element access - method and checking
- Use iterators?
- Memory management - reference counting or status variable?
- Evaluation of expressions - use two stage method?
- How to overcome an explosion in number of operations
- Using const
- A calculus of matrix types
- Error handling
- Band and sparse matrices
- Problem report form
-
-
- ---------------------------------------------------------------------------
-
-
- General description
- ===================
-
- The package is intented 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.
-
- It supports matrix types
-
- Matrix (rectangular matrix)
- nricMatrix (variant of rectangular matrix)
- UpperTriangularMatrix
- LowerTriangularMatrix
- DiagonalMatrix
- SymmetricMatrix
- RowVector (derived from Matrix)
- ColumnVector (derived from Matrix).
-
- Only one element type (float or double) is supported.
-
- The package includes the operations *, +, -, inverse, transpose,
- conversion between types, submatrix, determinant, Cholesky
- decomposition, Householder triangularisation, singular value
- decomposition, eigenvalues of a symmetric matrix, sorting, fast fourier
- transform, printing and an interface with "Numerical Recipes in C".
-
- It is intended for matrices in the range 4 x 4 to about 90 x 90 (125 x
- 125 for triangular matrices). The upper limit is imposed by the maximum
- number of elements that can be contained in a single array (8192 doubles
- in some machines).
-
- A two-stage approach to evaluating matrix expressions is used to improve
- efficiency and reduce use of temporary storage.
-
- The package is designed for version 2 of C++. It works with Turbo C++,
- Borland C++, Glockenspiel C++ (2.00a) on a PC and AT&T C++ (2.0) and Gnu
- C++ on a Sun. It works with some problems with Zortech C++ (version 2).
-
-
- ---------------------------------------------------------------------------
-
-
- Is this the package you need?
- =============================
-
- Do you
-
- 1. need matrix operators such as * and + defined as operators so you
- can write things like
-
- X = A * (B + C);
-
- 2. need a variety of types of matrices
-
- 3. need only one element type (float or double)
-
- 4. work with matrices in the range 4x4 to 90x90
-
- 5. tolerate a large and complex package
-
-
- Then maybe this is the right package for you.
-
- If you don't need (1) then there may be better options. Likewise if you
- don't need (2) there may be better options. If you require "not (5)"
- then this is not the package for you.
-
-
- If you need (2) and "not (3)" and have some spare money, then maybe you
- should look at M++ from Dyad or the Rogue Wave matrix package.
-
-
- ---------------------------------------------------------------------------
-
-
- Changes
- =======
-
- Newmat03 - November 1991:
-
- Col and Cols become Column and Columns. Added Sort, SVD, Jacobi,
- Eigenvalues, FFT, real conversion of 1x1 matrix, "Numerical Recipes in
- C" interface, output operations, various scalar functions. Improved
- return from functions. Reorganised setting options in "include.hxx".
-
-
- Newmat02 - July 1991:
-
- Version with matrix row/column operations and numerous additional
- functions.
-
-
- Matrix - October 1990:
-
- Early version of package.
-
-
- ---------------------------------------------------------------------------
-
-
- How to get a copy of this package
- =================================
-
- I am putting copies on Compuserve (Borland library, zip format),
- SIMTEL20 (MsDos library, zip format), comp.sources.misc on Internet
- (shar format), and on the MsDos program library at Victoria University,
- Wellington.
-
-
- ---------------------------------------------------------------------------
-
-
- Compiler performance
- ====================
-
- I have tested this package on a number of compilers. Here are the
- levels of success with this package. 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 MsDos
- versions, I am using a 386/387sx computer running MsDos 5, except that
- Turbo is on an old XT. The unix versions are on a Sun Sparc station.
-
- A series of #defines at the beginning of "include.hxx" customises the
- package for the compiler you are using. Turbo, Borland and Zortech are
- recognised automatically, otherwise you have to set the appropriate
- #define statement.
-
- The compilers are looking a bit old now. I do intend to test the package
- against newer versions as they become available.
-
- Borland C++ 2.0: Recently, this has been my main development platform,
- so naturally almost everything works with this compiler. The library
- manager "tlib" fails but you can use "zorlib" from Zortech instead.
- Sometimes Borland crashes during a compiler or mis-compiles. You just
- have to reboot and continue the compile.
-
- Turbo C++ (? version): Almost works OK. My rather elderly version does
- show a problem. Probably not worth tracking down - buy a newer version.
- Haven't tried the linker.
-
- Zortech C++ 2.12: "const" doesn't work correctly with this compiler, so
- the package skips all of the statements Zortech can't handle. If you are
- using a later version of Zortech you could probably re-activate these
- statements. Zortech leaves rubbish on the heap. I don't know whether
- this is my programming error or a Zortech error. It works better when
- one doesn't optimise but there still are problems. The nric routines
- don't work. Zortech does not support IO manipulators.
-
- Glockenspiel C++ (2.00a for MsDos loading into Microsoft C 5.1): I
- haven't tested the latest version of my package with Glockenspiel. I had
- to #define the matrix names to shorter names to avoid ambiguities and
- had quite a bit of difficulty stopping the compiles from running out of
- space and not exceeding Microsoft's block nesting limit. A couple of my
- test statements produced statements too complex for Microsoft, but
- basically the package worked. This was my original development platform
- and I still use .cxx and .hxx as my file name extensions. However,
- Glockenspiel is no longer competitive for MsDos and I am not updating my
- copy of the compiler.
-
- Sun AT&T C++ 2.00: This works fine. Except aggregates are not supported.
-
- Gnu G++ 1.37.1: This mostly works. You don't seem to be able to use
- expressions like Matrix(X*Y) in the middle of an expression and
- (Matrix)(X*Y) is unreliable. Gnu does not support IO manipulators. Gnu
- leaves rubbish on the heap. This is from output statements and not my
- package and may not be an error. The previous version of the package did
- not work under Gnu 1.37 or 1.39.
-
-
- --
- ============================================================
- Bob Crowe Voice: (619) 931-2695
- Pre-Press Technologies. Email: bob@prepress.com
- 2443 Impala dr. FAX: (619) 931-2698
-