home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / sgi / 16634 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  10.6 KB

  1. Path: sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!usc!news!benton.prepress.com!bob
  2. From: bob@prepress.com (Robert Crowe)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: matrix class in C++
  5. Message-ID: <1992Nov18.235738.12736@prepress.com>
  6. Date: 18 Nov 92 23:57:38 GMT
  7. Article-I.D.: prepress.1992Nov18.235738.12736
  8. References: <34113@adm.brl.mil> <1992Nov17.050752.14929@odin.corp.sgi.com>
  9. Organization: Pre-Press Technologies, Carlsbad Ca.
  10. Lines: 292
  11.  
  12. In article <1992Nov17.050752.14929@odin.corp.sgi.com> ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz) writes:
  13. >In article <34113@adm.brl.mil>, rose@baby.swmed.utexas.edu (Rose Oguz) writes:
  14. >|> I haven't seen any mention of a matrix class in C++.  I have no information
  15. >|> that tells me that there should be.  I just assume that matrices/2D arrays
  16. >|> are commonly used and there would a class definition.  All I have found is
  17. >|> a complex class and a vector class.  Any chance that I missed the matrix
  18. >|> class?
  19. >|> 
  20. >|> Rose
  21. >|> 
  22. >
  23. >Nope, there isn't one.  Some people out there may have written some but there
  24. >isn't one that comes with the C++ compiler. The Vector and Complex classes
  25. >are just traditional C++ classes that were created by AT&T to demonstrate
  26. >classes as much as anything else.  It is pretty obvious how a Complex class
  27. >can be used to demonstrate overloading of operators such as operator+().
  28. >Notice that the term "vector" is use more in a data structure sense by the
  29. >Vector classes than in the sense of a vector used in linear algebra.  I think
  30. >the name was chosen to avoid confusion with intrinsic "array" structures.
  31. >
  32. >Writing your own Matrix class was left as an exercise to the user by
  33. >Stroustrup and company.
  34. >
  35.  
  36. There is in fact a package called newmat, which is a matrix package
  37. written in c++.  I believe it has been posted to one of the sources 
  38. newsgroups, but I'm not certain which one. Instructions for obtaining 
  39. follow below.
  40.  
  41. Following is the top portion of the documentation that comes with the
  42. package. I didn't include the whole thing because it is quite lengthy, 
  43. and contains details that the average net-reader won't be interested in.
  44.  
  45.  
  46. Please note that I have nothing to do with the production of this
  47. package, I just use it occasionally.
  48.  
  49. P.S.  Im not sure if this is from the most recent version of newmat.
  50.       I think the current rev is 04, not 03.
  51.  
  52.  
  53. --------- Top portion of newmat.txt follows -----------
  54. //$$ newmat.txt            Documentation file
  55.  
  56.  
  57.    Documentation for newmat03, an experimental matrix package in C++.
  58.    ==================================================================
  59.  
  60.  
  61. MATRIX PACKAGE                                           25 November, 1991
  62.  
  63. Copyright (C) 1991: R B Davies and DSIR
  64.  
  65. Permission is granted to use but not to sell.
  66.  
  67.  
  68. Contents
  69. ========
  70.  
  71. General description
  72. Is this the package you need?
  73. Changes
  74. Where you can get a copy of this package
  75. Compiler performance
  76. Example
  77. Detailed documentation
  78.    Customising
  79.    Constructors
  80.    Elements of matrices
  81.    Matrix copy
  82.    Unary operators
  83.    Binary operators
  84.    Combination of a matrix and scalar
  85.    Scalar functions of matrices
  86.    Submatrix operations
  87.    Change dimensions
  88.    Change type
  89.    Multiple matrix solve
  90.    Memory management
  91.    Output
  92.    Accessing matrices of unspecified type
  93.    Cholesky decomposition
  94.    Householder triangularisation
  95.    Singular Value Decomposition
  96.    Eigenvalues
  97.    Sorting
  98.    Fast Fourier Transform
  99.    Interface to Numerical Recipes in C
  100. List of files
  101. Notes on the design of the package
  102.    What this is package for
  103.    What size of matrices?
  104.    Allow matrix expressions?
  105.    Which matrix types?
  106.    What element types?
  107.    Naming convention
  108.    Row and Column index ranges
  109.    Structure of matrix objects
  110.    Data storage - one block or several
  111.    Data storage - by row or by column or other
  112.    Storage of symmetric matrices
  113.    Element access - method and checking
  114.    Use iterators?
  115.    Memory management - reference counting or status variable?
  116.    Evaluation of expressions - use two stage method?
  117.    How to overcome an explosion in number of operations
  118.    Using const
  119.    A calculus of matrix types
  120.    Error handling
  121.    Band and sparse matrices
  122. Problem report form
  123.  
  124.  
  125. ---------------------------------------------------------------------------
  126.  
  127.  
  128. General description
  129. ===================
  130.  
  131. The package is intented for scientists and engineers who need to
  132. manipulate a variety of types of matrices using standard matrix
  133. operations. Emphasis is on the kind of operations needed in statistical
  134. calculations such as least squares, linear equation solve and
  135. eigenvalues.
  136.  
  137. It supports matrix types
  138.  
  139.     Matrix                       (rectangular matrix)
  140.     nricMatrix                   (variant of rectangular matrix)
  141.     UpperTriangularMatrix
  142.     LowerTriangularMatrix
  143.     DiagonalMatrix
  144.     SymmetricMatrix
  145.     RowVector                    (derived from Matrix)
  146.     ColumnVector                 (derived from Matrix).
  147.  
  148. Only one element type (float or double) is supported.
  149.  
  150. The package includes the operations *, +, -, inverse, transpose,
  151. conversion between types, submatrix, determinant, Cholesky
  152. decomposition, Householder triangularisation, singular value
  153. decomposition, eigenvalues of a symmetric matrix, sorting, fast fourier
  154. transform, printing and an interface with "Numerical Recipes in C".
  155.  
  156. It is intended for matrices in the range 4 x 4 to about 90 x 90 (125 x
  157. 125 for triangular matrices). The upper limit is imposed by the maximum
  158. number of elements that can be contained in a single array (8192 doubles
  159. in some machines).
  160.  
  161. A two-stage approach to evaluating matrix expressions is used to improve
  162. efficiency and reduce use of temporary storage.
  163.  
  164. The package is designed for version 2 of C++. It works with Turbo C++,
  165. Borland C++, Glockenspiel C++ (2.00a) on a PC and AT&T C++ (2.0) and Gnu
  166. C++ on a Sun. It works with some problems with Zortech C++ (version 2).
  167.  
  168.  
  169. ---------------------------------------------------------------------------
  170.  
  171.  
  172. Is this the package you need?
  173. =============================
  174.  
  175. Do you
  176.  
  177. 1.   need matrix operators such as * and + defined as operators so you
  178.      can write things like
  179.  
  180.         X  = A * (B + C);
  181.  
  182. 2.   need a variety of types of matrices
  183.  
  184. 3.   need only one element type (float or double)
  185.  
  186. 4.   work with matrices in the range 4x4 to 90x90
  187.  
  188. 5.   tolerate a large and complex package
  189.  
  190.  
  191. Then maybe this is the right package for you. 
  192.  
  193. If you don't need (1) then there may be better options. Likewise if you
  194. don't need (2) there may be better options. If you require "not (5)"
  195. then this is not the package for you.
  196.  
  197.  
  198. If you need (2) and "not (3)" and have some spare money, then maybe you
  199. should look at M++ from Dyad or the Rogue Wave matrix package.
  200.  
  201.  
  202. ---------------------------------------------------------------------------
  203.  
  204.  
  205. Changes
  206. =======
  207.  
  208. Newmat03 - November 1991:
  209.  
  210. Col and Cols become Column and Columns. Added Sort, SVD, Jacobi,
  211. Eigenvalues, FFT, real conversion of 1x1 matrix, "Numerical Recipes in
  212. C" interface, output operations, various scalar functions. Improved
  213. return from functions. Reorganised setting options in "include.hxx".
  214.  
  215.  
  216. Newmat02 - July 1991:
  217.  
  218. Version with matrix row/column operations and numerous additional
  219. functions.
  220.  
  221.  
  222. Matrix - October 1990:
  223.  
  224. Early version of package.
  225.  
  226.  
  227. ---------------------------------------------------------------------------
  228.  
  229.  
  230. How to get a copy of this package
  231. =================================
  232.  
  233. I am putting copies on Compuserve (Borland library, zip format),
  234. SIMTEL20 (MsDos library, zip format), comp.sources.misc on Internet
  235. (shar format), and on the MsDos program library at Victoria University,
  236. Wellington.
  237.  
  238.  
  239. ---------------------------------------------------------------------------
  240.  
  241.  
  242. Compiler performance
  243. ====================
  244.  
  245. I have tested this package on a number of compilers. Here are the
  246. levels of success with this package. In most cases I have chosen code
  247. that works under all the compilers I have access to, but I have had to
  248. include some specific work-arounds for some compilers. For the MsDos
  249. versions, I am using a 386/387sx computer running MsDos 5, except that
  250. Turbo is on an old XT. The unix versions are on a Sun Sparc station.
  251.  
  252. A series of #defines at the beginning of "include.hxx" customises the
  253. package for the compiler you are using. Turbo, Borland and Zortech are
  254. recognised automatically, otherwise you have to set the appropriate
  255. #define statement.
  256.  
  257. The compilers are looking a bit old now. I do intend to test the package
  258. against newer versions as they become available.
  259.  
  260. Borland C++ 2.0: Recently, this has been my main development platform,
  261. so naturally almost everything works with this compiler. The library
  262. manager "tlib" fails but you can use "zorlib" from Zortech instead.
  263. Sometimes Borland crashes during a compiler or mis-compiles. You just
  264. have to reboot and continue the compile.
  265.  
  266. Turbo C++ (? version): Almost works OK. My rather elderly version does
  267. show a problem. Probably not worth tracking down - buy a newer version.
  268. Haven't tried the linker.
  269.  
  270. Zortech C++ 2.12: "const" doesn't work correctly with this compiler, so
  271. the package skips all of the statements Zortech can't handle. If you are
  272. using a later version of Zortech you could probably re-activate these
  273. statements. Zortech leaves rubbish on the heap. I don't know whether
  274. this is my programming error or a Zortech error. It works better when
  275. one doesn't optimise but there still are problems. The nric routines
  276. don't work. Zortech does not support IO manipulators.
  277.  
  278. Glockenspiel C++ (2.00a for MsDos loading into Microsoft C 5.1): I
  279. haven't tested the latest version of my package with Glockenspiel. I had
  280. to #define the matrix names to shorter names to avoid ambiguities and
  281. had quite a bit of difficulty stopping the compiles from running out of
  282. space and not exceeding Microsoft's block nesting limit. A couple of my
  283. test statements produced statements too complex for Microsoft, but
  284. basically the package worked. This was my original development platform
  285. and I still use .cxx and .hxx as my file name extensions. However,
  286. Glockenspiel is no longer competitive for MsDos and I am not updating my
  287. copy of the compiler.
  288.  
  289. Sun AT&T C++ 2.00: This works fine. Except aggregates are not supported.
  290.  
  291. Gnu G++ 1.37.1: This mostly works. You don't seem to be able to use
  292. expressions like Matrix(X*Y) in the middle of an expression and
  293. (Matrix)(X*Y) is unreliable. Gnu does not support IO manipulators. Gnu
  294. leaves rubbish on the heap. This is from output statements and not my
  295. package and may not be an error. The previous version of the package did
  296. not work under Gnu 1.37 or 1.39.
  297.  
  298.  
  299. -- 
  300. ============================================================
  301. Bob Crowe                      Voice:   (619) 931-2695
  302. Pre-Press Technologies.        Email:    bob@prepress.com
  303. 2443 Impala dr.               FAX:     (619) 931-2698
  304.