GNU Octave  3.8.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-2013 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 
53  : Array<T> (dim_vector (n, 1)) { }
54 
56  : Array<T> (dim_vector (n, 1), val) { }
57 
58  explicit MArray (const dim_vector& dv)
59  : Array<T> (dv) { }
60 
61  explicit MArray (const dim_vector& dv, const T& val)
62  : Array<T> (dv, val) { }
63 
64  MArray (const MArray<T>& a) : Array<T> (a) { }
65 
66  template <class U>
67  MArray (const Array<U>& a) : Array<T> (a) { }
68 
69  ~MArray (void) { }
70 
71  MArray<T>& operator = (const MArray<T>& a)
72  {
74  return *this;
75  }
76 
77  MArray<T> reshape (const dim_vector& new_dims) const
78  { return Array<T>::reshape (new_dims); }
79 
80  MArray<T> permute (const Array<octave_idx_type>& vec,
81  bool inv = false) const
82  { return Array<T>::permute (vec, inv); }
83 
84  MArray<T> ipermute (const Array<octave_idx_type>& vec) const
85  { return Array<T>::ipermute (vec); }
86 
87  MArray squeeze (void) const { return Array<T>::squeeze (); }
88 
89  MArray<T> transpose (void) const
90  { return Array<T>::transpose (); }
91 
92  MArray<T> hermitian (T (*fcn) (const T&) = 0) const
93  { return Array<T>::hermitian (fcn); }
94 
95  // Performs indexed accumulative addition.
96 
97  void idx_add (const idx_vector& idx, T val);
98 
99  void idx_add (const idx_vector& idx, const MArray<T>& vals);
100 
101  void idx_min (const idx_vector& idx, const MArray<T>& vals);
102 
103  void idx_max (const idx_vector& idx, const MArray<T>& vals);
104 
105  void idx_add_nd (const idx_vector& idx, const MArray<T>& vals, int dim = -1);
106 
107  void changesign (void);
108 };
109 
110 #endif