MSparse.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-2012 David Bateman
00004 Copyright (C) 1998-2004 Andy Adler
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_MSparse_h)
00025 #define octave_MSparse_h 1
00026 
00027 #include "MArray.h"
00028 
00029 #include "Sparse.h"
00030 
00031 // Two dimensional sparse array with math ops.
00032 
00033 // But first, some preprocessor abuse...
00034 
00035 #include "MSparse-defs.h"
00036 
00037 SPARSE_OPS_FORWARD_DECLS (MSparse, MArray, )
00038 
00039 template <class T>
00040 class
00041 MSparse : public Sparse<T>
00042 {
00043 public:
00044 
00045   MSparse (void) : Sparse<T> () { }
00046 
00047   MSparse (octave_idx_type n, octave_idx_type m) : Sparse<T> (n, m) { }
00048 
00049   MSparse (const dim_vector& dv, octave_idx_type nz = 0) :
00050     Sparse<T> (dv, nz) { }
00051 
00052   MSparse (const MSparse<T>& a) : Sparse<T> (a) { }
00053 
00054   MSparse (const MSparse<T>& a, const dim_vector& dv) : Sparse<T> (a, dv) { }
00055 
00056   MSparse (const Sparse<T>& a) : Sparse<T> (a) { }
00057 
00058   template <class U>
00059   MSparse (const Sparse<U>& a) : Sparse<T> (a) { }
00060 
00061   MSparse (const Array<T>& a, const idx_vector& r, const idx_vector& c,
00062            octave_idx_type nr = -1, octave_idx_type nc = -1,
00063            bool sum_terms = true, octave_idx_type nzm = -1)
00064     : Sparse<T> (a, r, c, nr, nc, sum_terms, nzm) { }
00065 
00066   explicit MSparse (octave_idx_type r, octave_idx_type c, T val) : Sparse<T> (r, c, val) { }
00067 
00068   explicit MSparse (const PermMatrix& a) : Sparse<T>(a) { }
00069 
00070   MSparse (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<T> (r, c, num_nz) { }
00071 
00072   ~MSparse (void) { }
00073 
00074   MSparse<T>& operator = (const MSparse<T>& a)
00075     {
00076       Sparse<T>::operator = (a);
00077       return *this;
00078     }
00079 
00080   MSparse<T>& insert (const Sparse<T>& a, octave_idx_type r, octave_idx_type c)
00081   {
00082     Sparse<T>::insert (a, r, c);
00083     return *this;
00084   }
00085 
00086   MSparse<T>& insert (const Sparse<T>& a, const Array<octave_idx_type>& indx)
00087   {
00088     Sparse<T>::insert (a, indx);
00089     return *this;
00090   }
00091 
00092   MSparse<T> transpose (void) const { return Sparse<T>::transpose (); }
00093 
00094   MSparse<T> squeeze (void) const { return Sparse<T>::squeeze (); }
00095 
00096   MSparse<T> reshape (const dim_vector& new_dims) const
00097     { return Sparse<T>::reshape (new_dims); }
00098 
00099   MSparse<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const
00100     { return Sparse<T>::permute (vec, inv); }
00101 
00102   MSparse<T> ipermute (const Array<octave_idx_type>& vec) const
00103     { return Sparse<T>::ipermute (vec); }
00104 
00105 
00106   MSparse<T> diag (octave_idx_type k = 0) const
00107   {
00108     return Sparse<T>::diag (k);
00109   }
00110 
00111   // FIXME: should go away.
00112   template <class U>
00113   MSparse<U>
00114   map (U (&fcn) (T)) const
00115   { return Sparse<T>::template map<U> (fcn); }
00116 
00117   template <class U>
00118   MSparse<U>
00119   map (U (&fcn) (const T&)) const
00120   { return Sparse<T>::template map<U> (fcn); }
00121 
00122   // Currently, the OPS functions don't need to be friends, but that
00123   // may change.
00124 
00125   // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray)
00126 };
00127 
00128 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines