GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
CNDArray.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2003-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_CNDArray_h)
27 #define octave_CNDArray_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MArray.h"
32 #include "bsxfun-decl.h"
33 #include "mx-defs.h"
34 #include "mx-op-decl.h"
35 
36 class
37 OCTAVE_API
39 {
40 public:
41 
42  ComplexNDArray (void) : MArray<Complex> () { }
43 
44  ComplexNDArray (const dim_vector& dv) : MArray<Complex> (dv) { }
45 
46  ComplexNDArray (const dim_vector& dv, const Complex& val)
47  : MArray<Complex> (dv, val) { }
48 
50 
51  template <typename U>
52  ComplexNDArray (const MArray<U>& a) : MArray<Complex> (a) { }
53 
54  template <typename U>
55  ComplexNDArray (const Array<U>& a) : MArray<Complex> (a) { }
56 
57  ComplexNDArray (const charNDArray&);
58 
59  ComplexNDArray& operator = (const ComplexNDArray& a)
60  {
62  return *this;
63  }
64 
65  // unary operations
66 
67  boolNDArray operator ! (void) const;
68 
69  // FIXME: this is not quite the right thing.
70 
71  bool any_element_is_nan (void) const;
72  bool any_element_is_inf_or_nan (void) const;
73  bool all_elements_are_real (void) const;
74  bool all_integers (double& max_val, double& min_val) const;
75  bool too_large_for_float (void) const;
76 
77  boolNDArray all (int dim = -1) const;
78  boolNDArray any (int dim = -1) const;
79 
80  ComplexNDArray cumprod (int dim = -1) const;
81  ComplexNDArray cumsum (int dim = -1) const;
82  ComplexNDArray prod (int dim = -1) const;
83  ComplexNDArray sum (int dim = -1) const;
84  ComplexNDArray xsum (int dim = -1) const;
85  ComplexNDArray sumsq (int dim = -1) const;
88  ComplexNDArray concat (const NDArray& rb,
90 
91  ComplexNDArray max (int dim = -1) const;
92  ComplexNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
93  ComplexNDArray min (int dim = -1) const;
94  ComplexNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
95 
96  ComplexNDArray cummax (int dim = -1) const;
97  ComplexNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
98  ComplexNDArray cummin (int dim = -1) const;
99  ComplexNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
100 
101  ComplexNDArray diff (octave_idx_type order = 1, int dim = -1) const;
102 
103  ComplexNDArray& insert (const NDArray& a,
105  ComplexNDArray& insert (const ComplexNDArray& a,
107  ComplexNDArray& insert (const ComplexNDArray& a,
109 
110  NDArray abs (void) const;
111  boolNDArray isnan (void) const;
112  boolNDArray isinf (void) const;
113  boolNDArray isfinite (void) const;
114 
115  friend OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a);
116 
117  ComplexNDArray fourier (int dim = 1) const;
118  ComplexNDArray ifourier (int dim = 1) const;
119 
120  ComplexNDArray fourier2d (void) const;
121  ComplexNDArray ifourier2d (void) const;
122 
123  ComplexNDArray fourierNd (void) const;
124  ComplexNDArray ifourierNd (void) const;
125 
126  ComplexNDArray squeeze (void) const { return MArray<Complex>::squeeze (); }
127 
129  const dim_vector& dimensions,
130  int start_dimension = 0);
131 
133  const dim_vector& dimensions);
134 
135  // i/o
136 
137  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
138  const ComplexNDArray& a);
139  friend OCTAVE_API std::istream& operator >> (std::istream& is,
140  ComplexNDArray& a);
141 
142  // bool all_elements_are_real (void) const;
143  // bool all_integers (double& max_val, double& min_val) const;
144 
145  ComplexNDArray diag (octave_idx_type k = 0) const;
146 
148 
150  {
152  return *this;
153  }
154 
155 };
156 
157 extern OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a);
158 
159 MINMAX_DECLS (ComplexNDArray, Complex, OCTAVE_API)
160 
163 
166 
169 
171 
172 extern OCTAVE_API ComplexNDArray& operator *= (ComplexNDArray& a, double s);
173 extern OCTAVE_API ComplexNDArray& operator /= (ComplexNDArray& a, double s);
174 
177 
178 BSXFUN_OP_DECL (pow, ComplexNDArray, OCTAVE_API)
179 
180 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:177
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:60
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
OCTAVE_API ComplexNDArray min(Complex d, const ComplexNDArray &m)
Definition: CNDArray.cc:631
OCTAVE_API ComplexNDArray max(Complex d, const ComplexNDArray &m)
Definition: CNDArray.cc:631
OCTAVE_API ComplexNDArray conj(const ComplexNDArray &a)
Definition: CNDArray.cc:502
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:128
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:281
#define BSXFUN_STDREL_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:53
#define BSXFUN_STDOP_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:38
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:29
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:128
ComplexNDArray squeeze(void) const
Definition: CNDArray.h:126
ComplexNDArray(const Array< U > &a)
Definition: CNDArray.h:55
ComplexNDArray(const dim_vector &dv, const Complex &val)
Definition: CNDArray.h:46
ComplexNDArray & changesign(void)
Definition: CNDArray.h:149
ComplexNDArray(void)
Definition: CNDArray.h:42
ComplexNDArray(const ComplexNDArray &a)
Definition: CNDArray.h:49
ComplexNDArray(const MArray< U > &a)
Definition: CNDArray.h:52
ComplexNDArray(const dim_vector &dv)
Definition: CNDArray.h:44
void changesign(void)
Definition: MArray.cc:204
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:87
MArray squeeze(void) const
Definition: MArray.h:103
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
T * r
Definition: mx-inlines.cc:773
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:227
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:219
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:173
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:192
#define MINMAX_DECLS(T, S, API)
Definition: mx-op-decl.h:289
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:165
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:200
bool isfinite(double x)
Definition: lo-mappers.h:192
bool isnan(bool)
Definition: lo-mappers.h:178
bool isinf(double x)
Definition: lo-mappers.h:203
std::complex< double > Complex
Definition: oct-cmplx.h:33
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition: ov.h:1536
static T abs(T x)
Definition: pr-output.cc:1678