MArray.h

Go to the documentation of this file.
00001 // Template array classes with like-type math ops
00002 /*
00003 
00004 Copyright (C) 1993-2012 John W. Eaton
00005 Copyright (C) 2010 VZLU Prague
00006 
00007 This file is part of Octave.
00008 
00009 Octave is free software; you can redistribute it and/or modify it
00010 under the terms of the GNU General Public License as published by the
00011 Free Software Foundation; either version 3 of the License, or (at your
00012 option) any later version.
00013 
00014 Octave is distributed in the hope that it will be useful, but WITHOUT
00015 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00017 for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with Octave; see the file COPYING.  If not, see
00021 <http://www.gnu.org/licenses/>.
00022 
00023 */
00024 
00025 #if !defined (octave_MArray_h)
00026 #define octave_MArray_h 1
00027 
00028 #include "Array.h"
00029 
00030 // N-dimensional array with math ops.
00031 
00032 // But first, some preprocessor abuse...
00033 
00034 #include "MArray-decl.h"
00035 
00036 MARRAY_OPS_FORWARD_DECLS (MArray, )
00037 
00038 template <class T>
00039 class
00040 MArray : public Array<T>
00041 {
00042 public:
00043 
00044   MArray (void) : Array<T> () {}
00045 
00046   explicit MArray (octave_idx_type n) GCC_ATTR_DEPRECATED
00047     : Array<T> (dim_vector (n, 1)) { }
00048 
00049   MArray (octave_idx_type n, const T& val) GCC_ATTR_DEPRECATED
00050     : Array<T> (dim_vector (n, 1), val) { }
00051 
00052   explicit MArray (const dim_vector& dv)
00053     : Array<T> (dv) { }
00054 
00055   explicit MArray (const dim_vector& dv, const T& val)
00056     : Array<T> (dv, val) { }
00057 
00058   MArray (const MArray<T>& a) : Array<T> (a) { }
00059 
00060   template <class U>
00061   MArray (const Array<U>& a) : Array<T> (a) { }
00062 
00063   ~MArray (void) { }
00064 
00065   MArray<T>& operator = (const MArray<T>& a)
00066     {
00067       Array<T>::operator = (a);
00068       return *this;
00069     }
00070 
00071   MArray<T> reshape (const dim_vector& new_dims) const
00072     { return Array<T>::reshape (new_dims); }
00073 
00074   MArray<T> permute (const Array<octave_idx_type>& vec,
00075                       bool inv = false) const
00076     { return Array<T>::permute (vec, inv); }
00077 
00078   MArray<T> ipermute (const Array<octave_idx_type>& vec) const
00079     { return Array<T>::ipermute (vec); }
00080 
00081   MArray squeeze (void) const { return Array<T>::squeeze (); }
00082 
00083   MArray<T> transpose (void) const
00084     { return Array<T>::transpose (); }
00085 
00086   MArray<T> hermitian (T (*fcn) (const T&) = 0) const
00087     { return Array<T>::hermitian (fcn); }
00088 
00089   // Performs indexed accumulative addition.
00090 
00091   void idx_add (const idx_vector& idx, T val);
00092 
00093   void idx_add (const idx_vector& idx, const MArray<T>& vals);
00094 
00095   void idx_min (const idx_vector& idx, const MArray<T>& vals);
00096 
00097   void idx_max (const idx_vector& idx, const MArray<T>& vals);
00098 
00099   void idx_add_nd (const idx_vector& idx, const MArray<T>& vals, int dim = -1);
00100 
00101   void changesign (void);
00102 };
00103 
00104 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines