GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
Cell.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1999-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_Cell_h)
27#define octave_Cell_h 1
28
29#include "octave-config.h"
30
31#include <list>
32#include <string>
33
34#include "Array.h"
35#include "str-vec.h"
36#include "ov.h"
37
39
40class OCTINTERP_API Cell : public Array<octave_value>
41{
42public:
43
44 Cell () = default;
45
46 Cell (const Cell& c) = default;
47
48 Cell& operator = (const Cell& c) = default;
49
50 ~Cell () = default;
51
52 Cell (const octave_value& val)
53 : Array<octave_value> (dim_vector (1, 1), val) { }
54
55 Cell (const octave_value_list& ovl);
56
58 const octave_value& val = Matrix ())
59 : Array<octave_value> (dim_vector (n, m), val) { }
60
61 Cell (const dim_vector& dv, const octave_value& val = Matrix ())
62 : Array<octave_value> (dv, val) { }
63
65 : Array<octave_value> (c) { }
66
69
70 Cell (const string_vector& sv, bool trim = false);
71
72 // Constructor for standard containers. V must be convertible to an
73 // octave_value object.
74 template <typename V, template <typename...> class C>
75 explicit
76 Cell (const C<V>& container)
78 {
79 std::size_t n = container.size ();
80
81 if (n > 0)
82 {
83 resize (dim_vector (n, 1));
84
85 octave_idx_type i = 0;
86
87 for (const auto& val : container)
88 elem(i++, 0) = val;
89 }
90 }
91
92 Cell (const std::list<std::string>& sl);
93
94 Cell (const Array<std::string>& sa);
95
96 Cell (const dim_vector& dv, const string_vector& sv, bool trim = false);
97
98 bool iscellstr () const;
99
100 Array<std::string> cellstr_value () const;
101
102 string_vector string_vector_value () const;
103
105
106 Cell index (const octave_value_list& idx, bool resize_ok = false) const;
107
109
110 void delete_elements (const octave_value_list& idx);
111
113
114 void assign (const octave_value_list& idx, const Cell& rhs,
115 const octave_value& fill_val = Matrix ());
116
117 Cell reshape (const dim_vector& new_dims) const
118 { return Array<octave_value>::reshape (new_dims); }
119
120 octave_idx_type nnz () const;
121
122 Cell column (octave_idx_type i) const;
123
124 // FIXME
125 boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); }
126
127 // FIXME
128 boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); }
129
130 Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx);
131
133 Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx);
134
135 // FIXME
136 bool any_element_is_nan () const { return false; }
137 bool is_true () const { return false; }
138
140
141 Cell diag (octave_idx_type k = 0) const;
142
144
145 Cell xisalnum () const { return map (&octave_value::xisalnum); }
146 Cell xisalpha () const { return map (&octave_value::xisalpha); }
147 Cell xisascii () const { return map (&octave_value::xisascii); }
148 Cell xiscntrl () const { return map (&octave_value::xiscntrl); }
149 Cell xisdigit () const { return map (&octave_value::xisdigit); }
150 Cell xisgraph () const { return map (&octave_value::xisgraph); }
151 Cell xislower () const { return map (&octave_value::xislower); }
152 Cell xisprint () const { return map (&octave_value::xisprint); }
153 Cell xispunct () const { return map (&octave_value::xispunct); }
154 Cell xisspace () const { return map (&octave_value::xisspace); }
155 Cell xisupper () const { return map (&octave_value::xisupper); }
157 Cell xtolower () const { return map (&octave_value::xtolower); }
158 Cell xtoupper () const { return map (&octave_value::xtoupper); }
159
160private:
161
162 typedef octave_value (octave_value::*ctype_mapper) () const;
163
164 Cell map (ctype_mapper) const;
165};
166
167template <>
169{ return v.cell_value (); }
170
171#endif
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition CNDArray.cc:418
Cell octave_value_extract< Cell >(const octave_value &v)
Definition Cell.h:168
#define C(a, b)
Definition Faddeeva.cc:256
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
void assign(const octave::idx_vector &i, const Array< T, Alloc > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
Array< T, Alloc > & operator=(const Array< T, Alloc > &a)
Definition Array.h:365
Array< T, Alloc > column(octave_idx_type k) const
Extract column: A(:,k+1).
Array< U, A > map(F fcn) const
Apply function fcn to each element of the Array<T, Alloc>.
Definition Array.h:861
octave_idx_type nnz() const
Count nonzero elements.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
void delete_elements(const octave::idx_vector &i)
Deleting elements.
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
Definition Array.h:636
Array< T, Alloc > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
virtual T resize_fill_value() const
Size of the specified dimension.
Definition Cell.h:41
boolMatrix any(int=0) const
Definition Cell.h:128
Cell(const Array< octave_value > &c, octave_idx_type nr, octave_idx_type nc)
Definition Cell.h:67
Cell xisspace() const
Definition Cell.h:154
Cell xisupper() const
Definition Cell.h:155
Cell xisprint() const
Definition Cell.h:152
Cell xislower() const
Definition Cell.h:151
bool any_element_is_nan() const
Definition Cell.h:136
Cell xisdigit() const
Definition Cell.h:149
Cell(const Array< octave_value > &c)
Definition Cell.h:64
Cell(const Cell &c)=default
Cell xtolower() const
Definition Cell.h:157
Cell reshape(const dim_vector &new_dims) const
Definition Cell.h:117
~Cell()=default
Cell xtoupper() const
Definition Cell.h:158
Cell xisxdigit() const
Definition Cell.h:156
Cell()=default
Cell(octave_idx_type n, octave_idx_type m, const octave_value &val=Matrix())
Definition Cell.h:57
Cell(const C< V > &container)
Definition Cell.h:76
Cell xiscntrl() const
Definition Cell.h:148
Cell(const dim_vector &dv, const octave_value &val=Matrix())
Definition Cell.h:61
Cell xisalpha() const
Definition Cell.h:146
Cell xisgraph() const
Definition Cell.h:150
boolMatrix all(int=0) const
Definition Cell.h:125
Cell xisalnum() const
Definition Cell.h:145
bool is_true() const
Definition Cell.h:137
Cell(const octave_value &val)
Definition Cell.h:52
Cell xispunct() const
Definition Cell.h:153
Cell xisascii() const
Definition Cell.h:147
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
octave_value xisgraph() const
Definition ov.h:1515
Cell cell_value() const
octave_value xispunct() const
Definition ov.h:1518
octave_value xtolower() const
Definition ov.h:1523
octave_value xisdigit() const
Definition ov.h:1514
octave_value xisascii() const
Definition ov.h:1512
octave_value xisalpha() const
Definition ov.h:1511
octave_value xisalnum() const
Definition ov.h:1510
octave_value xisxdigit() const
Definition ov.h:1521
octave_value xisprint() const
Definition ov.h:1517
octave_value xtoupper() const
Definition ov.h:1524
octave_value xisspace() const
Definition ov.h:1519
octave_value xisupper() const
Definition ov.h:1520
octave_value xiscntrl() const
Definition ov.h:1513
octave_value xislower() const
Definition ov.h:1516
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition ovl.h:217