GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
CDiagMatrix.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2025 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
40{
41public:
42
44
45 typedef double real_elt_type;
48
49 ComplexDiagMatrix () = default;
50
52
54
55 ~ComplexDiagMatrix () = default;
56
59
62
64 : MDiagArray2<Complex> (a) { }
65
66 explicit ComplexDiagMatrix (const Array<double>& a)
67 : MDiagArray2<Complex> (Array<Complex> (a)) { }
68
72
73 explicit OCTAVE_API ComplexDiagMatrix (const DiagMatrix& a);
74
77
78 template <typename U>
81
82 OCTAVE_API bool operator == (const ComplexDiagMatrix& a) const;
83 OCTAVE_API bool operator != (const ComplexDiagMatrix& a) const;
84
85 OCTAVE_API ComplexDiagMatrix& fill (double val);
86 OCTAVE_API ComplexDiagMatrix& fill (const Complex& val);
88 fill (double val, octave_idx_type beg, octave_idx_type end);
90 fill (const Complex& val, octave_idx_type beg, octave_idx_type end);
93 OCTAVE_API ComplexDiagMatrix& fill (const RowVector& a);
96 fill (const ColumnVector& a, octave_idx_type beg);
98 fill (const ComplexColumnVector& a, octave_idx_type beg);
101 fill (const ComplexRowVector& a, octave_idx_type beg);
102
104 { return MDiagArray2<Complex>::hermitian (std::conj); }
107 DiagMatrix abs () const;
108
110
111 // resize is the destructive analog for this one
112
114 extract (octave_idx_type r1, octave_idx_type c1,
115 octave_idx_type r2, octave_idx_type c2) const;
116
117 // extract row or column i
118
120 OCTAVE_API ComplexRowVector row (char *s) const;
121
123 OCTAVE_API ComplexColumnVector column (char *s) const;
124
125 OCTAVE_API ComplexDiagMatrix inverse (octave_idx_type& info) const;
126 OCTAVE_API ComplexDiagMatrix inverse () const;
127 OCTAVE_API ComplexDiagMatrix pseudo_inverse (double tol = 0.0) const;
128
129 OCTAVE_API bool all_elements_are_real () const;
130
131 // diagonal matrix by diagonal matrix -> diagonal matrix operations
132
135
136 // other operations
137
140
141 OCTAVE_API ComplexDET determinant () const;
142 OCTAVE_API double rcond () const;
143
144 // i/o
145
146 friend OCTAVE_API std::ostream&
147 operator << (std::ostream& os, const ComplexDiagMatrix& a);
148
149};
150
152
153// diagonal matrix by diagonal matrix -> diagonal matrix operations
154
157
159operator * (const ComplexDiagMatrix& a, const DiagMatrix& b);
160
162operator * (const DiagMatrix& a, const ComplexDiagMatrix& b);
163
165
166#endif
template std::ostream & operator<<(std::ostream &, const Array< bool > &)
ComplexColumnVector conj(const ComplexColumnVector &a)
ComplexColumnVector operator+=(ComplexColumnVector &x, const Complex &y)
Definition CColVector.h:156
ComplexColumnVector operator-=(ComplexColumnVector &x, const Complex &y)
Definition CColVector.h:156
ComplexDiagMatrix operator*(const ComplexDiagMatrix &a, const ComplexDiagMatrix &b)
ComplexDiagMatrix conj(const ComplexDiagMatrix &a)
#define MDIAGARRAY2_FORWARD_DEFS(B, R, T)
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
ComplexDiagMatrix hermitian() const
ComplexDiagMatrix(const Array< Complex > &a)
Definition CDiagMatrix.h:63
~ComplexDiagMatrix()=default
ComplexDiagMatrix(const ComplexDiagMatrix &a)=default
ComplexMatrix full_matrix_type
Definition CDiagMatrix.h:43
ComplexDiagMatrix()=default
ComplexDiagMatrix(const Array< double > &a)
Definition CDiagMatrix.h:66
Complex complex_elt_type
Definition CDiagMatrix.h:46
ComplexDiagMatrix(const Array< Complex > &a, octave_idx_type r, octave_idx_type c)
Definition CDiagMatrix.h:69
ComplexDiagMatrix(const DiagArray2< U > &a)
Definition CDiagMatrix.h:79
ComplexDiagMatrix transpose() const
ComplexDiagMatrix(const MDiagArray2< Complex > &a)
Definition CDiagMatrix.h:75
ComplexDiagMatrix(octave_idx_type r, octave_idx_type c, const Complex &val)
Definition CDiagMatrix.h:60
ComplexDiagMatrix(octave_idx_type r, octave_idx_type c)
Definition CDiagMatrix.h:57
ComplexColumnVector extract_diag(octave_idx_type k=0) const
Array< T > extract_diag(octave_idx_type k=0) const
Definition DiagArray2.cc:48
Template for two dimensional diagonal array with math operators.
Definition MDiagArray2.h:54
MDiagArray2< T > & operator=(const MDiagArray2< T > &a)
Definition MDiagArray2.h:78
MDiagArray2< T > hermitian(T(*fcn)(const T &)=nullptr) const
MDiagArray2< T > transpose() const
Definition DET.h:38
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition dim-vector.h:532
bool operator==(const dim_vector &a, const dim_vector &b)
Definition dim-vector.h:516
#define OCTAVE_API
Definition main.in.cc:55
std::complex< double > Complex
Definition oct-cmplx.h:33
template int8_t abs(int8_t)