GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
CDiagMatrix.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1994-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_CDiagMatrix_h)
27 #define octave_CDiagMatrix_h 1
28 
29 #include "octave-config.h"
30 
31 #include "CColVector.h"
32 #include "CRowVector.h"
33 #include "DET.h"
34 #include "MDiagArray2.h"
35 #include "dColVector.h"
36 #include "dRowVector.h"
37 #include "mx-defs.h"
38 
39 class
40 OCTAVE_API
42 {
43 public:
44 
46 
47  typedef double real_elt_type;
50 
51  ComplexDiagMatrix (void) = default;
52 
53  ComplexDiagMatrix (const ComplexDiagMatrix& a) = default;
54 
55  ComplexDiagMatrix& operator = (const ComplexDiagMatrix& a) = default;
56 
57  ~ComplexDiagMatrix (void) = default;
58 
60  : MDiagArray2<Complex> (r, c) { }
61 
63  : MDiagArray2<Complex> (r, c, val) { }
64 
65  explicit ComplexDiagMatrix (const Array<Complex>& a)
66  : MDiagArray2<Complex> (a) { }
67 
68  explicit ComplexDiagMatrix (const Array<double>& a)
69  : MDiagArray2<Complex> (Array<Complex> (a)) { }
70 
73  : MDiagArray2<Complex> (a, r, c) { }
74 
75  explicit ComplexDiagMatrix (const DiagMatrix& a);
76 
78  : MDiagArray2<Complex> (a) { }
79 
80  template <typename U>
82  : MDiagArray2<Complex> (a) { }
83 
84  bool operator == (const ComplexDiagMatrix& a) const;
85  bool operator != (const ComplexDiagMatrix& a) const;
86 
87  ComplexDiagMatrix& fill (double val);
88  ComplexDiagMatrix& fill (const Complex& val);
89  ComplexDiagMatrix& fill (double val,
91  ComplexDiagMatrix& fill (const Complex& val,
93  ComplexDiagMatrix& fill (const ColumnVector& a);
94  ComplexDiagMatrix& fill (const ComplexColumnVector& a);
95  ComplexDiagMatrix& fill (const RowVector& a);
96  ComplexDiagMatrix& fill (const ComplexRowVector& a);
97  ComplexDiagMatrix& fill (const ColumnVector& a, octave_idx_type beg);
99  ComplexDiagMatrix& fill (const RowVector& a, octave_idx_type beg);
100  ComplexDiagMatrix& fill (const ComplexRowVector& a, octave_idx_type beg);
101 
105  { return MDiagArray2<Complex>::transpose (); }
106  DiagMatrix abs (void) const;
107 
108  friend OCTAVE_API ComplexDiagMatrix conj (const ComplexDiagMatrix& a);
109 
110  // resize is the destructive analog for this one
111 
113  octave_idx_type r2, octave_idx_type c2) const;
114 
115  // extract row or column i
116 
117  ComplexRowVector row (octave_idx_type i) const;
118  ComplexRowVector row (char *s) const;
119 
120  ComplexColumnVector column (octave_idx_type i) const;
121  ComplexColumnVector column (char *s) const;
122 
123  ComplexDiagMatrix inverse (octave_idx_type& info) const;
124  ComplexDiagMatrix inverse (void) const;
125  ComplexDiagMatrix pseudo_inverse (double tol = 0.0) const;
126 
127  bool all_elements_are_real (void) const;
128 
129  // diagonal matrix by diagonal matrix -> diagonal matrix operations
130 
133 
134  // other operations
135 
137  { return MDiagArray2<Complex>::extract_diag (k); }
138 
139  ComplexDET determinant (void) const;
140  double rcond (void) const;
141 
142  // i/o
143 
144  friend std::ostream& operator << (std::ostream& os,
145  const ComplexDiagMatrix& a);
146 
147 };
148 
149 OCTAVE_API ComplexDiagMatrix conj (const ComplexDiagMatrix& a);
150 
151 // diagonal matrix by diagonal matrix -> diagonal matrix operations
152 
153 OCTAVE_API ComplexDiagMatrix
155 
156 OCTAVE_API ComplexDiagMatrix
157 operator * (const ComplexDiagMatrix& a, const DiagMatrix& b);
158 
159 OCTAVE_API ComplexDiagMatrix
160 operator * (const DiagMatrix& a, const ComplexDiagMatrix& b);
161 
163 
164 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
ComplexColumnVector operator+=(ComplexColumnVector &x, const Complex &y)
Definition: CColVector.h:152
ComplexColumnVector operator-=(ComplexColumnVector &x, const Complex &y)
Definition: CColVector.h:152
OCTAVE_API ComplexDiagMatrix conj(const ComplexDiagMatrix &a)
Definition: CDiagMatrix.cc:215
OCTAVE_API ComplexDiagMatrix operator*(const ComplexDiagMatrix &a, const ComplexDiagMatrix &b)
Definition: CDiagMatrix.cc:461
#define MDIAGARRAY2_FORWARD_DEFS(B, R, T)
Definition: MDiagArray2.h:128
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:128
ComplexDiagMatrix(const Array< Complex > &a)
Definition: CDiagMatrix.h:65
ComplexDiagMatrix hermitian(void) const
Definition: CDiagMatrix.h:102
ComplexDiagMatrix(const ComplexDiagMatrix &a)=default
ComplexMatrix full_matrix_type
Definition: CDiagMatrix.h:45
ComplexDiagMatrix(const Array< double > &a)
Definition: CDiagMatrix.h:68
double real_elt_type
Definition: CDiagMatrix.h:47
ComplexDiagMatrix(void)=default
Complex complex_elt_type
Definition: CDiagMatrix.h:48
ComplexDiagMatrix(const Array< Complex > &a, octave_idx_type r, octave_idx_type c)
Definition: CDiagMatrix.h:71
ComplexDiagMatrix(const DiagArray2< U > &a)
Definition: CDiagMatrix.h:81
ComplexDiagMatrix(const MDiagArray2< Complex > &a)
Definition: CDiagMatrix.h:77
ComplexDiagMatrix(octave_idx_type r, octave_idx_type c, const Complex &val)
Definition: CDiagMatrix.h:62
~ComplexDiagMatrix(void)=default
ComplexDiagMatrix transpose(void) const
Definition: CDiagMatrix.h:104
Complex element_type
Definition: CDiagMatrix.h:49
ComplexDiagMatrix(octave_idx_type r, octave_idx_type c)
Definition: CDiagMatrix.h:59
ComplexColumnVector extract_diag(octave_idx_type k=0) const
Definition: CDiagMatrix.h:136
Array< T > extract_diag(octave_idx_type k=0) const
Definition: DiagArray2.cc:50
MDiagArray2< T > hermitian(T(*fcn)(const T &)=nullptr) const
Definition: MDiagArray2.h:106
MDiagArray2< T > transpose(void) const
Definition: MDiagArray2.h:105
Definition: DET.h:39
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:601
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:585
T * r
Definition: mx-inlines.cc:773
std::complex< double > Complex
Definition: oct-cmplx.h:33
static T abs(T x)
Definition: pr-output.cc:1678