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 |
6823
|
48 MSparse (const dim_vector& dv, octave_idx_type nz = 0) : |
|
49 Sparse<T> (dv, nz) { } |
|
50 |
5164
|
51 MSparse (const MSparse<T>& a) : Sparse<T> (a) { } |
|
52 |
|
53 MSparse (const MSparse<T>& a, const dim_vector& dv) : Sparse<T> (a, dv) { } |
|
54 |
|
55 MSparse (const Sparse<T>& a) : Sparse<T> (a) { } |
|
56 |
5275
|
57 MSparse (const Array<T> a, const Array<octave_idx_type>& r, |
|
58 const Array<octave_idx_type>& c, octave_idx_type nr = -1, |
|
59 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
60 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
61 |
|
62 MSparse (const Array<T> a, const Array<double>& r, |
5275
|
63 const Array<double>& c, octave_idx_type nr = -1, |
|
64 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
65 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
66 |
5275
|
67 explicit MSparse (octave_idx_type r, octave_idx_type c, T val) : Sparse<T> (r, c, val) { } |
5164
|
68 |
5275
|
69 MSparse (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<T> (r, c, num_nz) { } |
5164
|
70 |
|
71 ~MSparse (void) { } |
|
72 |
|
73 MSparse<T>& operator = (const MSparse<T>& a) |
|
74 { |
|
75 Sparse<T>::operator = (a); |
|
76 return *this; |
|
77 } |
|
78 |
5275
|
79 MSparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c) |
5164
|
80 { |
|
81 Sparse<T>::insert (a, r, c); |
|
82 return *this; |
|
83 } |
|
84 |
6823
|
85 MSparse<T>& insert (const Sparse<T>& a, const Array<octave_idx_type>& indx) |
|
86 { |
|
87 Sparse<T>::insert (a, indx); |
|
88 return *this; |
|
89 } |
|
90 |
5164
|
91 MSparse<T> transpose (void) const { return Sparse<T>::transpose (); } |
|
92 |
|
93 MSparse<T> squeeze (void) const { return Sparse<T>::squeeze (); } |
|
94 |
|
95 MSparse<T> index (idx_vector& i, int resize_ok) const |
|
96 { return Sparse<T>::index (i, resize_ok); } |
|
97 |
|
98 MSparse<T> index (idx_vector& i, idx_vector& j, int resize_ok) const |
|
99 { return Sparse<T>::index (i, j, resize_ok); } |
|
100 |
|
101 MSparse<T> index (Array<idx_vector>& ra_idx, int resize_ok) const |
|
102 { return Sparse<T>::index (ra_idx, resize_ok); } |
|
103 |
|
104 MSparse<T> reshape (const dim_vector& new_dims) const |
|
105 { return Sparse<T>::reshape (new_dims); } |
|
106 |
5275
|
107 MSparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const |
5164
|
108 { return Sparse<T>::permute (vec, inv); } |
|
109 |
5275
|
110 MSparse<T> ipermute (const Array<octave_idx_type>& vec) const |
5164
|
111 { return Sparse<T>::ipermute (vec); } |
|
112 |
|
113 |
|
114 // Currently, the OPS functions don't need to be friends, but that |
|
115 // may change. |
|
116 |
|
117 // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray2) |
|
118 }; |
|
119 |
|
120 #endif |
|
121 |
|
122 /* |
|
123 ;;; Local Variables: *** |
|
124 ;;; mode: C++ *** |
|
125 ;;; End: *** |
|
126 */ |