diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b9eac1e..0fb228fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,13 @@ if(NOT (${CMAKE_MAJOR_VERSION} LESS 3)) endif() endif() +if(NOT (CMAKE_VERSION VERSION_LESS "3.1")) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + message(STATUS "CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}") +endif() + project(armadillo CXX C) include(CheckIncludeFileCXX) include(CheckLibraryExists) @@ -45,13 +52,13 @@ set(ARMA_USE_WRAPPER true) # the settings below will be automatically configured by the rest of this script -set(ARMA_USE_LAPACK false) -set(ARMA_USE_BLAS false) -set(ARMA_USE_ATLAS false) -set(ARMA_USE_HDF5_ALT false) -set(ARMA_USE_ARPACK false) -set(ARMA_USE_EXTERN_CXX11_RNG false) -set(ARMA_USE_SUPERLU false) # Caveat: only SuperLU version 5.x can be used! +set(ARMA_USE_LAPACK false) +set(ARMA_USE_BLAS false) +set(ARMA_USE_ATLAS false) +set(ARMA_USE_HDF5_ALT false) +set(ARMA_USE_ARPACK false) +set(ARMA_USE_EXTERN_RNG false) +set(ARMA_USE_SUPERLU false) # Caveat: only SuperLU version 5.x can be used! ## NOTE: OpenBLAS appears to have its own LAPACK functions, ## NOTE: but on some systems the installed version of OpenBLAS @@ -81,6 +88,59 @@ string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMA_VERSIO message(STATUS "Configuring Armadillo ${ARMA_VERSION_MAJOR}.${ARMA_VERSION_MINOR}.${ARMA_VERSION_PATCH}") +# NOTE: ARMA_USE_EXTERN_RNG requires compiler support for thread_local and C++11 +# NOTE: for Linux, this is available with gcc 4.8.3 onwards +# NOTE: for macOS, thread_local is supoported in Xcode 8 (mid 2016 onwards) in C++11 mode + +if(DEFINED CMAKE_CXX_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_VERSION) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.8.3)) + set(ARMA_USE_EXTERN_RNG true) + message(STATUS "Detected gcc 4.8.3 or later") + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + message(STATUS "Added '-std=c++11' to compiler flags") + endif() + else() + message(FATAL_ERROR "Compiler too old") + endif() + else() + if(NOT (${CMAKE_MAJOR_VERSION} LESS 3)) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 6.0) + set(ARMA_USE_EXTERN_RNG true) + message(STATUS "Detected Clang 6.0 or later") + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + message(STATUS "Added '-std=c++14' to compiler flags") + endif() + else() + message(FATAL_ERROR "Compiler too old") + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 8.0) + set(ARMA_USE_EXTERN_RNG true) + message(STATUS "Detected AppleClang 8.0 or later") + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + message(STATUS "Added '-std=c++14' to compiler flags") + endif() + else() + message(FATAL_ERROR "Compiler too old") + endif() + endif() + endif() + endif() +endif() + +if(MINGW OR MSYS OR CYGWIN OR MSVC) + # MinGW doesn't correctly handle thread_local + set(ARMA_USE_EXTERN_RNG false) +endif() + +message(STATUS "ARMA_USE_EXTERN_RNG = ${ARMA_USE_EXTERN_RNG}") + + # As Red Hat Enterprise Linux (and related systems such as Fedora) # does not search /usr/local/lib by default, we need to place the # library in either /usr/lib or /usr/lib64 @@ -261,8 +321,6 @@ else() set(ARMA_OS unix) include(ARMA_FindMKL) - include(ARMA_FindACMLMP) - include(ARMA_FindACML) include(ARMA_FindOpenBLAS) include(ARMA_FindATLAS) include(ARMA_FindBLAS) @@ -273,8 +331,6 @@ else() endif() message(STATUS " MKL_FOUND = ${MKL_FOUND}" ) - message(STATUS " ACMLMP_FOUND = ${ACMLMP_FOUND}" ) - message(STATUS " ACML_FOUND = ${ACML_FOUND}" ) message(STATUS " OpenBLAS_FOUND = ${OpenBLAS_FOUND}" ) message(STATUS " ATLAS_FOUND = ${ATLAS_FOUND}" ) message(STATUS " BLAS_FOUND = ${BLAS_FOUND}" ) @@ -303,50 +359,24 @@ else() message(STATUS "*** cmake -D ALLOW_FLEXIBLAS_LINUX=false .") message(STATUS "") - elseif(MKL_FOUND OR ACMLMP_FOUND OR ACML_FOUND) + elseif(MKL_FOUND) set(ARMA_USE_LAPACK true) set(ARMA_USE_BLAS true) + set(ARMA_LIBS ${ARMA_LIBS} ${MKL_LIBRARIES}) message(STATUS "") - message(STATUS "*** If the MKL or ACML libraries are installed in non-standard locations such as") + message(STATUS "*** If the MKL libraries are installed in non-standard locations 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 modifying the LD_LIBRARY_PATH environment variable.") message(STATUS "") message(STATUS "*** On systems with SELinux enabled (eg. Fedora, RHEL),") - message(STATUS "*** you may need to change the SELinux type of all MKL/ACML libraries") + message(STATUS "*** you may need to change the SELinux type of all MKL libraries") message(STATUS "*** to fix permission problems that may occur during run-time.") message(STATUS "") - if(MKL_FOUND) - set(ARMA_LIBS ${ARMA_LIBS} ${MKL_LIBRARIES}) - - if(ACMLMP_FOUND OR ACML_FOUND) - message(STATUS "*** Intel MKL as well as AMD ACML libraries were found.") - message(STATUS "*** Using only the MKL library to avoid linking conflicts.") - message(STATUS "*** If you wish to use ACML instead, please link manually with") - message(STATUS "*** acml or acml_mp instead of the armadillo wrapper library.") - message(STATUS "*** Alternatively, remove MKL from your system and rerun") - message(STATUS "*** Armadillo's configuration using ./configure") - endif() - - else() - - if(ACMLMP_FOUND) - set(ARMA_LIBS ${ARMA_LIBS} ${ACMLMP_LIBRARIES}) - - message(STATUS "*** Both single-core and multi-core ACML libraries were found.") - message(STATUS "*** Using only the multi-core library to avoid linking conflicts.") - else() - if(ACML_FOUND) - set(ARMA_LIBS ${ARMA_LIBS} ${ACML_LIBRARIES}) - endif() - endif() - - endif() - else() if(OpenBLAS_FOUND AND ATLAS_FOUND) @@ -470,41 +500,6 @@ message(STATUS "*** ARMA_LIBS = ${ARMA_LIBS}") message(STATUS "") -# NOTE: ARMA_USE_EXTERN_CXX11_RNG requires compiler support for thread_local and C++11 -# NOTE: for Linux, this is available with gcc 4.8.3 onwards -# NOTE: for macOS, thread_local is supoported in Xcode 8 (mid 2016 onwards) in C++11 mode - -if(DEFINED CMAKE_CXX_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_VERSION) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.8.3) - set(ARMA_USE_EXTERN_CXX11_RNG true) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - message(STATUS "Detected gcc 4.8.3 or later. Added '-std=c++11' to compiler flags") - else() - if(NOT (${CMAKE_MAJOR_VERSION} LESS 3)) - - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 6.0) - set(ARMA_USE_EXTERN_CXX11_RNG true) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") - message(STATUS "Detected Clang 6.0 or later. Added '-std=c++14' to compiler flags") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 8.0) - set(ARMA_USE_EXTERN_CXX11_RNG true) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") - message(STATUS "Detected AppleClang 8.0 or later. Added '-std=c++14' to compiler flags") - endif() - - endif() - endif() -endif() - - -if(MINGW OR MSYS OR CYGWIN OR MSVC) - # MinGW doesn't correctly handle thread_local - set(ARMA_USE_EXTERN_CXX11_RNG false) -endif() - -message(STATUS "ARMA_USE_EXTERN_CXX11_RNG = ${ARMA_USE_EXTERN_CXX11_RNG}") - - message(STATUS "Copying ${PROJECT_SOURCE_DIR}/include/ to ${PROJECT_BINARY_DIR}/tmp/include/") file(COPY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${PROJECT_BINARY_DIR}/tmp/include/) @@ -651,5 +646,5 @@ install(FILES "${PROJECT_BINARY_DIR}/tmp/misc/armadillo.pc" DESTINATION ${CMAKE_ if(BUILD_SMOKE_TEST) message(STATUS "*** configuring smoke_test") enable_testing() - add_subdirectory(smoke_test) + add_subdirectory(tests1) endif() diff --git a/README.md b/README.md index a5a93ced..98237b92 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,14 @@ Copyright 2017-2020 Data61, CSIRO 9. [Support for OpenBLAS and Intel MKL](#9-support-for-openblas-and-intel-mkl) 10. [Support for ATLAS](#10-support-for-atlas) -11. [Support for C++11 / C++14 Features](#11-support-for-c11-c14-features) -12. [Support for OpenMP](#12-support-for-openmp) +11. [Support for OpenMP](#12-support-for-openmp) -13. [Documentation](#13-documentation) -14. [API Stability and Versioning](#14-api-stability-and-versioning) -15. [Bug Reports and Frequently Asked Questions](#15-bug-reports-and-frequently-asked-questions) +12. [Documentation](#13-documentation) +13. [API Stability and Versioning](#14-api-stability-and-versioning) +14. [Bug Reports and Frequently Asked Questions](#15-bug-reports-and-frequently-asked-questions) -16. [MEX Interface to Octave/Matlab](#16-mex-interface-to-octavematlab) -17. [Related Software Using Armadillo](#17-related-software-using-armadillo) +15. [MEX Interface to Octave/Matlab](#16-mex-interface-to-octavematlab) +16. [Related Software Using Armadillo](#17-related-software-using-armadillo) --- @@ -106,8 +105,8 @@ informational purposes only and do not modify the License. ### 4: Compilers and External Dependencies -A compiler that properly supports the C++98/C++03 standards is required, -as Armadillo makes extensive use of template meta-programming. +Armadillo 10.x requires a C++ compiler that supports at least the C++11 standard. +Use Armadillo 9.900 if your compiler only supports the old C++98/C++03 standards. The functionality of Armadillo is partly dependent on other libraries: LAPACK, BLAS (preferably OpenBLAS), ARPACK and SuperLU. @@ -156,9 +155,8 @@ For example, for GCC and Clang compilers use -O2 or -O3 - On Linux-based systems, the following libraries are recommended to be present: OpenBLAS, LAPACK, SuperLU and ARPACK. - It is also necessary to install the corresponding development - files for each library. For example, when installing the "lapack" - package, also install the "lapack-devel" or "lapack-dev" package. + It is also necessary to install the corresponding development files for each library. + For example, when installing the "libopenblas" package, also install the "libopenblas-dev" package. * Step 4: Run the cmake installer. @@ -233,12 +231,12 @@ For example, for GCC and Clang compilers use -O2 or -O3 If you have installed Armadillo via the CMake installer, use the following command: - g++ prog.cpp -o prog -O2 -larmadillo + g++ prog.cpp -o prog -std=c++11 -O2 -larmadillo Otherwise, if you want to use Armadillo without installation (ie. without the Armadillo runtime library), use the following command: - g++ prog.cpp -o prog.cpp -O2 -I /home/blah/armadillo-7.200.3/include -DARMA_DONT_USE_WRAPPER -lopenblas + g++ prog.cpp -o prog.cpp -std=c++11 -O2 -I /home/blah/armadillo-7.200.3/include -DARMA_DONT_USE_WRAPPER -lopenblas The above command assumes that the armadillo archive was unpacked into /home/blah/ The command needs to be adjusted if the archive was unpacked into a different directory @@ -290,22 +288,15 @@ Within the "examples" folder, there is an MSVC project named "example1_win64" which can be used to compile "example1.cpp". The project needs to be compiled as a 64 bit program: the active solution platform must be set to x64, instead of win32. -The MSVC project was tested on Windows 7 (64 bit) with Visual Studio C++ 2012. +The MSVC project was tested on Windows 10 (64 bit) with Visual Studio C++ 2019. Adaptations may need to be made for 32 bit systems, later versions of Windows and/or the compiler. For example, options such as ARMA_BLAS_LONG and ARMA_BLAS_UNDERSCORE, defined in "armadillo_bits/config.hpp", may need to be either enabled or disabled. -The folder "examples/lib_win64" contains baseline (unoptimised) LAPACK and BLAS -libraries compiled for 64 bit Windows. The compilation was done by a third party. -USE AT YOUR OWN RISK. The compiled versions of LAPACK and BLAS were obtained from: - http://ylzhao.blogspot.com.au/2013/10/blas-lapack-precompiled-binaries-for.html - -Faster and/or alternative implementations of BLAS and LAPACK are available: - * http://www.openblas.net/ - * http://icl.cs.utk.edu/lapack-for-windows/lapack/ - * http://software.intel.com/en-us/intel-mkl/ - -OpenBLAS and Intel MKL are generally the fastest replacements for both BLAS and LAPACK. +The folder "examples/lib_win64" contains a copy of lib and dll files +obtained from a pre-compiled release of OpenBLAS 0.3.10: +https://github.com/xianyi/OpenBLAS/releases/download/v0.3.10/OpenBLAS-0.3.10-x64.zip +The compilation was done by a third party. USE AT YOUR OWN RISK. **Caveat:** for any high performance scientific/engineering workloads, @@ -354,11 +345,9 @@ where Intel MKL is installed in /opt/intel If MKL is installed and it is persistently giving problems during linking, Support for MKL can be disabled by editing the CMakeLists.txt file, deleting CMakeCache.txt and re-running the CMake based installation. -Comment out the lines containing: +Comment out the line containing: - INCLUDE(ARMA_FindMKL) - INCLUDE(ARMA_FindACMLMP) - INCLUDE(ARMA_FindACML) + INCLUDE(ARMA_FindMKL) --- @@ -374,26 +363,7 @@ results and/or corrupt memory, leading to random crashes. --- -### 11: Support for C++11 / C++14 Features - -Armadillo works with compilers supporting the older C++98 and C++03 standards, -as well as the newer C++11 and C++14 standards. - -Armadillo will enable extra features (such as move constructors) -when a C++11/C++14 compiler is detected. You can also force Armadillo -to make use of C++11 features by defining ARMA_USE_CXX11 before -`#include ` in your code. - -You may need to explicitly enable C++11 mode in your compiler. -For example, use the -std=c++11 or -std=c++14 options in gcc & clang. - -**Caveat:** use of the C++11 "auto" keyword is not recommended with Armadillo -objects and expressions. Armadillo has a template meta-programming framework -which creates lots of short lived temporaries that are not handled by auto. - ---- - -### 12: Support for OpenMP +### 11: Support for OpenMP Armadillo can use OpenMP to automatically speed up computationally expensive element-wise functions such as exp(), log(), cos(), etc. @@ -402,12 +372,9 @@ This requires a C++11/C++14 compiler with OpenMP 3.1+ support. When using gcc or clang, use the following options to enable both C++11 and OpenMP: -std=c++11 -fopenmp -Caveat: when using gcc, use of -march=native in conjunction with -fopenmp -may lead to speed regressions on recent processors. - --- -### 13: Documentation +### 12: Documentation The documentation for Armadillo functions and classes is available at: http://arma.sourceforge.net/docs.html @@ -417,7 +384,7 @@ which can be viewed with a web browser. --- -### 14: API Stability and Versioning +### 13: API Stability and Versioning Each release of Armadillo has its public API (functions, classes, constants) described in the accompanying API documentation (docs.html) specific @@ -452,7 +419,7 @@ implementation details, and may change or be removed without notice. --- -### 15: Bug Reports and Frequently Asked Questions +### 14: Bug Reports and Frequently Asked Questions Armadillo has gone through extensive testing and has been successfully used in production environments. However, as with almost all software, @@ -472,14 +439,14 @@ http://arma.sourceforge.net/faq.html --- -### 16: MEX Interface to Octave/Matlab +### 15: MEX Interface to Octave/Matlab The "mex_interface" folder contains examples of how to interface Octave/Matlab with C++ code that uses Armadillo matrices. --- -### 17: Related Software Using Armadillo +### 16: Related Software Using Armadillo * MLPACK: extensive library of machine learning algorithms http://mlpack.org diff --git a/cmake_aux/Modules/ARMA_FindACML.cmake b/cmake_aux/Modules/ARMA_FindACML.cmake deleted file mode 100644 index 7d0655e2..00000000 --- a/cmake_aux/Modules/ARMA_FindACML.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# - Find AMD's ACML library (no includes) which provides optimised BLAS and LAPACK functions -# This module defines -# ACML_LIBRARIES, the libraries needed to use ACML. -# ACML_FOUND, If false, do not try to use ACML. -# also defined, but not for general use are -# ACML_LIBRARY, where to find the ACML library. - -SET(ACML_NAMES ${ACML_NAMES} acml) -FIND_LIBRARY(ACML_LIBRARY - NAMES ${ACML_NAMES} - PATHS /usr/lib64 /usr/lib /usr/*/lib64 /usr/*/lib /usr/*/gfortran64/lib/ /usr/*/gfortran32/lib/ /usr/local/lib64 /usr/local/lib /opt/lib64 /opt/lib /opt/*/lib64 /opt/*/lib /opt/*/gfortran64/lib/ /opt/*/gfortran32/lib/ - ) - -IF (ACML_LIBRARY) - SET(ACML_LIBRARIES ${ACML_LIBRARY}) - SET(ACML_FOUND "YES") -ELSE (ACML_LIBRARY) - SET(ACML_FOUND "NO") -ENDIF (ACML_LIBRARY) - - -IF (ACML_FOUND) - IF (NOT ACML_FIND_QUIETLY) - MESSAGE(STATUS "Found ACML: ${ACML_LIBRARIES}") - ENDIF (NOT ACML_FIND_QUIETLY) -ELSE (ACML_FOUND) - IF (ACML_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find ACML") - ENDIF (ACML_FIND_REQUIRED) -ENDIF (ACML_FOUND) - -# Deprecated declarations. -GET_FILENAME_COMPONENT (NATIVE_ACML_LIB_PATH ${ACML_LIBRARY} PATH) - -MARK_AS_ADVANCED( - ACML_LIBRARY - ) diff --git a/cmake_aux/Modules/ARMA_FindACMLMP.cmake b/cmake_aux/Modules/ARMA_FindACMLMP.cmake deleted file mode 100644 index 33901795..00000000 --- a/cmake_aux/Modules/ARMA_FindACMLMP.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# - Find AMD's ACMLMP library (no includes) which provides optimised and parallelised BLAS and LAPACK functions -# This module defines -# ACMLMP_LIBRARIES, the libraries needed to use ACMLMP. -# ACMLMP_FOUND, If false, do not try to use ACMLMP. -# also defined, but not for general use are -# ACMLMP_LIBRARY, where to find the ACMLMP library. - -SET(ACMLMP_NAMES ${ACMLMP_NAMES} acml_mp) -FIND_LIBRARY(ACMLMP_LIBRARY - NAMES ${ACMLMP_NAMES} - PATHS /usr/lib64 /usr/lib /usr/*/lib64 /usr/*/lib /usr/*/gfortran64_mp/lib/ /usr/*/gfortran32_mp/lib/ /usr/local/lib64 /usr/local/lib /opt/lib64 /opt/lib /opt/*/lib64 /opt/*/lib /opt/*/gfortran64_mp/lib/ /opt/*/gfortran32_mp/lib/ - ) - -IF (ACMLMP_LIBRARY) - SET(ACMLMP_LIBRARIES ${ACMLMP_LIBRARY}) - SET(ACMLMP_FOUND "YES") -ELSE (ACMLMP_LIBRARY) - SET(ACMLMP_FOUND "NO") -ENDIF (ACMLMP_LIBRARY) - - -IF (ACMLMP_FOUND) - IF (NOT ACMLMP_FIND_QUIETLY) - MESSAGE(STATUS "Found ACMLMP: ${ACMLMP_LIBRARIES}") - ENDIF (NOT ACMLMP_FIND_QUIETLY) -ELSE (ACMLMP_FOUND) - IF (ACMLMP_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find ACMLMP") - ENDIF (ACMLMP_FIND_REQUIRED) -ENDIF (ACMLMP_FOUND) - -# Deprecated declarations. -GET_FILENAME_COMPONENT (NATIVE_ACMLMP_LIB_PATH ${ACMLMP_LIBRARY} PATH) - -MARK_AS_ADVANCED( - ACMLMP_LIBRARY - ) diff --git a/docs.html b/docs.html index 8dec33b5..3e137fbc 100644 --- a/docs.html +++ b/docs.html @@ -150,7 +150,7 @@ hr.greyline [top] -API Documentation for Armadillo 9.900 +API Documentation for Armadillo 10.1


