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 |
|
17 along with this program; see the file COPYING. If not, write to the Free |
|
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
19 |
|
20 */ |
|
21 |
|
22 #if !defined (octave_MSparse_h) |
|
23 #define octave_MSparse_h 1 |
|
24 |
|
25 #include "MArray2.h" |
|
26 |
|
27 #include "Sparse.h" |
|
28 |
|
29 // Two dimensional sparse array with math ops. |
|
30 |
|
31 // But first, some preprocessor abuse... |
|
32 |
|
33 #include "MSparse-defs.h" |
|
34 |
|
35 SPARSE_OPS_FORWARD_DECLS (MSparse, MArray2) |
|
36 |
|
37 template <class T> |
|
38 class |
|
39 MSparse : public Sparse<T> |
|
40 { |
|
41 public: |
|
42 |
|
43 MSparse (void) : Sparse<T> () { } |
|
44 |
5275
|
45 MSparse (octave_idx_type n, octave_idx_type m) : Sparse<T> (n, m) { } |
5164
|
46 |
|
47 MSparse (const MSparse<T>& a) : Sparse<T> (a) { } |
|
48 |
|
49 MSparse (const MSparse<T>& a, const dim_vector& dv) : Sparse<T> (a, dv) { } |
|
50 |
|
51 MSparse (const Sparse<T>& a) : Sparse<T> (a) { } |
|
52 |
5275
|
53 MSparse (const Array<T> a, const Array<octave_idx_type>& r, |
|
54 const Array<octave_idx_type>& c, octave_idx_type nr = -1, |
|
55 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
56 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
57 |
|
58 MSparse (const Array<T> a, const Array<double>& r, |
5275
|
59 const Array<double>& c, octave_idx_type nr = -1, |
|
60 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
61 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
62 |
5275
|
63 explicit MSparse (octave_idx_type r, octave_idx_type c, T val) : Sparse<T> (r, c, val) { } |
5164
|
64 |
5275
|
65 MSparse (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<T> (r, c, num_nz) { } |
5164
|
66 |
|
67 ~MSparse (void) { } |
|
68 |
|
69 MSparse<T>& operator = (const MSparse<T>& a) |
|
70 { |
|
71 Sparse<T>::operator = (a); |
|
72 return *this; |
|
73 } |
|
74 |
5275
|
75 MSparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c) |
5164
|
76 { |
|
77 Sparse<T>::insert (a, r, c); |
|
78 return *this; |
|
79 } |
|
80 |
|
81 MSparse<T> transpose (void) const { return Sparse<T>::transpose (); } |
|
82 |
|
83 MSparse<T> squeeze (void) const { return Sparse<T>::squeeze (); } |
|
84 |
|
85 MSparse<T> index (idx_vector& i, int resize_ok) const |
|
86 { return Sparse<T>::index (i, resize_ok); } |
|
87 |
|
88 MSparse<T> index (idx_vector& i, idx_vector& j, int resize_ok) const |
|
89 { return Sparse<T>::index (i, j, resize_ok); } |
|
90 |
|
91 MSparse<T> index (Array<idx_vector>& ra_idx, int resize_ok) const |
|
92 { return Sparse<T>::index (ra_idx, resize_ok); } |
|
93 |
|
94 MSparse<T> reshape (const dim_vector& new_dims) const |
|
95 { return Sparse<T>::reshape (new_dims); } |
|
96 |
5275
|
97 MSparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const |
5164
|
98 { return Sparse<T>::permute (vec, inv); } |
|
99 |
5275
|
100 MSparse<T> ipermute (const Array<octave_idx_type>& vec) const |
5164
|
101 { return Sparse<T>::ipermute (vec); } |
|
102 |
|
103 |
|
104 // Currently, the OPS functions don't need to be friends, but that |
|
105 // may change. |
|
106 |
|
107 // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray2) |
|
108 }; |
|
109 |
|
110 #endif |
|
111 |
|
112 /* |
|
113 ;;; Local Variables: *** |
|
114 ;;; mode: C++ *** |
|
115 ;;; End: *** |
|
116 */ |