CNDArray.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2003-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_ComplexNDArray_h)
00024 #define octave_ComplexNDArray_h 1
00025 
00026 #include "MArray.h"
00027 #include "CMatrix.h"
00028 
00029 #include "mx-defs.h"
00030 #include "mx-op-decl.h"
00031 #include "bsxfun-decl.h"
00032 
00033 class
00034 OCTAVE_API
00035 ComplexNDArray : public MArray<Complex>
00036 {
00037 public:
00038 
00039   typedef ComplexMatrix matrix_type;
00040 
00041   ComplexNDArray (void) : MArray<Complex> () { }
00042 
00043   ComplexNDArray (const dim_vector& dv) : MArray<Complex> (dv) { }
00044 
00045   ComplexNDArray (const dim_vector& dv, const Complex& val)
00046     : MArray<Complex> (dv, val) { }
00047 
00048   ComplexNDArray (const ComplexNDArray& a) : MArray<Complex> (a) { }
00049 
00050   ComplexNDArray (const ComplexMatrix& a) : MArray<Complex> (a) { }
00051 
00052   template <class U>
00053   ComplexNDArray (const MArray<U>& a) : MArray<Complex> (a) { }
00054 
00055   template <class U>
00056   ComplexNDArray (const Array<U>& a) : MArray<Complex> (a) { }
00057 
00058   ComplexNDArray (const charNDArray&);
00059 
00060   ComplexNDArray& operator = (const ComplexNDArray& a)
00061     {
00062       MArray<Complex>::operator = (a);
00063       return *this;
00064     }
00065 
00066   // unary operations
00067 
00068   boolNDArray operator ! (void) const;
00069 
00070   // FIXME -- this is not quite the right thing.
00071 
00072   bool any_element_is_nan (void) const;
00073   bool any_element_is_inf_or_nan (void) const;
00074   bool all_elements_are_real (void) const;
00075   bool all_integers (double& max_val, double& min_val) const;
00076   bool too_large_for_float (void) const;
00077 
00078   boolNDArray all (int dim = -1) const;
00079   boolNDArray any (int dim = -1) const;
00080 
00081   ComplexNDArray cumprod (int dim = -1) const;
00082   ComplexNDArray cumsum (int dim = -1) const;
00083   ComplexNDArray prod (int dim = -1) const;
00084   ComplexNDArray sum (int dim = -1) const;
00085   ComplexNDArray xsum (int dim = -1) const;
00086   ComplexNDArray sumsq (int dim = -1) const;
00087   ComplexNDArray concat (const ComplexNDArray& rb, const Array<octave_idx_type>& ra_idx);
00088   ComplexNDArray concat (const NDArray& rb, const Array<octave_idx_type>& ra_idx);
00089 
00090   ComplexNDArray max (int dim = -1) const;
00091   ComplexNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
00092   ComplexNDArray min (int dim = -1) const;
00093   ComplexNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
00094 
00095   ComplexNDArray cummax (int dim = -1) const;
00096   ComplexNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
00097   ComplexNDArray cummin (int dim = -1) const;
00098   ComplexNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
00099 
00100   ComplexNDArray diff (octave_idx_type order = 1, int dim = -1) const;
00101 
00102   ComplexNDArray& insert (const NDArray& a, octave_idx_type r, octave_idx_type c);
00103   ComplexNDArray& insert (const ComplexNDArray& a, octave_idx_type r, octave_idx_type c);
00104   ComplexNDArray& insert (const ComplexNDArray& a, const Array<octave_idx_type>& ra_idx);
00105 
00106   NDArray abs (void) const;
00107   boolNDArray isnan (void) const;
00108   boolNDArray isinf (void) const;
00109   boolNDArray isfinite (void) const;
00110 
00111   friend OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a);
00112 
00113   ComplexNDArray fourier (int dim = 1) const;
00114   ComplexNDArray ifourier (int dim = 1) const;
00115 
00116   ComplexNDArray fourier2d (void) const;
00117   ComplexNDArray ifourier2d (void) const;
00118 
00119   ComplexNDArray fourierNd (void) const;
00120   ComplexNDArray ifourierNd (void) const;
00121 
00122   ComplexMatrix matrix_value (void) const;
00123 
00124   ComplexNDArray squeeze (void) const { return MArray<Complex>::squeeze (); }
00125 
00126   static void increment_index (Array<octave_idx_type>& ra_idx,
00127                                const dim_vector& dimensions,
00128                                int start_dimension = 0);
00129 
00130   static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx,
00131                             const dim_vector& dimensions);
00132 
00133   // i/o
00134 
00135   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const ComplexNDArray& a);
00136   friend OCTAVE_API std::istream& operator >> (std::istream& is, ComplexNDArray& a);
00137 
00138   static Complex resize_fill_value (void) { return Complex (0.0, 0.0); }
00139 
00140   //  bool all_elements_are_real (void) const;
00141   //  bool all_integers (double& max_val, double& min_val) const;
00142 
00143   ComplexNDArray diag (octave_idx_type k = 0) const;
00144 
00145   ComplexNDArray& changesign (void)
00146     {
00147       MArray<Complex>::changesign ();
00148       return *this;
00149     }
00150 
00151 };
00152 
00153 extern OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a);
00154 
00155 MINMAX_DECLS (ComplexNDArray, Complex, OCTAVE_API)
00156 
00157 NDS_CMP_OP_DECLS (ComplexNDArray, Complex, OCTAVE_API)
00158 NDS_BOOL_OP_DECLS (ComplexNDArray, Complex, OCTAVE_API)
00159 
00160 SND_CMP_OP_DECLS (Complex, ComplexNDArray, OCTAVE_API)
00161 SND_BOOL_OP_DECLS (Complex, ComplexNDArray, OCTAVE_API)
00162 
00163 NDND_CMP_OP_DECLS (ComplexNDArray, ComplexNDArray, OCTAVE_API)
00164 NDND_BOOL_OP_DECLS (ComplexNDArray, ComplexNDArray, OCTAVE_API)
00165 
00166 MARRAY_FORWARD_DEFS (MArray, ComplexNDArray, Complex)
00167 
00168 extern OCTAVE_API ComplexNDArray& operator *= (ComplexNDArray& a, double s);
00169 extern OCTAVE_API ComplexNDArray& operator /= (ComplexNDArray& a, double s);
00170 
00171 BSXFUN_STDOP_DECLS (ComplexNDArray, OCTAVE_API)
00172 BSXFUN_STDREL_DECLS (ComplexNDArray, OCTAVE_API)
00173 
00174 BSXFUN_OP_DECL (pow, ComplexNDArray, OCTAVE_API)
00175 
00176 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines