home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume34 / newmat06 / part03 < prev    next >
Encoding:
Text File  |  1992-12-06  |  54.7 KB  |  1,699 lines

  1. Newsgroups: comp.sources.misc
  2. From: robertd@kauri.vuw.ac.nz (Robert Davies)
  3. Subject:  v34i009:  newmat06 - A matrix package in C++, Part03/07
  4. Message-ID: <1992Dec6.045259.3993@sparky.imd.sterling.com>
  5. X-Md4-Signature: 326a18926a36885cc99e1edc2bf7391f
  6. Date: Sun, 6 Dec 1992 04:52:59 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: robertd@kauri.vuw.ac.nz (Robert Davies)
  10. Posting-number: Volume 34, Issue 9
  11. Archive-name: newmat06/part03
  12. Environment: C++
  13. Supersedes: newmat04: Volume 26, Issue 87-91
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 3 (of 7)."
  22. # Contents:  newmat.h newmatc.txt tmt.cxx tmt.mak
  23. # Wrapped by robert@kea on Thu Dec  3 23:02:17 1992
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'newmat.h' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'newmat.h'\"
  27. else
  28. echo shar: Extracting \"'newmat.h'\" \(42428 characters\)
  29. sed "s/^X//" >'newmat.h' <<'END_OF_FILE'
  30. X//$$ newmat.h           definition file for new version of matrix package
  31. X
  32. X// Copyright (C) 1991,2: R B Davies
  33. X
  34. X#ifndef MATRIX_LIB
  35. X#define MATRIX_LIB 0
  36. X
  37. X#ifdef NO_LONG_NAMES
  38. X#define UpperTriangularMatrix UTMatrix
  39. X#define LowerTriangularMatrix LTMatrix
  40. X#define SymmetricMatrix SMatrix
  41. X#define DiagonalMatrix DMatrix
  42. X#endif
  43. X
  44. X#ifndef TEMPS_DESTROYED_QUICKLY
  45. X#define ReturnMatrix ReturnMatrixX
  46. X#else
  47. X#define ReturnMatrix ReturnMatrixX&
  48. X#endif
  49. X
  50. X#include "boolean.h"
  51. X#include "except.h"
  52. X
  53. X/**************************** general utilities ****************************/
  54. X
  55. Xclass GeneralMatrix;
  56. Xvoid MatrixErrorNoSpace(void*);                 // no space handler
  57. X
  58. Xclass LogAndSign
  59. X// Return from LogDeterminant function
  60. X//    - value of the log plus the sign (+, - or 0)
  61. X{
  62. X   Real log_value;
  63. X   int sign;
  64. Xpublic:
  65. X   LogAndSign() { log_value=0.0; sign=1; }
  66. X   LogAndSign(Real);
  67. X   void operator*=(Real);
  68. X   void ChangeSign() { sign = -sign; }
  69. X   Real LogValue() const { return log_value; }
  70. X   int Sign() const { return sign; }
  71. X   Real Value() const;
  72. X   FREE_CHECK(LogAndSign)
  73. X};
  74. X
  75. X// the following class is for counting the number of times a piece of code
  76. X// is executed. It is used for locating any code not executed by test
  77. X// routines. Use turbo GREP locate all places this code is called and
  78. X// check which ones are not accessed.
  79. X// Somewhat implementation dependent as it relies on "cout" still being
  80. X// present when ExeCounter objects are destructed.
  81. X
  82. Xclass ExeCounter
  83. X{
  84. X   int line;                                    // code line number
  85. X   int fileid;                                  // file identifier
  86. X   long nexe;                                   // number of executions
  87. X   static int nreports;                         // number of reports
  88. Xpublic:
  89. X   ExeCounter(int,int);
  90. X   void operator++() { nexe++; }
  91. X   ~ExeCounter();                               // prints out reports
  92. X};
  93. X
  94. X
  95. X/**************************** class MatrixType *****************************/
  96. X
  97. X// Is used for finding the type of a matrix resulting from the binary operations
  98. X// +, -, * and identifying what conversions are permissible.
  99. X// This class must be updated when new matrix types are added.
  100. X
  101. Xclass GeneralMatrix;                            // defined later
  102. Xclass BaseMatrix;                               // defined later
  103. X
  104. Xclass MatrixType
  105. X{
  106. Xpublic:
  107. X   enum Attribute {  Valid     = 1,
  108. X                     Symmetric = 2,
  109. X                     Band      = 4,
  110. X                     Upper     = 8,
  111. X                     Lower     = 16,
  112. X                     LUDeco    = 32,
  113. X                     OneRow    = 64,
  114. X                     OneCol    = 128 };
  115. X
  116. X   enum            { US = 0,
  117. X                     UT = Valid + Upper,
  118. X                     LT = Valid + Lower,
  119. X                     Rt = Valid,
  120. X                     Sm = Valid + Symmetric,
  121. X                     Dg = Valid + Band + Lower + Upper + Symmetric,
  122. X             RV = Valid + OneRow,
  123. X             CV = Valid + OneCol,
  124. X             BM = Valid + Band,
  125. X             UB = Valid + Band + Upper,
  126. X             LB = Valid + Band + Lower,
  127. X             SB = Valid + Band + Symmetric,
  128. X             Ct = Valid + LUDeco,
  129. X             BC = Valid + Band + LUDeco,
  130. X                   };
  131. X
  132. X   enum { USX,UTX,LTX,RtX,SmX,DgX,RVX,CVX,BMX,UBX,LBX,SBX,CtX,BCX };
  133. X
  134. X   static nTypes() { return 11; }              // number of different types
  135. X                           // exclude Ct, US, BC
  136. Xpublic:
  137. X   int attribute;
  138. Xpublic:
  139. X   MatrixType operator+(const MatrixType& t) const;
  140. X   MatrixType operator*(const MatrixType&) const;
  141. X   Boolean operator>=(const MatrixType& t) const;
  142. X   Boolean operator==(const MatrixType& t) const
  143. X      { return (attribute == t.attribute); }
  144. X   Boolean operator!=(const MatrixType& t) const { return !operator==(t); }
  145. X   Boolean operator!() const { return (attribute & Valid) == 0; }
  146. X   MatrixType i() const;                       // type of inverse
  147. X   MatrixType t() const;                       // type of transpose
  148. X   MatrixType AddEqualEl() const;              // Add constant to matrix
  149. X   MatrixType MultRHS() const;                 // type for rhs of multiply
  150. X   MatrixType sub() const;                     // type of submatrix
  151. X   MatrixType ssub() const;                    // type of sym submatrix
  152. X//   MatrixType (Type tx) : attribute((int)tx) {}
  153. X//                           // (& doesn't work with AT&T)
  154. X   MatrixType () {}
  155. X   MatrixType (int i) : attribute(i) {}
  156. X   GeneralMatrix* New() const;                 // new matrix of given type
  157. X   GeneralMatrix* New(int,int,BaseMatrix*) const;
  158. X                                               // new matrix of given type
  159. X   operator char*() const;                     // for printing type
  160. X   int BestFit() const;
  161. X   FREE_CHECK(MatrixType)
  162. X};
  163. X
  164. Xvoid TestTypeAdd();                            // test +
  165. Xvoid TestTypeMult();                           // test *
  166. Xvoid TestTypeOrder();                          // test >=
  167. X
  168. X
  169. X/************************* class MatrixBandWidth ***********************/
  170. X
  171. Xclass MatrixBandWidth
  172. X{
  173. Xpublic:
  174. X   int lower;
  175. X   int upper;
  176. X   MatrixBandWidth(const int l, const int u) : lower(l), upper (u) {}
  177. X   MatrixBandWidth(const int i) : lower(i), upper(i) {}
  178. X   MatrixBandWidth operator+(const MatrixBandWidth&) const;
  179. X   MatrixBandWidth operator*(const MatrixBandWidth&) const;
  180. X   MatrixBandWidth t() const { return MatrixBandWidth(upper,lower); }
  181. X   Boolean operator==(const MatrixBandWidth& bw) const
  182. X      { return (lower == bw.lower) && (upper == bw.upper); }
  183. X   FREE_CHECK(MatrixBandWidth)
  184. X};
  185. X
  186. X
  187. X/*********************** Array length specifier ************************/
  188. X
  189. X// This class is introduced to avoid constructors such as
  190. X//   ColumnVector(int)
  191. X// being used for conversions
  192. X
  193. Xclass ArrayLengthSpecifier
  194. X{
  195. X   int value;
  196. Xpublic:
  197. X   int Value() const { return value; }
  198. X   ArrayLengthSpecifier(int l) : value(l) {}
  199. X   FREE_CHECK(ArrayLengthSpecifier)
  200. X};
  201. X
  202. X
  203. X/*************************** Matrix routines ***************************/
  204. X
  205. X
  206. Xclass MatrixRowCol;                             // defined later
  207. Xclass MatrixRow;
  208. Xclass MatrixCol;
  209. X
  210. Xclass GeneralMatrix;                            // defined later
  211. Xclass AddedMatrix;
  212. Xclass MultipliedMatrix;
  213. Xclass SubtractedMatrix;
  214. Xclass SolvedMatrix;
  215. Xclass ShiftedMatrix;
  216. Xclass ScaledMatrix;
  217. Xclass TransposedMatrix;
  218. Xclass NegatedMatrix;
  219. Xclass InvertedMatrix;
  220. Xclass RowedMatrix;
  221. Xclass ColedMatrix;
  222. Xclass DiagedMatrix;
  223. Xclass MatedMatrix;
  224. Xclass GetSubMatrix;
  225. Xclass ConstMatrix;
  226. Xclass ReturnMatrixX;
  227. Xclass Matrix;
  228. Xclass nricMatrix;
  229. Xclass RowVector;
  230. Xclass ColumnVector;
  231. Xclass SymmetricMatrix;
  232. Xclass UpperTriangularMatrix;
  233. Xclass LowerTriangularMatrix;
  234. Xclass DiagonalMatrix;
  235. Xclass CroutMatrix;
  236. Xclass BandMatrix;
  237. Xclass LowerBandMatrix;
  238. Xclass UpperBandMatrix;
  239. Xclass SymmetricBandMatrix;
  240. Xclass LinearEquationSolver;
  241. X
  242. Xstatic MatrixType MatrixTypeUnSp(MatrixType::US);
  243. X                        // AT&T needs this
  244. X
  245. Xclass BaseMatrix : public Janitor               // base of all matrix classes
  246. X{
  247. Xprotected:
  248. X//   BaseMatrix() {}
  249. X   virtual ~BaseMatrix() {}
  250. X   virtual int search(const BaseMatrix*) const = 0;
  251. X                        // count number of times matrix
  252. X                        // is referred to
  253. X   virtual MatrixType Type() const = 0;         // type of a matrix
  254. X//   virtual int NrowsV()  const = 0;
  255. X//   virtual int NcolsV()  const = 0;
  256. Xpublic:
  257. X#ifndef GXX
  258. X   virtual GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp) = 0;
  259. X                        // evaluate temporary
  260. X#else
  261. X   virtual GeneralMatrix* Evaluate(MatrixType mt) = 0;
  262. X   GeneralMatrix* Evaluate() { return Evaluate(MatrixTypeUnSp); }
  263. X#endif
  264. X//   void MatrixParameters(int& nr, int& nc, MatrixType& mt)
  265. X//      { nr = NrowsV(); nc = NcolsV(); mt = Type(); }
  266. X#ifndef TEMPS_DESTROYED_QUICKLY
  267. X   AddedMatrix operator+(const BaseMatrix&) const;    // results of operations
  268. X   MultipliedMatrix operator*(const BaseMatrix&) const;
  269. X   SubtractedMatrix operator-(const BaseMatrix&) const;
  270. X   ShiftedMatrix operator+(Real) const;
  271. X   ScaledMatrix operator*(Real) const;
  272. X   ScaledMatrix operator/(Real) const;
  273. X   ShiftedMatrix operator-(Real) const;
  274. X   TransposedMatrix t() const;
  275. X//   TransposedMatrix t;
  276. X   NegatedMatrix operator-() const;                   // change sign of elements
  277. X   InvertedMatrix i() const;
  278. X//   InvertedMatrix i;
  279. X   RowedMatrix AsRow() const;
  280. X   ColedMatrix AsColumn() const;
  281. X   DiagedMatrix AsDiagonal() const;
  282. X   MatedMatrix AsMatrix(int,int) const;
  283. X   GetSubMatrix SubMatrix(int,int,int,int) const;
  284. X   GetSubMatrix SymSubMatrix(int,int) const;
  285. X   GetSubMatrix Row(int) const;
  286. X   GetSubMatrix Rows(int,int) const;
  287. X   GetSubMatrix Column(int) const;
  288. X   GetSubMatrix Columns(int,int) const;
  289. X#else
  290. X   AddedMatrix& operator+(const BaseMatrix&) const;    // results of operations
  291. X   MultipliedMatrix& operator*(const BaseMatrix&) const;
  292. X   SubtractedMatrix& operator-(const BaseMatrix&) const;
  293. X   ShiftedMatrix& operator+(Real) const;
  294. X   ScaledMatrix& operator*(Real) const;
  295. X   ScaledMatrix& operator/(Real) const;
  296. X   ShiftedMatrix& operator-(Real) const;
  297. X   TransposedMatrix& t() const;
  298. X//   TransposedMatrix& t;
  299. X   NegatedMatrix& operator-() const;                   // change sign of elements
  300. X   InvertedMatrix& i() const;
  301. X//   InvertedMatrix& i;
  302. X   RowedMatrix& AsRow() const;
  303. X   ColedMatrix& AsColumn() const;
  304. X   DiagedMatrix& AsDiagonal() const;
  305. X   MatedMatrix& AsMatrix(int,int) const;
  306. X   GetSubMatrix& SubMatrix(int,int,int,int) const;
  307. X   GetSubMatrix& SymSubMatrix(int,int) const;
  308. X   GetSubMatrix& Row(int) const;
  309. X   GetSubMatrix& Rows(int,int) const;
  310. X   GetSubMatrix& Column(int) const;
  311. X   GetSubMatrix& Columns(int,int) const;
  312. X#endif
  313. X   Real AsScalar() const;                      // conversion of 1 x 1 matrix
  314. X   virtual LogAndSign LogDeterminant() const;
  315. X   virtual Real SumSquare() const;
  316. X   virtual Real SumAbsoluteValue() const;
  317. X   virtual Real MaximumAbsoluteValue() const;
  318. X   virtual Real Trace() const;
  319. X   Real Norm1() const;
  320. X   Real NormInfinity() const;
  321. X   virtual MatrixBandWidth BandWidth() const;  // bandwidths of band matrix
  322. X   virtual void CleanUp() {}                     // to clear store
  323. X//protected:
  324. X//   BaseMatrix() : t(this), i(this) {}
  325. X
  326. X   friend GeneralMatrix;
  327. X   friend Matrix;
  328. X   friend nricMatrix;
  329. X   friend RowVector;
  330. X   friend ColumnVector;
  331. X   friend SymmetricMatrix;
  332. X   friend UpperTriangularMatrix;
  333. X   friend LowerTriangularMatrix;
  334. X   friend DiagonalMatrix;
  335. X   friend CroutMatrix;
  336. X   friend BandMatrix;
  337. X   friend LowerBandMatrix;
  338. X   friend UpperBandMatrix;
  339. X   friend SymmetricBandMatrix;
  340. X   friend AddedMatrix;
  341. X   friend MultipliedMatrix;
  342. X   friend SubtractedMatrix;
  343. X   friend SolvedMatrix;
  344. X   friend ShiftedMatrix;
  345. X   friend ScaledMatrix;
  346. X   friend TransposedMatrix;
  347. X   friend NegatedMatrix;
  348. X   friend InvertedMatrix;
  349. X   friend RowedMatrix;
  350. X   friend ColedMatrix;
  351. X   friend DiagedMatrix;
  352. X   friend MatedMatrix;
  353. X   friend GetSubMatrix;
  354. X   friend ConstMatrix;
  355. X   friend ReturnMatrixX;
  356. X   friend LinearEquationSolver;
  357. X   NEW_DELETE(BaseMatrix)
  358. X};
  359. X
  360. X
  361. X/******************************* working classes **************************/
  362. X
  363. Xclass GeneralMatrix : public BaseMatrix         // declarable matrix types
  364. X{
  365. Xprotected:
  366. X   int tag;                                     // shows whether can reuse
  367. X   int nrows, ncols;                            // dimensions
  368. X   int storage;                                 // total store required
  369. X   Real* store;                                 // point to store (0=not set)
  370. X   GeneralMatrix();                             // initialise with no store
  371. X   GeneralMatrix(ArrayLengthSpecifier);         // constructor getting store
  372. X   void Add(GeneralMatrix*, Real);              // sum of GM and Real
  373. X   void Add(Real);                              // add Real to this
  374. X   void Multiply(GeneralMatrix*, Real);         // product of GM and Real
  375. X   void Multiply(Real);                         // multiply this by Real
  376. X   void Negate(GeneralMatrix*);                 // change sign
  377. X   void Negate();                               // change sign
  378. X   void operator=(Real);                        // set matrix to constant
  379. X   Real* GetStore();                            // get store or copy
  380. X   GeneralMatrix* BorrowStore(GeneralMatrix*, MatrixType);
  381. X                                                // temporarily access store
  382. X   void GetMatrix(const GeneralMatrix*);        // used by = and initialise
  383. X   void Eq(const BaseMatrix&, MatrixType);      // used by =
  384. X   int search(const BaseMatrix*) const;
  385. X   virtual GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
  386. X   void CheckConversion(const BaseMatrix&);     // check conversion OK
  387. X   void ReDimension(int, int, int);             // change dimensions
  388. X//   int NrowsV() const;                          // get dimensions
  389. X//   int NcolsV() const;                          // virtual version
  390. Xpublic:
  391. X   GeneralMatrix* Evaluate(MatrixType);
  392. X   MatrixType Type() const = 0;                 // type of a matrix
  393. X   int Nrows() const { return nrows; }          // get dimensions
  394. X   int Ncols() const { return ncols; }
  395. X   int Storage() const { return storage; }
  396. X   Real* Store() const { return store; }
  397. X   virtual ~GeneralMatrix();                    // delete store if set
  398. X   void tDelete();                              // delete if tag permits
  399. X   Boolean reuse();                                // TRUE if tag allows reuse
  400. X   void Protect() { tag=-1; }                   // can't delete or reuse
  401. X   int Tag() const { return tag; }
  402. X   Boolean IsZero() const;                         // test matrix has all zeros
  403. X   void Release() { tag=1; }                    // del store after next use
  404. X   void Release(int t) { tag=t; }               // del store after t accesses
  405. X   void ReleaseAndDelete() { tag=0; }           // delete matrix after use
  406. X   void operator<<(const Real*);                // assignment from an array
  407. X   void operator<<(const BaseMatrix& X) { Eq(X,this->Type()); }
  408. X                                                // = without checking type
  409. X   void Inject(const GeneralMatrix&);           // copy stored els only
  410. X   virtual GeneralMatrix* MakeSolver();         // for solving
  411. X   virtual void Solver(MatrixRowCol&, const MatrixRowCol&) {}
  412. X   virtual void GetRow(MatrixRowCol&) = 0;      // Get matrix row
  413. X   virtual void RestoreRow(MatrixRowCol&) {}    // Restore matrix row
  414. X   virtual void NextRow(MatrixRowCol&);         // Go to next row
  415. X   virtual void GetCol(MatrixRowCol&) = 0;      // Get matrix col
  416. X   virtual void RestoreCol(MatrixRowCol&) {}    // Restore matrix col
  417. X   virtual void NextCol(MatrixRowCol&);         // Go to next col
  418. X   Real SumSquare() const;
  419. X   Real SumAbsoluteValue() const;
  420. X   Real MaximumAbsoluteValue() const;
  421. X   LogAndSign LogDeterminant() const;
  422. X#ifndef TEMPS_DESTROYED_QUICKLY
  423. X   ConstMatrix c() const;                       // to access constant matrices
  424. X#else
  425. X   ConstMatrix& c() const;                      // to access constant matrices
  426. X#endif
  427. X   void CheckStore() const;                     // check store is non-zero
  428. X   virtual void SetParameters(const GeneralMatrix*) {}
  429. X                                                // set parameters in GetMatrix
  430. X#ifndef TEMPS_DESTROYED_QUICKLY
  431. X   operator ReturnMatrixX() const;              // for building a ReturnMatrix
  432. X#else
  433. X   operator ReturnMatrixX&() const;             // for building a ReturnMatrix
  434. X#endif
  435. X   void CleanUp();                                // to clear store
  436. X
  437. X   friend Matrix;
  438. X   friend nricMatrix;
  439. X   friend SymmetricMatrix;
  440. X   friend UpperTriangularMatrix;
  441. X   friend LowerTriangularMatrix;
  442. X   friend DiagonalMatrix;
  443. X   friend CroutMatrix;
  444. X   friend RowVector;
  445. X   friend ColumnVector;
  446. X   friend BandMatrix;
  447. X   friend LowerBandMatrix;
  448. X   friend UpperBandMatrix;
  449. X   friend SymmetricBandMatrix;
  450. X   friend BaseMatrix;
  451. X   friend AddedMatrix;
  452. X   friend MultipliedMatrix;
  453. X   friend SubtractedMatrix;
  454. X   friend SolvedMatrix;
  455. X   friend ShiftedMatrix;
  456. X   friend ScaledMatrix;
  457. X   friend TransposedMatrix;
  458. X   friend NegatedMatrix;
  459. X   friend InvertedMatrix;
  460. X   friend RowedMatrix;
  461. X   friend ColedMatrix;
  462. X   friend DiagedMatrix;
  463. X   friend MatedMatrix;
  464. X   friend GetSubMatrix;
  465. X   friend ConstMatrix;
  466. X   friend ReturnMatrixX;
  467. X   friend LinearEquationSolver;
  468. X   NEW_DELETE(GeneralMatrix)
  469. X};
  470. X
  471. Xclass Matrix : public GeneralMatrix             // usual rectangular matrix
  472. X{
  473. Xpublic:
  474. X   Matrix() {}
  475. X   Matrix(int, int);                            // standard declaration
  476. X   Matrix(const BaseMatrix&);                   // evaluate BaseMatrix
  477. X   void operator=(const BaseMatrix&);
  478. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  479. X   MatrixType Type() const;
  480. X   Real& operator()(int, int);                  // access element
  481. X   Real& element(int, int);                     // access element
  482. X   Matrix(const Matrix& gm) { GetMatrix(&gm); }
  483. X#ifndef __ZTC__
  484. X   Real operator()(int, int) const;             // access element
  485. X#endif
  486. X   GeneralMatrix* MakeSolver();
  487. X   Real Trace() const;
  488. X   void GetRow(MatrixRowCol&);
  489. X   void GetCol(MatrixRowCol&);
  490. X   void RestoreCol(MatrixRowCol&);
  491. X   void NextRow(MatrixRowCol&);
  492. X   void NextCol(MatrixRowCol&);
  493. X   void ReDimension(int,int);                   // change dimensions
  494. X   NEW_DELETE(Matrix)
  495. X};
  496. X
  497. Xclass nricMatrix : public Matrix                // for use with Numerical
  498. X                                                // Recipes in C
  499. X{
  500. X   Real** row_pointer;                          // points to rows
  501. X   void MakeRowPointer();                       // build rowpointer
  502. X   void DeleteRowPointer();
  503. Xpublic:
  504. X   nricMatrix() {}
  505. X   nricMatrix(int m, int n)                     // standard declaration
  506. X      :  Matrix(m,n) { MakeRowPointer(); }
  507. X   nricMatrix(const BaseMatrix& bm)             // evaluate BaseMatrix
  508. X      :  Matrix(bm) { MakeRowPointer(); }
  509. X   void operator=(const BaseMatrix& bm)
  510. X      { DeleteRowPointer(); Matrix::operator=(bm); MakeRowPointer(); }
  511. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  512. X   void operator<<(const BaseMatrix& X)
  513. X      { DeleteRowPointer(); Eq(X,this->Type()); MakeRowPointer(); }
  514. X   nricMatrix(const nricMatrix& gm) { GetMatrix(&gm); MakeRowPointer(); }
  515. X   void ReDimension(int m, int n)               // change dimensions
  516. X      { DeleteRowPointer(); Matrix::ReDimension(m,n); MakeRowPointer(); }
  517. X   ~nricMatrix() { DeleteRowPointer(); }
  518. X#ifndef __ZTC__
  519. X   Real** nric() const { CheckStore(); return row_pointer-1; }
  520. X#endif
  521. X   void CleanUp();                                // to clear store
  522. X   NEW_DELETE(nricMatrix)
  523. X};
  524. X
  525. Xclass SymmetricMatrix : public GeneralMatrix
  526. X{
  527. Xpublic:
  528. X   SymmetricMatrix() {}
  529. X   SymmetricMatrix(ArrayLengthSpecifier);
  530. X   SymmetricMatrix(const BaseMatrix&);
  531. X   void operator=(const BaseMatrix&);
  532. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  533. X   Real& operator()(int, int);                  // access element
  534. X   Real& element(int, int);                     // access element
  535. X   MatrixType Type() const;
  536. X   SymmetricMatrix(const SymmetricMatrix& gm) { GetMatrix(&gm); }
  537. X#ifndef __ZTC__
  538. X   Real operator()(int, int) const;             // access element
  539. X#endif
  540. X   Real SumSquare() const;
  541. X   Real SumAbsoluteValue() const;
  542. X   Real Trace() const;
  543. X   void GetRow(MatrixRowCol&);
  544. X   void GetCol(MatrixRowCol&);
  545. X   GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
  546. X   void ReDimension(int);                       // change dimensions
  547. X   NEW_DELETE(SymmetricMatrix)
  548. X};
  549. X
  550. Xclass UpperTriangularMatrix : public GeneralMatrix
  551. X{
  552. Xpublic:
  553. X   UpperTriangularMatrix() {}
  554. X   UpperTriangularMatrix(ArrayLengthSpecifier);
  555. X   void operator=(const BaseMatrix&);
  556. X   UpperTriangularMatrix(const BaseMatrix&);
  557. X   UpperTriangularMatrix(const UpperTriangularMatrix& gm) { GetMatrix(&gm); }
  558. X#ifndef __ZTC__
  559. X   Real operator()(int, int) const;             // access element
  560. X#endif
  561. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  562. X   Real& operator()(int, int);                  // access element
  563. X   Real& element(int, int);                     // access element
  564. X   MatrixType Type() const;
  565. X   GeneralMatrix* MakeSolver() { return this; } // for solving
  566. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  567. X   LogAndSign LogDeterminant() const;
  568. X   Real Trace() const;
  569. X   void GetRow(MatrixRowCol&);
  570. X   void GetCol(MatrixRowCol&);
  571. X   void RestoreCol(MatrixRowCol&);
  572. X   void NextRow(MatrixRowCol&);
  573. X   void ReDimension(int);                       // change dimensions
  574. X   NEW_DELETE(UpperTriangularMatrix)
  575. X};
  576. X
  577. Xclass LowerTriangularMatrix : public GeneralMatrix
  578. X{
  579. Xpublic:
  580. X   LowerTriangularMatrix() {}
  581. X   LowerTriangularMatrix(ArrayLengthSpecifier);
  582. X   LowerTriangularMatrix(const LowerTriangularMatrix& gm) { GetMatrix(&gm); }
  583. X#ifndef __ZTC__
  584. X   Real operator()(int, int) const;             // access element
  585. X#endif
  586. X   LowerTriangularMatrix(const BaseMatrix& M);
  587. X   void operator=(const BaseMatrix&);
  588. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  589. X   Real& operator()(int, int);                  // access element
  590. X   Real& element(int, int);                     // access element
  591. X   MatrixType Type() const;
  592. X   GeneralMatrix* MakeSolver() { return this; } // for solving
  593. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  594. X   LogAndSign LogDeterminant() const;
  595. X   Real Trace() const;
  596. X   void GetRow(MatrixRowCol&);
  597. X   void GetCol(MatrixRowCol&);
  598. X   void RestoreCol(MatrixRowCol&);
  599. X   void NextRow(MatrixRowCol&);
  600. X   void ReDimension(int);                       // change dimensions
  601. X   NEW_DELETE(LowerTriangularMatrix)
  602. X};
  603. X
  604. Xclass DiagonalMatrix : public GeneralMatrix
  605. X{
  606. Xpublic:
  607. X   DiagonalMatrix() {}
  608. X   DiagonalMatrix(ArrayLengthSpecifier);
  609. X   DiagonalMatrix(const BaseMatrix&);
  610. X   DiagonalMatrix(const DiagonalMatrix& gm) { GetMatrix(&gm); }
  611. X#ifndef __ZTC__
  612. X   Real operator()(int, int) const;             // access element
  613. X   Real operator()(int) const;
  614. X#endif
  615. X   void operator=(const BaseMatrix&);
  616. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  617. X   Real& operator()(int, int);                  // access element
  618. X   Real& operator()(int);                       // access element
  619. X   Real& element(int, int);                     // access element
  620. X   Real& element(int);                          // access element
  621. X   MatrixType Type() const;
  622. X
  623. X   LogAndSign LogDeterminant() const;
  624. X   Real Trace() const;
  625. X   void GetRow(MatrixRowCol&);
  626. X   void GetCol(MatrixRowCol&);
  627. X   void NextRow(MatrixRowCol&);
  628. X   void NextCol(MatrixRowCol&);
  629. X   GeneralMatrix* MakeSolver() { return this; } // for solving
  630. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  631. X   GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
  632. X   void ReDimension(int);                       // change dimensions
  633. X#ifndef __ZTC__
  634. X   Real* nric() const
  635. X      { CheckStore(); return store-1; }         // for use by NRIC
  636. X#endif
  637. X   MatrixBandWidth BandWidth() const;
  638. X   NEW_DELETE(DiagonalMatrix)
  639. X};
  640. X
  641. Xclass RowVector : public Matrix
  642. X{
  643. Xpublic:
  644. X   RowVector() {}
  645. X   RowVector(ArrayLengthSpecifier n) : Matrix(1,n.Value()) {}
  646. X   RowVector(const BaseMatrix&);
  647. X   RowVector(const RowVector& gm) { GetMatrix(&gm); }
  648. X#ifndef __ZTC__
  649. X   Real operator()(int) const;                  // access element
  650. X#endif
  651. X   void operator=(const BaseMatrix&);
  652. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  653. X   Real& operator()(int);                       // access element
  654. X   Real& element(int);                          // access element
  655. X   MatrixType Type() const;
  656. X   void GetCol(MatrixRowCol&);
  657. X   void NextCol(MatrixRowCol&);
  658. X   void RestoreCol(MatrixRowCol&);
  659. X   GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
  660. X   void ReDimension(int);                       // change dimensions
  661. X#ifndef __ZTC__
  662. X   Real* nric() const
  663. X      { CheckStore(); return store-1; }         // for use by NRIC
  664. X#endif
  665. X   void CleanUp();                                // to clear store
  666. X   NEW_DELETE(RowVector)
  667. X};
  668. X
  669. Xclass ColumnVector : public Matrix
  670. X{
  671. Xpublic:
  672. X   ColumnVector() {}
  673. X   ColumnVector(ArrayLengthSpecifier n) : Matrix(n.Value(),1) {}
  674. X   ColumnVector(const BaseMatrix&);
  675. X   ColumnVector(const ColumnVector& gm) { GetMatrix(&gm); }
  676. X#ifndef __ZTC__
  677. X   Real operator()(int) const;                  // access element
  678. X#endif
  679. X   void operator=(const BaseMatrix&);
  680. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  681. X   Real& operator()(int);                       // access element
  682. X   Real& element(int);                          // access element
  683. X   MatrixType Type() const;
  684. X   GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
  685. X   void ReDimension(int);                       // change dimensions
  686. X#ifndef __ZTC__
  687. X   Real* nric() const
  688. X      { CheckStore(); return store-1; }         // for use by NRIC
  689. X#endif
  690. X   void CleanUp();                                // to clear store
  691. X   NEW_DELETE(ColumnVector)
  692. X};
  693. X
  694. Xclass CroutMatrix : public GeneralMatrix        // for LU decomposition
  695. X{
  696. X   int* indx;
  697. X   Boolean d;
  698. X   Boolean sing;
  699. X   void ludcmp();
  700. Xpublic:
  701. X   CroutMatrix(const BaseMatrix&);
  702. X   MatrixType Type() const;
  703. X   void lubksb(Real*, int=0);
  704. X   ~CroutMatrix();
  705. X   GeneralMatrix* MakeSolver() { return this; } // for solving
  706. X   LogAndSign LogDeterminant() const;
  707. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  708. X   void GetRow(MatrixRowCol&);
  709. X   void GetCol(MatrixRowCol&);
  710. X   void operator=(const BaseMatrix&);
  711. X   void CleanUp();                                // to clear store
  712. X   NEW_DELETE(CroutMatrix)
  713. X};
  714. X
  715. X/******************************* band matrices ***************************/
  716. X
  717. Xclass BandMatrix : public GeneralMatrix         // band matrix
  718. X{
  719. Xprotected:
  720. X   void CornerClear() const;                    // set unused elements to zero
  721. Xpublic:
  722. X   int lower, upper;                            // band widths
  723. X   BandMatrix() { lower=0; upper=0; CornerClear(); }
  724. X   BandMatrix(int n,int lb,int ub) { ReDimension(n,lb,ub); CornerClear(); }
  725. X                                                // standard declaration
  726. X   BandMatrix(const BaseMatrix&);               // evaluate BaseMatrix
  727. X   void operator=(const BaseMatrix&);
  728. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  729. X   MatrixType Type() const;
  730. X   Real& operator()(int, int);                  // access element
  731. X   Real& element(int, int);                     // access element
  732. X   BandMatrix(const BandMatrix& gm) { GetMatrix(&gm); }
  733. X#ifndef __ZTC__
  734. X   Real operator()(int, int) const;             // access element
  735. X#endif
  736. X   LogAndSign LogDeterminant() const;
  737. X   GeneralMatrix* MakeSolver();
  738. X   Real Trace() const;
  739. X   Real SumSquare() const { CornerClear(); return GeneralMatrix::SumSquare(); }
  740. X   Real SumAbsoluteValue() const
  741. X      { CornerClear(); return GeneralMatrix::SumAbsoluteValue(); }
  742. X   Real MaximumAbsoluteValue() const
  743. X      { CornerClear(); return GeneralMatrix::MaximumAbsoluteValue(); }
  744. X   void GetRow(MatrixRowCol&);
  745. X   void GetCol(MatrixRowCol&);
  746. X   void RestoreCol(MatrixRowCol&);
  747. X   void NextRow(MatrixRowCol&);
  748. X   void ReDimension(int, int, int);             // change dimensions
  749. X   MatrixBandWidth BandWidth() const;
  750. X   void SetParameters(const GeneralMatrix*);
  751. X   NEW_DELETE(BandMatrix)
  752. X};
  753. X
  754. Xclass UpperBandMatrix : public BandMatrix       // upper band matrix
  755. X{
  756. Xpublic:
  757. X   UpperBandMatrix() {}
  758. X   UpperBandMatrix(int n, int ubw)              // standard declaration
  759. X      : BandMatrix(n, 0, ubw) {}
  760. X   UpperBandMatrix(const BaseMatrix&);          // evaluate BaseMatrix
  761. X   void operator=(const BaseMatrix&);
  762. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  763. X   MatrixType Type() const;
  764. X   UpperBandMatrix(const UpperBandMatrix& gm) { GetMatrix(&gm); }
  765. X   GeneralMatrix* MakeSolver() { return this; }
  766. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  767. X   LogAndSign LogDeterminant() const;
  768. X   void ReDimension(int n,int ubw)              // change dimensions
  769. X      { BandMatrix::ReDimension(n,0,ubw); }
  770. X   Real& operator()(int, int);
  771. X   Real& element(int, int);
  772. X   NEW_DELETE(UpperBandMatrix)
  773. X};
  774. X
  775. Xclass LowerBandMatrix : public BandMatrix       // upper band matrix
  776. X{
  777. Xpublic:
  778. X   LowerBandMatrix() {}
  779. X   LowerBandMatrix(int n, int lbw)              // standard declaration
  780. X      : BandMatrix(n, lbw, 0) {}
  781. X   LowerBandMatrix(const BaseMatrix&);          // evaluate BaseMatrix
  782. X   void operator=(const BaseMatrix&);
  783. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  784. X   MatrixType Type() const;
  785. X   LowerBandMatrix(const LowerBandMatrix& gm) { GetMatrix(&gm); }
  786. X   GeneralMatrix* MakeSolver() { return this; }
  787. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  788. X   LogAndSign LogDeterminant() const;
  789. X   void ReDimension(int n,int lbw)             // change dimensions
  790. X      { BandMatrix::ReDimension(n,lbw,0); }
  791. X   Real& operator()(int, int);
  792. X   Real& element(int, int);
  793. X   NEW_DELETE(LowerBandMatrix)
  794. X};
  795. X
  796. Xclass SymmetricBandMatrix : public GeneralMatrix
  797. X{
  798. X   void CornerClear() const;                    // set unused elements to zero
  799. Xpublic:
  800. X   int lower;                                   // lower band width
  801. X   SymmetricBandMatrix() { lower=0; CornerClear(); }
  802. X   SymmetricBandMatrix(int n, int lb) { ReDimension(n,lb); CornerClear(); }
  803. X   SymmetricBandMatrix(const BaseMatrix&);
  804. X   void operator=(const BaseMatrix&);
  805. X   void operator=(Real f) { GeneralMatrix::operator=(f); }
  806. X   Real& operator()(int, int);                  // access element
  807. X   Real& element(int, int);                     // access element
  808. X   MatrixType Type() const;
  809. X   SymmetricBandMatrix(const SymmetricBandMatrix& gm) { GetMatrix(&gm); }
  810. X#ifndef __ZTC__
  811. X   Real operator()(int, int) const;             // access element
  812. X#endif
  813. X   GeneralMatrix* MakeSolver();
  814. X   Real SumSquare() const;
  815. X   Real SumAbsoluteValue() const;
  816. X   Real MaximumAbsoluteValue() const
  817. X      { CornerClear(); return GeneralMatrix::MaximumAbsoluteValue(); }
  818. X   Real Trace() const;
  819. X   LogAndSign LogDeterminant() const;
  820. X   void GetRow(MatrixRowCol&);
  821. X   void GetCol(MatrixRowCol&);
  822. X   GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
  823. X   void ReDimension(int,int);                       // change dimensions
  824. X   MatrixBandWidth BandWidth() const;
  825. X   void SetParameters(const GeneralMatrix*);
  826. X   NEW_DELETE(SymmetricBandMatrix)
  827. X};
  828. X
  829. Xclass BandLUMatrix : public GeneralMatrix
  830. X// for LU decomposition of band matrix
  831. X{
  832. X   int* indx;
  833. X   Boolean d;
  834. X   Boolean sing;                                   // TRUE if singular
  835. X   Real* store2;
  836. X   int storage2;
  837. X   void ludcmp();
  838. X   int m1,m2;                                   // lower and upper
  839. Xpublic:
  840. X   BandLUMatrix(const BaseMatrix&);
  841. X   MatrixType Type() const;
  842. X   void lubksb(Real*, int=0);
  843. X   ~BandLUMatrix();
  844. X   GeneralMatrix* MakeSolver() { return this; } // for solving
  845. X   LogAndSign LogDeterminant() const;
  846. X   void Solver(MatrixRowCol&, const MatrixRowCol&);
  847. X   void GetRow(MatrixRowCol&);
  848. X   void GetCol(MatrixRowCol&);
  849. X   void operator=(const BaseMatrix&);
  850. X   NEW_DELETE(BandLUMatrix)
  851. X   void CleanUp();                                // to clear store
  852. X};
  853. X
  854. X
  855. X/***************************** temporary classes *************************/
  856. X
  857. Xclass MultipliedMatrix : public BaseMatrix
  858. X{
  859. Xprotected:
  860. X   union { const BaseMatrix* bm1; GeneralMatrix* gm1; };
  861. X                          // pointers to summands
  862. X   union { const BaseMatrix* bm2; GeneralMatrix* gm2; };
  863. X   MultipliedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
  864. X      : bm1(bm1x),bm2(bm2x) {}
  865. X   int search(const BaseMatrix*) const;
  866. X//   int NrowsV() const;
  867. X//   int NcolsV() const;
  868. X   MatrixType Type() const;
  869. X   friend BaseMatrix;
  870. Xpublic:
  871. X   GeneralMatrix* Evaluate(MatrixType);
  872. X   MatrixBandWidth BandWidth() const;
  873. X   NEW_DELETE(MultipliedMatrix)
  874. X};
  875. X
  876. Xclass AddedMatrix : public MultipliedMatrix
  877. X{
  878. Xprotected:
  879. X   AddedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
  880. X      : MultipliedMatrix(bm1x,bm2x) {}
  881. X
  882. Xprivate:
  883. X   MatrixType Type() const;
  884. X   friend BaseMatrix;
  885. Xpublic:
  886. X   GeneralMatrix* Evaluate(MatrixType);
  887. X   MatrixBandWidth BandWidth() const;
  888. X#ifdef GXX
  889. X   void SelectVersion(MatrixType, int&, int&) const;
  890. X#else
  891. X   void SelectVersion(MatrixType, Boolean&, Boolean&) const;
  892. X#endif
  893. X   NEW_DELETE(AddedMatrix)
  894. X};
  895. X
  896. Xclass SolvedMatrix : public MultipliedMatrix
  897. X{
  898. X   SolvedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
  899. X      : MultipliedMatrix(bm1x,bm2x) {}
  900. X   MatrixType Type() const;
  901. X   friend BaseMatrix;
  902. X   friend InvertedMatrix;                        // for operator*
  903. Xpublic:
  904. X   GeneralMatrix* Evaluate(MatrixType);
  905. X   MatrixBandWidth BandWidth() const;
  906. X   NEW_DELETE(SolvedMatrix)
  907. X};
  908. X
  909. Xclass SubtractedMatrix : public AddedMatrix
  910. X{
  911. X   SubtractedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
  912. X      : AddedMatrix(bm1x,bm2x) {}
  913. X   MatrixType Type() const;
  914. X   friend BaseMatrix;
  915. Xpublic:
  916. X   GeneralMatrix* Evaluate(MatrixType);
  917. X   NEW_DELETE(SubtractedMatrix)
  918. X};
  919. X
  920. Xclass ShiftedMatrix : public BaseMatrix
  921. X{
  922. Xprotected:
  923. X   Real f;
  924. X   union { const BaseMatrix* bm; GeneralMatrix* gm; };
  925. X   ShiftedMatrix(const BaseMatrix* bmx, Real fx) : bm(bmx),f(fx) {}
  926. X   int search(const BaseMatrix*) const;
  927. X//   int NrowsV() const;
  928. X//   int NcolsV() const;
  929. Xprivate:
  930. X   MatrixType Type() const;
  931. X   friend BaseMatrix;
  932. Xpublic:
  933. X   GeneralMatrix* Evaluate(MatrixType);
  934. X   NEW_DELETE(ShiftedMatrix)
  935. X};
  936. X
  937. Xclass ScaledMatrix : public ShiftedMatrix
  938. X{
  939. X   ScaledMatrix(const BaseMatrix* bmx, Real fx) : ShiftedMatrix(bmx,fx) {}
  940. X   MatrixType Type() const;
  941. X   friend BaseMatrix;
  942. Xpublic:
  943. X   GeneralMatrix* Evaluate(MatrixType);
  944. X   MatrixBandWidth BandWidth() const;
  945. X   NEW_DELETE(ScaledMatrix)
  946. X};
  947. X
  948. Xclass NegatedMatrix : public BaseMatrix
  949. X{
  950. Xprotected:
  951. X   union { const BaseMatrix* bm; GeneralMatrix* gm; };
  952. X   NegatedMatrix(const BaseMatrix* bmx) : bm(bmx) {}
  953. X   int search(const BaseMatrix*) const;
  954. X//   int NrowsV() const;
  955. X//   int NcolsV() const;
  956. Xprivate:
  957. X   MatrixType Type() const;
  958. X   friend BaseMatrix;
  959. Xpublic:
  960. X   GeneralMatrix* Evaluate(MatrixType);
  961. X   MatrixBandWidth BandWidth() const;
  962. X   NEW_DELETE(NegatedMatrix)
  963. X};
  964. X
  965. Xclass TransposedMatrix : public NegatedMatrix
  966. X{
  967. X   TransposedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
  968. X//   int NrowsV() const;
  969. X//   int NcolsV() const;
  970. X   MatrixType Type() const;
  971. X   friend BaseMatrix;
  972. Xpublic:
  973. X   GeneralMatrix* Evaluate(MatrixType);
  974. X   MatrixBandWidth BandWidth() const;
  975. X   NEW_DELETE(TransposedMatrix)
  976. X};
  977. X
  978. Xclass InvertedMatrix : public NegatedMatrix
  979. X{
  980. X   InvertedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
  981. X   MatrixType Type() const;
  982. Xpublic:
  983. X#ifndef TEMPS_DESTROYED_QUICKLY
  984. X   SolvedMatrix operator*(const BaseMatrix&) const;       // inverse(A) * B
  985. X#else
  986. X   SolvedMatrix& operator*(const BaseMatrix&) const;       // inverse(A) * B
  987. X#endif
  988. X   friend BaseMatrix;
  989. X   GeneralMatrix* Evaluate(MatrixType);
  990. X   MatrixBandWidth BandWidth() const;
  991. X   NEW_DELETE(InvertedMatrix)
  992. X};
  993. X
  994. Xclass RowedMatrix : public NegatedMatrix
  995. X{
  996. X   MatrixType Type() const;
  997. X//   int NrowsV() const;
  998. X//   int NcolsV() const;
  999. X   RowedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
  1000. X   friend BaseMatrix;
  1001. Xpublic:
  1002. X   GeneralMatrix* Evaluate(MatrixType);
  1003. X   MatrixBandWidth BandWidth() const;
  1004. X   NEW_DELETE(RowedMatrix)
  1005. X};
  1006. X
  1007. Xclass ColedMatrix : public NegatedMatrix
  1008. X{
  1009. X   MatrixType Type() const;
  1010. X//   int NrowsV() const;
  1011. X//   int NcolsV() const;
  1012. X   ColedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
  1013. X   friend BaseMatrix;
  1014. Xpublic:
  1015. X   GeneralMatrix* Evaluate(MatrixType);
  1016. X   MatrixBandWidth BandWidth() const;
  1017. X   NEW_DELETE(ColedMatrix)
  1018. X};
  1019. X
  1020. Xclass DiagedMatrix : public NegatedMatrix
  1021. X{
  1022. X   MatrixType Type() const;
  1023. X//   int NrowsV() const;
  1024. X//   int NcolsV() const;
  1025. X   DiagedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
  1026. X   friend BaseMatrix;
  1027. Xpublic:
  1028. X   GeneralMatrix* Evaluate(MatrixType);
  1029. X   MatrixBandWidth BandWidth() const;
  1030. X   NEW_DELETE(DiagedMatrix)
  1031. X};
  1032. X
  1033. Xclass MatedMatrix : public NegatedMatrix
  1034. X{
  1035. X   int nr, nc;
  1036. X   MatrixType Type() const;
  1037. X//   int NrowsV() const;
  1038. X//   int NcolsV() const;
  1039. X   MatedMatrix(const BaseMatrix* bmx, int nrx, int ncx)
  1040. X      : NegatedMatrix(bmx), nr(nrx), nc(ncx) {}
  1041. X   friend BaseMatrix;
  1042. Xpublic:
  1043. X   GeneralMatrix* Evaluate(MatrixType);
  1044. X   MatrixBandWidth BandWidth() const;
  1045. X   NEW_DELETE(MatedMatrix)
  1046. X};
  1047. X
  1048. Xclass ConstMatrix : public BaseMatrix
  1049. X{
  1050. X   const GeneralMatrix* cgm;
  1051. X   MatrixType Type() const;
  1052. X//   int NrowsV() const;
  1053. X//   int NcolsV() const;
  1054. X   int search(const BaseMatrix*) const;
  1055. X   ConstMatrix(const GeneralMatrix* cgmx) : cgm(cgmx) {}
  1056. X   friend BaseMatrix;
  1057. X   friend GeneralMatrix;
  1058. Xpublic:
  1059. X   GeneralMatrix* Evaluate(MatrixType);
  1060. X   MatrixBandWidth BandWidth() const;
  1061. X   NEW_DELETE(ConstMatrix)
  1062. X};
  1063. X
  1064. Xclass ReturnMatrixX : public BaseMatrix    // for matrix return
  1065. X{
  1066. X   GeneralMatrix* gm;
  1067. X   MatrixType Type() const;
  1068. X//   int NrowsV() const;
  1069. X//   int NcolsV() const;
  1070. X   int search(const BaseMatrix*) const;
  1071. Xpublic:
  1072. X   GeneralMatrix* Evaluate(MatrixType);
  1073. X   friend BaseMatrix;
  1074. X#ifdef TEMPS_DESTROYED_QUICKLY
  1075. X   ReturnMatrixX(const ReturnMatrixX& tm);
  1076. X#else
  1077. X   ReturnMatrixX(const ReturnMatrixX& tm) : gm(tm.gm) {}
  1078. X#endif
  1079. X   ReturnMatrixX(const GeneralMatrix* gmx) : gm((GeneralMatrix*&)gmx) {}
  1080. X//   ReturnMatrixX(GeneralMatrix&);
  1081. X   MatrixBandWidth BandWidth() const;
  1082. X   NEW_DELETE(ReturnMatrixX)
  1083. X};
  1084. X
  1085. X
  1086. X/**************************** submatrices ******************************/
  1087. X
  1088. Xclass GetSubMatrix : public NegatedMatrix
  1089. X{
  1090. X   int row_skip;
  1091. X   int row_number;
  1092. X   int col_skip;
  1093. X   int col_number;
  1094. X   MatrixType mt;
  1095. X
  1096. X   GetSubMatrix
  1097. X      (const BaseMatrix* bmx, int rs, int rn, int cs, int cn, MatrixType mtx)
  1098. X      : NegatedMatrix(bmx),
  1099. X      row_skip(rs), row_number(rn), col_skip(cs), col_number(cn), mt(mtx) {}
  1100. X   GetSubMatrix(const GetSubMatrix& g)
  1101. X      : NegatedMatrix(g.bm), row_skip(g.row_skip), row_number(g.row_number),
  1102. X      col_skip(g.col_skip), col_number(g.col_number), mt(g.mt) {}
  1103. X   void SetUpLHS();
  1104. X   MatrixType Type() const;
  1105. X//   int NrowsV() const;
  1106. X//   int NcolsV() const;
  1107. X   friend BaseMatrix;
  1108. Xpublic:
  1109. X   GeneralMatrix* Evaluate(MatrixType);
  1110. X   void operator=(const BaseMatrix&);
  1111. X   void operator<<(const BaseMatrix&);
  1112. X   void operator<<(const Real*);                // copy from array
  1113. X   void operator<<(Real);                       // copy from constant
  1114. X   void Inject(const GeneralMatrix&);           // copy stored els only
  1115. X   MatrixBandWidth BandWidth() const;
  1116. X   NEW_DELETE(GetSubMatrix)
  1117. X};
  1118. X
  1119. X
  1120. X/***************************** exceptions ********************************/
  1121. X
  1122. Xclass MatrixDetails
  1123. X{
  1124. X   MatrixType type;
  1125. X   int nrows;
  1126. X   int ncols;
  1127. X   int ubw;
  1128. X   int lbw;
  1129. Xpublic:
  1130. X   MatrixDetails(const GeneralMatrix& A);
  1131. X   void PrintOut();
  1132. X};
  1133. X   
  1134. X
  1135. X
  1136. Xclass SpaceException : public Exception
  1137. X{
  1138. Xpublic:
  1139. X   static long st_type() { return 2; }
  1140. X   long type() const { return 2; }
  1141. X   static int action;
  1142. X   SpaceException();
  1143. X   static void SetAction(int a) { action=a; }
  1144. X};
  1145. X
  1146. X
  1147. Xclass MatrixException : public Exception
  1148. X{
  1149. Xpublic:
  1150. X   static long st_type() { return 3; }
  1151. X   long type() const { return 3; }
  1152. X   MatrixException(int);
  1153. X   MatrixException(int, const GeneralMatrix&);
  1154. X   MatrixException(int, const GeneralMatrix&, const GeneralMatrix&);
  1155. X};
  1156. X
  1157. Xclass DataException : public MatrixException
  1158. X{
  1159. Xpublic:
  1160. X   static long st_type() { return 3*53; }
  1161. X   long type() const { return 3*53; }
  1162. X   static int action;
  1163. X   DataException(const GeneralMatrix& A);
  1164. X   static void SetAction(int a) { action=a; }
  1165. X};
  1166. X
  1167. Xclass SingularException : public DataException
  1168. X{
  1169. Xpublic:
  1170. X   static long st_type() { return 3*53*109; }
  1171. X   long type() const { return 3*53*109; }
  1172. X   SingularException(const GeneralMatrix& A);
  1173. X};
  1174. X
  1175. Xclass NPDException : public DataException     // Not positive definite
  1176. X{
  1177. Xpublic:
  1178. X   static long st_type() { return 3*53*113; }
  1179. X   long type() const { return 3*53*113; }
  1180. X   NPDException(const GeneralMatrix&);
  1181. X};
  1182. X
  1183. Xclass ConvergenceException : public MatrixException
  1184. X{
  1185. Xpublic:
  1186. X   static long st_type() { return 3*59; }
  1187. X   long type() const { return 3*59; }
  1188. X   static int action;
  1189. X   ConvergenceException(const GeneralMatrix& A);
  1190. X   static void SetAction(int a) { action=a; }
  1191. X};
  1192. X
  1193. Xclass ProgramException : public MatrixException
  1194. X{
  1195. Xpublic:
  1196. X   static long st_type() { return 3*61; }
  1197. X   long type() const { return 3*61; }
  1198. X   static int action;
  1199. X   ProgramException(char* c);
  1200. X   ProgramException(char* c, const GeneralMatrix&);
  1201. X   ProgramException(char* c, const GeneralMatrix&, const GeneralMatrix&);
  1202. X   ProgramException();
  1203. X   ProgramException(const GeneralMatrix&);
  1204. X   static void SetAction(int a) { action=a; }
  1205. X};
  1206. X
  1207. Xclass IndexException : public ProgramException
  1208. X{
  1209. Xpublic:
  1210. X   static long st_type() { return 3*61*101; }
  1211. X   long type() const { return 3*61*101; }
  1212. X   IndexException(int i, const GeneralMatrix& A);
  1213. X   IndexException(int i, int j, const GeneralMatrix& A);
  1214. X   // next two are for access via element function
  1215. X   IndexException(int i, const GeneralMatrix& A, Boolean);
  1216. X   IndexException(int i, int j, const GeneralMatrix& A, Boolean);
  1217. X};
  1218. X
  1219. Xclass VectorException : public ProgramException    // can't convert to vector
  1220. X{
  1221. Xpublic:
  1222. X   static long st_type() { return 3*61*107; }
  1223. X   long type() const { return 3*61*107; }
  1224. X   VectorException();
  1225. X   VectorException(const GeneralMatrix& A);
  1226. X};
  1227. X
  1228. Xclass NotSquareException : public ProgramException
  1229. X{
  1230. Xpublic:
  1231. X   static long st_type() { return 3*61*109; }
  1232. X   long type() const { return 3*61*109; }
  1233. X   NotSquareException(const GeneralMatrix& A);
  1234. X};
  1235. X
  1236. Xclass SubMatrixDimensionException : public ProgramException
  1237. X{
  1238. Xpublic:
  1239. X   static long st_type() { return 3*61*113; }
  1240. X   long type() const { return 3*61*113; }
  1241. X   SubMatrixDimensionException();
  1242. X};
  1243. X
  1244. Xclass IncompatibleDimensionsException : public ProgramException
  1245. X{
  1246. Xpublic:
  1247. X   static long st_type() { return 3*61*127; }
  1248. X   long type() const { return 3*61*127; }
  1249. X   IncompatibleDimensionsException();
  1250. X};
  1251. X
  1252. Xclass NotDefinedException : public ProgramException
  1253. X{
  1254. Xpublic:
  1255. X   static long st_type() { return 3*61*131; }
  1256. X   long type() const { return 3*61*131; }
  1257. X   NotDefinedException(char* op, char* matrix);
  1258. X};
  1259. X
  1260. Xclass CannotBuildException : public ProgramException
  1261. X{
  1262. Xpublic:
  1263. X   static long st_type() { return 3*61*137; }
  1264. X   long type() const { return 3*61*137; }
  1265. X   CannotBuildException(char* matrix);
  1266. X};
  1267. X
  1268. X
  1269. Xclass InternalException : public MatrixException
  1270. X{
  1271. Xpublic:
  1272. X   static long st_type() { return 3*67; }
  1273. X   long type() const { return 3*67; }
  1274. X   static int action;
  1275. X   InternalException(char* c);
  1276. X   static void SetAction(int a) { action=a; }
  1277. X};
  1278. X
  1279. X
  1280. X/***************************** functions ***********************************/
  1281. X
  1282. X
  1283. Xinline LogAndSign LogDeterminant(const BaseMatrix& B)
  1284. X   { return B.LogDeterminant(); }
  1285. Xinline Real SumSquare(const BaseMatrix& B) { return B.SumSquare(); }
  1286. Xinline Real Trace(const BaseMatrix& B) { return B.Trace(); }
  1287. Xinline Real SumAbsoluteValue(const BaseMatrix& B)
  1288. X   { return B.SumAbsoluteValue(); }
  1289. Xinline Real MaximumAbsoluteValue(const BaseMatrix& B)
  1290. X   { return B.MaximumAbsoluteValue(); }
  1291. Xinline Real Norm1(const BaseMatrix& B) { return B.Norm1(); }
  1292. Xinline Real Norm1(RowVector& RV) { return RV.MaximumAbsoluteValue(); }
  1293. Xinline Real NormInfinity(const BaseMatrix& B) { return B.NormInfinity(); }
  1294. Xinline Real NormInfinity(ColumnVector& CV)
  1295. X   { return CV.MaximumAbsoluteValue(); } 
  1296. X
  1297. X#endif
  1298. END_OF_FILE
  1299. if test 42428 -ne `wc -c <'newmat.h'`; then
  1300.     echo shar: \"'newmat.h'\" unpacked with wrong size!
  1301. fi
  1302. # end of 'newmat.h'
  1303. fi
  1304. if test -f 'newmatc.txt' -a "${1}" != "-c" ; then 
  1305.   echo shar: Will not clobber existing file \"'newmatc.txt'\"
  1306. else
  1307. echo shar: Extracting \"'newmatc.txt'\" \(1887 characters\)
  1308. sed "s/^X//" >'newmatc.txt' <<'END_OF_FILE'
  1309. X//$$ newmatc.txt                                      Testing
  1310. X
  1311. X                    Testing newmat on your compiler
  1312. X                    ===============================
  1313. X
  1314. XThere are a series of files of the form tmt?.cxx included with some
  1315. Xversions of the package. These are used to check that the package is
  1316. Xperforming correctly. They consist of a large number of matrix formulae
  1317. Xall of which evaluate to zero (except the first one which is used to
  1318. Xcheck that we are detecting non-zero matrices). The printout should
  1319. Xstate that it has found one non-zero matrix.
  1320. X
  1321. XThere is an optional #define DO_FREE_CHECK in include.h. If this is
  1322. Xactivated the program will check that the new-s and delete-s are
  1323. Xbalanced. There should be no unbalanced new-s or delete-s. You need the
  1324. XANSI version of the preprocessor to run DO_FREE_CHECK.
  1325. X
  1326. XThe program also allocates and deletes a large block and small block of
  1327. Xmemory before it starts the main testing and then at the end of the
  1328. Xtest. It then checks that the blocks of memory were allocated in the
  1329. Xsame place. If not then one suspects that there has been a memory leak.
  1330. Xi.e. a piece of memory has been allocated and not deleted.
  1331. X
  1332. XThis is not completely foolproof. Programs may allocate extra print
  1333. Xbuffers while the program is running. I have tried to overcome this by
  1334. Xdoing a print before I allocate the first memory block. Programs may
  1335. Xallocate memory for different sized items in different places, or might
  1336. Xnot allocate items consecutively. Or they might mix the items with memory
  1337. Xblocks from other programs. Nevertheless, I seem to get consistent
  1338. Xanswers from most of the compilers I am working with, so I think this is
  1339. Xa worthwhile test.
  1340. X
  1341. XGnu 2.2 and Zortech do not pass this test. There may be good reasons for
  1342. Xthis, but I think it would be a good idea if the authors of these
  1343. Xpackages made sure they knew what was happening.
  1344. X
  1345. X
  1346. X
  1347. X
  1348. X
  1349. X
  1350. X
  1351. X
  1352. X
  1353. X
  1354. X
  1355. X
  1356. X
  1357. X
  1358. X
  1359. X
  1360. X
  1361. X
  1362. X
  1363. X
  1364. X
  1365. END_OF_FILE
  1366. if test 1887 -ne `wc -c <'newmatc.txt'`; then
  1367.     echo shar: \"'newmatc.txt'\" unpacked with wrong size!
  1368. fi
  1369. # end of 'newmatc.txt'
  1370. fi
  1371. if test -f 'tmt.cxx' -a "${1}" != "-c" ; then 
  1372.   echo shar: Will not clobber existing file \"'tmt.cxx'\"
  1373. else
  1374. echo shar: Extracting \"'tmt.cxx'\" \(4634 characters\)
  1375. sed "s/^X//" >'tmt.cxx' <<'END_OF_FILE'
  1376. X#define WANT_STREAM
  1377. X
  1378. X#include "include.h"
  1379. X
  1380. X#include "newmat.h"
  1381. X
  1382. X/**************************** test program ******************************/
  1383. X
  1384. Xclass PrintCounter
  1385. X{
  1386. X   int count;
  1387. X   char* s;
  1388. Xpublic:
  1389. X   ~PrintCounter();
  1390. X   PrintCounter(char * sx) : count(0), s(sx) {}
  1391. X   void operator++() { count++; }
  1392. X};
  1393. X
  1394. X   PrintCounter PCZ("Number of non-zero matrices = ");
  1395. X   PrintCounter PCN("Number of matrices tested   = ");
  1396. X
  1397. XPrintCounter::~PrintCounter()
  1398. X{ cout << s << count << "\n"; }
  1399. X
  1400. X
  1401. Xvoid Print(const Matrix& X)
  1402. X{
  1403. X   ++PCN;
  1404. X   cout << "\nMatrix type: " << (char*)X.Type() << " (";
  1405. X   cout << X.Nrows() << ", ";
  1406. X   cout << X.Ncols() << ")\n\n";
  1407. X   if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
  1408. X   int nr=X.Nrows(); int nc=X.Ncols();
  1409. X   for (int i=1; i<=nr; i++)
  1410. X   {
  1411. X      for (int j=1; j<=nc; j++)  cout << X(i,j) << "\t";
  1412. X      cout << "\n";
  1413. X   }
  1414. X   cout << flush; ++PCZ;
  1415. X}
  1416. X
  1417. Xvoid Print(const UpperTriangularMatrix& X)
  1418. X{
  1419. X   ++PCN;
  1420. X   cout << "\nMatrix type: " << (char*)X.Type() << " (";
  1421. X   cout << X.Nrows() << ", ";
  1422. X   cout << X.Ncols() << ")\n\n";
  1423. X   if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
  1424. X   int nr=X.Nrows(); int nc=X.Ncols();
  1425. X   for (int i=1; i<=nr; i++)
  1426. X   {
  1427. X      for (int j=1; j<i; j++) cout << "\t";
  1428. X      for (j=i; j<=nc; j++)  cout << X(i,j) << "\t";
  1429. X      cout << "\n";
  1430. X   }
  1431. X   cout << flush; ++PCZ;
  1432. X}
  1433. X
  1434. Xvoid Print(const DiagonalMatrix& X)
  1435. X{
  1436. X   ++PCN;
  1437. X   cout << "\nMatrix type: " << (char*)X.Type() << " (";
  1438. X   cout << X.Nrows() << ", ";
  1439. X   cout << X.Ncols() << ")\n\n";
  1440. X   if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
  1441. X   int nr=X.Nrows(); int nc=X.Ncols();
  1442. X   for (int i=1; i<=nr; i++)
  1443. X   {
  1444. X      for (int j=1; j<i; j++) cout << "\t";
  1445. X      if (i<=nc) cout << X(i,i) << "\t";
  1446. X      cout << "\n";
  1447. X   }
  1448. X   cout << flush; ++PCZ;
  1449. X}
  1450. X
  1451. Xvoid Print(const SymmetricMatrix& X)
  1452. X{
  1453. X   ++PCN;
  1454. X   cout << "\nMatrix type: " << (char*)X.Type() << " (";
  1455. X   cout << X.Nrows() << ", ";
  1456. X   cout << X.Ncols() << ")\n\n";
  1457. X   if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
  1458. X   int nr=X.Nrows(); int nc=X.Ncols();
  1459. X   for (int i=1; i<=nr; i++)
  1460. X   {
  1461. X      for (int j=1; j<i; j++) cout << X(j,i) << "\t";
  1462. X      for (j=i; j<=nc; j++)  cout << X(i,j) << "\t";
  1463. X      cout << "\n";
  1464. X   }
  1465. X   cout << flush; ++PCZ;
  1466. X}
  1467. X
  1468. Xvoid Print(const LowerTriangularMatrix& X)
  1469. X{
  1470. X   ++PCN;
  1471. X   cout << "\nMatrix type: " << (char*)X.Type() << " (";
  1472. X   cout << X.Nrows() << ", ";
  1473. X   cout << X.Ncols() << ")\n\n";
  1474. X   if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
  1475. X   int nr=X.Nrows();
  1476. X   for (int i=1; i<=nr; i++)
  1477. X   {
  1478. X      for (int j=1; j<=i; j++) cout << X(i,j) << "\t";
  1479. X      cout << "\n";
  1480. X   }
  1481. X   cout << flush; ++PCZ;
  1482. X}
  1483. X
  1484. X
  1485. Xvoid Clean(Matrix& A, Real c)
  1486. X{
  1487. X   int nr = A.Nrows(); int nc = A.Ncols();
  1488. X   for (int i=1; i<=nr; i++)
  1489. X   {
  1490. X      for ( int j=1; j<=nc; j++)
  1491. X      { Real a = A(i,j); if ((a < c) && (a > -c)) A(i,j) = 0.0; }
  1492. X   }
  1493. X}
  1494. X
  1495. Xvoid Clean(DiagonalMatrix& A, Real c)
  1496. X{
  1497. X   int nr = A.Nrows();
  1498. X   for (int i=1; i<=nr; i++)
  1499. X   { Real a = A(i,i); if ((a < c) && (a > -c)) A(i,i) = 0.0; }
  1500. X}
  1501. X
  1502. X
  1503. Xvoid trymat1(); void trymat2(); void trymat3();
  1504. Xvoid trymat4(); void trymat5(); void trymat6();
  1505. Xvoid trymat7(); void trymat8(); void trymat9();
  1506. Xvoid trymata(); void trymatb(); void trymatc();
  1507. Xvoid trymatd(); void trymate(); void trymatf();
  1508. Xvoid trymatg(); void trymath(); void trymati();
  1509. X
  1510. Xmain()
  1511. X{
  1512. X   Real* s1; Real* s2; Real* s3; Real* s4;
  1513. X   cout << "\nBegin test\n";   // Forces cout to allocate memory at beginning
  1514. X   { Matrix A1(25,200); s1 = A1.Store(); }
  1515. X   { Matrix A1(1,1); s3 = A1.Store(); }
  1516. X   {
  1517. X      Tracer et("Matrix test program");
  1518. X
  1519. X      Matrix A(25,150);
  1520. X      {
  1521. X     int i;
  1522. X     RowVector A(8);
  1523. X     for (i=1;i<=7;i++) A(i)=0.0; A(8)=1.0;
  1524. X     Print(A);
  1525. X      }
  1526. X      cout << "\n";
  1527. X
  1528. X      TestTypeAdd(); TestTypeMult(); TestTypeOrder();
  1529. X
  1530. X      trymat1();
  1531. X      trymat2();
  1532. X      trymat3();
  1533. X      trymat4();
  1534. X      trymat5();
  1535. X      trymat6();
  1536. X      trymat7();
  1537. X      trymat8();
  1538. X      trymat9();
  1539. X      trymata();
  1540. X      trymatb();
  1541. X      trymatc();
  1542. X      trymatd();
  1543. X      trymate();
  1544. X      trymatf();
  1545. X      trymatg();
  1546. X      trymath();
  1547. X      trymati();
  1548. X   }
  1549. X   { Matrix A1(25,200); s2 = A1.Store(); }
  1550. X   cout << "\nChecking for lost memory: "
  1551. X      << (unsigned long)s1 << " " << (unsigned long)s2 << " ";
  1552. X   if (s1 != s2) cout << " - error\n"; else cout << " - ok\n\n";
  1553. X   { Matrix A1(1,1); s4 = A1.Store(); }
  1554. X   cout << "\nChecking for lost memory: "
  1555. X      << (unsigned long)s3 << " " << (unsigned long)s4 << " ";
  1556. X   if (s3 != s4) cout << " - error\n"; else cout << " - ok\n\n";
  1557. X#ifdef DO_FREE_CHECK
  1558. X   FreeCheck::Status();
  1559. X#endif 
  1560. X   return 0;
  1561. X}
  1562. X
  1563. END_OF_FILE
  1564. if test 4634 -ne `wc -c <'tmt.cxx'`; then
  1565.     echo shar: \"'tmt.cxx'\" unpacked with wrong size!
  1566. fi
  1567. # end of 'tmt.cxx'
  1568. fi
  1569. if test -f 'tmt.mak' -a "${1}" != "-c" ; then 
  1570.   echo shar: Will not clobber existing file \"'tmt.mak'\"
  1571. else
  1572. echo shar: Extracting \"'tmt.mak'\" \(2558 characters\)
  1573. sed "s/^X//" >'tmt.mak' <<'END_OF_FILE'
  1574. XOBJ = fft.o evalue.o submat.o cholesky.o hholder.o sort.o newmatrm.o     \
  1575. X  jacobi.o tmtf.o svd.o tmte.o tmtd.o newmat8.o tmtc.o tmtb.o            \
  1576. X  newmat7.o newmat6.o newmat5.o newmat3.o newmat4.o newmat2.o newmat1.o  \
  1577. X  tmt.o tmt1.o tmt2.o tmt3.o tmt4.o tmt5.o tmt6.o tmt7.o tmt8.o          \
  1578. X  tmt9.o tmta.o tmtg.o tmth.o tmti.o bandmat.o except.o newmatex.o
  1579. X
  1580. Xtmt:          $(OBJ)
  1581. X          g++ -o $@ $(OBJ) -lm
  1582. X
  1583. X%.o:          %.cxx
  1584. X          g++ -c $*.cxx
  1585. X
  1586. Xnewmatxx:     include.h newmat.h boolean.h except.h
  1587. X          rm -f newmatxx
  1588. X          echo "main .h files uptodate?" > newmatxx
  1589. X
  1590. Xexcept.o:     except.h except.cxx
  1591. X
  1592. Xnewmatex.o:   newmatxx newmatex.cxx
  1593. X
  1594. Xexample.o:    newmatxx newmatap.h example.cxx
  1595. X
  1596. Xcholesky.o:   newmatxx cholesky.cxx
  1597. X
  1598. Xevalue.o:     newmatxx newmatrm.h precisio.h evalue.cxx
  1599. X
  1600. Xfft.o:        newmatxx newmatap.h fft.cxx
  1601. X
  1602. Xhholder.o:    newmatxx newmatap.h hholder.cxx
  1603. X
  1604. Xjacobi.o:     newmatxx precisio.h newmatrm.h jacobi.cxx
  1605. X
  1606. Xbandmat.o:    newmatxx newmatrc.h controlw.h bandmat.cxx
  1607. X
  1608. Xnewmat1.o:    newmatxx newmat1.cxx
  1609. X
  1610. Xnewmat2.o:    newmatxx newmatrc.h controlw.h newmat2.cxx
  1611. X
  1612. Xnewmat3.o:    newmatxx newmatrc.h controlw.h newmat3.cxx
  1613. X
  1614. Xnewmat4.o:    newmatxx newmatrc.h controlw.h newmat4.cxx
  1615. X
  1616. Xnewmat5.o:    newmatxx newmatrc.h controlw.h newmat5.cxx
  1617. X
  1618. Xnewmat6.o:    newmatxx newmatrc.h controlw.h newmat6.cxx
  1619. X
  1620. Xnewmat7.o:    newmatxx newmatrc.h controlw.h newmat7.cxx
  1621. X
  1622. Xnewmat8.o:    newmatxx newmatap.h newmat8.cxx
  1623. X
  1624. Xnewmat9.o:    newmatxx newmatrc.h controlw.h newmatio.h newmat9.cxx
  1625. X
  1626. Xnewmatrm.o:   newmatxx newmatrm.h newmatrm.cxx
  1627. X
  1628. Xsort.o:       newmatxx newmatap.h sort.cxx
  1629. X
  1630. Xsubmat.o:     newmatxx newmatrc.h controlw.h submat.cxx
  1631. X
  1632. Xsvd.o:        newmatxx newmatrm.h precisio.h svd.cxx
  1633. X
  1634. Xtmt.o:        newmatxx newmatap.h tmt.cxx 
  1635. X
  1636. Xtmt1.o:       newmatxx newmatap.h tmt1.cxx 
  1637. X
  1638. Xtmt2.o:       newmatxx newmatap.h tmt2.cxx 
  1639. X
  1640. Xtmt3.o:       newmatxx newmatap.h tmt3.cxx 
  1641. X
  1642. Xtmt4.o:       newmatxx newmatap.h tmt4.cxx 
  1643. X
  1644. Xtmt5.o:       newmatxx newmatap.h tmt5.cxx 
  1645. X
  1646. Xtmt6.o:       newmatxx newmatap.h tmt6.cxx 
  1647. X
  1648. Xtmt7.o:       newmatxx newmatap.h tmt7.cxx 
  1649. X
  1650. Xtmt8.o:       newmatxx newmatap.h tmt8.cxx 
  1651. X
  1652. Xtmt9.o:       newmatxx newmatap.h tmt9.cxx 
  1653. X
  1654. Xtmta.o:       newmatxx newmatap.h tmta.cxx 
  1655. X
  1656. Xtmtb.o:       newmatxx newmatap.h tmtb.cxx 
  1657. X
  1658. Xtmtc.o:       newmatxx newmatap.h tmtc.cxx 
  1659. X
  1660. Xtmtd.o:       newmatxx newmatap.h tmtd.cxx 
  1661. X
  1662. Xtmte.o:       newmatxx newmatap.h tmte.cxx 
  1663. X
  1664. Xtmtf.o:       newmatxx newmatap.h tmtf.cxx 
  1665. X
  1666. Xtmtg.o:       newmatxx newmatap.h tmtg.cxx 
  1667. X
  1668. Xtmth.o:       newmatxx newmatap.h tmth.cxx
  1669. X
  1670. Xtmti.o:       newmatxx newmatap.h tmti.cxx
  1671. X
  1672. X
  1673. END_OF_FILE
  1674. if test 2558 -ne `wc -c <'tmt.mak'`; then
  1675.     echo shar: \"'tmt.mak'\" unpacked with wrong size!
  1676. fi
  1677. # end of 'tmt.mak'
  1678. fi
  1679. echo shar: End of archive 3 \(of 7\).
  1680. cp /dev/null ark3isdone
  1681. MISSING=""
  1682. for I in 1 2 3 4 5 6 7 ; do
  1683.     if test ! -f ark${I}isdone ; then
  1684.     MISSING="${MISSING} ${I}"
  1685.     fi
  1686. done
  1687. if test "${MISSING}" = "" ; then
  1688.     echo You have unpacked all 7 archives.
  1689.     rm -f ark[1-9]isdone
  1690. else
  1691.     echo You still need to unpack the following archives:
  1692.     echo "        " ${MISSING}
  1693. fi
  1694. ##  End of shell archive.
  1695. exit 0
  1696.  
  1697. exit 0 # Just in case...
  1698.