5164
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 2004, 2005, 2007 David Bateman |
7016
|
4 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Andy Adler |
|
5 |
|
6 This file is part of Octave. |
5164
|
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 |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
5164
|
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 |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
5164
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_MSparse_h) |
|
25 #define octave_MSparse_h 1 |
|
26 |
|
27 #include "MArray2.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 |
6708
|
37 SPARSE_OPS_FORWARD_DECLS (MSparse, MArray2, ) |
5164
|
38 |
|
39 template <class T> |
|
40 class |
|
41 MSparse : public Sparse<T> |
|
42 { |
|
43 public: |
|
44 |
|
45 MSparse (void) : Sparse<T> () { } |
|
46 |
5275
|
47 MSparse (octave_idx_type n, octave_idx_type m) : Sparse<T> (n, m) { } |
5164
|
48 |
6823
|
49 MSparse (const dim_vector& dv, octave_idx_type nz = 0) : |
|
50 Sparse<T> (dv, nz) { } |
|
51 |
5164
|
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 |
5275
|
58 MSparse (const Array<T> a, const Array<octave_idx_type>& r, |
|
59 const Array<octave_idx_type>& 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 |
|
63 MSparse (const Array<T> a, const Array<double>& r, |
5275
|
64 const Array<double>& c, octave_idx_type nr = -1, |
|
65 octave_idx_type nc = -1, bool sum_terms = true) |
5164
|
66 : Sparse<T> (a, r, c, nr, nc, sum_terms) { } |
|
67 |
5275
|
68 explicit MSparse (octave_idx_type r, octave_idx_type c, T val) : Sparse<T> (r, c, val) { } |
5164
|
69 |
5275
|
70 MSparse (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<T> (r, c, num_nz) { } |
5164
|
71 |
|
72 ~MSparse (void) { } |
|
73 |
|
74 MSparse<T>& operator = (const MSparse<T>& a) |
|
75 { |
|
76 Sparse<T>::operator = (a); |
|
77 return *this; |
|
78 } |
|
79 |
5275
|
80 MSparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c) |
5164
|
81 { |
|
82 Sparse<T>::insert (a, r, c); |
|
83 return *this; |
|
84 } |
|
85 |
6823
|
86 MSparse<T>& insert (const Sparse<T>& a, const Array<octave_idx_type>& indx) |
|
87 { |
|
88 Sparse<T>::insert (a, indx); |
|
89 return *this; |
|
90 } |
|
91 |
5164
|
92 MSparse<T> transpose (void) const { return Sparse<T>::transpose (); } |
|
93 |
|
94 MSparse<T> squeeze (void) const { return Sparse<T>::squeeze (); } |
|
95 |
|
96 MSparse<T> index (idx_vector& i, int resize_ok) const |
|
97 { return Sparse<T>::index (i, resize_ok); } |
|
98 |
|
99 MSparse<T> index (idx_vector& i, idx_vector& j, int resize_ok) const |
|
100 { return Sparse<T>::index (i, j, resize_ok); } |
|
101 |
|
102 MSparse<T> index (Array<idx_vector>& ra_idx, int resize_ok) const |
|
103 { return Sparse<T>::index (ra_idx, resize_ok); } |
|
104 |
|
105 MSparse<T> reshape (const dim_vector& new_dims) const |
|
106 { return Sparse<T>::reshape (new_dims); } |
|
107 |
5275
|
108 MSparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const |
5164
|
109 { return Sparse<T>::permute (vec, inv); } |
|
110 |
5275
|
111 MSparse<T> ipermute (const Array<octave_idx_type>& vec) const |
5164
|
112 { return Sparse<T>::ipermute (vec); } |
|
113 |
|
114 |
|
115 // Currently, the OPS functions don't need to be friends, but that |
|
116 // may change. |
|
117 |
|
118 // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray2) |
|
119 }; |
|
120 |
|
121 #endif |
|
122 |
|
123 /* |
|
124 ;;; Local Variables: *** |
|
125 ;;; mode: C++ *** |
|
126 ;;; End: *** |
|
127 */ |