GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-ch-mat.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 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_ov_ch_mat_h)
27 #define octave_ov_ch_mat_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstdlib>
32 
33 #include <iosfwd>
34 #include <string>
35 
36 #include "mx-base.h"
37 #include "str-vec.h"
38 
39 #include "error.h"
40 #include "ov.h"
41 #include "ov-base.h"
42 #include "ov-base-mat.h"
43 #include "ov-int64.h"
44 #include "ov-re-mat.h"
45 #include "ov-typeinfo.h"
46 
47 class octave_value_list;
48 
49 // Character matrix values.
50 
51 class
53 {
54 protected:
55 
58 
60  : octave_base_matrix<charNDArray> (chm) { }
61 
63  : octave_base_matrix<charNDArray> (chm) { }
64 
66  : octave_base_matrix<charNDArray> (chm) { }
67 
70 
71  octave_char_matrix (const char *s)
73 
74  octave_char_matrix (const std::string& s)
76 
79 
81  : octave_base_matrix<charNDArray> (chm) { }
82 
83 public:
84 
85  ~octave_char_matrix (void) = default;
86 
87  octave_base_value * clone (void) const
88  { return new octave_char_matrix (*this); }
90  { return new octave_char_matrix (); }
91 
92  idx_vector index_vector (bool require_integers = false) const;
93 
94  builtin_type_t builtin_type (void) const { return btyp_char; }
95 
96  bool is_char_matrix (void) const { return true; }
97  bool is_real_matrix (void) const { return true; }
98 
99  bool isreal (void) const { return true; }
100 
101  double double_value (bool = false) const;
102 
103  float float_value (bool = false) const;
104 
105  double scalar_value (bool frc_str_conv = false) const
106  { return double_value (frc_str_conv); }
107 
108  float float_scalar_value (bool frc_str_conv = false) const
109  { return float_value (frc_str_conv); }
110 
111  octave_int64 int64_scalar_value () const;
112  octave_uint64 uint64_scalar_value () const;
113 
114  Matrix matrix_value (bool = false) const
115  { return Matrix (charMatrix (matrix)); }
116 
117  FloatMatrix float_matrix_value (bool = false) const
118  { return FloatMatrix (charMatrix (matrix)); }
119 
120  NDArray array_value (bool = false) const
121  { return NDArray (matrix); }
122 
123  FloatNDArray float_array_value (bool = false) const
124  { return FloatNDArray (matrix); }
125 
126  Complex complex_value (bool = false) const;
127 
128  FloatComplex float_complex_value (bool = false) const;
129 
130  ComplexMatrix complex_matrix_value (bool = false) const
131  { return ComplexMatrix (charMatrix (matrix)); }
132 
134  { return FloatComplexMatrix (charMatrix (matrix)); }
135 
136  ComplexNDArray complex_array_value (bool = false) const
137  { return ComplexNDArray (matrix); }
138 
140  { return FloatComplexNDArray (matrix); }
141 
142  charMatrix char_matrix_value (bool = false) const
143  { return charMatrix (matrix); }
144 
145  charNDArray char_array_value (bool = false) const
146  { return matrix; }
147 
148  octave_value convert_to_str_internal (bool, bool, char type) const
149  { return octave_value (matrix, type); }
150 
151  octave_value as_double (void) const;
152  octave_value as_single (void) const;
153 
154  octave_value as_int8 (void) const;
155  octave_value as_int16 (void) const;
156  octave_value as_int32 (void) const;
157  octave_value as_int64 (void) const;
158 
159  octave_value as_uint8 (void) const;
160  octave_value as_uint16 (void) const;
161  octave_value as_uint32 (void) const;
162  octave_value as_uint64 (void) const;
163 
164  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
165 
166  // Unsafe. This function exists to support the MEX interface.
167  // You should not use it anywhere else.
168  void * mex_get_data (void) const { return matrix.mex_get_data (); }
169 
170  mxArray * as_mxArray (void) const;
171 
172  octave_value map (unary_mapper_t umap) const;
173 };
174 
175 #endif
Definition: dMatrix.h:42
octave_char_matrix(char c)
Definition: ov-ch-mat.h:68
octave_base_value * empty_clone(void) const
Definition: ov-ch-mat.h:89
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-ch-mat.h:130
FloatNDArray float_array_value(bool=false) const
Definition: ov-ch-mat.h:123
octave_char_matrix(const std::string &s)
Definition: ov-ch-mat.h:74
bool is_char_matrix(void) const
Definition: ov-ch-mat.h:96
octave_char_matrix(const char *s)
Definition: ov-ch-mat.h:71
octave_value convert_to_str_internal(bool, bool, char type) const
Definition: ov-ch-mat.h:148
void * mex_get_data(void) const
Definition: ov-ch-mat.h:168
builtin_type_t builtin_type(void) const
Definition: ov-ch-mat.h:94
octave_char_matrix(const charMatrix &chm)
Definition: ov-ch-mat.h:59
FloatMatrix float_matrix_value(bool=false) const
Definition: ov-ch-mat.h:117
octave_base_value * clone(void) const
Definition: ov-ch-mat.h:87
charMatrix char_matrix_value(bool=false) const
Definition: ov-ch-mat.h:142
bool isreal(void) const
Definition: ov-ch-mat.h:99
charNDArray char_array_value(bool=false) const
Definition: ov-ch-mat.h:145
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-ch-mat.h:136
bool is_real_matrix(void) const
Definition: ov-ch-mat.h:97
~octave_char_matrix(void)=default
octave_char_matrix(const octave_char_matrix &chm)
Definition: ov-ch-mat.h:80
Matrix matrix_value(bool=false) const
Definition: ov-ch-mat.h:114
float float_scalar_value(bool frc_str_conv=false) const
Definition: ov-ch-mat.h:108
octave_char_matrix(const charNDArray &chm)
Definition: ov-ch-mat.h:62
octave_char_matrix(void)
Definition: ov-ch-mat.h:56
double scalar_value(bool frc_str_conv=false) const
Definition: ov-ch-mat.h:105
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-ch-mat.h:139
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-ch-mat.h:133
octave_char_matrix(const string_vector &s)
Definition: ov-ch-mat.h:77
octave_char_matrix(const Array< char > &chm)
Definition: ov-ch-mat.h:65
NDArray array_value(bool=false) const
Definition: ov-ch-mat.h:120
std::complex< double > Complex
Definition: oct-cmplx.h:33
std::complex< float > FloatComplex
Definition: oct-cmplx.h:34
static double as_double(time_t sec, long usec)
Definition: oct-time.h:37
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
builtin_type_t
Definition: ov-base.h:72
@ btyp_char
Definition: ov-base.h:86