3294
|
1 @c Copyright (C) 1996, 1997 John W. Eaton |
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
4167
|
5 @node Data Types |
3294
|
6 @chapter Data Types |
|
7 @cindex data types |
|
8 |
|
9 All versions of Octave include a number of built-in data types, |
|
10 including real and complex scalars and matrices, character strings, and |
|
11 a data structure type. |
|
12 |
|
13 It is also possible to define new specialized data types by writing a |
|
14 small amount of C++ code. On some systems, new data types can be loaded |
|
15 dynamically while Octave is running, so it is not necessary to recompile |
|
16 all of Octave just to add a new type. @xref{Dynamically Linked |
3402
|
17 Functions}, for more information about Octave's dynamic linking |
3294
|
18 capabilities. @ref{User-defined Data Types} describes what you must do |
|
19 to define a new data type for Octave. |
|
20 |
3428
|
21 @DOCSTRING(typeinfo) |
|
22 |
3294
|
23 @menu |
|
24 * Built-in Data Types:: |
|
25 * User-defined Data Types:: |
|
26 * Object Sizes:: |
|
27 @end menu |
|
28 |
4167
|
29 @node Built-in Data Types |
3294
|
30 @section Built-in Data Types |
|
31 @cindex data types, built-in |
|
32 @cindex built-in data types |
|
33 |
|
34 The standard built-in data types are real and complex scalars and |
|
35 matrices, ranges, character strings, and a data structure type. |
|
36 Additional built-in data types may be added in future versions. If you |
|
37 need a specialized data type that is not currently provided as a |
|
38 built-in type, you are encouraged to write your own user-defined data |
|
39 type and contribute it for distribution in a future release of Octave. |
|
40 |
6550
|
41 @DOCSTRING(class) |
|
42 |
|
43 @DOCSTRING(isa) |
|
44 |
|
45 @DOCSTRING(cast) |
|
46 |
3294
|
47 @menu |
|
48 * Numeric Objects:: |
4169
|
49 * Missing Data:: |
3294
|
50 * String Objects:: |
|
51 * Data Structure Objects:: |
|
52 @end menu |
|
53 |
4167
|
54 @node Numeric Objects |
3294
|
55 @subsection Numeric Objects |
|
56 @cindex numeric constant |
|
57 @cindex numeric value |
|
58 |
|
59 Octave's built-in numeric objects include real and complex scalars and |
|
60 matrices. All built-in numeric data is currently stored as double |
|
61 precision numbers. On systems that use the IEEE floating point format, |
|
62 values in the range of approximately |
|
63 @iftex |
|
64 @tex |
|
65 $2.2251\times10^{-308}$ to $1.7977\times10^{308}$ |
|
66 @end tex |
|
67 @end iftex |
|
68 @ifinfo |
|
69 2.2251e-308 to 1.7977e+308 |
|
70 @end ifinfo |
|
71 can be stored, and the relative precision is approximately |
|
72 @iftex |
|
73 @tex |
|
74 $2.2204\times10^{-16}$. |
|
75 @end tex |
|
76 @end iftex |
|
77 @ifinfo |
|
78 2.2204e-16. |
|
79 @end ifinfo |
|
80 The exact values are given by the variables @code{realmin}, |
|
81 @code{realmax}, and @code{eps}, respectively. |
|
82 |
|
83 Matrix objects can be of any size, and can be dynamically reshaped and |
|
84 resized. It is easy to extract individual rows, columns, or submatrices |
|
85 using a variety of powerful indexing features. @xref{Index Expressions}. |
|
86 |
|
87 @xref{Numeric Data Types}, for more information. |
|
88 |
4169
|
89 @node Missing Data |
|
90 @subsection Missing Data |
|
91 @cindex missing data |
|
92 |
|
93 @DOCSTRING(NA) |
|
94 |
|
95 @DOCSTRING(isna) |
|
96 |
4167
|
97 @node String Objects |
3294
|
98 @subsection String Objects |
|
99 @cindex strings |
|
100 @cindex character strings |
|
101 @opindex " |
|
102 @opindex ' |
|
103 |
|
104 A character string in Octave consists of a sequence of characters |
|
105 enclosed in either double-quote or single-quote marks. Internally, |
|
106 Octave currently stores strings as matrices of characters. All the |
|
107 indexing operations that work for matrix objects also work for strings. |
|
108 |
|
109 @xref{Strings}, for more information. |
|
110 |
4167
|
111 @node Data Structure Objects |
3294
|
112 @subsection Data Structure Objects |
|
113 @cindex structures |
|
114 @cindex data structures |
|
115 |
|
116 Octave's data structure type can help you to organize related objects of |
|
117 different types. The current implementation uses an associative array |
|
118 with indices limited to strings, but the syntax is more like C-style |
|
119 structures. |
|
120 |
|
121 @xref{Data Structures}, for more information. |
|
122 |
4167
|
123 @node User-defined Data Types |
3294
|
124 @section User-defined Data Types |
|
125 @cindex user-defined data types |
|
126 @cindex data types, user-defined |
|
127 |
|
128 Someday I hope to expand this to include a complete description of |
|
129 Octave's mechanism for managing user-defined data types. Until this |
|
130 feature is documented here, you will have to make do by reading the code |
|
131 in the @file{ov.h}, @file{ops.h}, and related files from Octave's |
|
132 @file{src} directory. |
|
133 |
4167
|
134 @node Object Sizes |
3294
|
135 @section Object Sizes |
|
136 |
|
137 The following functions allow you to determine the size of a variable or |
|
138 expression. These functions are defined for all objects. They return |
|
139 @minus{}1 when the operation doesn't make sense. For example, Octave's |
|
140 data structure type doesn't have rows or columns, so the @code{rows} and |
|
141 @code{columns} functions return @minus{}1 for structure arguments. |
|
142 |
6549
|
143 @DOCSTRING(ndims) |
|
144 |
3373
|
145 @DOCSTRING(columns) |
3294
|
146 |
3373
|
147 @DOCSTRING(rows) |
3294
|
148 |
6549
|
149 @DOCSTRING(numel) |
|
150 |
3373
|
151 @DOCSTRING(length) |
3294
|
152 |
3373
|
153 @DOCSTRING(size) |
3294
|
154 |
3373
|
155 @DOCSTRING(isempty) |
3294
|
156 |
6549
|
157 @DOCSTRING(sizeof) |
|
158 |
|
159 @DOCSTRING(size_equal) |
6550
|
160 |
|
161 @DOCSTRING(squeeze) |