Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 135

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Built-in Data Types - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Data-Types.html#Data-Types" title="Data Types">
<link rel="next" href="User_002ddefined-Data-Types.html#User_002ddefined-Data-Types" title="User-defined Data Types">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Built-in-Data-Types"></a>
<a name="Built_002din-Data-Types"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="User_002ddefined-Data-Types.html#User_002ddefined-Data-Types">User-defined Data Types</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Data-Types.html#Data-Types">Data Types</a>
<hr>
</div>

<h3 class="section">3.1 Built-in Data Types</h3>

<p><a name="index-data-types_002c-built_002din-199"></a><a name="index-built_002din-data-types-200"></a>
The standard built-in data types are real and complex scalars and
matrices, ranges, character strings, a data structure type, and cell
arrays.  Additional built-in data types may be added in future versions. 
If you need a specialized data type that is not currently provided as a
built-in type, you are encouraged to write your own user-defined data
type and contribute it for distribution in a future release of Octave.

   <p>The data type of a variable can be determined and changed through the
use of the following functions.

<!-- class src/ov-class.cc -->
   <p><a name="doc_002dclass"></a>

<div class="defun">
&mdash; Built-in Function:  <b>class</b> (<var>expr</var>)<var><a name="index-class-201"></a></var><br>
&mdash; Built-in Function:  <b>class</b> (<var>s, id</var>)<var><a name="index-class-202"></a></var><br>
&mdash; Built-in Function:  <b>class</b> (<var>s, id, p, <small class="dots">...</small></var>)<var><a name="index-class-203"></a></var><br>
<blockquote><p>Return the class of the expression <var>expr</var> or create a class with
fields from structure <var>s</var> and name (string) <var>id</var>.  Additional
arguments name a list of parent classes from which the new class is
derived. 
</p></blockquote></div>

<!-- isa scripts/general/isa.m -->
   <p><a name="doc_002disa"></a>

<div class="defun">
&mdash; Function File:  <b>isa</b> (<var>obj, class</var>)<var><a name="index-isa-204"></a></var><br>
<blockquote><p>Return true if <var>obj</var> is an object from the class <var>class</var>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dclass.html#doc_002dclass">class</a>, <a href="doc_002dtypeinfo.html#doc_002dtypeinfo">typeinfo</a>. 
</p></blockquote></div>

<!-- cast scripts/miscellaneous/cast.m -->
   <p><a name="doc_002dcast"></a>

<div class="defun">
&mdash; Function File:  <b>cast</b> (<var>val, type</var>)<var><a name="index-cast-205"></a></var><br>
<blockquote><p>Convert <var>val</var> to data type <var>type</var>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dint8.html#doc_002dint8">int8</a>, <a href="doc_002duint8.html#doc_002duint8">uint8</a>, <a href="doc_002dint16.html#doc_002dint16">int16</a>, <a href="doc_002duint16.html#doc_002duint16">uint16</a>, <a href="doc_002dint32.html#doc_002dint32">int32</a>, <a href="doc_002duint32.html#doc_002duint32">uint32</a>, <a href="doc_002dint64.html#doc_002dint64">int64</a>, <a href="doc_002duint64.html#doc_002duint64">uint64</a>, <a href="doc_002ddouble.html#doc_002ddouble">double</a>. 
</p></blockquote></div>

<!-- typecast src/DLD-FUNCTIONS/typecast.cc -->
   <p><a name="doc_002dtypecast"></a>

<div class="defun">
&mdash; Loadable Function:  <b>typecast</b> (<var>x, class</var>)<var><a name="index-typecast-206"></a></var><br>
<blockquote><p>Return a new array <var>y</var> resulting from interpreting the data of
<var>x</var> in memory as data of the numeric class <var>class</var>.  Both the class
of <var>x</var> and <var>class</var> must be one of the built-in numeric classes:

     <pre class="example">            "logical"
            "char"
            "int8"
            "int16"
            "int32"
            "int64"
            "uint8"
            "uint16"
            "uint32"
            "uint64"
            "double"
            "single"
            "double complex"
            "single complex"
</pre>
        <p class="noindent">the last two are reserved for <var>class</var>; they indicate that a
