# Difference between revisions of "Enable large arrays: Build octave such that it can use arrays larger than 2Gb."

The following only applies to systems that have 64-bit pointers (64bit architecture).

Starting with Octave 4.4.0, 64-bit indexing is the default for targets with 64-bit pointers. You can override that default by specifying `--disable-64` when configuring Octave.

However, if the configure script determines that the BLAS library uses 32-bit integers, then operations using the following libraries are limited to arrays with dimensions that are smaller than 2^31 elements:

• BLAS
• LAPACK
• QRUPDATE
• SuiteSparse
• ARPACK

Additionally, the following libraries use "int" internally, so maximum problem sizes are always limited:

• glpk
• Qhull

To determine the integer size of the BLAS library used by Octave, the following code can be executed:

```clear all;
N = 2^31;
## The following line requires about 8 GB of RAM!
a = b = ones (N, 1, "single");
c = a' * b
```

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
```

Otherwise, if the BLAS library uses 64-bit integers, the result is:

```c = 2^31 = 2147483648
```

Note that the test case above usually requires twice the memory, if `a` and `b` are not assigned by `a = b = ...`. Note further, that the data type "single" has a precision of about 23 binary bits. In this particular example no rounding errors occur.

### Versions prior to Octave 4.4

On previous versions of Octave, the default is that the size of a single Octave array cannot exceed 2 GB of memory. Trying to create one will produce the following error:

```>> a = zeros (1024*1024*1024*3, 1, 'int8');
error: out of memory or dimension too large for Octave's index type
```

You will obtain this error even if your system has enough RAM to create this array (4 GB in the above case).

To use arrays with more than (approximately) ${\displaystyle 2^{31}}$ elements, Octave has to be configured with the option `--enable-64`. This option is experimental and you are (as always) encouraged to submit bug reports if you find a problem. With this option, Octave will use internally 64-bit integers for array dimensions and indexing. However, all numerical libraries used by Octave will need to use also 64-bit integers for array dimensions and indexing, and in most cases they need to be compiled from source.

For details about how to compile these libraries please read the GNU Octave manual, or alternatively you can use MXE (M Cross Environment) which takes care of the different packages automatically (especially the configure flags `--enable-64` and `--enable-fortran-int64`).
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 1, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.3855920135974884, "perplexity": 2296.3721356702226}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-50/segments/1606141542358.71/warc/CC-MAIN-20201201013119-20201201043119-00029.warc.gz"}