5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 Andy Adler |
|
5 |
|
6 Octave is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
5307
|
17 along with this program; see the file COPYING. If not, write to the |
|
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 Boston, MA 02110-1301, USA. |
5164
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_MSparse_h) |
|
24 #define octave_MSparse_h 1 |
|
25 |
|
26 #include "MArray2.h" |
|
27 |
|
28 #include "Sparse.h" |
|
29 |
|
30 // Two dimensional sparse array with math ops. |
|
31 |
|
32 // But first, some preprocessor abuse... |
|
33 |
|
34 #include "MSparse-defs.h" |
|
35 |
6708
|
36 SPARSE_OPS_FORWARD_DECLS (MSparse, MArray2, ) |
5164
|
37 |
|
38 template <class T> |
|
39 class |
|
40 MSparse : public Sparse<T> |
|
41 { |
|
42 public: |
|
43 |
|
44 MSparse (void) : Sparse<T> () { } |
|
45 |
5275
|
46 MSparse (octave_idx_type n, octave_idx_type m) : Sparse<T> (n, m) { } |
5164
|
47 |
|
48 MSparse (const MSparse<T>& a) : Sparse<T> (a) { } |
|
49 |
|
50 MSparse (const MSparse<T>& a, const dim_vector& dv) : Sparse<T> (a, dv) { } |
|
51 |
|
52 MSparse (const Sparse<T>& a) : Sparse<T> (a) { } |
|
53 |
5275
|
54 MSparse (const Array<T> a, const Array<octave_idx_type>& r, |
|
55 const Array<octave_idx_type>& c, octave_idx_type nr = -1, |
|
56 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
57 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
58 |
|
59 MSparse (const Array<T> a, const Array<double>& r, |
5275
|
60 const Array<double>& c, octave_idx_type nr = -1, |
|
61 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
62 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
63 |
5275
|
64 explicit MSparse (octave_idx_type r, octave_idx_type c, T val) : Sparse<T> (r, c, val) { } |
5164
|
65 |
5275
|
66 MSparse (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<T> (r, c, num_nz) { } |
5164
|
67 |
|
68 ~MSparse (void) { } |
|
69 |
|
70 MSparse<T>& operator = (const MSparse<T>& a) |
|
71 { |
|
72 Sparse<T>::operator = (a); |
|
73 return *this; |
|
74 } |
|
75 |
5275
|
76 MSparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c) |
5164
|
77 { |
|
78 Sparse<T>::insert (a, r, c); |
|
79 return *this; |
|
80 } |
|
81 |
|
82 MSparse<T> transpose (void) const { return Sparse<T>::transpose (); } |
|
83 |
|
84 MSparse<T> squeeze (void) const { return Sparse<T>::squeeze (); } |
|
85 |
|
86 MSparse<T> index (idx_vector& i, int resize_ok) const |
|
87 { return Sparse<T>::index (i, resize_ok); } |
|
88 |
|
89 MSparse<T> index (idx_vector& i, idx_vector& j, int resize_ok) const |
|
90 { return Sparse<T>::index (i, j, resize_ok); } |
|
91 |
|
92 MSparse<T> index (Array<idx_vector>& ra_idx, int resize_ok) const |
|
93 { return Sparse<T>::index (ra_idx, resize_ok); } |
|
94 |
|
95 MSparse<T> reshape (const dim_vector& new_dims) const |
|
96 { return Sparse<T>::reshape (new_dims); } |
|
97 |
5275
|
98 MSparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const |
5164
|
99 { return Sparse<T>::permute (vec, inv); } |
|
100 |
5275
|
101 MSparse<T> ipermute (const Array<octave_idx_type>& vec) const |
5164
|
102 { return Sparse<T>::ipermute (vec); } |
|
103 |
|
104 |
|
105 // Currently, the OPS functions don't need to be friends, but that |
|
106 // may change. |
|
107 |
|
108 // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray2) |
|
109 }; |
|
110 |
|
111 #endif |
|
112 |
|
113 /* |
|
114 ;;; Local Variables: *** |
|
115 ;;; mode: C++ *** |
|
116 ;;; End: *** |
|
117 */ |