Compare commits

...
26 Commits
Author SHA1 Message Date
conrad 5e4ce67bf4 patch bump 2025-12-16 13:25:46 +10:00
conrad 7dbe9fa6c3 add LLM prohibition section 2025-12-16 13:03:19 +10:00
conrad 7da30298dd add RSL section to head 2025-12-15 14:19:05 +10:00
conrad f347a5640e simplification 2025-12-11 19:07:05 +10:00
conrad c7433b6e60 allow memory reuse with size growth 2025-12-11 16:22:29 +10:00
conrad e712b832e8 simplification 2025-12-11 15:14:55 +10:00
conrad 8a736f85a3 reuse memory where possible 2025-12-11 15:09:16 +10:00
conrad 9f8bf056c2 simplification 2025-12-11 14:20:05 +10:00
conrad b79a7e005c use explicit initialisation 2025-12-10 18:57:17 +10:00
conrad cae3a6a4bf optimise .resize() for small vectors that fit within pre-allocated memory 2025-12-10 15:12:17 +10:00
conrad fb6278f692 return early if resized matrix is empty 2025-12-10 15:11:10 +10:00
conrad 8622e81b8a faster repcube() 2025-12-10 12:31:03 +10:00
conrad f788d4032f emit more info on linker config 2025-12-10 12:28:19 +10:00
conrad c2b1eea864 patch bump 2025-11-20 00:09:55 +10:00
conrad 6eb9394e13 prevent bad line breaks 2025-11-17 23:33:52 +10:00
conrad 391a1df2e8 simplification 2025-11-17 23:30:08 +10:00
conrad 7b718b1ae9 sanitise n_threads 2025-11-12 10:43:09 +10:00
conrad bc18db7a51 use ordered clause 2025-11-09 23:42:09 +10:00
conrad 505339b6e5 rename variable 2025-11-09 22:24:17 +10:00
conrad f015fac562 set rng seed for each thread 2025-11-08 19:51:07 +10:00
conrad 502cbca4ba add internal links 2025-10-30 21:44:19 +10:00
conrad 5e5331acd4 cleanup layout 2025-10-30 20:49:25 +10:00
conrad 2dddc1367e add internal link 2025-10-30 20:45:41 +10:00
conrad 5ca720b31f simpler wording 2025-10-30 13:32:01 +10:00
conradsnicta f72922fa68 fix documentation typo 2025-10-30 00:00:52 +00:00
Ryan Curtin c18e7f0aff Fix documentation typo 2025-10-30 00:00:52 +00:00
8 changed files with 275 additions and 177 deletions
+4 -2
View File
@@ -381,10 +381,11 @@ else()
set(ARMA_LIBS ${ARMA_LIBS} ${MKL_LIBRARIES})
message(STATUS "")
message(STATUS "*** If the MKL libraries are installed in non-standard locations such as")
message(STATUS "*** If the MKL libraries are installed in a non-standard location such as")
message(STATUS "*** /opt/intel/mkl, /opt/intel/composerxe/, /usr/local/intel/mkl")
message(STATUS "*** make sure the run-time linker can find them.")
message(STATUS "*** On Linux systems this can be done by editing /etc/ld.so.conf")
message(STATUS "*** or specifying the location through a file in /etc/ld.so.conf.d/")
message(STATUS "*** or modifying the LD_LIBRARY_PATH environment variable.")
message(STATUS "")
message(STATUS "*** On systems with SELinux enabled (eg. Fedora, RHEL),")
@@ -419,10 +420,11 @@ else()
endif()
message(STATUS "")
message(STATUS "*** If the OpenBLAS library is installed in")
message(STATUS "*** If the OpenBLAS library is installed in a location such as")
message(STATUS "*** /usr/local/lib or /usr/local/lib64")
message(STATUS "*** make sure the run-time linker can find it.")
message(STATUS "*** On Linux systems this can be done by editing /etc/ld.so.conf")
message(STATUS "*** or specifying the location through a file in /etc/ld.so.conf.d/")
message(STATUS "*** or modifying the LD_LIBRARY_PATH environment variable.")
message(STATUS "")
+14 -4
View File
@@ -38,7 +38,8 @@ Copyright 2017-2025 Data61 / CSIRO
13. [API Stability and Version Policy](#13-api-stability-and-version-policy)
14. [Bug Reports and Frequently Asked Questions](#14-bug-reports-and-frequently-asked-questions)
15. [Related Software Using Armadillo](#15-related-software-using-armadillo)
15. [Prohibition on Use of Large Language Models (LLMs)](#15-prohibition-on-use-of-large-language-models-llms)
16. [Related Software Using Armadillo](#16-related-software-using-armadillo)
---
@@ -390,8 +391,8 @@ Use a web browser to view it.
Use of the C++11 `auto` keyword is not recommended with Armadillo objects and expressions.
Armadillo has a template meta-programming framework which creates short-lived temporaries
that are not properly handled by `auto`.
Armadillo has a template meta-programming framework which creates short-lived
temporary objects that are not properly handled by `auto`.
---
@@ -451,7 +452,16 @@ https://arma.sourceforge.net/faq.html
---
### 15: Related Software Using Armadillo
### 15: Prohibition on Use of Large Language Models (LLMs)
The Armadillo codebase has been developed entirely without the use of LLMs.
We do not accept any code which has been created (directly or indirectly)
with the aid of LLMs. This is due to issues with code provenance and low quality
of LLM generated code.
---
### 16: Related Software Using Armadillo
* MLPACK: extensive library of machine learning algorithms
https://mlpack.org
+128 -125
View File
@@ -21,6 +21,15 @@ limitations under the License.
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title>Armadillo: API Documentation</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAARpJREFUOMtjYMABzFuiGYE4BohPA/FvIP6Phv8CMTcuzVxAvAGqeTYQT0HCd6AG3MSlmRWIdwNxLhY5MyC+ADVgLS4DyqAK2NDEBaAuiobKt+Ay4CZUgQRaeKwCYj8gTofKR+My4CNUQSSSWCYQT4ay+6HyprgMOADEs4BYFso3AOITQMwB5W+HGsCPMxCR2LxAfA6INZHE7gHxGwZCAOrvFUDcCsQqUKwFxP+A+CQxBpRgSTwwvIKQZm8gfgbEVkCsgYRToQZ049NsBtVshEUuA2pAAYpfoTQzEEcB8QsgtsdheA/UgFhkwV1AfBuIPwDxOyC2xeO6jVAD5kBd6gQS/AbEX4F4JRDLEwgbUHp4CsRboLETzkApAADMF8+Pl3d18QAAAABJRU5ErkJggg==">
<script type="application/rsl+xml">
<rsl xmlns="https://rslstandard.org/rsl">
<content url="">
<license>
<prohibits type="usage">ai-train ai-input</prohibits>
</license>
</content>
</rsl>
</script>
<style type="text/css">
<!--
body
@@ -778,7 +787,7 @@ which is one of:
<ul>
<table>
<tbody>
<tr><td><code>fill::zeros</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 0 &nbsp; (default in Armadillo &gt;= 10.5)</td></tr>
<tr><td><code>fill::zeros</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 0</td></tr>
<tr><td><code>fill::ones</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 1</td></tr>
<tr><td><code>fill::eye</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set the elements on the main diagonal to 1 and off-diagonal elements to 0</td></tr>
<tr><td><code>fill::randu</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to random values from a uniform distribution in the [0,1] interval</td></tr>
@@ -790,13 +799,7 @@ which is one of:
</ul>
</li>
<br>
<li>
<b>Caveat:</b>
<ul>
<li>in Armadillo &gt;= 10.5, the default initialisation is <code>fill::zeros</code></li>
<li>in Armadillo &lt;= 10.4, the default initialisation is <code>fill::none</code></li>
</ul>
</li>
<li>Default element initialisation is <code>fill::zeros</code> (since Armadillo 10.5)</li>
<br>
<li>
For the <i>mat(string)</i> constructor, the format is elements separated by spaces, and rows denoted by semicolons;
@@ -1722,7 +1725,7 @@ which is one of:
<ul>
<table>
<tbody>
<tr><td><code>fill::zeros</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 0 &nbsp; (default in Armadillo &gt;= 10.5)</td></tr>
<tr><td><code>fill::zeros</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 0</td></tr>
<tr><td><code>fill::ones</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to 1</td></tr>
<tr><td><code>fill::randu</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to random values from a uniform distribution in the [0,1] interval</td></tr>
<tr><td><code>fill::randn</code></td><td>&nbsp;&mapsto;&nbsp;</td><td>set all elements to random values from a normal/Gaussian distribution with zero mean and unit variance</td></tr>
@@ -1733,13 +1736,7 @@ which is one of:
</ul>
</li>
<br>
<li>
<b>Caveat:</b>
<ul>
<li>in Armadillo &gt;= 10.5, the default initialisation is <code>fill::zeros</code></li>
<li>in Armadillo &lt;= 10.4, the default initialisation is <code>fill::none</code></li>
</ul>
</li>
<li>Default element initialisation is <code>fill::zeros</code> (since Armadillo 10.5)</li>
<br>
<li>
Each instance of <i>cube</i> automatically allocates and releases internal memory.
@@ -4299,7 +4296,7 @@ Similar to "broadcasting" in Matlab&thinsp;/&thinsp;Octave
</li>
<br>
<li>
Supported operations for forms 1 and 2:
Supported operations for forms&nbsp;1 and&nbsp;2:
<br>
<br>
<ul>
@@ -4314,7 +4311,7 @@ Supported operations for forms 1 and 2:
</li>
<br>
<li>
For form 2:
For form&nbsp;2:
<ul>
<li>the argument <i>vector_of_indices</i> contains a list of indices of the columns/rows to be used; it must evaluate to a vector of type <i><a href="#Col">uvec</a></i></li>
<li>arithmetic operations as per form 1 are supported</li>
@@ -4322,7 +4319,7 @@ For form 2:
</li>
<br>
<li>
For form 3:
For form&nbsp;3:
<ul>
<li>apply the given <i>lambda_function</i> to each column vector or row vector</li>
<li>the function must accept a reference to a <a href="#Col">Col</a> or <a href="#Row">Row</a> object with the same element type as the underlying matrix</li>
@@ -4395,7 +4392,7 @@ Similar to "broadcasting" in Matlab&thinsp;/&thinsp;Octave
</li>
<br>
<li>
Supported operations for form 1:
Supported operations for form&nbsp;1:
<br>
<br>
<ul>
@@ -4411,7 +4408,7 @@ Supported operations for form 1:
</li>
<br>
<li>
For form 2:
For form&nbsp;2:
<ul>
<li>the argument <i>vector_of_indices</i> contains a list of indices of the slices to be used; it must evaluate to a vector of type <i><a href="#Col">uvec</a></i></li>
<li>arithmetic operations as per form 1 are supported, except for <code><b>*</b></code> and <code><b>*=</b></code> (ie. matrix multiplication)</li>
@@ -4419,7 +4416,7 @@ For form 2:
</li>
<br>
<li>
For form 3:
For form&nbsp;3:
<ul>
<li>apply the given <i>lambda_function</i> to each slice</li>
<li>the function must accept a reference to a <a href="#Mat">Mat</a> object with the same element type as the underlying cube</li>
@@ -4427,7 +4424,7 @@ For form 3:
</li>
<br>
<li>
For form 4:
For form&nbsp;4:
<ul>
<li>apply the given <i>lambda_function</i> to each slice, as per form 3</li>
<li>the argument <i>use_mp</i> is a bool to enable the use of OpenMP for multi-threaded execution of <i>lambda_function</i> on multiple slices at the same time</li>
@@ -6822,6 +6819,7 @@ See also:
<li><a href="#has_nan">.has_nan()</a></li>
<li><a href="#find_finite_nonfinite">find_finite() / find_nonfinite()</a></li>
<li><a href="#find_nan_nonnan">find_nan() / find_nonnan()</a></li>
<li><a href="#omit_nan_nonfinite">omit_nan() / omit_nonfinite()</a></li>
<li><a href="#constants">constants (pi, nan, inf, ...)</a></li>
</ul>
</li>
@@ -6864,6 +6862,7 @@ See also:
<li><a href="#replace">.replace()</a></li>
<li><a href="#is_finite">.is_finite()</a>
<li><a href="#find_finite_nonfinite">find_finite() / find_nonfinite()</a></li>
<li><a href="#omit_nan_nonfinite">omit_nonfinite()</a></li>
<li><a href="#constants">constants (pi, nan, inf, ...)</a></li>
</ul>
</li>
@@ -6911,6 +6910,7 @@ See also:
<li><a href="#replace">.replace()</a></li>
<li><a href="#is_finite">.is_finite()</a>
<li><a href="#find_nan_nonnan">find_nan() / find_nonnan()</a></li>
<li><a href="#omit_nan_nonfinite">omit_nan()</a></li>
<li><a href="#constants">constants (pi, nan, inf, ...)</a></li>
</ul>
</li>
@@ -7129,58 +7129,58 @@ A.brief_print("A:");
<br>
<br>
<ul>
<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;"><b>auto_detect</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;"><b>auto_detect</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Used only by <i>.load()</i> only: attempt to automatically detect the file type as one of the formats described below;
<br>[&nbsp;default operation for <i>.load()</i>&nbsp;]<br><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>arma_binary</b><br></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>arma_binary</b><br></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored in machine dependent binary format, with a simple header to speed up loading.
The header indicates the type and size of matrix/cube.
<br>[&nbsp;default operation for <i>.save()</i>&nbsp;]
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>arma_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>arma_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored in human readable text format, with a simple header to speed up loading.
The header indicates the type and size of matrix/cube.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>raw_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>raw_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored in machine dependent raw binary format, without a header.
Matrices are loaded to have one column,
while cubes are loaded to have one slice with one column.
The <a href="#reshape_member">.reshape()</a> function can be used to alter the size of the loaded matrix/cube without losing data.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>raw_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>raw_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored in raw ASCII format, without a header.
The numbers are separated by whitespace.
The number of columns must be the same in each row.
@@ -7189,26 +7189,26 @@ Data which was saved in Matlab/Octave using the <i>-ascii</i> option can be read
Complex numbers are stored in standard C++ notation, which is a tuple surrounded by brackets: eg. (1.23,4.56) indicates 1.24&thinsp;+&thinsp;4.56i.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>csv_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>csv_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored in comma separated value (CSV) text format, <b>without</b> a header.
To save/load <b>with</b> a header, use the <b>csv_name(</b>filename,header<b>)</b> specification instead (more details below).
Handles complex numbers stored in the compound form of 1.24+4.56i.
Applicable to <i>Mat</i> and <i>SpMat</i>.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>coord_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>coord_ascii</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored as a text file in coordinate list format, without a header.
Only non-zero values are stored.
<br>
@@ -7219,39 +7219,39 @@ For real matrices, each line contains information in the following format:&nbsp;
<br><b>Caveat:</b> not supported by <i>auto_detect</i>.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>pgm_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>pgm_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Image data stored in Portable Gray Map (PGM) format.
Applicable to <i>Mat</i> only.
Saving <i>int</i>, <i>float</i> or <i>double</i> matrices is a lossy operation, as each element is copied and converted to an 8 bit representation.
As such the matrix should have values in the [0,255] interval, otherwise the resulting image may not display correctly.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>ppm_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>ppm_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Image data stored in Portable Pixel Map (PPM) format.
Applicable to <i>Cube</i> only.
Saving <i>int</i>, <i>float</i> or <i>double</i> matrices is a lossy operation, as each element is copied and converted to an 8 bit representation.
As such the cube/field should have values in the [0,255] interval, otherwise the resulting image may not display correctly.
<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>hdf5_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>hdf5_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
Numerical data stored in portable <a href="https://en.wikipedia.org/wiki/Hierarchical_Data_Format">HDF5</a> binary format.
<ul>
<li>
@@ -7267,10 +7267,10 @@ for loading, the order of operations is:
to explicitly control the dataset name, specify it via the <b>hdf5_name()</b> argument (more details below)
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</ul>
</li>
<br>
@@ -7387,6 +7387,7 @@ if(ok == false)
<li><a href="https://en.wikipedia.org/wiki/Hierarchical_Data_Format">HDF</a> in Wikipedia</li>
<li><a href="https://en.wikipedia.org/wiki/Comma-separated_values">CSV</a> in Wikipedia
<li><a href="#save_load_field">saving&thinsp;/&thinsp;loading fields</a></li>
<li><a href="#element_initialisation">element initialisation</a></li>
</ul>
</li>
<br>
@@ -7439,26 +7440,26 @@ Other than storing string fields as text files, the following file formats are s
<br>
<br>
<ul>
<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;"><b>auto_detect</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;"><b>auto_detect</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
<br>
<li>
<i>.load()</i>: attempt to automatically detect the field format type as one of the formats described below;
this is the default operation
</li>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>arma_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>arma_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
<br>
<li>
objects are stored in machine dependent binary format
@@ -7469,13 +7470,13 @@ default type for fields of type <i>Mat</i>, <i>Col</i>, <i>Row</i> or <i>Cube</i
only applicable to fields of type <i>Mat</i>, <i>Col</i>, <i>Row</i> or <i>Cube</i>
</li>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>ppm_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
</td>
</tr>
<tr>
<td style="vertical-align: top;"><b>ppm_binary</b></td>
<td style="vertical-align: top;"><br>
</td>
<td style="vertical-align: top;">
<br>
<li>
image data stored in Portable Pixmap Map (PPM) format
@@ -7494,11 +7495,10 @@ it is assumed that the red, green and blue components are stored in the first, s
saving <i>int</i>, <i>float</i> or <i>double</i> matrices is a lossy operation,
as each matrix element is copied and converted to an 8 bit representation
</li>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</ul>
</li>
<br>
@@ -11092,6 +11092,9 @@ See also:
<li><a href="#nonzeros">nonzeros()</a>
<li><a href="#vectorise">vectorise()</a>
<li><a href="#for_each">.for_each()</a>
<li><a href="#is_finite">.is_finite()</a>
<li><a href="#has_inf">.has_inf()</a>
<li><a href="#has_nan">.has_nan()</a>
</ul>
</li>
<br>
@@ -18490,7 +18493,7 @@ See also:
<b>RNG seed setting</b>
<ul>
<li>
There are two functions to change the seed used by the random number generator (RNG):
Functions to change the seed used by the random number generator (RNG):
<br>
<br>
<table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
@@ -18781,7 +18784,7 @@ rudimentary <i>fp16</i> hardware support is present on x86-64 CPUs with the F16C
<br>
</ul>
<li>
If no compiler or hardware support is detected, support for <i>fp16</i> element types is <b>not</b> automatically enableds
If no compiler or hardware support is detected, support for <i>fp16</i> element types is <b>not</b> automatically enabled
</li>
<br>
<li>
+42 -24
View File
@@ -49,7 +49,7 @@ Mat<eT>::Mat()
, n_alloc(0)
, vec_state(0)
, mem_state(0)
, mem()
, mem(nullptr)
{
arma_debug_sigprint_this(this);
}
@@ -312,15 +312,10 @@ Mat<eT>::init_cold()
const char* error_message = "Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
#endif
arma_conform_check
(
(
( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
? ( (double(n_rows) * double(n_cols)) > double(ARMA_MAX_UWORD) )
: false
),
error_message
);
if( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
{
arma_conform_check( ( (double(n_rows) * double(n_cols)) > double(ARMA_MAX_UWORD) ), error_message );
}
if(n_elem <= arma_config::mat_prealloc)
{
@@ -383,17 +378,10 @@ Mat<eT>::init_warm(uword in_n_rows, uword in_n_cols)
const char* error_message_4 = "Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
#endif
arma_conform_set_error
(
err_state,
err_msg,
(
( (in_n_rows > ARMA_MAX_UHWORD) || (in_n_cols > ARMA_MAX_UHWORD) )
? ( (double(in_n_rows) * double(in_n_cols)) > double(ARMA_MAX_UWORD) )
: false
),
error_message_4
);
if( (in_n_rows > ARMA_MAX_UHWORD) || (in_n_cols > ARMA_MAX_UHWORD) )
{
arma_conform_set_error( err_state, err_msg, ( (double(in_n_rows) * double(in_n_cols)) > double(ARMA_MAX_UWORD) ), error_message_4 );
}
arma_conform_check(err_state, err_msg);
@@ -7580,10 +7568,40 @@ Mat<eT>::resize(const uword new_n_elem)
{
arma_debug_sigprint();
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
const bool reuse_mem =
( is_vec() && (mem_state == 0) )
&&
(
( (new_n_elem <= arma_config::mat_prealloc) && (n_elem <= arma_config::mat_prealloc) && ( n_elem > 0 ) )
|| ( (new_n_elem > arma_config::mat_prealloc) && (n_elem > arma_config::mat_prealloc) && (new_n_elem <= n_alloc) )
);
return (*this).resize(new_n_rows, new_n_cols);
if(reuse_mem)
{
arma_debug_print("Mat::resize(): reusing memory");
if(new_n_elem > n_elem)
{
arma_debug_print("Mat::resize(): zeroing memory");
eT* t_mem = (*this).memptr(); // the (n_elem > 0) check above ensures that (*this).memptr() is a valid pointer
for(uword ii = n_elem; ii < new_n_elem; ++ii) { t_mem[ii] = eT(0); }
}
access::rw(n_rows) = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
access::rw(n_cols) = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
access::rw(n_elem) = new_n_elem;
}
else
{
const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem);
const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 );
(*this).resize(new_n_rows, new_n_cols);
}
return (*this);
}
+73 -12
View File
@@ -26,6 +26,9 @@
#undef ARMA_USE_THREAD_LOCAL
#define ARMA_USE_THREAD_LOCAL
#undef ARMA_USE_THREAD_UNIQUE_RNG_SEED
#define ARMA_USE_THREAD_UNIQUE_RNG_SEED
#if (defined(ARMA_RNG_ALT) || defined(ARMA_DONT_USE_CXX11_RNG))
#undef ARMA_USE_CXX11_RNG
#endif
@@ -34,6 +37,10 @@
#undef ARMA_USE_THREAD_LOCAL
#endif
#if defined(ARMA_DONT_USE_THREAD_UNIQUE_RNG_SEED)
#undef ARMA_USE_THREAD_UNIQUE_RNG_SEED
#endif
// NOTE: ARMA_WARMUP_PRODUCER enables a workaround
// NOTE: for thread_local issue on macOS 11 and/or AppleClang 12.0
@@ -129,24 +136,42 @@ arma_rng::get_producer()
{
#if defined(ARMA_USE_THREAD_LOCAL)
// use a thread-safe RNG, with each thread having its own unique starting seed
// thread-safe RNG
static std::atomic<std::size_t> mt19937_64_producer_counter(0);
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed + mt19937_64_producer_counter++ );
arma_rng::warmup_producer(mt19937_64_producer);
#if defined(ARMA_USE_THREAD_UNIQUE_RNG_SEED)
// each thread has unique starting seed
#if defined(ARMA_USE_OPENMP)
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed + arma_rng::seed_type(omp_get_thread_num()) );
#else
static std::atomic<std::size_t> mt19937_64_producer_counter(0);
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed + mt19937_64_producer_counter++ );
#endif
#else
// each thread has the same starting seed
static thread_local std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed );
#endif
#else
// use a plain RNG in case we don't have thread_local
// plain RNG in case we don't have thread_local
static std::mt19937_64 mt19937_64_producer( std::mt19937_64::default_seed );
arma_rng::warmup_producer(mt19937_64_producer);
#endif
arma_rng::warmup_producer(mt19937_64_producer);
return mt19937_64_producer;
}
@@ -226,9 +251,45 @@ arma_rng::set_seed(const arma_rng::seed_type val)
}
#elif defined(ARMA_USE_CXX11_RNG)
{
arma_rng::lock_producer();
arma_rng::get_producer().seed(val);
arma_rng::unlock_producer();
#if defined(ARMA_USE_OPENMP) && defined(ARMA_USE_THREAD_LOCAL)
{
arma_rng::lock_producer();
#if defined(ARMA_USE_THREAD_UNIQUE_RNG_SEED)
constexpr bool thread_unique_rng_seed = true;
#else
constexpr bool thread_unique_rng_seed = false;
#endif
// if we're already in a parallel region, assume the user is setting the seed for each thread
if( (thread_unique_rng_seed == false) || bool(omp_in_parallel()) )
{
arma_rng::get_producer().seed(val);
}
else
{
const int n_threads = int( (std::max)( int(1), int(omp_get_max_threads()) ) );
#pragma omp parallel for ordered schedule(static) num_threads(n_threads)
for(int t=0; t < n_threads; ++t)
{
#pragma omp ordered
{
arma_rng::get_producer().seed(val + arma_rng::seed_type(omp_get_thread_num()));
}
}
}
arma_rng::unlock_producer();
}
#else
{
arma_rng::lock_producer();
arma_rng::get_producer().seed(val);
arma_rng::unlock_producer();
}
#endif
}
#else
{
+1 -1
View File
@@ -23,7 +23,7 @@
#define ARMA_VERSION_MAJOR 15
#define ARMA_VERSION_MINOR 2
#define ARMA_VERSION_PATCH 1
#define ARMA_VERSION_PATCH 3
#define ARMA_VERSION_NAME "Medium Roast Deluxe"
+12 -8
View File
@@ -153,15 +153,19 @@ op_repcube::apply_noalias(Cube<eT>& out, const Cube<eT>& X, const uword copies_p
if(out.is_empty()) { return; }
// TODO: this is a rudimentary implementation
const SizeCube X_size = SizeCube(X.n_rows, X.n_cols, X.n_slices);
for(uword s = 0; s < out.n_slices; s += X.n_slices)
for(uword c = 0; c < out.n_cols; c += X.n_cols )
for(uword r = 0; r < out.n_rows; r += X.n_rows )
for(uword s=0; s < X.n_slices; ++s)
{
out.subcube(r, c, s, X_size) = X;
// avoid use of Cube::slice() to prevent generating Mat objects that the user may not need
const Mat<eT> X_slice_s(const_cast<eT*>(X.slice_memptr(s)), X.n_rows, X.n_cols, false, true);
Mat<eT> out_slice_s( out.slice_memptr(s) , out.n_rows, out.n_cols, false, true);
op_repmat::apply_noalias(out_slice_s, X_slice_s, copies_per_row, copies_per_col);
for(uword t=1; t < copies_per_slice; ++t)
{
arrayops::copy(out.slice_memptr(s + (t * X.n_slices)), out_slice_s.memptr(), out_slice_s.n_elem);
}
}
}
+1 -1
View File
@@ -81,7 +81,7 @@ op_resize::apply_mat_inplace(Mat<eT>& A, const uword new_n_rows, const uword new
arma_conform_check( (A.vec_state == 1) && (new_n_cols != 1), "resize(): requested size is not compatible with column vector layout" );
arma_conform_check( (A.vec_state == 2) && (new_n_rows != 1), "resize(): requested size is not compatible with row vector layout" );
if(A.is_empty()) { A.zeros(new_n_rows, new_n_cols); return; }
if( A.is_empty() || (new_n_rows == 0) || (new_n_cols == 0) ) { A.zeros(new_n_rows, new_n_cols); return; }
Mat<eT> B(new_n_rows, new_n_cols, arma_nozeros_indicator());