GNU Octave  9.1.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-2024 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 () = default;
86 
88  { return new octave_char_matrix (*this); }
90  { return new octave_char_matrix (); }
91 
92  octave::idx_vector index_vector (bool require_integers = false) const;
93 
94  builtin_type_t builtin_type () const { return btyp_char; }
95 
96  bool is_char_matrix () const { return true; }
97  bool is_real_matrix () const { return true; }
98 
99  bool isreal () 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 (m_matrix)); }
116 
117  FloatMatrix float_matrix_value (bool = false) const
118  { return FloatMatrix (charMatrix (m_matrix)); }
119 
120  NDArray array_value (bool = false) const
121  { return NDArray (m_matrix); }
122 
123  FloatNDArray float_array_value (bool = false) const
124  { return FloatNDArray (m_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 (m_matrix)); }
132 
134  { return FloatComplexMatrix (charMatrix (m_matrix)); }
135 
136  ComplexNDArray complex_array_value (bool = false) const
137  { return ComplexNDArray (m_matrix); }
138 
140  { return FloatComplexNDArray (m_matrix); }
141 
142  charMatrix char_matrix_value (bool = false) const
143  { return charMatrix (m_matrix); }
144 
145  charNDArray char_array_value (bool = false) const
146  { return m_matrix; }
147 
148  octave_value convert_to_str_internal (bool, bool, char type) const
149  { return octave_value (m_matrix, type); }
150 
151  octave_value as_double () const;
152  octave_value as_single () const;
153 
154  octave_value as_int8 () const;
155  octave_value as_int16 () const;
156  octave_value as_int32 () const;
157  octave_value as_int64 () const;
158 
159  octave_value as_uint8 () const;
160  octave_value as_uint16 () const;
161  octave_value as_uint32 () const;
162  octave_value as_uint64 () const;
163 
164  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
165 
166  mxArray * as_mxArray (bool interleaved) const;
167 
168  octave_value map (unary_mapper_t umap) const;
169 };
170 
171 #endif
Definition: dMatrix.h:42
octave_char_matrix(char c)
Definition: ov-ch-mat.h:68
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-ch-mat.h:130
octave_base_value * empty_clone() const
Definition: ov-ch-mat.h:89
builtin_type_t builtin_type() const
Definition: ov-ch-mat.h:94
octave_base_value * clone() const
Definition: ov-ch-mat.h:87
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
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
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
charMatrix char_matrix_value(bool=false) const
Definition: ov-ch-mat.h:142
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 isreal() const
Definition: ov-ch-mat.h:99
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
~octave_char_matrix()=default
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
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
bool is_char_matrix() const
Definition: ov-ch-mat.h:96
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
bool is_real_matrix() const
Definition: ov-ch-mat.h:97
octave::idx_vector idx_vector
Definition: idx-vector.h:1022
std::complex< double > Complex
Definition: oct-cmplx.h:33
std::complex< float > FloatComplex
Definition: oct-cmplx.h:34
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:83
@ btyp_char
Definition: ov-base.h:97