GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
array
MDiagArray2.h
Go to the documentation of this file.
1
// Template array classes with like-type math ops
2
/*
3
4
Copyright (C) 1996-2013 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
37
MDIAGARRAY2_OPS_FORWARD_DECLS
(
MDiagArray2
, )
38
39
template <class T>
40
class
41
MDiagArray2
: public
DiagArray2
<T>
42
{
43
public
:
44
45
MDiagArray2
(
void
) :
DiagArray2
<T> () { }
46
47
MDiagArray2
(
octave_idx_type
r,
octave_idx_type
c) :
DiagArray2
<T> (r, c) { }
48
49
MDiagArray2
(
octave_idx_type
r,
octave_idx_type
c,
const
T& val)
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
61
MDiagArray2
(
const
Array<T>
& a,
octave_idx_type
r,
octave_idx_type
c)
62
:
DiagArray2
<T> (a, r, c) { }
63
64
~MDiagArray2
(
void
) { }
65
66
MDiagArray2<T>
&
operator =
(
const
MDiagArray2<T>
& a)
67
{
68
DiagArray2<T>::operator =
(a);
69
return
*
this
;
70
}
71
72
MArray<T>
array_value
()
const
73
{
74
return
DiagArray2<T>::array_value
();
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
94
MArray<T>
diag
(
octave_idx_type
k = 0)
const
95
{
return
DiagArray2<T>::extract_diag
(k); }
96
97
MDiagArray2<T>
transpose
(
void
)
const
{
return
DiagArray2<T>::transpose
(); }
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
106
MDIAGARRAY2_OPS_FRIEND_DECLS
(
MDiagArray2
, )
107
108
};
109
110
#endif
Generated on Mon Dec 30 2013 03:04:44 for GNU Octave by
1.8.1.2