GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-ch-mat.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://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 <cstdlib>
28 
29 #include <iosfwd>
30 #include <string>
31 
32 #include "mx-base.h"
33 #include "oct-alloc.h"
34 #include "str-vec.h"
35 
36 #include "error.h"
37 #include "ov.h"
38 #include "ov-base.h"
39 #include "ov-base-mat.h"
40 #include "ov-re-mat.h"
41 #include "ov-typeinfo.h"
42 
43 class octave_value_list;
44 
45 class tree_walker;
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 
72  octave_char_matrix (const std::string& s)
74 
77 
79  : octave_base_matrix<charNDArray> (chm) { }
80 
81 public:
82 
84 
85  octave_base_value *clone (void) const
86  { return new octave_char_matrix (*this); }
87  octave_base_value *empty_clone (void) const
88  { return new octave_char_matrix (); }
89 
90  idx_vector index_vector (void) 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 is_real_type (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  Matrix matrix_value (bool = false) const
110  { return Matrix (matrix.matrix_value ()); }
111 
112  FloatMatrix float_matrix_value (bool = false) const
113  { return FloatMatrix (matrix.matrix_value ()); }
114 
115  NDArray array_value (bool = false) const
116  { return NDArray (matrix); }
117 
118  FloatNDArray float_array_value (bool = false) const
119  { return FloatNDArray (matrix); }
120 
121  Complex complex_value (bool = false) const;
122 
123  FloatComplex float_complex_value (bool = false) const;
124 
125  ComplexMatrix complex_matrix_value (bool = false) const
126  { return ComplexMatrix (matrix.matrix_value ()); }
127 
128  FloatComplexMatrix float_complex_matrix_value (bool = false) const
129  { return FloatComplexMatrix (matrix.matrix_value ()); }
130 
131  ComplexNDArray complex_array_value (bool = false) const
132  { return ComplexNDArray (matrix); }
133 
134  FloatComplexNDArray float_complex_array_value (bool = false) const
135  { return FloatComplexNDArray (matrix); }
136 
137  charMatrix char_matrix_value (bool = false) const
138  { return matrix.matrix_value (); }
139 
140  charNDArray char_array_value (bool = false) const
141  { return matrix; }
142 
143  octave_value convert_to_str_internal (bool, bool, char type) const
144  { return octave_value (matrix, type); }
145 
146  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
147 
148  // Unsafe. This function exists to support the MEX interface.
149  // You should not use it anywhere else.
150  void *mex_get_data (void) const { return matrix.mex_get_data (); }
151 
152  mxArray *as_mxArray (void) const;
153 
154  octave_value map (unary_mapper_t umap) const;
155 };
156 
157 #endif