complex-valued result is requested.  Complex arrays are stored in memory as
consecutive pairs of real numbers.  The sizes of integer types are given by
their bit counts.  Both logical and char are typically one byte wide;
however, this is not guaranteed by C++.  If your system is IEEE conformant,
single and double should be 4 bytes and 8 bytes wide, respectively. 
"logical" is not allowed for <var>class</var>.  If the input is a row vector,
the return value is a row vector, otherwise it is a column vector.  If the
bit length of <var>x</var> is not divisible by that of <var>class</var>, an error
occurs.

        <p>An example of the use of typecast on a little-endian machine is

     <pre class="example">          <var>x</var> = uint16 ([1, 65535]);
          typecast (<var>x</var>, 'uint8')
          &rArr; [   1,   0, 255, 255]
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dcast.html#doc_002dcast">cast</a>, <a href="doc_002dbitunpack.html#doc_002dbitunpack">bitunpack</a>, <a href="doc_002dbitpack.html#doc_002dbitpack">bitpack</a>, <a href="doc_002dswapbytes.html#doc_002dswapbytes">swapbytes</a>. 
</p></blockquote></div>

<!-- swapbytes scripts/miscellaneous/swapbytes.m -->
   <p><a name="doc_002dswapbytes"></a>

<div class="defun">
&mdash; Function File:  <b>swapbytes</b> (<var>x</var>)<var><a name="index-swapbytes-207"></a></var><br>
<blockquote><p>Swap the byte order on values, converting from little endian to big
endian and vice versa.  For example:

     <pre class="example">          swapbytes (uint16 (1:4))
          &rArr; [   256   512   768  1024]
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dtypecast.html#doc_002dtypecast">typecast</a>, <a href="doc_002dcast.html#doc_002dcast">cast</a>. 
</p></blockquote></div>

<!-- bitpack src/DLD-FUNCTIONS/typecast.cc -->
   <p><a name="doc_002dbitpack"></a>

<div class="defun">
&mdash; Loadable Function: <var>y</var> = <b>bitpack</b> (<var>x, class</var>)<var><a name="index-bitpack-208"></a></var><br>
<blockquote><p>Return a new array <var>y</var> resulting from interpreting an array
<var>x</var> as raw bit patterns for data of the numeric class <var>class</var>. 
<var>class</var> must be one of the built-in numeric classes:

     <pre class="example">            "char"
            "int8"
            "int16"
            "int32"
            "int64"
            "uint8"
            "uint16"
            "uint32"
            "uint64"
            "double"
            "single"
</pre>
        <p>The number of elements of <var>x</var> should be divisible by the bit length of
<var>class</var>.  If it is not, excess bits are discarded.  Bits come in
increasing order of significance, i.e., <code>x(1)</code> is bit 0, <code>x(2)</code> is
bit 1, etc.  The result is a row vector if <var>x</var> is a row vector, otherwise
it is a column vector. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dbitunpack.html#doc_002dbitunpack">bitunpack</a>, <a href="doc_002dtypecast.html#doc_002dtypecast">typecast</a>. 
</p></blockquote></div>

<!-- bitunpack src/DLD-FUNCTIONS/typecast.cc -->
   <p><a name="doc_002dbitunpack"></a>

<div class="defun">
&mdash; Loadable Function: <var>y</var> = <b>bitunpack</b> (<var>x</var>)<var><a name="index-bitunpack-209"></a></var><br>
<blockquote><p>Return an array <var>y</var> corresponding to the raw bit patterns of
<var>x</var>.  <var>x</var> must belong to one of the built-in numeric classes:

     <pre class="example">            "char"
            "int8"
            "int16"
            "int32"
            "int64"
            "uint8"
            "uint16"
            "uint32"
            "uint64"
            "double"
            "single"
</pre>
        <p>The result is a row vector if <var>x</var> is a row vector; otherwise, it is a
column vector. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dbitpack.html#doc_002dbitpack">bitpack</a>, <a href="doc_002dtypecast.html#doc_002dtypecast">typecast</a>. 
</p></blockquote></div>

<ul class="menu">
<li><a accesskey="1" href="Numeric-Objects.html#Numeric-Objects">Numeric Objects</a>
<li><a accesskey="2" href="Missing-Data.html#Missing-Data">Missing Data</a>
<li><a accesskey="3" href="String-Objects.html#String-Objects">String Objects</a>
<li><a accesskey="4" href="Data-Structure-Objects.html#Data-Structure-Objects">Data Structure Objects</a>
<li><a accesskey="5" href="Cell-Array-Objects.html#Cell-Array-Objects">Cell Array Objects</a>
</ul>

   </body></html>