home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / octave-1.1.1-src.lha / octave-1.1.1 / liboctave / CMatrix.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-04  |  9.7 KB  |  296 lines

  1. //                                  -*- C++ -*-
  2. /*
  3.  
  4. Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
  5.  
  6. This file is part of Octave.
  7.  
  8. Octave is free software; you can redistribute it and/or modify it
  9. under the terms of the GNU General Public License as published by the
  10. Free Software Foundation; either version 2, or (at your option) any
  11. later version.
  12.  
  13. Octave is distributed in the hope that it will be useful, but WITHOUT
  14. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16. for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with Octave; see the file COPYING.  If not, write to the Free
  20. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. */
  23.  
  24. #if !defined (octave_ComplexMatrix_h)
  25. #define octave_ComplexMatrix_h 1
  26.  
  27. #include <Complex.h>
  28.  
  29. #include "Array.h"
  30.  
  31. #include "mx-defs.h"
  32.  
  33. extern "C++" {
  34.  
  35. class ComplexMatrix : public Array2<Complex>
  36. {
  37. friend class ComplexCHOL;
  38. friend class ComplexHESS;
  39. friend class ComplexLU;
  40. friend class ComplexQR;
  41. friend class ComplexQRP;
  42. friend class ComplexSCHUR;
  43. friend class ComplexSVD;
  44. friend class ComplexColumnVector;
  45. friend class Matrix;
  46.  
  47. public:
  48.  
  49.   ComplexMatrix (void) : Array2<Complex> () { }
  50.   ComplexMatrix (int r, int c) : Array2<Complex> (r, c) { }
  51.   ComplexMatrix (int r, int c, const Complex& val)
  52.     : Array2<Complex> (r, c, val) { }
  53.   ComplexMatrix (const Matrix& a);
  54.   ComplexMatrix (const Array2<Complex>& a) : Array2<Complex> (a) { }
  55.   ComplexMatrix (const ComplexMatrix& a) : Array2<Complex> (a) { }
  56.   ComplexMatrix (const DiagMatrix& a);
  57.   ComplexMatrix (const DiagArray<Complex>& a) : Array2<Complex> (a) { }
  58.   ComplexMatrix (const ComplexDiagMatrix& a);
  59. //  ComplexMatrix (double a) : Array2<Complex> (1, 1, a) { }
  60. //  ComplexMatrix (const Complex& a) : Array2<Complex> (1, 1, a) { }
  61.  
  62.   ComplexMatrix& operator = (const ComplexMatrix& a)
  63.     {
  64.       Array2<Complex>::operator = (a);
  65.       return *this;
  66.     }
  67.  
  68. //  operator Array2<Complex>& () const { return *this; }
  69.  
  70.   int operator == (const ComplexMatrix& a) const;
  71.   int operator != (const ComplexMatrix& a) const;
  72.  
  73. // destructive insert/delete/reorder operations
  74.  
  75.   ComplexMatrix& insert (const Matrix& a, int r, int c);
  76.   ComplexMatrix& insert (const RowVector& a, int r, int c);
  77.   ComplexMatrix& insert (const ColumnVector& a, int r, int c);
  78.   ComplexMatrix& insert (const DiagMatrix& a, int r, int c);
  79.  
  80.   ComplexMatrix& insert (const ComplexMatrix& a, int r, int c);
  81.   ComplexMatrix& insert (const ComplexRowVector& a, int r, int c);
  82.   ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c);
  83.   ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c);
  84.  
  85.   ComplexMatrix& fill (double val);
  86.   ComplexMatrix& fill (const Complex& val);
  87.   ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2);
  88.   ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2);
  89.  
  90.   ComplexMatrix append (const Matrix& a) const;
  91.   ComplexMatrix append (const RowVector& a) const;
  92.   ComplexMatrix append (const ColumnVector& a) const;
  93.   ComplexMatrix append (const DiagMatrix& a) const;
  94.  
  95.   ComplexMatrix append (const ComplexMatrix& a) const;
  96.   ComplexMatrix append (const ComplexRowVector& a) const;
  97.   ComplexMatrix append (const ComplexColumnVector& a) const;
  98.   ComplexMatrix append (const ComplexDiagMatrix& a) const;
  99.  
  100.   ComplexMatrix stack (const Matrix& a) const;
  101.   ComplexMatrix stack (const RowVector& a) const;
  102.   ComplexMatrix stack (const ColumnVector& a) const;
  103.   ComplexMatrix stack (const DiagMatrix& a) const;
  104.  
  105.   ComplexMatrix stack (const ComplexMatrix& a) const;
  106.   ComplexMatrix stack (const ComplexRowVector& a) const;
  107.   ComplexMatrix stack (const ComplexColumnVector& a) const;
  108.   ComplexMatrix stack (const ComplexDiagMatrix& a) const;
  109.  
  110.   ComplexMatrix hermitian (void) const;  // complex conjugate transpose
  111.   ComplexMatrix transpose (void) const;
  112.  
  113.   friend Matrix real (const ComplexMatrix& a);
  114.   friend Matrix imag (const ComplexMatrix& a);
  115.   friend ComplexMatrix conj (const ComplexMatrix& a);
  116.  
  117. // resize is the destructive equivalent for this one
  118.  
  119.   ComplexMatrix extract (int r1, int c1, int r2, int c2) const;
  120.  
  121. // extract row or column i.
  122.  
  123.   ComplexRowVector row (int i) const;
  124.   ComplexRowVector row (char *s) const;
  125.  
  126.   ComplexColumnVector column (int i) const;
  127.   ComplexColumnVector column (char *s) const;
  128.  
  129.   ComplexMatrix inverse (void) const;
  130.   ComplexMatrix inverse (int& info) const;
  131.   ComplexMatrix inverse (int& info, double& rcond) const;
  132.  
  133.   ComplexMatrix pseudo_inverse (double tol = 0.0);
  134.  
  135.   ComplexMatrix fourier (void) const;
  136.   ComplexMatrix ifourier (void) const;
  137.  
  138.   ComplexMatrix fourier2d (void) const;
  139.   ComplexMatrix ifourier2d (void) const;
  140.  
  141.   ComplexDET determinant (void) const;
  142.   ComplexDET determinant (int& info) const;
  143.   ComplexDET determinant (int& info, double& rcond) const;
  144.  
  145.   ComplexMatrix solve (const Matrix& b) const;
  146.   ComplexMatrix solve (const Matrix& b, int& info) const;
  147.   ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const;
  148.  
  149.   ComplexMatrix solve (const ComplexMatrix& b) const;
  150.   ComplexMatrix solve (const ComplexMatrix& b, int& info) const;
  151.   ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const;
  152.  
  153.   ComplexColumnVector solve (const ComplexColumnVector& b) const;
  154.   ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const;
  155.   ComplexColumnVector solve (const ComplexColumnVector& b, int& info,
  156.                  double& rcond) const;
  157.  
  158.   ComplexMatrix lssolve (const ComplexMatrix& b) const;
  159.   ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const;
  160.   ComplexMatrix lssolve (const ComplexMatrix& b, int& info,
  161.              int& rank) const;
  162.  
  163.   ComplexColumnVector lssolve (const ComplexColumnVector& b) const;
  164.   ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const;
  165.   ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info,
  166.                    int& rank) const;
  167.  
  168. // matrix by diagonal matrix -> matrix operations
  169.  
  170.   ComplexMatrix& operator += (const DiagMatrix& a);
  171.   ComplexMatrix& operator -= (const DiagMatrix& a);
  172.  
  173.   ComplexMatrix& operator += (const ComplexDiagMatrix& a);
  174.   ComplexMatrix& operator -= (const ComplexDiagMatrix& a);
  175.  
  176. // matrix by matrix -> matrix operations
  177.  
  178.   ComplexMatrix& operator += (const Matrix& a);
  179.   ComplexMatrix& operator -= (const Matrix& a);
  180.  
  181.   ComplexMatrix& operator += (const ComplexMatrix& a);
  182.   ComplexMatrix& operator -= (const ComplexMatrix& a);
  183.  
  184. // unary operations
  185.  
  186.   Matrix operator ! (void) const;
  187.  
  188. // matrix by scalar -> matrix operations
  189.  
  190.   friend ComplexMatrix operator + (const ComplexMatrix& a, double s);
  191.   friend ComplexMatrix operator - (const ComplexMatrix& a, double s);
  192.   friend ComplexMatrix operator * (const ComplexMatrix& a, double s);
  193.   friend ComplexMatrix operator / (const ComplexMatrix& a, double s);
  194.  
  195. // scalar by matrix -> matrix operations
  196.  
  197.   friend ComplexMatrix operator + (double s, const ComplexMatrix& a);
  198.   friend ComplexMatrix operator - (double s, const ComplexMatrix& a);
  199.   friend ComplexMatrix operator * (double s, const ComplexMatrix& a);
  200.   friend ComplexMatrix operator / (double s, const ComplexMatrix& a);
  201.  
  202. // matrix by column vector -> column vector operations
  203.  
  204.   friend ComplexColumnVector operator * (const ComplexMatrix& a,
  205.                      const ColumnVector& b);
  206.  
  207.   friend ComplexColumnVector operator * (const ComplexMatrix& a,
  208.                      const ComplexColumnVector& b);
  209.  
  210. // matrix by diagonal matrix -> matrix operations
  211.  
  212.   friend ComplexMatrix operator + (const ComplexMatrix& a,
  213.                    const DiagMatrix& b);
  214.   friend ComplexMatrix operator - (const ComplexMatrix& a,
  215.                    const DiagMatrix& b);
  216.   friend ComplexMatrix operator * (const ComplexMatrix& a,
  217.                    const DiagMatrix& b);
  218.  
  219.   friend ComplexMatrix operator + (const ComplexMatrix& a,
  220.                    const ComplexDiagMatrix& b);
  221.   friend ComplexMatrix operator - (const ComplexMatrix& a,
  222.                    const ComplexDiagMatrix& b);
  223.   friend ComplexMatrix operator * (const ComplexMatrix& a,
  224.                    const ComplexDiagMatrix& b);
  225.  
  226. // matrix by matrix -> matrix operations
  227.  
  228.   friend ComplexMatrix operator + (const ComplexMatrix& a, const Matrix& b);
  229.   friend ComplexMatrix operator - (const ComplexMatrix& a, const Matrix& b);
  230.  
  231.   friend ComplexMatrix operator * (const ComplexMatrix& a, const Matrix& b);
  232.   friend ComplexMatrix operator * (const ComplexMatrix& a,
  233.                    const ComplexMatrix& b);
  234.  
  235.   friend ComplexMatrix product (const ComplexMatrix& a, const Matrix& b);
  236.   friend ComplexMatrix quotient (const ComplexMatrix& a, const Matrix& b);
  237.  
  238. // other operations
  239.  
  240.   friend ComplexMatrix map (c_c_Mapper f, const ComplexMatrix& a);
  241.   friend Matrix map (d_c_Mapper f, const ComplexMatrix& a);
  242.   void map (c_c_Mapper f);
  243.  
  244.   Matrix all (void) const;
  245.   Matrix any (void) const;
  246.  
  247.   ComplexMatrix cumprod (void) const;
  248.   ComplexMatrix cumsum (void) const;
  249.   ComplexMatrix prod (void) const;
  250.   ComplexMatrix sum (void) const;
  251.   ComplexMatrix sumsq (void) const;
  252.  
  253.   ComplexColumnVector diag (void) const;
  254.   ComplexColumnVector diag (int k) const;
  255.  
  256.   ComplexColumnVector row_min (void) const;
  257.   ComplexColumnVector row_min_loc (void) const;
  258.  
  259.   ComplexColumnVector row_max (void) const;
  260.   ComplexColumnVector row_max_loc (void) const;
  261.  
  262.   ComplexRowVector column_min (void) const;
  263.   ComplexRowVector column_min_loc (void) const;
  264.  
  265.   ComplexRowVector column_max (void) const;
  266.   ComplexRowVector column_max_loc (void) const;
  267.  
  268. // i/o
  269.  
  270.   friend ostream& operator << (ostream& os, const ComplexMatrix& a);
  271.   friend istream& operator >> (istream& is, ComplexMatrix& a);
  272.  
  273. #define KLUDGE_MATRICES
  274. #define TYPE Complex
  275. #define KL_MAT_TYPE ComplexMatrix
  276. #include "mx-kludge.h"
  277. #undef KLUDGE_MATRICES
  278. #undef TYPE
  279. #undef KL_MAT_TYPE
  280.  
  281. private:
  282.  
  283.   ComplexMatrix (Complex *d, int r, int c) : Array2<Complex> (d, r, c) { }
  284. };
  285.  
  286. } // extern "C++"
  287.  
  288. #endif
  289.  
  290. /*
  291. ;;; Local Variables: ***
  292. ;;; mode: C++ ***
  293. ;;; page-delimiter: "^/\\*" ***
  294. ;;; End: ***
  295. */
  296.