GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dDiagMatrix.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_dDiagMatrix_h)
24 #define octave_dDiagMatrix_h 1
25 
26 #include "octave-config.h"
27 
28 #include "MDiagArray2.h"
29 
30 #include "dRowVector.h"
31 #include "dColVector.h"
32 #include "DET.h"
33 
34 #include "mx-defs.h"
35 
36 class
37 OCTAVE_API
39 {
40 public:
41 
42  DiagMatrix (void) : MDiagArray2<double> () { }
43 
45  : MDiagArray2<double> (r, c) { }
46 
48  : MDiagArray2<double> (r, c, val) { }
49 
51 
53 
54  template <typename U>
56 
57  explicit DiagMatrix (const Array<double>& a) : MDiagArray2<double> (a) { }
58 
60  : MDiagArray2<double> (a, r, c) { }
61 
63  {
65  return *this;
66  }
67 
68  bool operator == (const DiagMatrix& a) const;
69  bool operator != (const DiagMatrix& a) const;
70 
71  DiagMatrix& fill (double val);
72  DiagMatrix& fill (double val, octave_idx_type beg, octave_idx_type end);
73  DiagMatrix& fill (const ColumnVector& a);
74  DiagMatrix& fill (const RowVector& a);
75  DiagMatrix& fill (const ColumnVector& a, octave_idx_type beg);
76  DiagMatrix& fill (const RowVector& a, octave_idx_type beg);
77 
78  DiagMatrix transpose (void) const
79  { return MDiagArray2<double>::transpose (); }
80  DiagMatrix abs (void) const;
81 
82  friend OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a);
83  friend OCTAVE_API DiagMatrix imag (const ComplexDiagMatrix& a);
84 
85  // resize is the destructive analog for this one
86 
87  Matrix extract (octave_idx_type r1, octave_idx_type c1,
88  octave_idx_type r2, octave_idx_type c2) const;
89 
90  // extract row or column i.
91 
93  RowVector row (char *s) const;
94 
96  ColumnVector column (char *s) const;
97 
98  DiagMatrix inverse (void) const;
99  DiagMatrix inverse (octave_idx_type& info) const;
100  DiagMatrix pseudo_inverse (double tol = 0.0) const;
101 
102  // other operations
103 
106 
107  DET determinant (void) const;
108  double rcond (void) const;
109 
110  // i/o
111 
112  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
113  const DiagMatrix& a);
114 
115 };
116 
117 OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a);
118 OCTAVE_API DiagMatrix imag (const ComplexDiagMatrix& a);
119 
120 // diagonal matrix by diagonal matrix -> diagonal matrix operations
121 
122 OCTAVE_API DiagMatrix
123 operator * (const DiagMatrix& a, const DiagMatrix& b);
124 
126 
127 #endif
OCTAVE_API DiagMatrix operator*(const DiagMatrix &a, const DiagMatrix &b)
Definition: dDiagMatrix.cc:281
OCTAVE_API DiagMatrix real(const ComplexDiagMatrix &a)
Definition: dDiagMatrix.cc:133
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:567
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
MDiagArray2< T > & operator=(const MDiagArray2< T > &a)
Definition: MDiagArray2.h:78
DiagMatrix(octave_idx_type r, octave_idx_type c)
Definition: dDiagMatrix.h:44
SparseBoolMatrix & operator=(const SparseBoolMatrix &a)
Definition: boolSparse.h:82
OCTAVE_API DiagMatrix imag(const ComplexDiagMatrix &a)
Definition: dDiagMatrix.cc:139
for large enough k
Definition: lu.cc:606
DiagMatrix(void)
Definition: dDiagMatrix.h:42
DiagMatrix transpose(void) const
Definition: dDiagMatrix.h:78
Array< T > extract_diag(octave_idx_type k=0) const
Definition: DiagArray2.cc:58
#define MDIAGARRAY2_FORWARD_DEFS(B, R, T)
Definition: MDiagArray2.h:132
s
Definition: file-io.cc:2682
ColumnVector extract_diag(octave_idx_type k=0) const
Definition: dDiagMatrix.h:104
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
DiagMatrix(const DiagMatrix &a)
Definition: dDiagMatrix.h:50
Definition: DET.h:33
DiagMatrix(octave_idx_type r, octave_idx_type c, double val)
Definition: dDiagMatrix.h:47
DiagMatrix(const DiagArray2< U > &a)
Definition: dDiagMatrix.h:55
Template for two dimensional diagonal array with math operators.
Definition: MDiagArray2.h:33
Definition: dMatrix.h:37
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:538
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup abs(local error in x(i))<
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
issues an error eealso double
Definition: ov-bool-mat.cc:594
b
Definition: cellfun.cc:398
DiagMatrix(const MDiagArray2< double > &a)
Definition: dDiagMatrix.h:52
MDiagArray2< T > transpose(void) const
Definition: MDiagArray2.h:109
DiagMatrix(const Array< double > &a, octave_idx_type r, octave_idx_type c)
Definition: dDiagMatrix.h:59
DiagMatrix(const Array< double > &a)
Definition: dDiagMatrix.h:57
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
Definition: str2double.cc:342