GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CDiagMatrix.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1994-2024 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
42 {
43 public:
44 
46 
47  typedef double real_elt_type;
50 
51  ComplexDiagMatrix () = default;
52 
53  ComplexDiagMatrix (const ComplexDiagMatrix& a) = default;
54 
55  ComplexDiagMatrix& operator = (const ComplexDiagMatrix& a) = default;
56 
57  ~ComplexDiagMatrix () = 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 OCTAVE_API ComplexDiagMatrix (const DiagMatrix& a);
76 
78  : MDiagArray2<Complex> (a) { }
79 
80  template <typename U>
82  : MDiagArray2<Complex> (a) { }
83 
84  OCTAVE_API bool operator == (const ComplexDiagMatrix& a) const;
85  OCTAVE_API bool operator != (const ComplexDiagMatrix& a) const;
86 
87  OCTAVE_API ComplexDiagMatrix& fill (double val);
88  OCTAVE_API ComplexDiagMatrix& fill (const Complex& val);
90  fill (double val, octave_idx_type beg, octave_idx_type end);
92  fill (const Complex& val, octave_idx_type beg, octave_idx_type end);
93  OCTAVE_API ComplexDiagMatrix& fill (const ColumnVector& a);
95  OCTAVE_API ComplexDiagMatrix& fill (const RowVector& a);
98  fill (const ColumnVector& a, octave_idx_type beg);
100  fill (const ComplexColumnVector& a, octave_idx_type beg);
103  fill (const ComplexRowVector& a, octave_idx_type beg);
104 
108  { return MDiagArray2<Complex>::transpose (); }
109  DiagMatrix abs () const;
110 
112 
113  // resize is the destructive analog for this one
114 
116  extract (octave_idx_type r1, octave_idx_type c1,
117  octave_idx_type r2, octave_idx_type c2) const;
118 
119  // extract row or column i
120 
122  OCTAVE_API ComplexRowVector row (char *s) const;
123 
125  OCTAVE_API ComplexColumnVector column (char *s) const;
126 
127  OCTAVE_API ComplexDiagMatrix inverse (octave_idx_type& info) const;
128  OCTAVE_API ComplexDiagMatrix inverse () const;
129  OCTAVE_API ComplexDiagMatrix pseudo_inverse (double tol = 0.0) const;
130 
131  OCTAVE_API bool all_elements_are_real () const;
132 
133  // diagonal matrix by diagonal matrix -> diagonal matrix operations
134 
137 
138  // other operations
139 
141  { return MDiagArray2<Complex>::extract_diag (k); }
142 
143  OCTAVE_API ComplexDET determinant () const;
144  OCTAVE_API double rcond () const;
145 
146  // i/o
147 
148  friend OCTAVE_API std::ostream&
149  operator << (std::ostream& os, const ComplexDiagMatrix& a);
150 
151 };
152 
154 
155 // diagonal matrix by diagonal matrix -> diagonal matrix operations
156 
159 
161 operator * (const ComplexDiagMatrix& a, const DiagMatrix& b);
162 
164 operator * (const DiagMatrix& a, const ComplexDiagMatrix& b);
165 
167 
168 #endif
template std::ostream & operator<<(std::ostream &, const Array< bool > &)
ComplexColumnVector operator+=(ComplexColumnVector &x, const Complex &y)
Definition: CColVector.h:158
ComplexColumnVector operator-=(ComplexColumnVector &x, const Complex &y)
Definition: CColVector.h:158
ComplexDiagMatrix operator*(const ComplexDiagMatrix &a, const ComplexDiagMatrix &b)
Definition: CDiagMatrix.cc:461
ComplexDiagMatrix conj(const ComplexDiagMatrix &a)
Definition: CDiagMatrix.cc:215
#define MDIAGARRAY2_FORWARD_DEFS(B, R, T)
Definition: MDiagArray2.h:132
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:130
ComplexDiagMatrix hermitian() const
Definition: CDiagMatrix.h:105
ComplexDiagMatrix(const Array< Complex > &a)
Definition: CDiagMatrix.h:65
~ComplexDiagMatrix()=default
ComplexDiagMatrix(const ComplexDiagMatrix &a)=default
ComplexMatrix full_matrix_type
Definition: CDiagMatrix.h:45
ComplexDiagMatrix()=default
ComplexDiagMatrix(const Array< double > &a)
Definition: CDiagMatrix.h:68
double real_elt_type
Definition: CDiagMatrix.h:47
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 transpose() const
Definition: CDiagMatrix.h:107
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
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:140
Array< T > extract_diag(octave_idx_type k=0) const
Definition: DiagArray2.cc:50
MDiagArray2< T > transpose() const
Definition: MDiagArray2.h:106
MDiagArray2< T > hermitian(T(*fcn)(const T &)=nullptr) const
Definition: MDiagArray2.h:107
Definition: DET.h:39
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:536
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:520
#define OCTAVE_API
Definition: main.cc:55
T * r
Definition: mx-inlines.cc:781
std::complex< double > Complex
Definition: oct-cmplx.h:33
template int8_t abs(int8_t)