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
MArray.h
Go to the documentation of this file.
1 // Template array classes with like-type math ops
2 /*
3 
4 Copyright (C) 1993-2015 John W. Eaton
5 Copyright (C) 2010 VZLU Prague
6 
7 This file is part of Octave.
8 
9 Octave is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if !defined (octave_MArray_h)
26 #define octave_MArray_h 1
27 
28 #include "Array.h"
29 
30 // N-dimensional array with math ops.
31 
32 // But first, some preprocessor abuse...
33 
34 #include "MArray-decl.h"
35 
37 
38 template <class T>
39 class
40 MArray : public Array<T>
41 {
42 protected:
43 
44  // For jit support
45  MArray (T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
46  : Array<T> (sdata, slen, adims, arep) { }
47 
48 public:
49 
50  MArray (void) : Array<T> () { }
51 
52  explicit MArray (const dim_vector& dv)
53  : Array<T> (dv) { }
54 
55  explicit MArray (const dim_vector& dv, const T& val)
56  : Array<T> (dv, val) { }
57 
58  MArray (const MArray<T>& a) : Array<T> (a) { }
59 
60  template <class U>
61  MArray (const Array<U>& a) : Array<T> (a) { }
62 
63  ~MArray (void) { }
64 
65  MArray<T>& operator = (const MArray<T>& a)
66  {
68  return *this;
69  }
70 
71  MArray<T> reshape (const dim_vector& new_dims) const
72  { return Array<T>::reshape (new_dims); }
73 
75  bool inv = false) const
76  { return Array<T>::permute (vec, inv); }
77 
79  { return Array<T>::ipermute (vec); }
80 
81  MArray squeeze (void) const { return Array<T>::squeeze (); }
82 
83  MArray<T> transpose (void) const
84  { return Array<T>::transpose (); }
85 
86  MArray<T> hermitian (T (*fcn) (const T&) = 0) const
87  { return Array<T>::hermitian (fcn); }
88 
89  // Performs indexed accumulative addition.
90 
91  void idx_add (const idx_vector& idx, T val);
92 
93  void idx_add (const idx_vector& idx, const MArray<T>& vals);
94 
95  void idx_min (const idx_vector& idx, const MArray<T>& vals);
96 
97  void idx_max (const idx_vector& idx, const MArray<T>& vals);
98 
99  void idx_add_nd (const idx_vector& idx, const MArray<T>& vals, int dim = -1);
100 
101  void changesign (void);
102 };
103 
104 #endif
MArray< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: MArray.h:74
MArray squeeze(void) const
Definition: MArray.h:81
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: Array.cc:441
MArray< T > transpose(void) const
Definition: MArray.h:83
MArray< T > ipermute(const Array< octave_idx_type > &vec) const
Definition: MArray.h:78
Definition: MArray.h:36
~MArray(void)
Definition: MArray.h:63
MArray(const dim_vector &dv)
Definition: MArray.h:52
MArray(T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
Definition: MArray.h:45
Array< T > transpose(void) const
Definition: Array.cc:1607
static const octave_idx_type idx_max
Definition: dlmread.cc:44
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Definition: Array.cc:114
MArray(const Array< U > &a)
Definition: MArray.h:61
MArray< T > hermitian(T(*fcn)(const T &)=0) const
Definition: MArray.h:86
Handles the reference counting for all the derived classes.
Definition: Array.h:45
MArray(void)
Definition: MArray.h:50
Array< T > hermitian(T(*fcn)(const T &)=0) const
Definition: Array.cc:1650
MArray(const MArray< T > &a)
Definition: MArray.h:58
#define MARRAY_OPS_FORWARD_DECLS(A_T, API)
Definition: MArray-decl.h:207
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Definition: Array.h:460
Array< T > ipermute(const Array< octave_idx_type > &vec) const
Definition: Array.h:467
MArray(const dim_vector &dv, const T &val)
Definition: MArray.h:55
MArray< T > reshape(const dim_vector &new_dims) const
Definition: MArray.h:71
Array< T > & operator=(const Array< T > &a)
Definition: Array.h:226