GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
array
chNDArray.cc
Go to the documentation of this file.
1
// N-D Array manipulations.
2
/*
3
4
Copyright (C) 2003-2013 John W. Eaton
5
6
This file is part of Octave.
7
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
12
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
21
22
*/
23
24
#ifdef HAVE_CONFIG_H
25
#include <config.h>
26
#endif
27
28
#include "
Array-util.h
"
29
#include "
chNDArray.h
"
30
#include "
mx-base.h
"
31
#include "
lo-ieee.h
"
32
#include "
lo-mappers.h
"
33
#include "
mx-op-defs.h
"
34
35
#include "
bsxfun-defs.cc
"
36
37
// FIXME: this is not quite the right thing.
38
39
boolNDArray
40
charNDArray::all
(
int
dim)
const
41
{
42
return
do_mx_red_op<bool, char> (*
this
, dim,
mx_inline_all
);
43
}
44
45
boolNDArray
46
charNDArray::any
(
int
dim)
const
47
{
48
return
do_mx_red_op<bool, char> (*
this
, dim,
mx_inline_any
);
49
}
50
51
charNDArray
52
charNDArray::concat
(
const
charNDArray
& rb,
53
const
Array<octave_idx_type>
& ra_idx)
54
{
55
if
(rb.
numel
() > 0)
56
insert
(rb, ra_idx);
57
return
*
this
;
58
}
59
60
charNDArray
61
charNDArray::concat
(
const
NDArray
& rb,
const
Array<octave_idx_type>
& ra_idx)
62
{
63
charNDArray
tmp (rb.
dims
());
64
octave_idx_type
nel = rb.
numel
();
65
66
if
(rb.
numel
() == 0)
67
return
*
this
;
68
69
for
(
octave_idx_type
i = 0; i < nel; i++)
70
{
71
double
d
= rb.
elem
(i);
72
73
if
(
xisnan
(d))
74
{
75
(*current_liboctave_error_handler)
76
(
"invalid conversion from NaN to character"
);
77
return
*
this
;
78
}
79
else
80
{
81
octave_idx_type
ival =
NINTbig
(d);
82
83
if
(ival < 0 || ival >
std::numeric_limits<unsigned char>::max
())
84
// FIXME: is there something better to do? Should we warn the user?
85
ival = 0;
86
87
tmp.elem (i) =
static_cast<
char
>
(ival);
88
}
89
}
90
91
insert
(tmp, ra_idx);
92
return
*
this
;
93
}
94
95
charNDArray
96
charNDArray::max
(
int
dim)
const
97
{
98
return
do_mx_minmax_op<char> (*
this
, dim,
mx_inline_max
);
99
}
100
101
charNDArray
102
charNDArray::max
(
Array<octave_idx_type>
& idx_arg,
int
dim)
const
103
{
104
return
do_mx_minmax_op<char> (*
this
, idx_arg, dim,
mx_inline_max
);
105
}
106
107
charNDArray
108
charNDArray::min
(
int
dim)
const
109
{
110
return
do_mx_minmax_op<char> (*
this
, dim,
mx_inline_min
);
111
}
112
113
charNDArray
114
charNDArray::min
(
Array<octave_idx_type>
& idx_arg,
int
dim)
const
115
{
116
return
do_mx_minmax_op<char> (*
this
, idx_arg, dim,
mx_inline_min
);
117
}
118
119
charNDArray
&
120
charNDArray::insert
(
const
charNDArray
& a,
octave_idx_type
r,
octave_idx_type
c)
121
{
122
Array<char>::insert
(a, r, c);
123
return
*
this
;
124
}
125
126
charNDArray
&
127
charNDArray::insert
(
const
charNDArray
& a,
const
Array<octave_idx_type>
& ra_idx)
128
{
129
Array<char>::insert
(a, ra_idx);
130
return
*
this
;
131
}
132
133
charMatrix
134
charNDArray::matrix_value
(
void
)
const
135
{
136
return
*
this
;
137
}
138
139
void
140
charNDArray::increment_index
(
Array<octave_idx_type>
& ra_idx,
141
const
dim_vector
&
dimensions
,
142
int
start_dimension)
143
{
144
::increment_index
(ra_idx, dimensions, start_dimension);
145
}
146
147
octave_idx_type
148
charNDArray::compute_index
(
Array<octave_idx_type>
& ra_idx,
149
const
dim_vector
&
dimensions
)
150
{
151
return ::compute_index
(ra_idx, dimensions);
152
}
153
154
charNDArray
155
charNDArray::diag
(
octave_idx_type
k)
const
156
{
157
return
Array<char>::diag
(k);
158
}
159
160
charNDArray
161
charNDArray::diag
(
octave_idx_type
m,
octave_idx_type
n)
const
162
{
163
return
Array<char>::diag
(m, n);
164
}
165
166
charNDArray
167
min
(
char
d
,
const
charNDArray
& m)
168
{
169
return
do_sm_binary_op
<
charNDArray::element_type
,
char
,
170
charNDArray::element_type> (
d
, m,
mx_inline_xmin
);
171
}
172
173
charNDArray
174
min
(
const
charNDArray
& m,
char
d
)
175
{
176
return
do_ms_binary_op
<
charNDArray::element_type
,
charNDArray::element_type
,
177
char
> (m,
d
,
mx_inline_xmin
);
178
}
179
180
charNDArray
181
min
(
const
charNDArray
& a,
const
charNDArray
& b)
182
{
183
return
do_mm_binary_op
<
charNDArray::element_type
,
charNDArray::element_type
,
184
charNDArray::element_type> (a, b,
mx_inline_xmin
,
185
mx_inline_xmin
,
186
mx_inline_xmin
,
"min"
);
187
}
188
189
charNDArray
190
max
(
char
d
,
const
charNDArray
& m)
191
{
192
return
do_sm_binary_op
<
charNDArray::element_type
,
char
,
193
charNDArray::element_type> (
d
, m,
mx_inline_xmax
);
194
}
195
196
charNDArray
197
max
(
const
charNDArray
& m,
char
d
)
198
{
199
return
do_ms_binary_op
<
charNDArray::element_type
,
charNDArray::element_type
,
200
char
> (m,
d
,
mx_inline_xmax
);
201
}
202
203
charNDArray
204
max
(
const
charNDArray
& a,
const
charNDArray
& b)
205
{
206
return
do_mm_binary_op
<
charNDArray::element_type
,
charNDArray::element_type
,
207
charNDArray::element_type> (a, b,
mx_inline_xmax
,
208
mx_inline_xmax
,
209
mx_inline_xmax
,
"max"
);
210
}
211
212
NDS_CMP_OPS
(
charNDArray
,
char
)
213
NDS_BOOL_OPS
(
charNDArray
,
char
)
214
215
SND_CMP_OPS
(
char
, charNDArray)
216
SND_BOOL_OPS
(
char
, charNDArray)
217
218
NDND_CMP_OPS
(charNDArray, charNDArray)
219
NDND_BOOL_OPS
(charNDArray, charNDArray)
220
221
BSXFUN_STDREL_DEFS_MXLOOP
(charNDArray)
Generated on Mon Dec 30 2013 03:04:39 for GNU Octave by
1.8.1.2