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
MSparse.h
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 2004-2013 David Bateman
4
Copyright (C) 1998-2004 Andy Adler
5
6
This file is part of Octave.
7
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
12
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
21
22
*/
23
24
#if !defined (octave_MSparse_h)
25
#define octave_MSparse_h 1
26
27
#include "
MArray.h
"
28
29
#include "
Sparse.h
"
30
31
// Two dimensional sparse array with math ops.
32
33
// But first, some preprocessor abuse...
34
35
#include "
MSparse-defs.h
"
36
37
SPARSE_OPS_FORWARD_DECLS
(
MSparse
,
MArray
, )
38
39
template <class T>
40
class
41
MSparse
: public
Sparse
<T>
42
{
43
public
:
44
45
MSparse
(
void
) :
Sparse
<T> () { }
46
47
MSparse
(
octave_idx_type
n,
octave_idx_type
m) :
Sparse
<T> (n, m) { }
48
49
MSparse
(
const
dim_vector
& dv,
octave_idx_type
nz = 0)
50
:
Sparse
<T> (dv, nz) { }
51
52
MSparse
(
const
MSparse<T>
& a) :
Sparse
<T> (a) { }
53
54
MSparse
(
const
MSparse<T>
& a,
const
dim_vector
& dv) :
Sparse
<T> (a, dv) { }
55
56
MSparse
(
const
Sparse<T>
& a) :
Sparse
<T> (a) { }
57
58
template
<
class
U>
59
MSparse
(
const
Sparse<U>
& a) :
Sparse
<T> (a) { }
60
61
MSparse
(
const
Array<T>
& a,
const
idx_vector
& r,
const
idx_vector
& c,
62
octave_idx_type
nr = -1,
octave_idx_type
nc = -1,
63
bool
sum_terms =
true
,
octave_idx_type
nzm = -1)
64
:
Sparse
<T> (a, r, c, nr, nc, sum_terms, nzm) { }
65
66
explicit
MSparse
(
octave_idx_type
r,
octave_idx_type
c, T val)
67
:
Sparse
<T> (r, c, val) { }
68
69
explicit
MSparse
(
const
PermMatrix
& a) :
Sparse
<T>(a) { }
70
71
MSparse
(
octave_idx_type
r,
octave_idx_type
c,
octave_idx_type
num_nz)
72
:
Sparse
<T> (r, c, num_nz) { }
73
74
~MSparse
(
void
) { }
75
76
MSparse<T>
&
operator =
(
const
MSparse<T>
& a)
77
{
78
Sparse<T>::operator =
(a);
79
return
*
this
;
80
}
81
82
MSparse<T>
&
insert
(
const
Sparse<T>
& a,
octave_idx_type
r,
octave_idx_type
c)
83
{
84
Sparse<T>::insert
(a, r, c);
85
return
*
this
;
86
}
87
88
MSparse<T>
&
insert
(
const
Sparse<T>
& a,
const
Array<octave_idx_type>
& indx)
89
{
90
Sparse<T>::insert
(a, indx);
91
return
*
this
;
92
}
93
94
MSparse<T>
transpose
(
void
)
const
{
return
Sparse<T>::transpose
(); }
95
96
MSparse<T>
squeeze
(
void
)
const
{
return
Sparse<T>::squeeze
(); }
97
98
MSparse<T>
reshape
(
const
dim_vector
& new_dims)
const
99
{
return
Sparse<T>::reshape
(new_dims); }
100
101
MSparse<T>
permute
(
const
Array<octave_idx_type>
& vec,
bool
inv =
false
)
const
102
{
return
Sparse<T>::permute
(vec, inv); }
103
104
MSparse<T>
ipermute
(
const
Array<octave_idx_type>
& vec)
const
105
{
return
Sparse<T>::ipermute
(vec); }
106
107
MSparse<T>
diag
(
octave_idx_type
k = 0)
const
108
{
109
return
Sparse<T>::diag
(k);
110
}
111
112
// FIXME: should go away.
113
template
<
class
U>
114
MSparse<U>
115
map
(U (&fcn) (T))
const
116
{
return
Sparse<T>::template
map<U> (fcn); }
117
118
template
<
class
U>
119
MSparse<U>
120
map
(U (&fcn) (
const
T&))
const
121
{
return
Sparse<T>::template
map<U> (fcn); }
122
123
// Currently, the OPS functions don't need to be friends, but that
124
// may change.
125
126
// SPARSE_OPS_FRIEND_DECLS (MSparse, MArray)
127
};
128
129
#endif
Generated on Mon Dec 30 2013 03:04:44 for GNU Octave by
1.8.1.2