@@ -257,7 +257,7 @@ Conrad Sanderson and Ryan Curtin. attributes .n_rows, .n_cols, .n_elem, .n_slices, ... element access element/object access via (), [] and .at() -element initialisation set elements via << operator or initialiser list +element initialisation set elements via initialiser lists     .zeros set all elements to zero .ones set all elements to one @@ -283,8 +283,8 @@ Conrad Sanderson and Ryan Curtin. subfield views read/write access to contiguous subfields     .diag read/write access to matrix diagonals -.each_col / .each_row repeated operations on each column or row of matrix -.each_slice repeated operations on each slice of cube +.each_col / .each_row repeated operations on each column or row of matrix (aka "broadcasting") +.each_slice repeated operations on each slice of cube (aka "broadcasting")     .set_imag / .set_real set imaginary/real part .insert_rows/cols/slices insert vector/matrix/cube at specified row/column/slice @@ -741,12 +741,19 @@ with the following meanings:
  • -When using the mat(string) constructor, the format is elements separated by spaces, and rows denoted by semicolons; +For the mat(string) constructor, the format is elements separated by spaces, and rows denoted by semicolons; for example, the 2x2 identity matrix can be created using "1 0; 0 1".
    Caveat: string based initialisation is slower than directly setting the elements or using element initialisation.

  • +
  • +Each instance of mat automatically allocates and releases internal memory. +All internally allocated memory used by an instance of mat is automatically released as soon as the instance goes out of scope. +For example, if an instance of mat is declared inside a function, it will be automatically destroyed at the end of the function. +To forcefully release memory at any point, use .reset(); note that in normal use this is not required. +
  • +
  • Advanced constructors: @@ -1155,9 +1162,9 @@ Examples: @@ -1411,9 +1418,9 @@ Examples: @@ -1601,6 +1608,13 @@ memory can be explicitly initialised by specifying the fill_type, as per the Mat class (except for fill::eye)

  • +
  • +Each instance of cube automatically allocates and releases internal memory. +All internally allocated memory used by an instance of cube is automatically released as soon as the instance goes out of scope. +For example, if an instance of cube is declared inside a function, it will be automatically destroyed at the end of the function. +To forcefully release memory at any point, use .reset(); note that in normal use this is not required. +
  • +
  • Advanced constructors: @@ -1657,13 +1671,13 @@ where ptr_aux_mem is a pointer to the memory Examples: