GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MSparse.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2015 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 
38 
39 template <class T>
40 class
41 MSparse : public Sparse<T>
42 {
43 public:
44 
45  MSparse (void) : Sparse<T> () { }
46 
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 
72  : Sparse<T> (r, c, num_nz) { }
73 
74  ~MSparse (void) { }
75 
77  {
79  return *this;
80  }
81 
83  {
84  Sparse<T>::insert (a, r, c);
85  return *this;
86  }
87 
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 
105  { return Sparse<T>::ipermute (vec); }
106 
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
Sparse< T > ipermute(const Array< octave_idx_type > &vec) const
Definition: Sparse.h:482
Sparse< T > & operator=(const Sparse< T > &a)
Definition: Sparse.cc:683
MSparse(const MSparse< T > &a)
Definition: MSparse.h:52
MSparse(void)
Definition: MSparse.h:45
MSparse(octave_idx_type n, octave_idx_type m)
Definition: MSparse.h:47
MSparse< T > & insert(const Sparse< T > &a, const Array< octave_idx_type > &indx)
Definition: MSparse.h:88
MSparse(octave_idx_type r, octave_idx_type c, T val)
Definition: MSparse.h:66
Sparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: Sparse.cc:882
Sparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
Definition: Sparse.cc:998
Definition: MArray.h:36
MSparse(const Sparse< T > &a)
Definition: MSparse.h:56
MSparse< T > transpose(void) const
Definition: MSparse.h:94
MSparse(const PermMatrix &a)
Definition: MSparse.h:69
Sparse< T > squeeze(void) const
Definition: Sparse.h:285
MSparse< T > squeeze(void) const
Definition: MSparse.h:96
Sparse< T > reshape(const dim_vector &new_dims) const
Definition: Sparse.cc:815
MSparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
Definition: MSparse.h:82
MSparse(const Array< T > &a, const idx_vector &r, const idx_vector &c, octave_idx_type nr=-1, octave_idx_type nc=-1, bool sum_terms=true, octave_idx_type nzm=-1)
Definition: MSparse.h:61
MSparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: MSparse.h:101
MSparse(const dim_vector &dv, octave_idx_type nz=0)
Definition: MSparse.h:49
MSparse(const MSparse< T > &a, const dim_vector &dv)
Definition: MSparse.h:54
MSparse< T > ipermute(const Array< octave_idx_type > &vec) const
Definition: MSparse.h:104
MSparse(const Sparse< U > &a)
Definition: MSparse.h:59
MSparse< U > map(U(&fcn)(const T &)) const
Definition: MSparse.h:120
Handles the reference counting for all the derived classes.
Definition: Array.h:45
MSparse< U > map(U(&fcn)(T)) const
Definition: MSparse.h:115
~MSparse(void)
Definition: MSparse.h:74
MSparse(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition: MSparse.h:71
MSparse< T > diag(octave_idx_type k=0) const
Definition: MSparse.h:107
#define SPARSE_OPS_FORWARD_DECLS(A_T, F_T, API)
Definition: MSparse-defs.h:164
Sparse< T > diag(octave_idx_type k=0) const
Definition: Sparse.cc:2411
Sparse< T > transpose(void) const
Definition: Sparse.cc:1096
MSparse< T > reshape(const dim_vector &new_dims) const
Definition: MSparse.h:98
SparseComplexMatrix & operator=(const SparseComplexMatrix &a)
Definition: CSparse.h:104