GNU Octave  4.4.1
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-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_CNDArray_h)
24 #define octave_CNDArray_h 1
25 
26 #include "octave-config.h"
27 
28 #include "MArray.h"
29 #include "bsxfun-decl.h"
30 #include "mx-defs.h"
31 #include "mx-op-decl.h"
32 
33 class
34 OCTAVE_API
36 {
37 public:
38 
39  ComplexNDArray (void) : MArray<Complex> () { }
40 
42 
44  : MArray<Complex> (dv, val) { }
45 
47 
48  template <typename U>
50 
51  template <typename U>
53 
54  ComplexNDArray (const charNDArray&);
55 
57  {
59  return *this;
60  }
61 
62  // unary operations
63 
64  boolNDArray operator ! (void) const;
65 
66  // FIXME: this is not quite the right thing.
67 
68  bool any_element_is_nan (void) const;
69  bool any_element_is_inf_or_nan (void) const;
70  bool all_elements_are_real (void) const;
71  bool all_integers (double& max_val, double& min_val) const;
72  bool too_large_for_float (void) const;
73 
74  boolNDArray all (int dim = -1) const;
75  boolNDArray any (int dim = -1) const;
76 
77  ComplexNDArray cumprod (int dim = -1) const;
78  ComplexNDArray cumsum (int dim = -1) const;
79  ComplexNDArray prod (int dim = -1) const;
80  ComplexNDArray sum (int dim = -1) const;
81  ComplexNDArray xsum (int dim = -1) const;
82  ComplexNDArray sumsq (int dim = -1) const;
85  ComplexNDArray concat (const NDArray& rb,
87 
88  ComplexNDArray max (int dim = -1) const;
89  ComplexNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
90  ComplexNDArray min (int dim = -1) const;
91  ComplexNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
92 
93  ComplexNDArray cummax (int dim = -1) const;
94  ComplexNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
95  ComplexNDArray cummin (int dim = -1) const;
96  ComplexNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
97 
98  ComplexNDArray diff (octave_idx_type order = 1, int dim = -1) const;
99 
100  ComplexNDArray& insert (const NDArray& a,
106 
107  NDArray abs (void) const;
108  boolNDArray isnan (void) const;
109  boolNDArray isinf (void) const;
110  boolNDArray isfinite (void) const;
111 
112  friend OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a);
113 
114  ComplexNDArray fourier (int dim = 1) const;
115  ComplexNDArray ifourier (int dim = 1) const;
116 
117  ComplexNDArray fourier2d (void) const;
118  ComplexNDArray ifourier2d (void) const;
119 
120  ComplexNDArray fourierNd (void) const;
121  ComplexNDArray ifourierNd (void) const;
122 
123  ComplexNDArray squeeze (void) const { return MArray<Complex>::squeeze (); }
124 
126  const dim_vector& dimensions,
127  int start_dimension = 0);
128 
130  const dim_vector& dimensions);
131 
132  // i/o
133 
134  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
135  const ComplexNDArray& a);
136  friend OCTAVE_API std::istream& operator >> (std::istream& is,
137  ComplexNDArray& a);
138 
139  // bool all_elements_are_real (void) const;
140  // bool all_integers (double& max_val, double& min_val) const;
141 
142  ComplexNDArray diag (octave_idx_type k = 0) const;
143 
145 
147  {
149  return *this;
150  }
151 
152 };
153 
154 extern OCTAVE_API ComplexNDArray conj (const ComplexNDArray& a);
155 
156 MINMAX_DECLS (ComplexNDArray, Complex, OCTAVE_API)
157 
160 
163 
166 
168 
169 extern OCTAVE_API ComplexNDArray& operator *= (ComplexNDArray& a, double s);
170 extern OCTAVE_API ComplexNDArray& operator /= (ComplexNDArray& a, double s);
171 
174 
175 BSXFUN_OP_DECL (pow, ComplexNDArray, OCTAVE_API)
176 
177 #endif
dim_vector dimensions
Definition: Array.h:216
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:175
ComplexNDArray fourierNd(void) const
Definition: CNDArray.cc:158
ComplexNDArray ifourierNd(void) const
Definition: CNDArray.cc:173
ComplexMatrix sumsq(int dim=-1) const
Definition: CMatrix.cc:2987
OCTAVE_API ComplexNDArray min(Complex d, const ComplexNDArray &m)
Definition: CNDArray.cc:866
ComplexNDArray(const ComplexNDArray &a)
Definition: CNDArray.h:46
const octave_base_value const Array< octave_idx_type > & ra_idx
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
#define BSXFUN_STDREL_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:51
ComplexNDArray xsum(int dim=-1) const
Definition: CNDArray.cc:617
ComplexMatrix fourier(void) const
Definition: CMatrix.cc:1020
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:218
void changesign(void)
Definition: MArray.cc:204
for large enough k
Definition: lu.cc:617
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:199
ComplexMatrix cumsum(int dim=-1) const
Definition: CMatrix.cc:2969
bool isnan(bool)
Definition: lo-mappers.h:187
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:226
bool isinf(double x)
Definition: lo-mappers.h:225
ComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: CNDArray.cc:629
static T abs(T x)
Definition: pr-output.cc:1696
ComplexMatrix fourier2d(void) const
Definition: CMatrix.cc:1078
the second is matched to the second specifier and placed in the second column and so forth If there are more words than specifiers then the process is repeated until all words have been processed or the limit imposed by any(non-whitespace) text in the format that is not one of these specifiers is considered a literal. If there is a literal between two format specifiers then that same literal must appear in the input stream between the matching words. The following specifiers are valid
Definition: file-io.cc:1499
ComplexNDArray cummin(int dim=-1) const
Definition: CNDArray.cc:701
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
s
Definition: file-io.cc:2729
bool too_large_for_float(void) const
Definition: CNDArray.cc:575
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:126
ComplexMatrix cumprod(int dim=-1) const
Definition: CMatrix.cc:2963
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:172
ComplexNDArray squeeze(void) const
Definition: CNDArray.h:123
ComplexMatrix ifourier2d(void) const
Definition: CMatrix.cc:1092
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:164
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
boolMatrix all(int dim=-1) const
Definition: CMatrix.cc:2951
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:191
ComplexNDArray cummax(int dim=-1) const
Definition: CNDArray.cc:689
Array< Complex > index(const idx_vector &i) const
Indexing without resizing.
Definition: Array.cc:697
ComplexMatrix diag(octave_idx_type k=0) const
Definition: CMatrix.cc:2999
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:58
ComplexNDArray(const MArray< U > &a)
Definition: CNDArray.h:49
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
ComplexNDArray & changesign(void)
Definition: CNDArray.h:146
ComplexNDArray & operator=(const ComplexNDArray &a)
Definition: CNDArray.h:56
bool any_element_is_inf_or_nan(void) const
Definition: CNDArray.cc:506
ComplexMatrix & insert(const Matrix &a, octave_idx_type r, octave_idx_type c)
Definition: CMatrix.cc:194
bool any_element_is_nan(void) const
Definition: CNDArray.cc:500
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:85
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:125
bool all_integers(double &max_val, double &min_val) const
Definition: CNDArray.cc:524
ComplexNDArray(void)
Definition: CNDArray.h:39
OCTAVE_API ComplexNDArray max(Complex d, const ComplexNDArray &m)
Definition: CNDArray.cc:866
ComplexMatrix ifourier(void) const
Definition: CMatrix.cc:1049
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
bool isfinite(double x)
Definition: lo-mappers.h:201
MArray squeeze(void) const
Definition: MArray.h:101
ComplexNDArray(const dim_vector &dv, const Complex &val)
Definition: CNDArray.h:43
#define BSXFUN_STDOP_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:36
bool all_elements_are_real(void) const
Definition: CNDArray.cc:514
octave_value operator!(const octave_value &a)
Definition: ov.h:1573
ComplexMatrix prod(int dim=-1) const
Definition: CMatrix.cc:2975
std::complex< double > Complex
Definition: oct-cmplx.h:31
ComplexMatrix sum(int dim=-1) const
Definition: CMatrix.cc:2981
write the output to stdout if nargout is
Definition: load-save.cc:1612
#define MINMAX_DECLS(T, S, API)
Definition: mx-op-decl.h:288
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263
ComplexNDArray(const dim_vector &dv)
Definition: CNDArray.h:41
octave::stream os
Definition: file-io.cc:627
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:27
ComplexNDArray(const Array< U > &a)
Definition: CNDArray.h:52
OCTAVE_API ComplexNDArray conj(const ComplexNDArray &a)
Definition: CNDArray.cc:737