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