CDiagMatrix.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1994-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_ComplexDiagMatrix_h)
00024 #define octave_ComplexDiagMatrix_h 1
00025 
00026 #include "MDiagArray2.h"
00027 
00028 #include "dRowVector.h"
00029 #include "CRowVector.h"
00030 #include "dColVector.h"
00031 #include "CColVector.h"
00032 #include "DET.h"
00033 
00034 #include "mx-defs.h"
00035 
00036 class
00037 OCTAVE_API
00038 ComplexDiagMatrix : public MDiagArray2<Complex>
00039 {
00040 public:
00041 
00042   ComplexDiagMatrix (void) : MDiagArray2<Complex> () { }
00043 
00044   ComplexDiagMatrix (octave_idx_type r, octave_idx_type c) : MDiagArray2<Complex> (r, c) { }
00045 
00046   ComplexDiagMatrix (octave_idx_type r, octave_idx_type c, const Complex& val)
00047     : MDiagArray2<Complex> (r, c, val) { }
00048 
00049   explicit ComplexDiagMatrix (const Array<Complex>& a)
00050     : MDiagArray2<Complex> (a) { }
00051 
00052   explicit ComplexDiagMatrix (const Array<double>& a)
00053     : MDiagArray2<Complex> (Array<Complex> (a)) { }
00054 
00055   ComplexDiagMatrix (const Array<Complex>& a, octave_idx_type r, octave_idx_type c)
00056     : MDiagArray2<Complex> (a, r, c) { }
00057 
00058   explicit ComplexDiagMatrix (const DiagMatrix& a);
00059 
00060   ComplexDiagMatrix (const MDiagArray2<Complex>& a)
00061     : MDiagArray2<Complex> (a) { }
00062 
00063   ComplexDiagMatrix (const ComplexDiagMatrix& a)
00064     : MDiagArray2<Complex> (a) { }
00065 
00066   template <class U>
00067   ComplexDiagMatrix (const DiagArray2<U>& a)
00068     : MDiagArray2<Complex> (a) { }
00069 
00070   ComplexDiagMatrix& operator = (const ComplexDiagMatrix& a)
00071     {
00072       MDiagArray2<Complex>::operator = (a);
00073       return *this;
00074     }
00075 
00076   bool operator == (const ComplexDiagMatrix& a) const;
00077   bool operator != (const ComplexDiagMatrix& a) const;
00078 
00079   ComplexDiagMatrix& fill (double val);
00080   ComplexDiagMatrix& fill (const Complex& val);
00081   ComplexDiagMatrix& fill (double val, octave_idx_type beg, octave_idx_type end);
00082   ComplexDiagMatrix& fill (const Complex& val, octave_idx_type beg, octave_idx_type end);
00083   ComplexDiagMatrix& fill (const ColumnVector& a);
00084   ComplexDiagMatrix& fill (const ComplexColumnVector& a);
00085   ComplexDiagMatrix& fill (const RowVector& a);
00086   ComplexDiagMatrix& fill (const ComplexRowVector& a);
00087   ComplexDiagMatrix& fill (const ColumnVector& a, octave_idx_type beg);
00088   ComplexDiagMatrix& fill (const ComplexColumnVector& a, octave_idx_type beg);
00089   ComplexDiagMatrix& fill (const RowVector& a, octave_idx_type beg);
00090   ComplexDiagMatrix& fill (const ComplexRowVector& a, octave_idx_type beg);
00091 
00092   ComplexDiagMatrix hermitian (void) const { return MDiagArray2<Complex>::hermitian (std::conj); }
00093   ComplexDiagMatrix transpose (void) const { return MDiagArray2<Complex>::transpose(); }
00094   DiagMatrix abs (void) const;
00095 
00096   friend OCTAVE_API ComplexDiagMatrix conj (const ComplexDiagMatrix& a);
00097 
00098   // resize is the destructive analog for this one
00099 
00100   ComplexMatrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const;
00101 
00102   // extract row or column i
00103 
00104   ComplexRowVector row (octave_idx_type i) const;
00105   ComplexRowVector row (char *s) const;
00106 
00107   ComplexColumnVector column (octave_idx_type i) const;
00108   ComplexColumnVector column (char *s) const;
00109 
00110   ComplexDiagMatrix inverse (octave_idx_type& info) const;
00111   ComplexDiagMatrix inverse (void) const;
00112   ComplexDiagMatrix pseudo_inverse (void) const;
00113 
00114   bool all_elements_are_real (void) const;
00115 
00116   // diagonal matrix by diagonal matrix -> diagonal matrix operations
00117 
00118   ComplexDiagMatrix& operator += (const DiagMatrix& a);
00119   ComplexDiagMatrix& operator -= (const DiagMatrix& a);
00120 
00121   // other operations
00122 
00123   ComplexColumnVector diag (octave_idx_type k = 0) const
00124     { return MDiagArray2<Complex>::diag (k); }
00125 
00126   ComplexDET determinant (void) const;
00127   double rcond (void) const;
00128 
00129   // i/o
00130 
00131   friend std::ostream& operator << (std::ostream& os, const ComplexDiagMatrix& a);
00132 
00133 };
00134 
00135 OCTAVE_API ComplexDiagMatrix conj (const ComplexDiagMatrix& a);
00136 
00137 // diagonal matrix by diagonal matrix -> diagonal matrix operations
00138 
00139 OCTAVE_API ComplexDiagMatrix
00140 operator * (const ComplexDiagMatrix& a, const ComplexDiagMatrix& b);
00141 
00142 OCTAVE_API ComplexDiagMatrix
00143 operator * (const ComplexDiagMatrix& a, const DiagMatrix& b);
00144 
00145 OCTAVE_API ComplexDiagMatrix
00146 operator * (const DiagMatrix& a, const ComplexDiagMatrix& b);
00147 
00148 MDIAGARRAY2_FORWARD_DEFS (MDiagArray2, ComplexDiagMatrix, Complex)
00149 
00150 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines