GNU Octave  4.0.0
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
MDiagArray2.h
Go to the documentation of this file.
1 // Template array classes with like-type math ops
2 /*
3 
4 Copyright (C) 1996-2015 John W. Eaton
5 Copyright (C) 2010 VZLU Prague
6 
7 This file is part of Octave.
8 
9 Octave is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if !defined (octave_MDiagArray2_h)
26 #define octave_MDiagArray2_h 1
27 
28 #include "DiagArray2.h"
29 #include "MArray.h"
30 
31 // Two dimensional diagonal array with math ops.
32 
33 // But first, some preprocessor abuse...
34 
35 #include "MArray-decl.h"
36 
38 
39 template <class T>
40 class
41 MDiagArray2 : public DiagArray2<T>
42 {
43 public:
44 
45  MDiagArray2 (void) : DiagArray2<T> () { }
46 
48 
50  : DiagArray2<T> (r, c, val) { }
51 
52  MDiagArray2 (const MDiagArray2<T>& a) : DiagArray2<T> (a) { }
53 
54  MDiagArray2 (const DiagArray2<T>& a) : DiagArray2<T> (a) { }
55 
56  template <class U>
57  MDiagArray2 (const DiagArray2<U>& a) : DiagArray2<T> (a) { }
58 
59  explicit MDiagArray2 (const Array<T>& a) : DiagArray2<T> (a) { }
60 
62  : DiagArray2<T> (a, r, c) { }
63 
64  ~MDiagArray2 (void) { }
65 
67  {
69  return *this;
70  }
71 
73  {
75  }
76 
77  octave_idx_type nnz (void) const
78  {
79  octave_idx_type retval = 0;
80 
81  const T *d = this->data ();
82 
83  octave_idx_type nel = this->length ();
84 
85  for (octave_idx_type i = 0; i < nel; i++)
86  {
87  if (d[i] != T ())
88  retval++;
89  }
90 
91  return retval;
92  }
93 
95  { return DiagArray2<T>::extract_diag (k); }
96 
98  MDiagArray2<T> hermitian (T (*fcn) (const T&) = 0) const
99  { return DiagArray2<T>::hermitian (fcn); }
100 
101  bool is_multiple_of_identity (T val) const;
102 
103  // Currently, the OPS functions don't need to be friends, but that
104  // may change.
105 
107 
108 };
109 
110 #endif
MDiagArray2< T > hermitian(T(*fcn)(const T &)=0) const
Definition: MDiagArray2.h:98
octave_idx_type nnz(void) const
Definition: MDiagArray2.h:77
Complex * data(void)
Definition: Sparse.h:509
MDiagArray2(const DiagArray2< U > &a)
Definition: MDiagArray2.h:57
MDiagArray2(const Array< T > &a)
Definition: MDiagArray2.h:59
Array< T > extract_diag(octave_idx_type k=0) const
Definition: DiagArray2.cc:58
Definition: MArray.h:36
DiagArray2< T > hermitian(T(*fcn)(const T &)=0) const
Definition: DiagArray2.cc:84
MDiagArray2(octave_idx_type r, octave_idx_type c, const T &val)
Definition: MDiagArray2.h:49
F77_RET_T const double const double double * d
DiagArray2< T > & operator=(const DiagArray2< T > &a)
Definition: DiagArray2.h:71
MDiagArray2(octave_idx_type r, octave_idx_type c)
Definition: MDiagArray2.h:47
MDiagArray2(void)
Definition: MDiagArray2.h:45
MArray< T > diag(octave_idx_type k=0) const
Definition: MDiagArray2.h:94
MDiagArray2(const DiagArray2< T > &a)
Definition: MDiagArray2.h:54
Array< T > array_value(void) const
Definition: DiagArray2.cc:111
MArray< T > array_value() const
Definition: MDiagArray2.h:72
Handles the reference counting for all the derived classes.
Definition: Array.h:45
MDiagArray2(const Array< T > &a, octave_idx_type r, octave_idx_type c)
Definition: MDiagArray2.h:61
#define MDIAGARRAY2_OPS_FRIEND_DECLS(A_T, API)
Definition: MArray-decl.h:230
#define MDIAGARRAY2_OPS_FORWARD_DECLS(A_T, API)
Definition: MArray-decl.h:216
DiagArray2< T > transpose(void) const
Definition: DiagArray2.cc:77
MDiagArray2< T > transpose(void) const
Definition: MDiagArray2.h:97
~MDiagArray2(void)
Definition: MDiagArray2.h:64
SparseComplexMatrix & operator=(const SparseComplexMatrix &a)
Definition: CSparse.h:104
MDiagArray2(const MDiagArray2< T > &a)
Definition: MDiagArray2.h:52