GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
intNDArray.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-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_intNDArray_h)
24 #define octave_intNDArray_h 1
25 
26 #include "octave-config.h"
27 
28 #include "MArray.h"
29 #include "boolNDArray.h"
30 
31 class NDArray;
32 
33 template <typename T>
34 class
35 intNDArray : public MArray<T>
36 {
37 public:
38 
39  using typename MArray<T>::element_type;
40 
41  intNDArray (void) : MArray<T> () { }
42 
43  intNDArray (T val) : MArray<T> (dim_vector (1, 1), val) { }
44 
45  intNDArray (const dim_vector& dv) : MArray<T> (dv) { }
46 
48  : MArray<T> (dv, val) { }
49 
50  template <typename U>
51  intNDArray (const Array<U>& a) : MArray<T> (a) { }
52 
53  template <typename U>
54  intNDArray (const MArray<U>& a) : MArray<T> (a) { }
55 
56  template <typename U>
57  intNDArray (const intNDArray<U>& a) : MArray<T> (a) { }
58 
60  {
62  return *this;
63  }
64 
65  boolNDArray operator ! (void) const;
66 
67  bool any_element_is_nan (void) const { return false; }
68  bool any_element_not_one_or_zero (void) const;
69 
70  intNDArray diag (octave_idx_type k = 0) const;
71 
73 
75  {
77  return *this;
78  }
79 
80  // FIXME: this is not quite the right thing.
81 
82  boolNDArray all (int dim = -1) const;
83  boolNDArray any (int dim = -1) const;
84 
85  intNDArray max (int dim = -1) const;
86  intNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
87  intNDArray min (int dim = -1) const;
88  intNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
89 
90  intNDArray cummax (int dim = -1) const;
91  intNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
92  intNDArray cummin (int dim = -1) const;
93  intNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
94 
95  intNDArray prod (int dim) const;
96  intNDArray sum (int dim) const;
97  NDArray dsum (int dim) const;
98  intNDArray cumsum (int dim) const;
99 
100  intNDArray diff (octave_idx_type order = 1, int dim = -1) const;
101 
102  intNDArray abs (void) const;
103  intNDArray signum (void) const;
104 
105  intNDArray squeeze (void) const
106  { return intNDArray<T> (MArray<T>::squeeze ()); }
107 
108  intNDArray transpose (void) const
109  { return intNDArray<T> (MArray<T>::transpose ()); }
110 
111  intNDArray concat (const intNDArray<T>& rb,
113 
114  intNDArray& insert (const intNDArray<T>& a,
116  intNDArray& insert (const intNDArray<T>& a,
118 
120  const dim_vector& dimensions,
121  int start_dimension = 0);
122 
124  const dim_vector& dimensions);
125 };
126 
127 // i/o
128 
129 template <typename T>
130 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a);
131 
132 template <typename T>
133 std::istream& operator >> (std::istream& is, intNDArray<T>& a);
134 
135 #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
intNDArray(T val)
Definition: intNDArray.h:43
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:32
intNDArray squeeze(void) const
Definition: intNDArray.h:105
bool any_element_is_nan(void) const
Definition: intNDArray.h:67
const octave_base_value const Array< octave_idx_type > & ra_idx
NDArray cummin(int dim=-1) const
Definition: dNDArray.cc:714
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
NDArray & operator=(const NDArray &a)
Definition: dNDArray.h:69
void changesign(void)
Definition: MArray.cc:204
for large enough k
Definition: lu.cc:617
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
static T abs(T x)
Definition: pr-output.cc:1696
NDArray cumsum(int dim=-1) const
Definition: dNDArray.cc:648
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
intNDArray(const Array< U > &a)
Definition: intNDArray.h:51
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
MArray< T > transpose(void) const
Definition: MArray.h:103
NDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: dNDArray.cc:726
intNDArray & changesign(void)
Definition: intNDArray.h:74
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
boolNDArray all(int dim=-1) const
Definition: dNDArray.cc:630
NDArray diag(octave_idx_type k=0) const
Definition: dNDArray.cc:844
Array< double > index(const idx_vector &i) const
Indexing without resizing.
Definition: Array.cc:697
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:58
intNDArray(const MArray< U > &a)
Definition: intNDArray.h:54
NDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: dNDArray.cc:791
double signum(double x)
Definition: lo-mappers.h:244
NDArray cummax(int dim=-1) const
Definition: dNDArray.cc:702
intNDArray(const dim_vector &dv)
Definition: intNDArray.h:45
intNDArray transpose(void) const
Definition: intNDArray.h:108
intNDArray(const dim_vector &dv, T val)
Definition: intNDArray.h:47
intNDArray(void)
Definition: intNDArray.h:41
intNDArray(const intNDArray< U > &a)
Definition: intNDArray.h:57
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:85
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:125
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:227
T element_type
Definition: Array.h:201
bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:565
std::istream & operator>>(std::istream &is, intNDArray< T > &a)
Definition: intNDArray.cc:155
NDArray sum(int dim=-1) const
Definition: dNDArray.cc:660
MArray squeeze(void) const
Definition: MArray.h:101
NDArray prod(int dim=-1) const
Definition: dNDArray.cc:654
octave_value operator!(const octave_value &a)
Definition: ov.h:1573
write the output to stdout if nargout is
Definition: load-save.cc:1612
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:204