// Template array classes with like-type math ops
/*
Copyright (C) 1993-2015 John W. Eaton
Copyright (C) 2010 VZLU Prague
This file is part of Octave.
Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
Octave is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING. If not, see
.
*/
#if !defined (octave_MArray_h)
#define octave_MArray_h 1
#include "Array.h"
// N-dimensional array with math ops.
// But first, some preprocessor abuse...
#include "MArray-decl.h"
MARRAY_OPS_FORWARD_DECLS (MArray, )
template
class
MArray : public Array
{
protected:
// For jit support
MArray (T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
: Array (sdata, slen, adims, arep) { }
public:
MArray (void) : Array () { }
explicit MArray (const dim_vector& dv)
: Array (dv) { }
explicit MArray (const dim_vector& dv, const T& val)
: Array (dv, val) { }
MArray (const MArray& a) : Array (a) { }
template
MArray (const Array& a) : Array (a) { }
~MArray (void) { }
MArray& operator = (const MArray& a)
{
Array::operator = (a);
return *this;
}
MArray reshape (const dim_vector& new_dims) const
{ return Array::reshape (new_dims); }
MArray permute (const Array& vec,
bool inv = false) const
{ return Array::permute (vec, inv); }
MArray ipermute (const Array& vec) const
{ return Array::ipermute (vec); }
MArray squeeze (void) const { return Array::squeeze (); }
MArray transpose (void) const
{ return Array::transpose (); }
MArray hermitian (T (*fcn) (const T&) = 0) const
{ return Array::hermitian (fcn); }
// Performs indexed accumulative addition.
void idx_add (const idx_vector& idx, T val);
void idx_add (const idx_vector& idx, const MArray& vals);
void idx_min (const idx_vector& idx, const MArray& vals);
void idx_max (const idx_vector& idx, const MArray& vals);
void idx_add_nd (const idx_vector& idx, const MArray& vals, int dim = -1);
void changesign (void);
};
#endif