Mercurial > hg > octave-nkf
annotate liboctave/array/chNDArray.cc @ 19508:6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
* chMatrix.h: both charMatrix and charNDArray are Array<char>, the first
being simply 2 dimensional. We change this so that charMatrix inherits from
charNDArray instead.
* chMatrix.cc: remove all constructors which are now inherited from
charNDArray.
* chNDArray.h, chNDArray.cc: implement all constructors here rather than
calling charMatrix. Remove matrix_value() since a charMatrix constructor is
now enough.
* pr-output.cc, octave-value/ov-ch-mat.h, octave-value/ov-str-mat.cc:
replace calls to charNDArray::matrix_value () with the charMatrix constructor.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Fri, 24 Oct 2014 01:31:53 +0100 |
parents | 49a5a4be04a1 |
children | 1f4455ff2329 |
rev | line source |
---|---|
4514 | 1 // N-D Array manipulations. |
2 /* | |
3 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
16370
diff
changeset
|
4 Copyright (C) 2003-2013 John W. Eaton |
4514 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
4514 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
4514 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
19508
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
28 #include <string> |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
29 |
4588 | 30 #include "Array-util.h" |
4514 | 31 #include "chNDArray.h" |
32 #include "mx-base.h" | |
33 #include "lo-ieee.h" | |
4915 | 34 #include "lo-mappers.h" |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8750
diff
changeset
|
35 #include "mx-op-defs.h" |
19508
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
36 #include "str-vec.h" |
4514 | 37 |
10107
fd262afea1d1
optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
38 #include "bsxfun-defs.cc" |
fd262afea1d1
optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
39 |
19508
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
40 charNDArray::charNDArray (char c) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
41 : Array<char> () |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
42 { |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
43 octave_idx_type nc = 1; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
44 octave_idx_type nr = 1; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
45 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
46 resize (nr, nc); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
47 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
48 elem (0, 0) = c; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
49 } |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
50 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
51 charNDArray::charNDArray (const char *s) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
52 : Array<char> () |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
53 { |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
54 octave_idx_type nc = s ? strlen (s) : 0; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
55 octave_idx_type nr = s && nc > 0 ? 1 : 0; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
56 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
57 resize (nr, nc); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
58 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
59 for (octave_idx_type i = 0; i < nc; i++) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
60 elem (0, i) = s[i]; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
61 } |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
62 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
63 charNDArray::charNDArray (const std::string& s) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
64 : Array<char> () |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
65 { |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
66 octave_idx_type nc = s.length (); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
67 octave_idx_type nr = nc > 0 ? 1 : 0; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
68 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
69 resize (nr, nc); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
70 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
71 for (octave_idx_type i = 0; i < nc; i++) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
72 elem (0, i) = s[i]; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
73 } |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
74 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
75 charNDArray::charNDArray (const string_vector& s, char fill_value) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
76 : Array<char> (dim_vector (s.length (), s.max_length ()), fill_value) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
77 { |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
78 octave_idx_type nr = rows (); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
79 |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
80 for (octave_idx_type i = 0; i < nr; i++) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
81 { |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
82 const std::string si = s(i); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
83 octave_idx_type nc = si.length (); |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
84 for (octave_idx_type j = 0; j < nc; j++) |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
85 elem (i, j) = si[j]; |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
86 } |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
87 } |
6c9ea5be96bf
Change charMatrix to subclass charNDArray rather than be another Array<char>.
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
88 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 // FIXME: this is not quite the right thing. |
4514 | 90 |
4556 | 91 boolNDArray |
4514 | 92 charNDArray::all (int dim) const |
93 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
94 return do_mx_red_op<bool, char> (*this, dim, mx_inline_all); |
4514 | 95 } |
96 | |
4556 | 97 boolNDArray |
4514 | 98 charNDArray::any (int dim) const |
99 { | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
100 return do_mx_red_op<bool, char> (*this, dim, mx_inline_any); |
4514 | 101 } |
102 | |
4915 | 103 charNDArray |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
104 charNDArray::concat (const charNDArray& rb, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
105 const Array<octave_idx_type>& ra_idx) |
4915 | 106 { |
4940 | 107 if (rb.numel () > 0) |
5073 | 108 insert (rb, ra_idx); |
109 return *this; | |
4915 | 110 } |
111 | |
112 charNDArray | |
5275 | 113 charNDArray::concat (const NDArray& rb, const Array<octave_idx_type>& ra_idx) |
4758 | 114 { |
4915 | 115 charNDArray tmp (rb.dims ()); |
5275 | 116 octave_idx_type nel = rb.numel (); |
4915 | 117 |
4940 | 118 if (rb.numel () == 0) |
5073 | 119 return *this; |
4915 | 120 |
5275 | 121 for (octave_idx_type i = 0; i < nel; i++) |
4915 | 122 { |
123 double d = rb.elem (i); | |
124 | |
125 if (xisnan (d)) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
126 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
127 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
128 ("invalid conversion from NaN to character"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
129 return *this; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
130 } |
4915 | 131 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
132 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
133 octave_idx_type ival = NINTbig (d); |
4915 | 134 |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
135 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ()) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 // FIXME: is there something better to do? Should we warn the user? |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
137 ival = 0; |
4915 | 138 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
139 tmp.elem (i) = static_cast<char>(ival); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
140 } |
4915 | 141 } |
142 | |
5073 | 143 insert (tmp, ra_idx); |
144 return *this; | |
4915 | 145 } |
146 | |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
147 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
148 charNDArray::max (int dim) const |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
149 { |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
150 return do_mx_minmax_op<char> (*this, dim, mx_inline_max); |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
151 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
152 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
153 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
154 charNDArray::max (Array<octave_idx_type>& idx_arg, int dim) const |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
155 { |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
156 return do_mx_minmax_op<char> (*this, idx_arg, dim, mx_inline_max); |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
157 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
158 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
159 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
160 charNDArray::min (int dim) const |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
161 { |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
162 return do_mx_minmax_op<char> (*this, dim, mx_inline_min); |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
163 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
164 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
165 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
166 charNDArray::min (Array<octave_idx_type>& idx_arg, int dim) const |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
167 { |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
168 return do_mx_minmax_op<char> (*this, idx_arg, dim, mx_inline_min); |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
169 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
170 |
4915 | 171 charNDArray& |
5275 | 172 charNDArray::insert (const charNDArray& a, octave_idx_type r, octave_idx_type c) |
4915 | 173 { |
174 Array<char>::insert (a, r, c); | |
175 return *this; | |
176 } | |
177 | |
178 charNDArray& | |
5275 | 179 charNDArray::insert (const charNDArray& a, const Array<octave_idx_type>& ra_idx) |
4915 | 180 { |
181 Array<char>::insert (a, ra_idx); | |
182 return *this; | |
4758 | 183 } |
184 | |
4532 | 185 void |
5275 | 186 charNDArray::increment_index (Array<octave_idx_type>& ra_idx, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
187 const dim_vector& dimensions, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
188 int start_dimension) |
4532 | 189 { |
190 ::increment_index (ra_idx, dimensions, start_dimension); | |
191 } | |
192 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
193 octave_idx_type |
5275 | 194 charNDArray::compute_index (Array<octave_idx_type>& ra_idx, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10267
diff
changeset
|
195 const dim_vector& dimensions) |
4556 | 196 { |
197 return ::compute_index (ra_idx, dimensions); | |
198 } | |
199 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
200 charNDArray |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
201 charNDArray::diag (octave_idx_type k) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
202 { |
10267
479c7df0cc96
don't instantiate MArray<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
203 return Array<char>::diag (k); |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
204 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
205 |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
206 charNDArray |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
207 charNDArray::diag (octave_idx_type m, octave_idx_type n) const |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
208 { |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
209 return Array<char>::diag (m, n); |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
210 } |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
211 |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
212 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
213 min (char d, const charNDArray& m) |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
214 { |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
215 return do_sm_binary_op<charNDArray::element_type, char, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
216 charNDArray::element_type> (d, m, mx_inline_xmin); |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
217 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
218 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
219 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
220 min (const charNDArray& m, char d) |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
221 { |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
222 return do_ms_binary_op<charNDArray::element_type, charNDArray::element_type, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
223 char> (m, d, mx_inline_xmin); |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
224 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
225 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
226 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
227 min (const charNDArray& a, const charNDArray& b) |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
228 { |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 return do_mm_binary_op<charNDArray::element_type, charNDArray::element_type, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 charNDArray::element_type> (a, b, mx_inline_xmin, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
231 mx_inline_xmin, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 mx_inline_xmin, "min"); |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
233 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
234 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
235 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
236 max (char d, const charNDArray& m) |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
237 { |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 return do_sm_binary_op<charNDArray::element_type, char, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
239 charNDArray::element_type> (d, m, mx_inline_xmax); |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
240 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
241 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
242 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
243 max (const charNDArray& m, char d) |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
244 { |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
245 return do_ms_binary_op<charNDArray::element_type, charNDArray::element_type, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
246 char> (m, d, mx_inline_xmax); |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
247 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
248 |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
249 charNDArray |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
250 max (const charNDArray& a, const charNDArray& b) |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
251 { |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
252 return do_mm_binary_op<charNDArray::element_type, charNDArray::element_type, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
253 charNDArray::element_type> (a, b, mx_inline_xmax, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
254 mx_inline_xmax, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
255 mx_inline_xmax, "max"); |
16370
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
256 } |
7ce21619a4b9
min Matlab compatibility issue (bug #33530)
Axel Mathéi <axel.mathei@gmail.com>
parents:
15271
diff
changeset
|
257 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
258 NDS_CMP_OPS (charNDArray, char) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
259 NDS_BOOL_OPS (charNDArray, char) |
6456 | 260 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
261 SND_CMP_OPS (char, charNDArray) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
262 SND_BOOL_OPS (char, charNDArray) |
6456 | 263 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
264 NDND_CMP_OPS (charNDArray, charNDArray) |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
9227
diff
changeset
|
265 NDND_BOOL_OPS (charNDArray, charNDArray) |
6456 | 266 |
10107
fd262afea1d1
optimize bsxfun for chars
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
267 BSXFUN_STDREL_DEFS_MXLOOP (charNDArray) |