Mercurial > octave-nkf
annotate src/Cell.h @ 8626:1dce30ab0e72
don't convert NaN to logical in bool expressions
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Jan 2009 12:50:25 -0500 |
parents | 7e0f36dfefbe |
children | 280fae940bb0 |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1999, 2002, 2003, 2004, 2005, 2006, 2007 John W. Eaton |
3353 | 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 the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3353 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3353 | 20 |
21 */ | |
22 | |
23 #if !defined (Cell_h) | |
24 #define Cell_h 1 | |
25 | |
26 #include <string> | |
27 | |
4513 | 28 #include "ArrayN.h" |
3353 | 29 #include "oct-alloc.h" |
30 #include "str-vec.h" | |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
31 #include "ov.h" |
3353 | 32 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
33 class octave_value_list; |
3353 | 34 |
35 class | |
6169 | 36 OCTINTERP_API |
4513 | 37 Cell : public ArrayN<octave_value> |
3353 | 38 { |
39 public: | |
40 | |
41 Cell (void) | |
4548 | 42 : ArrayN<octave_value> (dim_vector (0, 0)) { } |
3928 | 43 |
44 Cell (const octave_value& val) | |
4513 | 45 : ArrayN<octave_value> (dim_vector (1, 1), val) { } |
46 | |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
47 Cell (const octave_value_list& ovl); |
3353 | 48 |
7209 | 49 Cell (octave_idx_type n, octave_idx_type m, |
50 const octave_value& val = resize_fill_value ()) | |
4513 | 51 : ArrayN<octave_value> (dim_vector (n, m), val) { } |
3353 | 52 |
4587 | 53 Cell (const dim_vector& dv, const octave_value& val = resize_fill_value ()) |
54 : ArrayN<octave_value> (dv, val) { } | |
4563 | 55 |
4513 | 56 Cell (const ArrayN<octave_value>& c) |
57 : ArrayN<octave_value> (c) { } | |
3354 | 58 |
4567 | 59 Cell (const Array<octave_value>& c) |
60 : ArrayN<octave_value> (c) { } | |
61 | |
5275 | 62 Cell (const Array<octave_value>& c, octave_idx_type nr, octave_idx_type nc) |
4513 | 63 : ArrayN<octave_value> (c, dim_vector (nr, nc)) { } |
3933 | 64 |
5805 | 65 Cell (const string_vector& sv, bool trim = false); |
4216 | 66 |
6116 | 67 Cell (const dim_vector& dv, const string_vector& sv, bool trim = false); |
68 | |
3353 | 69 Cell (const Cell& c) |
4513 | 70 : ArrayN<octave_value> (c) { } |
71 | |
6116 | 72 bool is_cellstr (void) const; |
73 | |
4513 | 74 Cell index (const octave_value_list& idx, bool resize_ok = false) const; |
75 | |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
76 Cell index (const idx_vector& i, bool resize_ok = 0, |
4513 | 77 const octave_value& rfv = resize_fill_value ()) const |
4567 | 78 { return Cell (ArrayN<octave_value>::index (i, resize_ok, rfv)); } |
4513 | 79 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
80 Cell index (const idx_vector& i, idx_vector& j, bool resize_ok = 0, |
4513 | 81 const octave_value& rfv = resize_fill_value ()) const |
4567 | 82 { return Cell (ArrayN<octave_value>::index (i, j, resize_ok, rfv)); } |
4513 | 83 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
84 Cell index (const Array<idx_vector>& ra_idx, bool resize_ok = 0, |
4513 | 85 const octave_value& rfv = resize_fill_value ()) const |
4567 | 86 { return Cell (ArrayN<octave_value>::index (ra_idx, resize_ok, rfv)); } |
4513 | 87 |
8333 | 88 // FIXME -- this seems necessary for |
89 // octave_base_mat<Cell>::delete_elements to work, but I don't | |
90 // understand why. | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
91 void delete_elements (const Array<idx_vector>& ia) |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
92 { ArrayN<octave_value>::delete_elements (ia); } |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
93 |
8175
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
94 Cell& delete_elements (const octave_value_list& idx); |
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
95 |
4513 | 96 Cell& assign (const octave_value_list& idx, const Cell& rhs, |
97 const octave_value& fill_val = octave_value ()); | |
98 | |
8333 | 99 // FIXME -- this seems necessary for octave_base_mat<Cell>::assign |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
100 // to work, but I don't understand why. |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
101 void assign (const Array<idx_vector>& ia, const Array<octave_value>& rhs, |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
102 const octave_value& fill_val = octave_value ()) |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
103 { ArrayN<octave_value>::assign (ia, rhs, fill_val); } |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
104 |
4901 | 105 Cell reshape (const dim_vector& new_dims) const |
106 { return ArrayN<octave_value>::reshape (new_dims); } | |
107 | |
5602 | 108 octave_idx_type nnz (void) const; |
109 | |
5570 | 110 Cell column (octave_idx_type i) const; |
111 | |
5775 | 112 // FIXME |
4932 | 113 boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); } |
3933 | 114 |
5775 | 115 // FIXME |
4932 | 116 boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); } |
3933 | 117 |
5275 | 118 Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx); |
4915 | 119 |
5275 | 120 Cell& insert (const Cell& a, octave_idx_type r, octave_idx_type c); |
121 Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx); | |
4806 | 122 |
5775 | 123 // FIXME |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8579
diff
changeset
|
124 bool any_element_is_nan (void) const { return false; } |
3933 | 125 bool is_true (void) const { return false; } |
126 | |
4219 | 127 static octave_value resize_fill_value (void) { return Matrix (); } |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
128 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7618
diff
changeset
|
129 Cell diag (octave_idx_type k = 0) const; |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
130 |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
131 Cell xisalnum (void) const { return map (&octave_value::xisalnum); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
132 Cell xisalpha (void) const { return map (&octave_value::xisalpha); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
133 Cell xisascii (void) const { return map (&octave_value::xisascii); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
134 Cell xiscntrl (void) const { return map (&octave_value::xiscntrl); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
135 Cell xisdigit (void) const { return map (&octave_value::xisdigit); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
136 Cell xisgraph (void) const { return map (&octave_value::xisgraph); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
137 Cell xislower (void) const { return map (&octave_value::xislower); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
138 Cell xisprint (void) const { return map (&octave_value::xisprint); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
139 Cell xispunct (void) const { return map (&octave_value::xispunct); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
140 Cell xisspace (void) const { return map (&octave_value::xisspace); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
141 Cell xisupper (void) const { return map (&octave_value::xisupper); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
142 Cell xisxdigit (void) const { return map (&octave_value::xisxdigit); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
143 Cell xtoascii (void) const { return map (&octave_value::xtoascii); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
144 Cell xtolower (void) const { return map (&octave_value::xtolower); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
145 Cell xtoupper (void) const { return map (&octave_value::xtoupper); } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
146 |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
147 private: |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
148 |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
149 typedef octave_value (octave_value::*ctype_mapper) (void) const; |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
150 |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
151 Cell map (ctype_mapper) const; |
3353 | 152 }; |
153 | |
154 #endif | |
155 | |
156 /* | |
157 ;;; Local Variables: *** | |
158 ;;; mode: C++ *** | |
159 ;;; End: *** | |
160 */ |