GNU Octave  9.1.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-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_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
40 {
41 public:
42 
44 
45  FloatDiagMatrix () = default;
46 
47  FloatDiagMatrix (const FloatDiagMatrix& a) = default;
48 
49  FloatDiagMatrix& operator = (const FloatDiagMatrix& a) = default;
50 
51  ~FloatDiagMatrix () = 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  OCTAVE_API bool operator == (const FloatDiagMatrix& a) const;
70  OCTAVE_API bool operator != (const FloatDiagMatrix& a) const;
71 
72  OCTAVE_API FloatDiagMatrix& fill (float val);
74  fill (float val, octave_idx_type beg, octave_idx_type end);
76  OCTAVE_API FloatDiagMatrix& fill (const FloatRowVector& a);
78  fill (const FloatColumnVector& a, octave_idx_type beg);
80  fill (const FloatRowVector& a, octave_idx_type beg);
81 
83  { return MDiagArray2<float>::transpose (); }
84 
86 
89 
90  // resize is the destructive analog for this one
91 
93  extract (octave_idx_type r1, octave_idx_type c1,
94  octave_idx_type r2, octave_idx_type c2) const;
95 
96  // extract row or column i.
97 
99  OCTAVE_API FloatRowVector row (char *s) const;
100 
102  OCTAVE_API FloatColumnVector column (char *s) const;
103 
104  OCTAVE_API FloatDiagMatrix inverse () const;
105  OCTAVE_API FloatDiagMatrix inverse (octave_idx_type& info) const;
106  OCTAVE_API FloatDiagMatrix pseudo_inverse (float tol = 0.0f) const;
107 
108  // other operations
109 
111  { return MDiagArray2<float>::extract_diag (k); }
112 
113  OCTAVE_API FloatDET determinant () const;
114  OCTAVE_API float rcond () const;
115 
116  // i/o
117 
118  friend OCTAVE_API std::ostream&
119  operator << (std::ostream& os, const FloatDiagMatrix& a);
120 
121 };
122 
125 
126 // diagonal matrix by diagonal matrix -> diagonal matrix operations
127 
129 operator * (const FloatDiagMatrix& a, const FloatDiagMatrix& b);
130 
132 
133 #endif
template std::ostream & operator<<(std::ostream &, const Array< bool > &)
#define MDIAGARRAY2_FORWARD_DEFS(B, R, T)
Definition: MDiagArray2.h:132
Array< T > extract_diag(octave_idx_type k=0) const
Definition: DiagArray2.cc:50
FloatDiagMatrix(octave_idx_type r, octave_idx_type c)
Definition: fDiagMatrix.h:53
FloatDiagMatrix(const DiagArray2< U > &a)
Definition: fDiagMatrix.h:62
FloatDiagMatrix transpose() const
Definition: fDiagMatrix.h:82
FloatMatrix full_matrix_type
Definition: fDiagMatrix.h:43
~FloatDiagMatrix()=default
FloatColumnVector extract_diag(octave_idx_type k=0) const
Definition: fDiagMatrix.h:110
FloatDiagMatrix(const MDiagArray2< float > &a)
Definition: fDiagMatrix.h:59
FloatDiagMatrix(const Array< double > &a)
Definition: fDiagMatrix.h:64
FloatDiagMatrix()=default
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() const
Definition: MDiagArray2.h:106
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
FloatDiagMatrix real(const FloatComplexDiagMatrix &a)
Definition: fDiagMatrix.cc:134
FloatDiagMatrix operator*(const FloatDiagMatrix &a, const FloatDiagMatrix &b)
Definition: fDiagMatrix.cc:282
FloatDiagMatrix imag(const FloatComplexDiagMatrix &a)
Definition: fDiagMatrix.cc:140
#define OCTAVE_API
Definition: main.cc:55
T * r
Definition: mx-inlines.cc:781
template int8_t abs(int8_t)