GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Cell.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1999-2018 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
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
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License 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 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_Cell_h)
25 #define octave_Cell_h 1
26 
27 #include "octave-config.h"
28 
29 #include <string>
30 
31 #include "Array.h"
32 #include "str-vec.h"
33 #include "ov.h"
34 
35 class octave_value_list;
36 
37 class
38 OCTINTERP_API
40 {
41 public:
42 
43  Cell (void)
44  : Array<octave_value> (dim_vector (0, 0)) { }
45 
47  : Array<octave_value> (dim_vector (1, 1), val) { }
48 
49  Cell (const octave_value_list& ovl);
50 
52  const octave_value& val = Matrix ())
53  : Array<octave_value> (dim_vector (n, m), val) { }
54 
55  Cell (const dim_vector& dv, const octave_value& val = Matrix ())
56  : Array<octave_value> (dv, val) { }
57 
59  : Array<octave_value> (c) { }
60 
62  : Array<octave_value> (c, dim_vector (nr, nc)) { }
63 
64  Cell (const string_vector& sv, bool trim = false);
65 
66  // Constructor for standard containers. V must be convertible to an
67  // octave_value object.
68  template <typename V, template <typename...> class C>
69  explicit
70  Cell (const C<V>& container)
71  : Array<octave_value> ()
72  {
73  size_t n = container.size ();
74 
75  if (n > 0)
76  {
77  resize (dim_vector (n, 1));
78 
79  octave_idx_type i = 0;
80 
81  for (const auto& val : container)
82  elem(i++,0) = val;
83  }
84  }
85 
86  Cell (const Array<std::string>& sa);
87 
88  Cell (const dim_vector& dv, const string_vector& sv, bool trim = false);
89 
90  Cell (const Cell& c)
91  : Array<octave_value> (c) { }
92 
93  bool iscellstr (void) const;
94 
95  Array<std::string> cellstr_value (void) const;
96 
97  string_vector string_vector_value (void) const;
98 
100 
101  Cell index (const octave_value_list& idx, bool resize_ok = false) const;
102 
104 
105  void delete_elements (const octave_value_list& idx);
106 
108 
109  void assign (const octave_value_list& idx, const Cell& rhs,
110  const octave_value& fill_val = Matrix ());
111 
112  Cell reshape (const dim_vector& new_dims) const
113  { return Array<octave_value>::reshape (new_dims); }
114 
115  octave_idx_type nnz (void) const;
116 
117  Cell column (octave_idx_type i) const;
118 
119  // FIXME
120  boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); }
121 
122  // FIXME
123  boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); }
124 
125  Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx);
126 
127  Cell& insert (const Cell& a, octave_idx_type r, octave_idx_type c);
128  Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx);
129 
130  // FIXME
131  bool any_element_is_nan (void) const { return false; }
132  bool is_true (void) const { return false; }
133 
134  octave_value resize_fill_value (void) const;
135 
136  Cell diag (octave_idx_type k = 0) const;
137 
138  Cell diag (octave_idx_type m, octave_idx_type n) const;
139 
140  Cell xisalnum (void) const { return map (&octave_value::xisalnum); }
141  Cell xisalpha (void) const { return map (&octave_value::xisalpha); }
142  Cell xisascii (void) const { return map (&octave_value::xisascii); }
143  Cell xiscntrl (void) const { return map (&octave_value::xiscntrl); }
144  Cell xisdigit (void) const { return map (&octave_value::xisdigit); }
145  Cell xisgraph (void) const { return map (&octave_value::xisgraph); }
146  Cell xislower (void) const { return map (&octave_value::xislower); }
147  Cell xisprint (void) const { return map (&octave_value::xisprint); }
148  Cell xispunct (void) const { return map (&octave_value::xispunct); }
149  Cell xisspace (void) const { return map (&octave_value::xisspace); }
150  Cell xisupper (void) const { return map (&octave_value::xisupper); }
151  Cell xisxdigit (void) const { return map (&octave_value::xisxdigit); }
152  Cell xtolower (void) const { return map (&octave_value::xtolower); }
153  Cell xtoupper (void) const { return map (&octave_value::xtoupper); }
154 
155 private:
156 
157  typedef octave_value (octave_value::*ctype_mapper) (void) const;
158 
159  Cell map (ctype_mapper) const;
160 };
161 
162 template <>
164 { return v.cell_value (); }
165 
166 #endif
Cell xisupper(void) const
Definition: Cell.h:150
Cell xisspace(void) const
Definition: Cell.h:149
octave_value xislower(void) const
Definition: ov.h:1461
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
Definition: Cell.h:37
Cell(const C< V > &container)
Definition: Cell.h:70
#define C(a, b)
Definition: Faddeeva.cc:246
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value xisupper(void) const
Definition: ov.h:1465
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
octave_value xisalnum(void) const
Definition: ov.h:1455
Cell(const dim_vector &dv, const octave_value &val=Matrix())
Definition: Cell.h:55
for large enough k
Definition: lu.cc:617
Cell xisgraph(void) const
Definition: Cell.h:145
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
octave_value xisspace(void) const
Definition: ov.h:1464
octave_value xisxdigit(void) const
Definition: ov.h:1466
Cell xislower(void) const
Definition: Cell.h:146
Cell xisxdigit(void) const
Definition: Cell.h:151
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
Cell xisdigit(void) const
Definition: Cell.h:144
Cell(const Cell &c)
Definition: Cell.h:90
Cell(const Array< octave_value > &c)
Definition: Cell.h:58
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Definition: Array.h:549
octave_value xisascii(void) const
Definition: ov.h:1457
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
Cell xtoupper(void) const
Definition: Cell.h:153
static int elem
Definition: __contourc__.cc:47
Cell(octave_idx_type n, octave_idx_type m, const octave_value &val=Matrix())
Definition: Cell.h:51
Cell xisascii(void) const
Definition: Cell.h:142
octave_value xtoupper(void) const
Definition: ov.h:1469
Definition: dMatrix.h:36
Cell xispunct(void) const
Definition: Cell.h:148
Cell(const Array< octave_value > &c, octave_idx_type nr, octave_idx_type nc)
Definition: Cell.h:61
octave_value xisprint(void) const
Definition: ov.h:1462
Cell xisalpha(void) const
Definition: Cell.h:141
Cell octave_value_extract< Cell >(const octave_value &v)
Definition: Cell.h:163
OCTAVE_EXPORT octave_value_list iscellstr
Definition: ov-cell.cc:1220
Cell xisalnum(void) const
Definition: Cell.h:140
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value xtolower(void) const
Definition: ov.h:1468
octave_value xisdigit(void) const
Definition: ov.h:1459
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
boolMatrix any(int=0) const
Definition: Cell.h:123
bool is_true(void) const
Definition: Cell.h:132
octave_map map(dims)
Cell(void)
Definition: Cell.h:43
octave_value xiscntrl(void) const
Definition: ov.h:1458
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
Definition: ovl.h:100
Cell xisprint(void) const
Definition: Cell.h:147
Cell xiscntrl(void) const
Definition: Cell.h:143
for i
Definition: data.cc:5264
boolMatrix all(int=0) const
Definition: Cell.h:120
bool any_element_is_nan(void) const
Definition: Cell.h:131
Cell reshape(const dim_vector &new_dims) const
Definition: Cell.h:112
Cell(const octave_value &val)
Definition: Cell.h:46
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
octave_value xispunct(void) const
Definition: ov.h:1463
Cell xtolower(void) const
Definition: Cell.h:152
dim_vector dv
Definition: sub2ind.cc:263
octave_value xisgraph(void) const
Definition: ov.h:1460
octave_value xisalpha(void) const
Definition: ov.h:1456