GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
fDiagMatrix.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_fDiagMatrix_h)
27 #define octave_fDiagMatrix_h 1
28 
29 #include "octave-config.h"
30 
31 #include "DET.h"
32 #include "MDiagArray2.h"
33 #include "fColVector.h"
34 #include "fRowVector.h"
35 #include "mx-defs.h"
36 
37 class
38 OCTAVE_API
40 {
41 public:
42 
44 
45  FloatDiagMatrix (void) = default;
46 
47  FloatDiagMatrix (const FloatDiagMatrix& a) = default;
48 
49  FloatDiagMatrix& operator = (const FloatDiagMatrix& a) = default;
50 
51  ~FloatDiagMatrix (void) = default;
52 
54  : MDiagArray2<float> (r, c) { }
55 
57  : MDiagArray2<float> (r, c, val) { }
58 
59  FloatDiagMatrix (const MDiagArray2<float>& a) : MDiagArray2<float> (a) { }
60 
61  template <typename U>
62  FloatDiagMatrix (const DiagArray2<U>& a) : MDiagArray2<float> (a) { }
63 
64  explicit FloatDiagMatrix (const Array<double>& a) : MDiagArray2<float> (a) { }
65 
67  : MDiagArray2<float> (a, r, c) { }
68 
69  bool operator == (const FloatDiagMatrix& a) const;
70  bool operator != (const FloatDiagMatrix& a) const;
71 
72  FloatDiagMatrix& fill (float val);
73  FloatDiagMatrix& fill (float val, octave_idx_type beg, octave_idx_type end);
74  FloatDiagMatrix& fill (const FloatColumnVector& a);
75  FloatDiagMatrix& fill (const FloatRowVector& a);
77  FloatDiagMatrix& fill (const FloatRowVector& a, octave_idx_type beg);
78 
80  { return MDiagArray2<float>::transpose (); }
81 
82  FloatDiagMatrix abs (void) const;
83 
84  friend OCTAVE_API FloatDiagMatrix real (const FloatComplexDiagMatrix& a);
85  friend OCTAVE_API FloatDiagMatrix imag (const FloatComplexDiagMatrix& a);
86 
87  // resize is the destructive analog for this one
88 
90  octave_idx_type r2, octave_idx_type c2) const;
91 
92  // extract row or column i.
93 
94  FloatRowVector row (octave_idx_type i) const;
95  FloatRowVector row (char *s) const;
96 
97  FloatColumnVector column (octave_idx_type i) const;
98  FloatColumnVector column (char *s) const;
99 
100  FloatDiagMatrix inverse (void) const;
101  FloatDiagMatrix inverse (octave_idx_type& info) const;
102  FloatDiagMatrix pseudo_inverse (float tol = 0.0f) const;
103 
104  // other operations
105 
107  { return MDiagArray2<float>::extract_diag (k); }
108 
109  FloatDET determinant (void) const;
110  float rcond (void) const;
111 
112  // i/o
113 
114  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
115  const FloatDiagMatrix& a);
116 
117 };
118 
119 OCTAVE_API FloatDiagMatrix real (const FloatComplexDiagMatrix& a);
120 OCTAVE_API FloatDiagMatrix imag (const FloatComplexDiagMatrix& a);
121 
122 // diagonal matrix by diagonal matrix -> diagonal matrix operations
123 
124 OCTAVE_API FloatDiagMatrix operator * (const FloatDiagMatrix& a,
125  const FloatDiagMatrix& b);
126 
128 
129 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
#define MDIAGARRAY2_FORWARD_DEFS(B, R, T)
Definition: MDiagArray2.h:128
Array< T > extract_diag(octave_idx_type k=0) const
Definition: DiagArray2.cc:50
FloatDiagMatrix transpose(void) const
Definition: fDiagMatrix.h:79
FloatDiagMatrix(octave_idx_type r, octave_idx_type c)
Definition: fDiagMatrix.h:53
FloatDiagMatrix(const DiagArray2< U > &a)
Definition: fDiagMatrix.h:62
FloatDiagMatrix(void)=default
FloatMatrix full_matrix_type
Definition: fDiagMatrix.h:43
FloatColumnVector extract_diag(octave_idx_type k=0) const
Definition: fDiagMatrix.h:106
FloatDiagMatrix(const MDiagArray2< float > &a)
Definition: fDiagMatrix.h:59
~FloatDiagMatrix(void)=default
FloatDiagMatrix(const Array< double > &a)
Definition: fDiagMatrix.h:64
FloatDiagMatrix(const Array< float > &a, octave_idx_type r, octave_idx_type c)
Definition: fDiagMatrix.h:66
FloatDiagMatrix(const FloatDiagMatrix &a)=default
FloatDiagMatrix(octave_idx_type r, octave_idx_type c, float val)
Definition: fDiagMatrix.h:56
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
OCTAVE_API FloatDiagMatrix operator*(const FloatDiagMatrix &a, const FloatDiagMatrix &b)
Definition: fDiagMatrix.cc:282
OCTAVE_API FloatDiagMatrix real(const FloatComplexDiagMatrix &a)
Definition: fDiagMatrix.cc:134
OCTAVE_API FloatDiagMatrix imag(const FloatComplexDiagMatrix &a)
Definition: fDiagMatrix.cc:140
T * r
Definition: mx-inlines.cc:773
static T abs(T x)
Definition: pr-output.cc:1678