252
edits
(Add an example to see the effect of using BLAS libraries with either 32 or 64 bit indices.) |
|||
(One intermediate revision by one other user not shown) | |||
Line 14: | Line 14: | ||
* Qhull | * Qhull | ||
To determine the integer size of the BLAS library used by Octave | To determine the integer size of the BLAS library used by Octave, the following code can be executed: | ||
<syntaxhighlight lang="Octave"> | <syntaxhighlight lang="Octave"> | ||
clear all; N = 2^31; | clear all; | ||
N = 2^31; | |||
## The following line requires about 8 GB of RAM! | |||
a = b = ones (N, 1, "single"); | |||
c = a' * b | |||
</syntaxhighlight> | </syntaxhighlight> | ||
If the BLAS library uses '''32-bit integers''', an error will be thrown | If the BLAS library uses '''32-bit integers''', an error will be thrown: | ||
error: integer dimension or index out of range for Fortran INTEGER type | error: integer dimension or index out of range for Fortran INTEGER type | ||
Line 29: | Line 32: | ||
c = 2^31 = 2147483648 | c = 2^31 = 2147483648 | ||
Note that the | Note that the test case above usually requires twice the memory, if <code>a</code> and <code>b</code> are not assigned by <code>a = b = ...</code>. | ||
Note further, that the | Note further, that the data type "single" has a precision of about 23 binary bits. | ||
In this particular example no rounding errors occur. | In this particular example no rounding errors occur. | ||
===Versions prior to Octave 4.4=== | ===Versions prior to Octave 4.4=== | ||
On previous versions of Octave, the default is that the size of a single Octave array cannot | On previous versions of Octave, the default is that the size of a single Octave array cannot have more than approximately 2^31 elements, even on systems that use 64-bit pointers. This is because array indices were limited to 32-bit signed integers by default. Trying to create one will produce the following error: | ||
<pre> | <pre> | ||
Line 41: | Line 44: | ||
</pre> | </pre> | ||
You will obtain this error even if your system has enough RAM to create this array ( | You will obtain this error even if your system has enough RAM to create this array (3 GB in the above case). | ||
To use arrays with more than (approximately) <math>2^{31}</math> elements, Octave has to be configured with the option <code>--enable-64</code>. This option is experimental and you are (as always) encouraged to submit bug reports if you find a problem. | To use arrays with more than (approximately) <math>2^{31}</math> elements, Octave has to be configured with the option <code>--enable-64</code>. This option is experimental and you are (as always) encouraged to submit bug reports if you find a problem. |