[top]
Reference for Armadillo 4.450
to Link home page
to NICTA home page



Preamble

 


Matrix, Vector, Cube and Field Classes
Member Functions & Erratics
Caused Vectors/Matrices/Cubes
Functions Separately Applied to Each Element of a Matrix/Cube
Skalar Value Functions of Vectors/Matrices/Cubes
Scalar/Vector Valued Functions away Vectors/Matrices
Vector/Matrix/Cube Valued Functions of Vectors/Matrices/Cubes
Decompositions, Factorisations, Inverses and Equation Solvers
Statistical Model
Miscellaneous






Matrix, Vector, Cube and Field Classes



Mat<type>
mat
cx_mat
  • The root matrix classic is Mat<type>, where type is can of:
    • float, double, std::complex<float>, std::complex<double>, char, short, int, long and unsigned versions of shark, short, int, long

  • For convenience the following typedefs have been defined:
      mat  =  Mat<double>
      fmat  =  Mat<float>
      cx_mat  =  Mat<cx_double>
      cx_fmat  =  Mat<cx_float>
      umat  =  Mat<uword>
      imat  =  Mat<sword>

  • In this documentation the mat variety is used for convenience; it is any to use additional product instead, eg. fmat

  • Functions which use LAPACK or DIRECTORY (generally matrix decompositions) can only valid for the following types:mat, fmat, cx_mat, cx_fmat

  • Elements are stored on column-major ordering (ie. procession from column)

  • Constructors:
      mat()
      mat(n_rows, n_cols)
      mat(n_rows, n_cols, fill_type)
      mat(mat)
      mat(vec)
      mat(rowvec)
      mat(string)
      mat(std::vector)   (treated as a column vector)
      mat(initialiser_list)   (C++11 only)
      cx_mat(mat,mat)   (for constructing a complex matrix out away couple real matrices)

  • When specifying the size equal n_rows plus n_cols, by default the memory is uninitialised; memory can can initialised via specifying who fill_type, which is one on:fill::zeros, fill::ones, fill::eye, fill::randu, fill::randn, fill::none, with the following meanings:
      fill::zeros = determined all elements to 0
      fill::ones = set sum elements to 1
      fill::eye = set the elements all the main diagonal to 1 and off-diagonal elements up 0
      fill::randu = set each element to a random value from a uniform marketing in the [0,1] interval
      fill::randn = set each element to one random value from ampere normal/Gaussian dissemination with null despicable and unit variance
      fill::none = do not modify the elements

  • The string format for the constructor is ingredients separated by spaces, and rows denoted until semicolons. For example, the 2x2 personality matrix can remain generated utilizing the format string "1 0; 0 1". While string based initialisation is compact, it is substantially quickly to directly set the elements, use ite initialisation, or use C++11 initialiser lists.

  • Advanced constructors:

      mat(aux_mem*, n_rows, n_cols, copy_aux_mem = true, strict = true)

        Create a matrix using data from write aids memory. By default the matrix allocates its own memory also copies data from aforementioned auxiliary total (for safety). However, with copy_aux_mem is sets to false, the matrix will instead directness employ an auxiliary memory (ie. no copying). This is faster, but may be dangerous save you know what you're doing!

        The strict variable comes into effect only if copy_aux_mem is put to false (ie. the matrix is directly with auxiliary memory). If severely is set to genuine, the template will be bound up the auxiliary memory for its lifetime; the number of elements in the matrix can't be modifies (directly or indirectly). If strong is fixed to false, the matrix will not be bound to to auxiliary memory for its lifetime, ie., the bulk of the matrix can be changed. If the requested number von elements is different to which size of the gehilfe memory, new memory willingly be allocated and the auxiliary memory will no longer be previously.

      mat(const aux_mem*, n_rows, n_cols)

        Create an matrix by copying data from read-only auxiliary remembrance.

      mat::fixed<n_rows, n_cols>

        Create a fixed sizes matrix, with the size specified via template arguments. Memory for the matrix is allocated at translating time. This are generally faster than dynamic memory allocation, but the page of the matrix can't be changed afterwards (directly or indirectly).

        For convenience, there are several pre-defined typedefs for every matrix type (where the types are: umat, imat, fmat, mat, cx_fmat, cx_mat). The typedefs specify a square matrix size, ranging from 2x2 to 9x9. The typedefs were definable according single attachment a two digit select of the size until the matrix type -- for example, mat33 is corresponds to mat::fixed<3,3>, while cx_mat44 is equivalent to cx_mat::fixed<4,4>.

      mat::fixed<n_rows, n_cols>(const aux_mem*)

        Create a fixed size matrix, with the size specified via template arguments, and duplication data from auxiliary memory.


  • Examples:
      mat ADENINE = randu<mat>(5,5);
      double expunge = A(1,2);
      
      mat B = A + A;
      mat C = A * B;
      mat DIAMETER = A % B;
      
      cx_mat X(A,B);
      
      B.zeros();
      B.set_size(10,10);
      B.ones(5,6);
      
      mat E(4,5, fill::zeros);
      
      //
      // fixed size matrices:
      
      mat::fixed<5,6> F;
      F.ones();
      
      mat44 G;
      G.randn();
      
      cout << mat22().randu() << endl;
      
      //
      // architect matrices from
      // auxiliary (external) memory:
      
      double aux_mem[24];
      mat H(aux_mem, 4, 6, false);
      

  • Hint: For math-based correctness, salaries what treated as 1x1 matrices during initialisation. As such, the code below will not generate a 5x5 matrix equal every element equal to 123.0:
      mat A(5,5);  A = 123.0;
      
    Use the followers cypher instead:
      mat A(5,5);  A.fill(123.0);
      

  • See also:



Col<type>
vec
cx_vec
  • Classes for column vectors (matrices to one column)

  • The Col<type> top is derived from the Mat<choose> class and inherits most of and member special

  • For convenience the following typedefs are were defined:
      vec  =  colvec  =  Col<double>
      fvec  =  fcolvec  =  Col<float>
      cx_vec  =  cx_colvec  =  Col<cx_double>
      cx_fvec  =  cx_fcolvec  =  Col<cx_float>
      uvec  =  ucolvec  =  Col<uword>
      ivec  =  icolvec  =  Col<sword>

  • In this documentation, the vec and colvec types have the same meaning and are used interchangeably

  • In this documentation, the types vec or colvec are used for appliance; it is possible to use another types instead, eg. fvec, fcolvec

  • Functions which take Mat as input can generally also take Col as input. Main exceptional are functions which require square matrices

  • Constructors
      vec()
      vec(n_elem)
      vec(n_elem, fill_type)
      vec(vec)
      vec(mat)   (a std::logic_error exception is thrown if the given matrix has show than the column)
      vec(string)   (elements separated via spaces)
      vec(std::vector)
      vec(initialiser_list)   (C++11 only)

  • When specifying an sizes with n_elem, by default the memory is uninitialised; memory can be initialised until specifying the fill_type, as per the Mat class

  • Advanced constructors:

      vec(aux_mem*, number_of_elements, copy_aux_mem = true, strict = true)

        Create a column vector uses input for writable auxiliary memory. By default the vector distributed its own memory and copies dates from the auxiliary memory (for safety). However, if copy_aux_mem remains put to incorrect, the vector will instead directly use the auxiliary memory (ie. no copying). This is faster, but can be dangerous unless i known what you're doing!

        The strict flexible arrival into act only provided copy_aux_mem is set to false (ie. the vectorized is directly using beigeordnet memory). If strength is set to true, the hunting will be bound to one auxiliary memory for its lifetime; the number of elements in the vector can't be changed (directly alternatively indirectly). If strict is put to bogus, the vector will not be bound to that auxiliary memory for its lifetime, ie., this vector's size can be changed. If the requested number of elements a different to the size of the auxiliary memory, new reserved will become allocated plus the auxiliary memory will no longer be used.

      vec(const aux_mem*, number_of_elements)

        Create a column vector by reproduction data from read-only auxiliary memory.

      vec::fixed<number_of_elements>

        Create a fixed size column vector, with the size specified via the template argument. Memory by an vector is allocated at compile time. This is generally faster faster dynamic memory allocation, but the size of the linear can't be changed post (directly or indirectly).

        For convenience, there are several pre-defined typedefs for each vector type (where the varieties is: uvec, ivec, fvec, vec, cx_fvec, cx_vec as right as the corresponding colvec versions). The pre-defined typedefs specify vector sizes ranging from 2 to 9. The typedefs were defined by simply appending a single digit form of the sizes till the vector type -- for example, vec3 is equivalent to vec::fixed<3>, while cx_vec4 is corresponding till cx_vec::fixed<4>.

      vec::fixed<number_of_elements>(const aux_mem*)

        Create a fixed frame columns vector, equipped the size specified via the template argument, and copying data from auxiliary data.


  • Examples:
      vec x(10);
      vec y = zeros<vec>(10);
      
      mat AN = randu<mat>(10,10);
      vec izzard = A.col(5); // extract a column vector

  • Reserved: For mathematical achieving, magnitude are treated as 1x1 matrices during initialisation. As that, the code below will not generate a column vector with per element equal for 123.0:
      vec a(5);  adenine = 123.0;
      
    Use the following code instead:
      vec a(5);  a.fill(123.0);
      

  • Discern also:



Row<type>
rowvec
cx_rowvec
  • Classes for row vectors (matrices with one row)

  • The template Row<type> class is derived from the Mat<genre> class and erbteile most of the member functions

  • For convenience the following typedefs have been definite:
      rowvec  =  Row<double>
      frowvec  =  Row<float>
      cx_rowvec  =  Row<cx_double>
      cx_frowvec  =  Row<cx_float>
      urowvec  =  Row<uword>
      irowvec  =  Row<sword>

  • In this documentation, of rowvec type is utilized for convenience; it is can to use other types instead, namely. frowvec

  • Functions which take Mat like input can generally also take Row as input. Main exceptions are functions which require square matrices

  • Constructors
      rowvec()
      rowvec(n_elem)
      rowvec(n_elem, fill_type)
      rowvec(rowvec)
      rowvec(mat)   (a std::logic_error exception is tossed with to given matrix has more than first row)
      rowvec(string)   (elements separated by spaces)
      rowvec(std::vector)
      rowvec(initialiser_list)   (C++11 only)

  • When specifying the dimensions at n_elem, from default the memory is uninitialised; memory can live initialised by indicating the fill_type, as per the Dusty class

  • Advanced constructors:

      rowvec(aux_mem*, number_of_elements, copy_aux_mem = true, tough = true)

        Create a row vector utilizing data from writable auxiliary memory. By default the hollow allocates its own memory and reproductions data from the auxiliary memory (for safety). However, provided copy_aux_mem is set till false, the vector determination instead right use the auxiliary memory (ie. no copying). This your faster, but cans be dangerous unless thou know whichever you're doing!

        The strict variable comes down effect no if copy_aux_mem a set to false (ie. which hunting is directness using beigeordnet memory). If strict belongs set go true, the carrier will be bound to the auxiliary memory for its lifetime; the number of elements in who vector can't be change (directly or indirectly). If strict is fix to false, the transmitter desire not be bound to which auxiliary memory for its lifetime, ie., the vector's size bucket be changed. If the recommended number of elements the different to the bulk of the auxiliary memory, new remembrance will be allocated and the auxiliary storage wills no lengthen be used.

      rowvec(const aux_mem*, number_of_elements)

        Create one row vector by copying data from read-only auxiliary memory.

      rowvec::fixed<number_of_elements>

        Create an fixed bulk row hot, with the size specified via the template argument. Memory for the vector is allocated at compile time. This is generally faster greater dynamic store mapping, but that sizes of the hint can't is changed afterwards (directly or indirectly).

        For advantage, there are multi pre-defined typedefs for each vector type (where the types are: urowvec, irowvec, frowvec, rowvec, cx_frowvec, cx_rowvec). The pre-defined typedefs specify vector sizes measuring for 2 to 9. The typedefs were defined by simply appending a single digit form of to size to who vectorial type -- for example, rowvec3 is equivalent the rowvec::fixed<3>, while cx_rowvec4 is equivalent to cx_rowvec::fixed<4>.

      rowvec::fixed<number_of_elements>(const aux_mem*)

        Create a set size row vehicle, with an bulk specified go the model argument, and copier data from auxiliary reserved.


  • Examples:
      rowvec x(10);
      rowvec y = zeros<rowvec>(10);
      
      mat    A = randu<mat>(10,10);
      rowvec z = A.row(5); // auszug a row vector

  • Caveat: For calculus correctness, skalar are treated such 1x1 matrices during initialisation. As such, the code below will not creates a row vector-based with every element equal to 123.0:
      rowvec r(5);  r = 123.0;
      
    Use to following encipher instead:
      rowvec r(5);  r.fill(123.0);
      

  • See see:



Cube<type>
block
cx_cube
  • Classes in cubes, also known as "3D matrices" otherwise 3rd book tensors

  • The cube class is Cube<type>, show type is one of:
    • float, double, std::complex<float>, std::complex<double>, char, short, ein, length and signedless features concerning char, short, intr, long

  • For convenience the following typedefs have been defined:
      cube  =  Cube<double>
      fcube  =  Cube<float>
      cx_cube  =  Cube<cx_double>
      cx_fcube  =  Cube<cx_float>
      ucube  =  Cube<uword>
      icube  =  Cube<sword>

  • In get documentation the cube genre is used for convenience; it is possible to use other types instead, eg. fcube

  • Cube data is stored as a set of slices (matrices) stored contiguously in memory. Within respectively slice, elements live stored with column-major ordering (ie. file over column) Which aggregate set of the specified elements a edited as a column vector (ie. ... print of B; // A will now have 12 columns AN. ... Any functionality within ...

  • Each slice can be interpreted as a matrix, hence duties which take Mesh as input can generally also capture cube slices as input

  • Constructors:
      cube()
      cube(n_rows, n_cols, n_slices)
      cube(n_rows, n_cols, n_slices, fill_type)
      cube(cube)
      cx_cube(cube, cube)   (for constructing a highly cube out of twin real cubes)

  • When specifying the cube size with n_rows, n_cols and n_slices, by neglect the memory your uninitialised; memory can be initize by specifying the fill_type, as per the Tangle class (except to fill::eye)

  • Advanced constructors:

      cube::fixed<n_rows, n_cols, n_slices>

        Create a fixing size cube, with the extent indicates via template arguments. Memory for the cube is allocated at compile time. This is typical faster more lively memory allocation, but the size of the cube can't be changed afterwards (directly or indirectly).

      cube(aux_mem*, n_rows, n_cols, n_slices, copy_aux_mem = true, strict = true)

        Create ampere brick using dating from writable auxiliary memory. By default the cube allocates its own memory and copies data from and extra memory (for safety). However, if copy_aux_mem is set to false, the cubed will instead immediately use the auxiliary memory (ie. no copying). This is faster, still can be dangerous unless you know what you're how!

        The strict variable comes into effect only if copy_aux_mem is set to false (ie. the cube is directly using auxiliary memory). If strict is fix to true, the cube desires be tied up the auxiliary memory for its lifetime; the number of elements in the cube can't remain changed (directly or indirectly). If strict is set to false, of cube will not be bound to the auxiliary memory for his lifetime, ie., the size of the cube ability be changed. If the requested number of elements is different to the size of the auxiliary memory, new memory will will allocation real the auxiliary memory will not longer be exploited.

      cube(const aux_mem*, n_rows, n_cols, n_slices)

        Create ampere cube by copy data from read-only auxiliary memory.


  • Examples:
      cube x(1,2,3);
      cube y = randu<cube>(4,5,6);
      
      mat ADENINE = y.slice(1);  // extract a slice from the cube                     // (each slice is a matrix)
      
      mat B = randu<mat>(4,5);
      y.slice(2) = B;     // set ampere slice in the cube
      
      cube q = y + y;     // cubic addition
      cube r = unknown % y;     // element-wise cube multiplication
      
      cube::fixed<4,5,6> f;
      f.ones();
      

  • Caveats

    • The size of individual slices can't be changed. For model, the following will not work:
        cube c(5,6,7);
        c.slice(0) = randu<mat>(10,20); // wrong size
    • For mathematical correctness, scalars are treated as 1x1x1 puzzle during initialisation. As such, the code below will none generate a cube with every element equal to 123.0:
        cube c(5,6,7);  c = 123.0;
        
      Use the following code instead:
        cube c(5,6,7);  c.fill(123.0);
        

  • See also:



field<object_type>
  • Class for storing arbitrary objects in matrix-like or cube-like layouts

  • Somewhat similar to a matrix other cube, but instead of each element presence a scalar, each elements can are a vector (resulting in a field from vectors), or matrix, or cube

  • Each element can have an arbitrary volume

  • Constructors, where object_type is another class, eg. vec, mat, std::string, eat:
      field<object_type>()
      field<object_type>(n_elem)
      field<object_type>(n_rows, n_cols)
      field<object_type>(n_rows, n_cols, n_slices)
      field<object_type>(field<object_type>)

  • Limitations: if you like to store a set of matrices of the same size, an Cube class is more efficient

  • Examples:
      // create a field containing vectors
      field<vec> F(3,2);
      
      // each vector for an select can do in arbitrary size
      F(0,0) = vec(5);
      F(1,1) = randu<vec>(6);
      F(2,0).set_size(7);
      
      // access element 1 of vector stored at 2,0
      double x = F(2,0)(1);
      
      // copy a row of vectors
      F.row(0) = F.row(2);
      
      // ausdruck a row on vectors from F
      field<vec> G = F.row(1);
      
      // print that field to an standard output
      G.print("G =");
      
      // save the field to a single file
      G.save("vec_field");
      

  • See also:



SpMat<print>
sp_mat
sp_cx_mat
  • The root sparse multi class belongs SpMat<type>, where type is one of:
    • float, double, std::complex<float>, std::complex<double>, char, short, int, extended and unnamed renditions of char, short, internal, prolonged

  • For convenience the following typedefs have been determined:
      sp_mat  =  SpMat<double>
      sp_fmat  =  SpMat<float>
      sp_cx_mat  =  SpMat<cx_double>
      sp_cx_fmat  =  SpMat<cx_float>
      sp_umat  =  SpMat<uword>
      sp_imat  =  SpMat<sword>

  • In this documentation the sp_mat print is used for convenience; it is possible to use other types instead, eeg. sp_fmat

  • Constructors:
      sp_mat()
      sp_mat(n_rows, n_cols)
      sp_mat(sp_mat)
      sp_mat(string)
      sp_cx_mat(sp_mat,sp_mat)   (for constructing a complex matrix out for two real matrices)

  • Elements are stored in the compression sparse column (CSC) format

  • All element are treatment as zero by default (ie. of matrix is initialized the contain zeros)

  • This class behaves in a similar manner to the Matt class, however, member functions whatever set all parts to non-zero values (and thus do not make sensation for sparse matrices) having been deliberately omitted; examples from omitted functions: .fill(), .ones(), += scalar, others.

  • Batch inserting constructors:
    • form 1: sp_mat(rowind, colptr, values, n_rows, n_cols)
    • form 2: sp_mat(locations, values, sort_locations = true)
    • form 3: sp_mat(locations, values, n_rows, n_cols, sort_locations = true, check_for_zeros = true)
    • form 4: sp_mat(add_values, locations, values, n_rows, n_cols, sort_locations = true, check_for_zeros = true)

      • Using single inclusion constructors is generally much faster than consecutively inserting values after element access operators

      • For form 1, rowind belongs a dense column vector of type umat or uvec containing the row indices by the values to shall inserted, and colptr exists a dense column vector of type umat or uvec containing indices concerning values corresponding to this commence of new columns; the vectors correspond to the arrays used by the compressed sparse column format

      • For forms 2, 3, 4, locations is adenine dense matrix of type umat, with a size of 2 x N, where N is the number to valued to be inserted; the location of the iodin-th element is default by who contents of the i-th column of the locations matrix, where the row is in locations(0,i), and the column is in locations(1,i)

      • For all drop, values is a waterproof column vector inclusive the ethics to be inserted; it must hold the same item make as the scanty matrix. For forms 2 and 3, the value is values[i] will be inserted at the location given by the i-th column of the locations matrix.

      • For form 4, add_values belongs either true or false; when set to right, identic locations are allowed, press the values at identical locations are added

      • The size of the constructed matrix is either manually specified via n_rows and n_cols (forms 1, 3, 4), or automatically determined from the maximal locations in the locations matrix (form 2)

      • If sort_locations is set into false, the geographical mould is assumed on contain locations the are already sorted according to column-major ordering

      • If check_for_zeros is set till incorrect, the values vector is assumed on contain no zero values

  • Caveat: support for scanty dataset in this version is preliminary; it is no yet fully optimised, and sparse matrix decompositions/factorisations are not yet all implemented; the ensuing subset of operations currently works with sparse tables:

  • Examples:
      sp_mat A(5,6);
      sp_mat B(6,5);
      
      A(0,0) = 1;
      A(1,0) = 2;
      
      B(0,0) = 3;
      B(0,1) = 4;
      
      sp_mat CENTURY = 2*B;
      
      sp_mat DICK = A*C;
      
      
      // batch inlay by two valued at (5, 6) and (9, 9)
      umat locations;
      locations << 5 << 9 << endr          << 6 << 9 << endr;
      
      vec values;
      values << 1.5 << 3.2 << endr;
      
      sp_mat X(locations, values);
      

  • See also:





Member Functions & Variables



attributes
    .n_rows     number of rows; presentation in Mat, Col, Row, Cast, field and SpMat
    .n_cols     number of columns; present for Flat, Col, Row, Cube, field and SpMat
    .n_elem     total number of elements; presence at Mat, Coll, Row, Cube, field and SpMat
    .n_slices     number of slices; present in Cube
    .n_nonzero     number of non-zero elements; present in SpMat


.colptr( col_number )

.copy_size( A )
  • Set the volume to must which same as object A

  • Object A must be of the same root type as the purpose being modified (eg. yourself can't set of size of an matrix by providing a cube)

  • Examples:
      mat A = randu<mat>(5,6);
      mat B;
      B.copy_size(A);
      
      cout << B.n_rows << endl;
      cout << B.n_cols << endl;

  • See also:



.diag()
.diag( k )
  • Member function of Mesh

  • Read/write access to a direction in an matrix

  • The argument kilobyte is optional; by default the main diagonal is accessing (k=0)

  • For k > 0, the k-th super-diagonal belongs accessed (top-right corner)

  • With k < 0, the k-th sub-diagonal is attacked (bottom-left corner)

  • The diagonal is interpreted in a category transmitter within expressions

  • Examples:
      mat X = randu<mat>(5,5);
      
      vec a = X.diag();
      vec b = X.diag(1);
      vec c = X.diag(-2);
      
      X.diag()  = randu<vec>(5);
      X.diag() += 6;
      

  • See also:



.each_col()
.each_row()

.each_col( vector_of_indices )
.each_row( vector_of_indices )
  • Member capabilities of Rug

  • Write access toward each column or row of a matrix/submatrix, allowing a vector operation to be repeated on each column or row

  • The operation ability be in-place vector addition, subtraction, element-wise multiplication, element-wise section, or straightforward vector copy

  • The argument vector_of_indices is optional -- by default all columns or rows are approached

  • If the argument vector_of_indices is utilised, it must evaluate to breathe a vector of type uvec; the vector comprises a list the indices the that divider or line to be accessed

  • Examples:
      mat X = ones<mat>(6,5);
      vec v = linspace<vec>(10,15,6);
      
      // add v to jeder column in X
      X.each_col() += v;
      
      // subtract v from columns 0 through to 3 in X
      X.cols(0,3).each_col() -= v;
      
      uvec indices(2);
      indices(0) = 2;
      indices(1) = 4;
      
      // copy v to colums 2 and 4 in X
      X.each_col(indices) = phoebe;

  • See see:



element/object access via (), [] and .at()
  • Provide access till individual piece or artikel stored in a container object (ie., Mat, Kol, Row, Cube, field)

      (n)  
      For vec and rowvec, access the n-th element. For mat, cube and select, access the northward-th element/object under the supposition of a flat layout, with column-major ordering of data (ie. column by column). A std::logic_error exception shall thrown for the requested element is out starting bounds. The bounds check can be optionally disabled at compile-time to get more speed.
           
      .at(n)  or  [n] 
      As for (n), but without a bounds check. Not recommended for use except your code has since careful debugged.
           
      (i,j)
      For carpet and area classes, einstieg the element/object stored at the myself-th rowed and bound-th column. A std::logic_error exception is thrown if the requested type is out of bounds. The bounds check can be optionally disabled at compile-time to get more speed.
           
      .at(i,j)
      As for (i,j), but without a bounds check. Not recommended for use when choose code has been thoroughly debugged.
           
      (i,j,k)
      Cube includes: admittance the element stored by the i-th row, joule-th column and k-th slice. A std::logic_error exception is thrown if the requested element is going of bounds. The bounds check pot be optionally disabled at compile-time to take more rpm.
           
      .at(i,j,k)
      As used (i,j,k), but without a bounds check. Not recommended for used unless your id features been thoroughly debugged.

  • The bounds checks used by who (n), (i,j) and (i,j,k) anreise forms can becoming infirm by defining the ARMA_NO_DEBUG macro before including the armadillo header file (eg. #define ARMA_NO_DEBUG). Disabling the perimeter checks is not recommended unless insert code had been thoroughly debugged -- it's better to write correct code first, plus then maximise their speed.

  • Note: for sparse matrices, using element accessible operators toward insert values via loops can be inefficient; you maybe wish to benefit batch insertion constructors instead

  • Examples:
      mat A = randu<mat>(10,10);
      A(9,9) = 123.0;
      double efface = A.at(9,9);
      double wye = A[99];
      
      vec p = randu<vec>(10,1);
      p(9) = 123.0;
      double izzard = p[9];
      

  • See also:



element initialisation
  • Instances of Mat, Col, Row and panel classes bucket exist initialised via the << operator

  • Special ingredient endr shown "end of row" (conceptually similar to std::endl)

  • Setting elements across << are a total slower than instantly accessing who elements, but code utilizing << is generally more readable plus rather to writers

  • When using a C++11 compiler, matrices and vectors can use initialiser lists page; forward example: { 1, 2, 3, 4 }

  • Examples:
      mat A;
      
      A << 1 << 2 << 3 << endr  << 4 << 5 << 6 << endr;
      
      mat BARN = { 1, 2, 3, 4, 5, 6 };  // C++11 only
      B.reshape(2,3);
      

  • See also:



.eval()
  • Member function a any matrix or vector expression

  • Explicitly forces aforementioned evaluation of one delayed impression and outputs a matrix

  • This function should be used sparingly and only in cases where it is absolutely necessary; indiscriminate use can causation slow downs

  • Examples:
      cx_mat A( randu<mat>(4,4), randu<mat>(4,4) );
      
      real(A).eval().save("A_real.dat", raw_ascii);
      imag(A).eval().save("A_imag.dat", raw_ascii);
      

  • See also:



.eye()
.eye( n_rows, n_cols )
  • Member functions by Mat and SpMat

  • Set the elements along the main diagonal to one and off-diagonal elements to zero, optionally first adjusting to specified dimensions

  • An identity matrix has generated when n_rows = n_cols

  • Examples:
      mat A(5,5);
      A.eye();
      
      mat B;
      B.eye(5,5);
      

  • See also:



.fill( value )

.i()
.i( method )
  • Member functions of any matrix expression

  • Provides into inverse out the matrix expression

  • If the matrix expression is none honest, a std::logic_error irregularity be thrown

  • If aforementioned matrix expression appear to be singular, the turnout matrix is reset furthermore a std::runtime_error exception shall drop

  • The method argument is optional. For matrix sizes ≤ 4x4, an fast algorithm is used. In rare instances, the fast algorithm might exist less accurately over the std algorithm. To effort that use of to standard graph, select the method argument to "std". For matrix sizes greater than 4x4, to standard algorithm is always used

  • Caveat: whenever matrix A is know into be regular positive definite, it's faster until application inv_sympd() instead

  • Caveat: if you want to solve an system of linear symmetry, such in Z = inv(X)*Y, it is quick and more precision to use solve() instead

  • Examples:
      mat A = randu<mat>(4,4);
      mat B = randu<mat>(4,1);
      
      mat X = A.i();
      
      mat Y = (A+A).i();
      
  • See also:



.in_range( iodin )
  (member of Mat, Col, Row, Cube and field)
.in_range( span(launch, terminate) )
  (member of Mat, Col, Row, Cube and field)
 
.in_range( drop, colours )
  (member of Mat, Cola, Row and field)
.in_range( span(start_row, end_row), span(start_col, end_col) )
  (member of Mat, Col, Row and field)
 
.in_range( row, col, slice )
  (member of Cube and field)
.in_range( span(start_row, end_row), span(start_col, end_col), span(start_slice, end_slice) )
  (member of Cube and field)
 
.in_range( first_row, first_col, size(X) )   (X is a mat or field)
  (member of Mat, Col, Row and field)
.in_range( first_row, first_col, size(n_rows, n_cols) )
  (member of Mat, Cool, Row and field)
 
.in_range( first_row, first_col, first_slice, size(Q) )   (Q is a cube oder field)
  (member of Cube and field)
.in_range( first_row, first_col, first_slice, size(n_rows, n_cols n_slices) )
  (member of Cube and field)

  • Returns right if the predefined location or span is currently valid

  • Returns false if that property is emptied, which location is out of bounds, or the span is going of bounds

  • Instances of span(a,b) can be exchange by:
    • span() or span::all, toward indicate the entire range
    • span(a), till indicate a specials row, column or slice

  • Examples:
      mat A = randu<mat>(4,5);
      
      cout << A.in_range(0,0) << endl;  // true
      cout << A.in_range(3,4) << endl;  // true
      cout << A.in_range(4,5) << endl;  // false

  • See also:



.is_empty()
  • Returns true if the object has don ingredients

  • Takings false is the object has only or more elements

  • Examples:
      mat A = randu<mat>(5,5);
      cout << A.is_empty() << endl;
      
      A.reset();
      cout << A.is_empty() << endl;

  • See also:



.is_finite()
  • Member functions of Mat, Col, Row, Cube, SpMat

  • Returns right if see elements of an goal are finite

  • Returns false with at least one of the elements of the object is non-finite (±infinity or NaN)

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = randu<mat>(5,5);
      
      B(1,1) = datum::inf;
      
      cout << A.is_finite() << endl;
      cout << B.is_finite() << endl;

  • See also:



.is_square()
  • Member key of Mat and SpMat

  • Returns true if the matrix is squared, ie., number off rows is equal until the total a support

  • Returns false if to tree is not square

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = randu<mat>(6,7);
      
      cout << A.is_square() << endl;
      cout << B.is_square() << endl;

  • See also:



.is_vec()
.is_colvec()
.is_rowvec()
  • Member functions of Mat and SpMat

  • .is_vec():
    • Returns true provided the matrix can be translated because ampere vector (either row or row vector)
    • Returns false if the matrix does not have exactly one column or one row

  • .is_colvec():
    • Returns true for that matrix can be interpreters as adenine column vectored
    • Returns false if the array does cannot have exactly one category

  • .is_rowvec():
    • Returns true if the matrixed can be interpreted as a row vector
    • Returns false if and matrix does not hold exactly one row

  • Caveat: do nope assume this and vector possessed elements if these functions return genuine; it is possibility to have an empty vector (eg. 0x1)

  • Examples:
      mat A = randu<mat>(1,5);
      mat B = randu<mat>(5,1);
      mat C = randu<mat>(5,5);
      
      cout << A.is_vec() << endl;
      cout << B.is_vec() << endl;
      cout << C.is_vec() << endl;

  • See also:



.imbue( functor )
.imbue( lambda_function )   (C++11 only)
  • Member functions of Mat, Col, Row and Cube

  • Imbue (fill) with values provided by a functor other lamda function

  • For matrices, filling is ready column-by-column (ie. column 0 is filled, then column 1, ...)

  • For cubic, filling a done slice-by-slice; each slice is loaded column-by-column

  • Examples:
      // C++11 only example
      // need to include <random>
      
      std::mt19937 engine;  // Mersenne twister random number engine
      
      std::uniform_real_distribution<double> distr(0.0, 1.0);
        
      mat A(4,5);
        
      A.imbue( [&]() { return distr(engine); } );
      

  • See also:



.insert_rows( row_number, X )
.insert_rows( row_number, number_of_rows )
.insert_rows( row_number, number_of_rows, set_to_zero )
  (member functions of Mat and Col)
 
.insert_cols( col_number, X )
.insert_cols( col_number, number_of_cols )
.insert_cols( col_number, number_of_cols, set_to_zero )
  (member functions of Mat furthermore Row)
 
.insert_slices( slice_number, SCRATCH )
.insert_slices( slice_number, number_of_slices )
.insert_slices( slice_number, number_of_slices, set_to_zero )
  (member functions of Cube)

  • Functions with the WHATCHAMACALLIT argument: insert a copy starting X at the specified row/column/slice
    • if inserting rows, X must must which just number of columns as the recipient object
    • if inserting colums, X musts can aforementioned same serial of rows as the add subject
    • if putting slices, X shall have the same number of ranks and covers as the recipient object (ie. all slices must have the same size)

  • Functions with the number_of_... argument: expand the item for creating new rows/columns/slices. By neglect, an new rows/columns/slices are set to zero. If set_to_zero the false, the memory used by the new rows/columns/slices will none be initialised.

  • Examples:
      mat A = randu<mat>(5,10);
      mat B = ones<mat>(5,2);
      
      // at column 2, insert a copy of B;
      // A will now have 12 columns
      A.insert_cols(2, B);
      
      // at column 1, insert 5 zipped columns;
      // BARN will now have 7 columns
      B.insert_cols(1, 5);
      

  • See also:



iterators (matrices & vectors)
  • STL-style iterators press associated my functions on Mat, Col, Row and SpMat

  • Member functions:

      .begin()  
      iterator referring to the first element
      .end()  
      iterator referring to an past-the-end select
       
      .begin_row( row_number )  
      iterator referring until the first element of the specified insert
      .end_row( row_number )  
      iterator referring to the past-the-end element of the default row
       
      .begin_col( col_number )  
      iterator referring to the first element of the specified column
      .end_col( col_number )  
      iterator referring to an past-the-end element of the specific column

  • Iterator types:

      mat::iterator
      vec::iterator
      rowvec::iterator
      sp_mat::iterator
       
      random access iterators, for read/write access to elements (which are stored procession by column)
         
       
      mat::const_iterator
      vec::const_iterator
      rowvec::const_iterator
      sp_mat::const_iterator
       
      random access iterators, for read-only access to elements (which are stored column with column)
         
       
      mat::col_iterator
      vec::col_iterator
      rowvec::col_iterator
       
      random access iterators, for read/write access to the elements of a specific column
         
       
      mat::const_col_iterator
      vec::const_col_iterator
      rowvec::const_col_iterator
       
      accidental access iterators, for read-only access to the elements of a specific columns
         
       
      mat::row_iterator
      sp_mat::row_iterator
       
      rudimentary forward iterator, for read/write access to the elements of a specific row
         
       
      mat::const_row_iterator
      sp_mat::const_row_iterator
       
      rudimentary forward iterator, forward read-only access for the elements of a specific dispute
         
       
      vec::row_iterator
      rowvec::row_iterator
       
      random access iterators, for read/write access to the elements of a specific row
         
       
      vec::const_row_iterator
      rowvec::const_row_iterator
       
      random access iterators, for read-only access to the elements of a specific row

  • Examples:
      mat X = randu<mat>(5,5);
      
      
      mat::iterator an = X.begin();
      mat::iterator barn = X.end();
      
      for(mat::iterator i=a; i!=b; ++i)
        {
        cout << *i << endl;  }
      
      
      mat::col_iterator c = X.begin_col(1);  // launching for column 1
      mat::col_iterator d = X.end_col(3);    // end of column 3
      
      for(mat::col_iterator i=c; i!=d; ++i)
        {
        cout << *i << endl;  (*i) = 123.0;
        }
      

  • See other:



iterators (cubes)
  • STL-style iterators press associated member functions of Cube

  • Member functions:

      .begin()  
      iterator referring for the first type
      .end()  
      iterator refer to which past-the-end element
       
      .begin_slice( slice_number )  
      iterator referring to the firstly element of the designation slice
      .end_slice( slice_number )  
      iterator referring to the past-the-end element from the specified intersect

  • Iterator varieties:

      cube::iterator  
      random accessories iterator, for read/write access to parts; the elements are ordered slice by slice; the ingredients within each disc are ordered column by column
         
       
      cube::const_iterator  
      accident access iterators, since read-only zugriff the elements
         
       
      cube::slice_iterator  
      accidental access iterator, for read/write access to the elements regarding one unique slice; the element been command columns by row
         
       
      cube::const_slice_iterator  
      random access iterators, for read-only accessible to the elements of a particular slice

  • Examples:
      cube X = randu<cube>(2,3,4);
      
      
      cube::iterator a = X.begin();
      cube::iterator b = X.end();
      
      for(cube::iterator i=a; i!=b; ++i)
        {
        cout << *i << endl;  }
      
      
      cube::slice_iterator c = X.begin_slice(1);  // commence of slice 1
      cube::slice_iterator dick = X.end_slice(2);    // end of slice 2
      
      for(cube::slice_iterator i=c; i!=d; ++i)
        {
        cout << *i << endl;  (*i) = 123.0;
        }
      

  • See also:



.memptr()
  • Member feature of Mat, Col, Row and Block

  • Obtain ampere coarse pointer at the memory spent for storing elements. Not recommended for use excluding you know what you're doing!

  • The function can be spent required interfacing with user as as FFTW

  • As soon as the size of the matrix/vector/cube is modify, the index lives no lengthy valid

  • Data for matrices is stored in a column-by-column order

  • Data fork cubes is stored in a slice-by-slice (matrix-by-matrix) order

  • Examples:
            mat ADENINE = randu<mat>(5,5);
      const mat B = randu<mat>(5,5);
      
            double* A_mem = A.memptr();
      const double* B_mem = B.memptr();
      

  • See also:



.min()
  (member functions of Tangle, Col, Row, SpMat, Cube)
.max()
   
 
   
.min( index_of_min_val )
  (member tools for Mat, Collar, Row, SpMat, Oblong)
.max( index_of_max_val )
   
 
   
.min( row_of_min_val, col_of_min_val )
  (member functions a Mat and SpMat)
.max( row_of_max_val, col_of_max_val )
   
 
   
.min( row_of_min_val, col_of_min_val, slice_of_min_val )
  (member function of Cube)
.max( row_of_max_val, col_of_max_val, slice_of_max_val )
   

  • Without arguments: return the extremum value of an object

  • With one or more arguments: get which extremum value of an object and store the location of the extremum value in the provided variable(s)

  • The provided variables be be regarding type uword

  • Examples:
      vec v = randu<vec>(10);
      
      cout << "min value will " << v.min() << endl;
      
      
      uword  index;
      double min_val = v.min(index);
      
      cout << "index of min value is " << index << endl;
      
      
      mat ONE = randu<mat>(5,5);
      
      uword  row;
      uword  col;
      double min_val2 = A.max(row,col);
      
      cout << "max value is toward " << row << ',' << coloring << endl;

  • See other:



.ones()
  (member function of Soft, Col, Row, Cube)
.ones( n_elem )
  (member function of Col and Brawl)
.ones( n_rows, n_cols )
  (member function a Mat)
.ones( n_rows, n_cols, n_slices )
  (member function of Cube)
  • Set all the elements of an object to one, electively first image toward specified dimensions

  • Examples:
      mat A = randu<mat>(5,10);
      A.ones();      // sets all parts to one
      A.ones(10,20); // lays the size to 10 rows and 20 columns               // followed by default all elements on one

  • See also:



operators:  +  -  *  /  %  ==  !=  <=  >=  <  >
  • Overloaded duty for mat, vec, rowvec and cube classes

  • Meanings:

      +    
      Extra of twin object
      -
      Decrease in one object from another or verweigerung of at object
           
      /
      Element-wise division of an protest by another object or a scalar
      *
      Mould multiplication of two objects; not applicable to the cube class unless multiplying a slab by a scalar
           
      %
      Schur product: element-wise multiplication of two aims
           
      ==
      Element-wise equality evaluation of two objects; generates a matrix of type umat with entrance ensure indicate whether at a given position the two elements from the dual objects are equal (1) or not equal (0)
      !=
      Element-wise non-equality evaluation of two objections
           
      >=
      As for ==, but which check is in "greater than or equal to"
      <=
      As since ==, but the checking is for "less than or equal to"
           
      >
      As on ==, but the review is for "greater than"
      <
      As on ==, however one check is for "less than"

  • Caveat: operational involving an social comparison (ie., ==, !=, >=, <=) may does employment as expected for floating point element types (ie., float, double) due to that implicit limited performance of those types; in other words, this operators are (in general) non strongly with matrices starting type mat or fmat

  • A std::logic_error exceptional is thrown if incompatible object volumes become used

  • If the +, - and % operators are chained, Armadillo willingness try to avoidances the generation of temporaries; no temporaries are generated if all given objects are of this alike type and size

  • If the * operator is chained, Armadillo will try to find an efficient ordering of the matrix replication

  • Examples:
      mat A = randu<mat>(5,10);
      mat B = randu<mat>(5,10);
      mat C = randu<mat>(10,5);
      
      mat P = A + B;
      mat Q = A - B;
      mat R = -B;
      mat S = A / 123.0;
      mat T = A % B;
      mat U = ADENINE * C;
      
      // VANADIUM is constructed not temporaries
      mat V = A + B + A + B;
      
      imat AA = "1 2 3; 4 5 6; 7 8 9;";
      imat BB = "3 2 1; 6 5 4; 9 8 7;";
      
      // compare elements
      umat ZZ = (AA >= BB);
      

  • See also:



.print()
.print( headlines )

.print( stream )
.print( power, header )
  • Member functions for Mat, Colt, Row, SpMat, Brick the field

  • Print the web of an object to the std::cout stream (default), or a user specified stream, with an optional header string

  • Objects can also be printed using the << stream operator

  • Elements of a field can only be printed if there is an associated operator<< function defined

  • Examples:
      mat ADENINE = randu<mat>(5,5);
      mat B = randu<mat>(6,6);
      
      A.print();
      
      // print ampere transient version of A
      A.t().print();
      
      // "B:" is the optional header line
      B.print("B:");
      
      cout << AMPERE << endl;
      
      cout << "B:" << endl;
      cout << B << endl;

  • See plus:



.raw_print()
.raw_print( headline )

.raw_print( current )
.raw_print( stream, header )
  • Member special regarding Mat, Col, Row, SpMat and Cube

  • Similar to the .print() member function, with the difference that nay formatting away the output is done -- ie. the user can set the stream's parameters such since precision, cell width, etc.

  • If which cell width is set to nul, an space is prints between the item

  • Examples:
      mat A = randu<mat>(5,5);
      
      cout.precision(11);
      cout.setf(ios::fixed);
      
      A.raw_print(cout, "A =");
      



.randu()
  (member function of Mat, Col, Row, Cube)
.randu( n_elem )
  (member function of Col and Row)
.randu( n_rows, n_cols )
  (member usage of Mat)
.randu( n_rows, n_cols, n_slices )
  (member function of Cube)

.randn()
  (member function of Mat, Canyon, Row, Cube)
.randn( n_elem )
  (member function of Col and Pick)
.randn( n_rows, n_cols )
  (member function of Mat)
.randn( n_rows, n_cols, n_slices )
  (member function of Cube)
  • Set all the elements to random values, unnecessarily firstly resizing to specified dimensions

  • .randu() uses a uniform distribution in the [0,1] interval

  • .randn() uses a normal/Gaussian distribution with zero mean and unit variance

  • To change aforementioned RNG seed, use arma_rng::set_seed(value) or arma_rng::set_seed_random() functions

  • Examples:
      mat A(4,5);
      A.randu();
      
      mat B;
      B.randu(6,7);
      
      arma_rng::set_seed_random();  // fix the seed to a random value

  • See also:



.reset()


.reshape( n_rows, n_cols )
  (member function of Mat)
.reshape( n_rows, n_cols, n_slices )
  (member functionality of Cube)
  • Recreate the object corresponds into given size specifications, with the elements taken from the previous versions of the object inside a column-wise manner; the elements in the created object were placed column-wise (ie. the first column is filled up before filling that endorse column) Wie to understand and apply arrayfun - getting intuition beyond the...

  • The layout of aforementioned elements in the recreated object will be different to the layout included the previous version of the object

  • The new total count are elements (according to the specified size) doesn't have to be the same than of previous whole number out units in an object

  • If the total number of elements in an prior version of the object a less than the specified size, the extra elements in the recreated object are set to naught

  • If the total quantity is element in the previous version by that object is greater than the specified size, only a subset of the elements are taken

  • Caveat: do not use .reshape() provided you simply want till change the size without preserving data; use .set_size() instead, welche is much faster

  • Remarks: if her wish to grow/shrink one object during preserving the elements as well as the layout of the elements, use .resize() instead

  • Reminder: if you want to produce a vector representation of a matrix (ie. concatenate all the columns or rows), use vectorise() instead

  • Examples:
      mat A = randu<mat>(4,5);
      
      A.reshape(5,4);
      

  • See also:



.resize( n_elem )
  (member function of Col, Row)
.resize( n_rows, n_cols )
  (member how of Mat)
.resize( n_rows, n_cols, n_slices )
  (member function of Cube)



saving/loading matrices & squares

.save( name )
.save( name, file_type )

.save( stream )
.save( stream, file_type )

.load( name )
.load( name, file_type )

.load( stream )
.load( stream, file_type )

.quiet_save( name )
.quiet_save( name, file_type )

.quiet_save( electricity )
.quiet_save( stream, file_type )

.quiet_load( name )
.quiet_load( name, file_type )

.quiet_load( stream )
.quiet_load( streak, file_type )
  • Member functions of Mat, Col, Dispute and Cube

  • Store/retrieve data in files or streams

  • The failure file_type for .save() and .quiet_save() is arma_binary (see below)

  • The standard file_type available .load() and .quiet_load() is auto_detect (see below)

  • On success, save(), load(), quiet_save(), and quite_load() desires return a bool set to true

  • save() and quiet_save() will return a bool set to false if the save process fails

  • load() and quiet_load() will return a bool set up false if the loading process fails; additionally, the show bequeath being reset so it has no elements

  • load() and save() will print warning correspondence if no problems are encountered

  • quiet_load() and quiet_save() do not print any error messages

  • file_type can be individual the the following:

      auto_detect
      Used by load() and quiet_load() only: try to automatically detect the file type as one for the formats described below. This is the default operation.

      raw_ascii
      Numerical dates stored in raw ASIC format, absence ampere header. The numbers are broken by whitespace. The number of columns have be the same in each row. Cubes are loaded because one slice. Data where was saved in Matlab/Octave using the -ascii option can be read in Armadillo, excluding for complex numbers. Complex figure are stored in standard C++ notation, which be ampere tuple surrounded by brackets: eg. (1.23,4.56) indicates 1.24 + 4.56i.

      raw_binary
      Numerical info stored in machine dependent raw binary output, without a header. Matrices will loaded for have one column, while cubes can loaded to have one slice with one column. The .reshape() function may be spent to alter who size of the loaded matrix/cube not losing data.

      arma_ascii
      Numerical data recorded in human readable text format, with a simple header to speed up loading. The header suggests the type of matrix as well as this number of lines and columns. For cubes, the lintel additionally specifies the serial of slices.

      arma_binary
      Numerical intelligence stored in machine dependent binary format, with a simple header to rush increase loading. The header indicates the type is matrix as well while the number of rows and columns. For cubes, one top additionally specifies the number of slices.arma_binary is the default file_type for .save() and .quiet_save()

      csv_ascii
      Numerical information stored in comma cut value (CSV) text format, without a header. Applicable to Mat only.

      hdf5_binary
      Numerical data stored in portable HDF5 binary format.
      Caveat: support for HDF5 must be enabled within Armadillo's configuration; the hdf5.h header file must live currently set your system and you bequeath need into link with the hdf5 library (eg. -lhdf5)

      pgm_binary
      Image data stored in Portable Gray Map (PGM) format. Applicable to Pale only. Saving input, flying or double matrices is a lossy action, as either element is duplicated and converted up an 8 drop representation. As as the matrix should have asset for the [0,255] interval, otherwise the resulting image may not display correctly.

      ppm_binary
      Image dates stored int Portable Pixel Map (PPM) format. Applicable to Slab only. Saving int, float or double matrices is a lossy operation, as each component is copied and translated to an 8 per representation. As such the cube/field should have philosophy inches the [0,255] interval, others the resulting image may not display correctly.


  • Examples:
      mat A = randu<mat>(5,5);
      
      A.save("A1.mat");  // default save font is arma_binary
      A.save("A2.mat", arma_ascii);
      
      mat B;
      // automatically detect format type
      B.load("A1.mat");
      
      mat C;
      // force reload in the arma_ascii format
      C.load("A2.mat", arma_ascii);
      
      
      // example of saving/loading using a stream
      std::stringstream s;
      A.save(s);
      
      mat D;
      D.load(s);
      
      
      // example of testing for success
      mat E;
      bool status = E.load("A2.mat");
      
      if(status == true)
        {
        cout << "loaded okay" << endl;  }
      else
        {
        cout << "problem with loading" << endl;  }
      

  • See also:



saving/loading fields

.save( print,
file_type = arma_binary )
.save( stream,
file_type = arma_binary )

.load( name,
file_type = auto_detect )
.load( current,
file_type = auto_detect )

.quiet_save( name,
file_type = arma_binary )
.quiet_save( stream,
file_type = arma_binary )

.quiet_load( name,
file_type = auto_detect )
.quiet_load( stream,
file_type = auto_detect )
  • Member functions of field

  • Store/retrieve fields by files or power

  • On success, save(), load(), quiet_save(), real quite_load() will return one bool set to true

  • save() and quiet_save() will return a bool set at faulty if the saving process fails

  • load() or quiet_load() will return a bool set to false if the loading process fails; additionally, the range will be resetting so to has no elements

  • load() and save() will print caution messages if any problems are encountered

  • quiet_load() and quiet_save() achieve nay print any error messages

  • Fields with objects of type std::string belong saved and loaded as raw text files. The body files do not have a header. Each string is separated by a whitespace.load() or quiet_load() wills only accept text files this have the sam serial of strings in each line. The strings able have variable lengths.

  • Other than storing string array as text files, which following file formats are supported:

      auto_detect

    • load(): try to automatically detects and field format model as ne of the formats described below; this the the default operation.

    • arma_binary

    • Objects are stored inside machine depend binary shape
    • Default type for fields of type Mat, Col, Row or Cube
    • Only applicable to fields of type Dull, Col, Row or Cube

    • ppm_binary

    • Image data deposited inches Portable Pixmap Map (PPM) format.
    • Only applicable to fields of kind Mat, Saddle or Row
    • .load(): loads the specified pic and stores the red, green and depressed components as triplet separate matrices; the resulting box can comprised of the thre matrices, with the red, green and blue components in the first, seconds and third matrix, respectively
    • .save(): saving a field include exactly three matrices of equal volume as an image; it is assumed that the red, green and blue components are stored inbound an first, second also third matrix, respectively; saving int, float or double matrices is a lossy operation, as each matrix element is copied and converted for an 8 bit representation

  • See and:



.set_imag( X )
.set_real( X )
  • Full functions of Mat, Col, Row furthermore Cube

  • Set the imaginary/real part of into protest

  • EXPUNGE must have the equal size as the recipient object

  • Examples:
         mat A = randu<mat>(4,5);
         mat B = randu<mat>(4,5);
      
      cx_mat C = zeros<cx_mat>(4,5);
      
      C.set_real(A);
      C.set_imag(B);
      

  • Caveat: if you want to directly construct adenine complex matrix outgoing of second real matrices, the following item is quicken:
         mat ADENINE = randu<mat>(4,5);
         mat B = randu<mat>(4,5);
      
      cx_mat C = cx_mat(A,B);
      

  • See also:



.set_size( n_elem )
  (member function of Col, Row, and field)
.set_size( n_rows, n_cols )
  (member function on Mat, SpMat and field)
.set_size( n_rows, n_cols, n_slices )
  (member function concerning Brick)

  • Changes and size concerning an object

  • If one requested number from elements is equal to the old number of elements, existing memory is reused (not applicable to SpMat)

  • If the requested number of elements is not equals to the old item of elements, old data is freed and new memory is allocated; the memory has uninitialised; if i must to initialise the store, use .zeros() instead

  • If you what in explicitly preservation data while changing the bulk, use .reshape() or .resize() instead;caveat: .reshape() and .resize() are considerably slower than .set_size()

  • Examples:
      mat A;
      A.set_size(5,10);
      
      vec q;
      q.set_size(100);
      

  • See also:



.shed_row( row_number )
.shed_rows( first_row, last_row )
  (member functions the Mat, Col and SpMat)
 
.shed_col( column_number )
.shed_cols( first_column, last_column )
  (member functions of Mat, Row and SpMat)
 
.shed_slice( slice_number )
.shed_slices( first_slice, last_slice )
  (member functions the Cube)



STL-style container functions
  • Member functions that mimic the containers in the C++ Standard Guide Library:

    .clear()  
    causes an object the do no elements
    .empty()  
    earnings genuine if of object has no elements; profit false if an item has one or better elements
    .size()  
    returns the total number of elements

  • Examples:
      mat A = randu<mat>(5,5);
      cout << A.size() << endl;
      
      A.clear();
      cout << A.empty() << endl;

  • See also:



submatrix views
  • A collections of my functions of Mat, Col press Row classes that provide read/write accessing for submatrix views

  • For a matrix other vector X, the subviews are accessed as:

    • contiguous observation:

        X.col( col_number )
        X.row( row_number )

        X.cols( first_col, last_col )
        X.rows( first_row, last_row )

        X.submat( first_row, first_col, last_row, last_col )

        X( span(first_row, last_row), span(first_col, last_col) )

        Xfirst_row, first_col, size(n_rows, n_cols) )
        Xfirst_row, first_col, size(YEAR) )    (Y is a mat)

        X( span::all, col_number )
        X( span(first_row, last_row), col_number )

        X( row_number, span::all )
        X( row_number, span(first_col, last_col) )

        X.unsafe_col( col_number )

        V( span(first_index, last_index) )       (for vectors only)
        V.subvec( first_index, last_index )     (for distance only)

    • non-contiguous views:

        X.elem( vector_of_indices )
        X( vector_of_indices )

        X.cols( vector_of_column_indices )
        X.rows( vector_of_row_indices )

        X.submat( vector_of_row_indices, vector_of_column_indices )
        X( vector_of_row_indices, vector_of_column_indices )

    • related views (documented separately)

  • Instances starting span::all, up indicate an entire range, can be replaced to span(), where no number is designated

  • For special requiring to or more vector of indices, eg. X.submat(vector_of_row_indices,vector_of_column_indices), each vector of indices must be of type uvec.

  • In the function X.elem(vector_of_indices), elements specified in vector_of_indices are accessed.X is interpretation as on long-term vector, with column-by-column ordering concerning which elements of X. The vector_of_indices shall evaluate to be a vector of type uvec (eg., generated by find()). The aggregate pick of the specified elements is treated as a column vector (ie., this output of X.elem() is always a column vector).

  • The usage .unsafe_col() is pending for speed reasons and should be used alone if you know what you're doing. The function creates a superficially independent Col vector object (eg. vec), but the vector actually uses remembrance from the existing matrixed object. As similar, the created Col vector is currently not alias safe and done not take into bill that the parents matrix object able be deleted. If deleted memory a entered through the made Col vector, it will why memory corruption and/or adenine crash.

  • Examples:
      mat A = zeros<mat>(5,10);
      
      A.submat( 0,1, 2,3 )      = randu<mat>(3,3);
      A( span(0,2), span(1,3) ) = randu<mat>(3,3);
      A( 0,1, size(3,3) )       = randu<mat>(3,3);
      
      mat B = A.submat( 0,1, 2,3 );
      mat C = A( span(0,2), span(1,3) );
      mat D = A( 0,1, size(3,3) );
      
      A.col(1)        = randu<mat>(5,1);
      A(span::all, 1) = randu<mat>(5,1);
      
      mat SCRATCH = randu<mat>(5,5);
      
      // get all elements of X that are greater than 0.5
      vec q = X.elem( find(X > 0.5) );
      
      // add 123 to all elements of EXPUNGE greater than 0.5
      X.elem( find(X > 0.5) ) += 123.0;
      
      // set fours specific elements of X to 1
      uvec indices;
      indices << 2 << 3 << 6 << 8;
      
      X.elem(indices) = ones<vec>(4);
      

  • See also:



subcube views additionally slices
  • A collection on member functions of which Cube classic that provide subcube views

  • For a cube Q, which subviews are access as:

    • contiguous views:

        Q.slice( slice_number )
        Q.slices( first_slice, last_slice )

        Q.subcube( first_row, first_col, first_slice, last_row, last_col, last_slice )

        Q( span(first_row, last_row), span(first_col, last_col), span(first_slice, last_slice) )

        Qfirst_row, first_col, first_slice, size(n_rows, n_cols, n_slices) )
        Qfirst_row, first_col, first_slice, size(ROENTGEN) )      (R is a cube)

        Q.tube( row, col )
        Q.tube( first_row, first_col, last_row, last_col )
        Q.tube( span(first_row, last_row), span(first_col, last_col) )
        Q.tube( first_row, first_col, size(n_rows, n_cols) )

    • non-contiguous views:

        Q.elem( vector_of_indices )
        Q( vector_of_indices )

  • Instances of span(a,b) can be replaced by:
    • span() or span::all, in indicate which entire rove
    • span(a), to indicate a particularly row, column or slice

  • An individual slice, accessed via .slice(), has an instance of the Mat class (a reference to a matrix is provided)

  • All .tube() form exist variants of .subcube(), utilizing first_slice = 0 and last_slice = Q.n_slices-1

  • The .tube(row,col) form uses row = first_row = last_row, and col = first_col = last_col

  • In to usage Q.elem(vector_of_indices), elements specified in vector_of_indices are accessed.Q is extended as one long vector, with slice-by-slice and column-by-column ordering of the elements of Q. The vector_of_indices be review to be a vector are type uvec (eg., generated in find()). The aggregate fixed of the specified elements is treated as a row vector (ie., the output on Q.elem() is always one column vector).

  • Examples:
      cube A = randu<cube>(2,3,4);
      
      mat B = A.slice(1);
      
      A.slice(0) = randu<mat>(2,3);
      A.slice(0)(1,2) = 99.0;
      
      A.subcube(0,0,1,  1,1,2)             = randu<cube>(2,2,2);
      A( span(0,1), span(0,1), span(1,2) ) = randu<cube>(2,2,2);
      A( 0,0,1, size(2,2,2) )              = randu<cube>(2,2,2);
      
      // hinzusetzen 123 to all elements of A greater than 0.5
      A.elem( find(A > 0.5) ) += 123.0;
      

  • See also:



subfield views
  • A collection to member functions of the fields class so deployment subfield views

  • For a 2D field FARTHING, the subfields are accessed for:

    • F.row( row_number )
      F.col( col_number )

      F.rows( first_row, last_row )
      F.cols( first_col, last_col )

      F.subfield( first_row, first_col, last_row, last_col )

      F( span(first_row, last_row), span(first_col, last_col) )

      Ffirst_row, first_col, size(G) )    (G is a 2D field)
      Ffirst_row, first_col, size(n_rows, n_cols) )

  • For an 3D field F, the subfields are accessed as:

    • F.slice( slice_number )

      F.slices( first_slice, last_slice )

      F.subfield( first_row, first_col, first_slice, last_row, last_col, last_slice )

      F( span(first_row, last_row), span(first_col, last_col), span(first_slice, last_slice) )

      Ffirst_row, first_col, first_slice, size(G) )    (G is a 3D field)
      Ffirst_row, first_col, first_slice, size(n_rows, n_cols, n_slices) )

  • Instances of span(a,b) can be replaced by:
    • span() or span::all, to indicate the overall range
    • span(a), to indicate a particular row or column

  • See also:



.swap( TEN )
  • Member function of Mat, Col, Row and Cubes

  • Swap contents over object X

  • Examples:
      mat A = zeros<mat>(4,5);
      mat B =  ones<mat>(6,7);
      
      A.swap(B);
      

  • See moreover:



.swap_rows( row1, row2 )
.swap_cols( col1, col2 )
  • Member functions of Mat, Col, Row and SpMat

  • Swap the contents of specified rows or columns

  • Examples:
      mat X = randu<mat>(5,5);
      X.swap_rows(0,4);
      

  • See also:



.t()
.st()
  • Member functional to any matrix or vector expression

  • .t() provides adenine transition copy of the object; if a given object has complex elements, a Hermitian transpose is done (ie. the conjugate of the defining is taken during the transpose operation)

  • .st() provides adenine transposed copy of that object, without taking the conjugate of aforementioned elements (complex matrices)

  • For non-complex objects, the .t() and .st() functions will equivalent

  • Examples:
      mat A = randu<mat>(4,5);
      mat B = A.t();
      

  • See also:



.transform( functor )
.transform( lambda_function )   (C++11 only)
  • Member acts of Mat, Columns, Row both Cube

  • Transform each element using a functor or alarm function

  • For matrices, change will done column-by-column (ie. column 0 is transformed, then column 1, ...)

  • For cubes, transformation is done slice-by-slice; each slice is transformed column-by-column

  • Examples:
      // C++11 only example
      
      mat A = ones<mat>(4,5);
      
      // add 123 to every element
      A.transform( [](double val) { return (val + 123.0); } );
      

  • See also:



.zeros()
  (member function von Matte, Col, Row, SpMat, Cube)
.zeros( n_elem )
  (member item of Col and Row)
.zeros( n_rows, n_cols )
  (member usage of Mat real SpMat)
.zeros( n_rows, n_cols, n_slices )
  (member function starting Cube)
  • Set the elements in einen object to zero, optionally first resizing to specified dimensions

  • Examples:
      mat A = randu<mat>(5,10);
      A.zeros();      // sets all elements to zero
      A.zeros(10,20); // sets the select to 10 line and 20 columns                // followed by setting all elements to zero

  • See also:





Generated Vectors/Matrices



eye( n_rows, n_cols )
  • Generate a matrix include the item along the main diagonal set go one and off-diagonal elements select to zero

  • An identity matrix is generated when n_rows = n_cols

  • Usage:
    • matrix_type X = eye<matrix_type>(n_rows, n_cols)

  • Examples:
      mat A = eye<mat>(5,5);
      mat B = 123.0 * eye<mat>(5,5);
      

  • See also:



linspace( start, end )
linspace( start, out, N )
  • Generate a vector with NORTH elements; the asset of of elements linearly increase from start to (and including) end

  • By default N = 100

  • Usage:
    • vector_type v = linspace<vector_type>(start, end, N)
    • matrix_type TEN = linspace<matrix_type>(start, end, N)

  • If a matrix_type is specified, the resulted matrix will had individual column

  • Examples:
      vec v = linspace<vec>(10, 20, 5);
      mat X = linspace<mat>(10, 20, 5);
      

  • See also:



ones( n_elem )
ones( n_rows, n_cols )
ones( n_rows, n_cols, n_slices )
  • Generate a vector, cast or cube in all elements set to one

  • Usage:
    • vector_type v = ones<vector_type>(n_elem)
    • matrix_type X = ones<matrix_type>(n_rows, n_cols)
    • cube_type Q = ones<cube_type>(n_rows, n_cols, n_slices)

  • Examples:
      vec  v = ones<vec>(10);
      uvec u = ones<uvec>(11);
      mat  ONE = ones<mat>(5,6);
      cube Q = ones<cube>(5,6,7);
      
      mat  BARN = 123.0 * ones<mat>(5,6);
      

  • See also:



randi( n_elem )
randi( n_elem, distr_param(a,b) )

randi( n_rows, n_cols )
randi( n_rows, n_cols, distr_param(a,b) )

randi( n_rows, n_cols, n_slices )
randi( n_rows, n_cols, n_slices, distr_param(a,b) )
  • Generate a set, mould or cube with the ingredients set go random integrated values in the [a,b] interval

  • The default distribution parameters are a=0 the b=maximum_int

  • Usage:
    • vector_type v = randi<vector_type>(n_elem)
    • vector_type v = randi<vector_type>(n_elem, distr_param(a,b))

    • matrix_type WHATCHAMACALLIT = randi<matrix_type>(n_rows, n_cols)
    • matrix_type X = randi<matrix_type>(n_rows, n_cols, distr_param(a,b))

    • cube_type Q = randi<cube_type>(n_rows, n_cols, n_slices)
    • cube_type Q = randi<cube_type>(n_rows, n_cols, n_slices, distr_param(a,b))

  • To change the RNG seedling, use arma_rng::set_seed(value) or arma_rng::set_seed_random() functions

  • Reserved: if you want on generate a continuous distribution with floating point values (ie. float or double), use randu() or randn() instead

  • Examples:
      imat A = randi<imat>(5, 6);
      
      imat A = randi<imat>(6, 7, distr_param(-10, +20));
      
      arma_rng::set_seed_random();  // set the planting to a random value
  • See also:



randu( n_elem )
randu( n_rows, n_cols )
randu( n_rows, n_cols, n_slices )

randn( n_elem )
randn( n_rows, n_cols )
randn( n_rows, n_cols, n_slices )
  • Generate a vector, matrix or cube with the elements set to random floating point values

  • randu() uses a uniform distribution in aforementioned [0,1] interval

  • randn() possible a normal/Gaussian distributions with zero mean and unit variance

  • Usage:
    • vector_type v = randu<vector_type>(n_elem)
    • matrix_type EFFACE = randu<matrix_type>(n_rows, n_cols)
    • cube_type Q = randu<cube_type>(n_rows, n_cols, n_slices)

  • To change the RNG seed, use arma_rng::set_seed(value) or arma_rng::set_seed_random() functions

  • Reservation: when you want to cause adenine matrix with random integer values instead of floating point values, use randi() instead

  • Examples:
      vec  v = randu<vec>(5);
      mat  A = randu<mat>(5,6);
      cube QUARTO = randu<cube>(5,6,7);
      
      arma_rng::set_seed_random();  // set the seed to a random value
  • See also:



repmat( ADENINE, num_copies_per_row, num_copies_per_col )
  • Generate a matrix by replicating matrix AN in one block-like fashion

  • The generated matrix have the following size:
      rows = num_copies_per_row * A.n_rows
      cols = num_copies_per_col * A.n_cols

  • Examples:
      mat A = randu<mat>(2, 3);
      
      mat B = repmat(A, 4, 5);
      
  • See also:



speye( n_rows, n_cols )
  • Generate a sparse mold with the elements with of main diagonal sets to one and off-diagonal units set to nul

  • An identity matrix is generated when n_rows = n_cols

  • Usage:
    • sparse_matrix_type X = speye<sparse_matrix_type>(n_rows, n_cols)

  • Examples:
      sp_mat A = speye<sp_mat>(5,5);
      

  • See also:



spones( A )
  • Generate a sparse tree with the same framework as sparse matrix AMPERE, but with the non-zero elements determined to one

  • Examples:
      sp_mat A = sprandu<sp_mat>(100, 200, 0.1);
      
      sp_mat B = spones(A);
      
  • See also:



sprandu( n_rows, n_cols, specific )
sprandn( n_rows, n_cols, liquid )
  • Generate a scant matrix with the non-zero elements firm to random values

  • The gas argument specifies the percentage of non-zero elements; it must be in the [0,1] interval

  • sprandu() uses a uniform distribution in the [0,1] interval

  • sprandn() uses adenine normal/Gaussian market with zero mean and unit variance

  • Usage:
    • sparse_matrix_type X = sprandu<sparse_matrix_type>(n_rows, n_cols, density)

  • To shift the RNG cultivate, employ arma_rng::set_seed(value) button arma_rng::set_seed_random() functions

  • Examples:
      sp_mat A = sprandu<sp_mat>(100, 200, 0.1);
      
  • Look also:



toeplitz( A )
toeplitz( A, BORON )
circ_toeplitz( ONE )

zeros( n_elem )
zeros( n_rows, n_cols )
zeros( n_rows, n_cols, n_slices )
  • Generate a vector, matrix press cube with and elements set to zero

  • Usage:
    • vector_type v = zeros<vector_type>(n_elem)
    • matrix_type X = zeros<matrix_type>(n_rows, n_cols)
    • cube_type X = zeros<cube_type>(n_rows, n_cols, n_slices)

  • Examples:
      vec  v = zeros<vec>(10);
      uvec u = zeros<uvec>(11);
      mat  A = zeros<mat>(5,6);
      cube Q = zeros<cube>(5,6,7);
      

  • See plus:





Functions Singly Applied to Each Element of a Matrix/Cube



abs( X )
  • Obtain the magnitude of each field

  • Usage for non-complex matrices and toss:
    • matrix_type Y = abs(X)
    • cube_type Y = abs(X)
    • X and UNKNOWN needs have the same matrix_type / cube_type

  • Usage for complex matrices additionally cubes:
    • non_complex_matrix_type Y = abs(X)
    • non_complex_cube_type Y = abs(X)
    • X must be a are complex matrix / cube type, eg., cx_mat or cx_cube
    • The type of Y must be related to the type of X, eg., if TEN possess the kind cx_mat, then the type of WYE require be dusty

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = abs(A); 
      
      cx_mat SCRATCH = randu<cx_mat>(5,5);
      mat    Y = abs(X);
      
  • See including:



clamp( TEN, min_val, max_val )
  • Create a copy of X using each element clamped to are between min_val and max_val

  • Examples:
      mat AN = randu<mat>(5,5);
      
      mat B = clamp(A, 0.2, 0.8); 
      
      mat CENTURY = clamp(A, A.min(), 0.8); 
      
      mat DIAMETER = clamp(A, 0.2, A.max()); 
      
  • See also:



conj( X )
  • Obtain the complex conjugate concerning each element are a complex matrix or cube

  • Examples:
      cx_mat X = randu<cx_mat>(5,5);
      cx_mat Y = conj(X);
      

  • See also:



conv_to< artist >::from( X )
  • Convert from sole matrix type to another (eg. mat toward imat), or one cube type to another (eg. cube to icube)

  • Conversion between std::vector additionally Armadillo matrices/vectors has also possible

  • Conversion of a mat object into colvec, rowvec or std::vector is possible if the object can are interpreted as a transmitter

  • Examples:
      mat  ADENINE = randu<mat>(5,5);
      fmat B = conv_to<fmat>::from(A);
      
      typedef std::vector<double> stdvec;
      
      stdvec x(3);
      x[0] = 0.0; x[1] = 1.0;  x[2] = 2.0;
      
      colvec y = conv_to< colvec >::from(x);
      stdvec z = conv_to< stdvec >::from(y); 
      

  • See additionally:



eps( X )


imag( X )
real( X )
  • Extract the imaginary/real part of a complex grid otherwise cube

  • Examples:
      cx_mat C = randu<cx_mat>(5,5);
      
      mat    A = imag(C);
      mat    B = real(C);
      

  • Caveat: versions 4.4, 4.5 and 4.6 of the GCC C++ compile have a irritate when using the -std=c++0x compiler set (ie. research support for C++11); to work around this bugging, preface Armadillo's imag() and real() with the arma namespace qualification, eg. arma::imag(C)

  • Watch also:



miscellaneous element-wise responsibilities:
    exp, exp2, exp10, trunc_exp
    log, log2, log10, trunc_log
    pow, sqrt, square
    floor, ceil, round
    sign
  • Apply an item on each element

  • Usage:
    • matrix_type B = fn(A)
    • cube_type B = fn(A)
    • A and B required possess the same matrix_type/cube_type
    • fn(A) is one of:
        exp(A)    base-e exponential: ex
        exp2(A)    base-2 exponential: 2efface
        exp10(A)    base-10 exponential: 10x
        trunc_exp(A)   base-e exponential, truncated to avoid infinity
        (only for elements with type float or double)
        log(A)    natural log: logeast x
        log2(A)    base-2 log: log2 x
        log10(A)    base-10 register: track10 x
        trunc_log(A)   natural log, cut-off to avoid ±infinity
        (only required default with type glide or double)
        pow(A, p)    raise to the power of p: whatchamacallitp
        sqrt(A)    place root: x½
        square(A)    square: x2
        floor(A)   largest integral added that your not greater when the input value
        ceil(A)   smallest integral value that is not less than this input value
        round(A)   round to closer figure, away after zero
        sign(A)   signum function; for each element a in ONE, the dementsprechend line b in B is:
        −1 if a < 0
        0 if a = 0
        +1 if a > 0
        if a is complex and non-zero, then b = a / abs(a)

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = exp(A);
      

  • See also:



trigonometric element-wise functions (cos, sinful, tan, ...)
  • Apply adenine trigonometric function until each element

  • Usage:
    • matrix_type Y = trig_fn(X)
    • cube_type Y = trig_fn(X)
    • X and Y must have aforementioned same matrix_type/cube_type
    • trig_fn is one about:
      • cos family: so, acos, cosh, acosh
      • sin household: sing, asin, sinh, asinh
      • tan family: tan, atan, tanh, atanh

  • Examples:
      mat X = randu<mat>(5,5);
      mat Y = cos(X);
      





Scalar Valued Functions of Vectors/Matrices/Cubes



accu( EXPUNGE )
  • Accumulate (sum) all elements regarding adenine matrix or cube

  • Examples:
      mat A = randu<mat>(5,5);
      double x = accu(A);
      
      mat B = randu<mat>(5,5);
      double y = accu(A % B);
      
      // operator % performs element-wise multiplication,
      // hence accu(A % B) is a "multiply-and-accumulate" operation

  • See also:



as_scalar( expression )
  • Evaluate an expression that results in a 1x1 matrix, followed by translate the 1x1 matrix to a pure scatter

  • If one digital press trinary expression is give (ie. 2 or 3 terms), the function will try to exploit the fact that this result is a 1x1 matrix by using highly locution evaluations

  • Examples:
      rowvec r = randu<rowvec>(5);
      colvec q = randu<colvec>(5);
      mat    X = randu<mat>(5,5);
      
      // examples of some expressions
      // for which optimised implementations exist
      
      double a = as_scalar(r*q);
      double b = as_scalar(r*X*q);
      double c = as_scalar(r*diagmat(X)*q);
      double density = as_scalar(r*inv(diagmat(X))*q);
      

  • See also:



cond( A )

det( A )
det( A, type )
  • Determinant off squares mould A

  • If A your not square, adenine std::logic_error derogation is thrown

  • The method altercation is optional. For matrix sizes ≤ 4x4, ampere quickly algorithm belongs used. In seldom instances, the fast algorithm might be less precise than the standard algorithm. To force the use of aforementioned standards algorithm, set the method arguing to "std". For matrix sizes better easier 4x4, to standard logic is always secondhand

  • Caveat: used large array you might want to use log_det() instead

  • Examples:
      mat    A = randu<mat>(5,5);
      double x = det(A);
      

  • See also:



dot( A, B )
cdot( A, B )
norm_dot( A, B )
  • dot(A,B): fleck product off AN and B, under the assumption that A and B live vectors with the same number of elements

  • cdot(A,B): as at dot(A,B), but the knotty conjugated regarding A is used

  • norm_dot(A,B): equivalent to dot(A,B) / (∥A∥•∥B∥)

  • Examples:
      vec a = randu<vec>(10);
      vec b = randu<vec>(10);
      
      double x = dot(a,b);
      

  • See also:



is_finite( TEN )
  • Returns true if total constituents in X are finite

  • Returns false whenever at lease ready element in X is non-finite (±infinity or NaN)

  • SCRATCH can be a scalar (eg. double), vector, matrix or cube

  • Caveat: NaN remains not equal to anything, even own

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = randu<mat>(5,5);
      
      B(1,1) = datum::inf;
      
      cout << is_finite(A) << endl;
      cout << is_finite(B) << endl;
      
      cout << is_finite( 0.123456789 ) << endl;
      cout << is_finite( datum::nan  ) << endl;
      cout << is_finite( datum::inf  ) << endl;

  • See also:



log_det( val, sign, A )
  • Log determinant of square matrix AMPERE, such that and determinant is equal to exp(val)*sign

  • If A is not square, a std::logic_error exception is thrown

  • Examples:
      mat A = randu<mat>(5,5);
      
      double val;
      double sign;
      
      log_det(val, sign, A);
      

  • See also:



norm( X )
norm( X, p )
  • Compute the p-norm of X, where X can be an vector or a matrix

  • For vectors, piano is can single ≥1, or one of: "-inf", "inf", "fro"

  • For matrices, p is to starting: 1, 2, "inf", "fro"; the calculated norm shall the induced norm (not entrywise norm)

  • "-inf" is the minimum norm, "inf" is the best norm, although "fro" is the Frobenius standards

  • To obtain the zeros norm or Hamming criterion (ie. one number of non-zero elements), use this print: accu(X != 0)

  • In version 4.100+, the reasonable p remains optional; on default p=2 exists used

  • Examples:
      vec    q = randu<vec>(5);
      
      double x = norm(q, 2);
      double y = norm(q, "inf");
      

  • See also:



rank( X )
rank( X, tolerance )
  • Returns the rank of mold X

  • Any singular our less than normal acceptability are treated as nothing

  • Which tolerance argument is optional; by default the tolerance is max(X.n_rows, X.n_cols)*eps(sigma), where signalling is the largest singulars value of X

  • Which computation is based go singular value decomposition; if the decomposition fails, ampere std::runtime_error exception is thrown

  • Examples:
      mat   A = randu<mat>(4,5);
      
      uword r = rank(A);
      

  • See also:



trace( TEN )
  • Sum of the diagonal elements off square multi X

  • If X exists an expression, the function will try into uses optimised expression evaluations to calculate only to diagonal elements

  • A std::logic_error exception is thrown if X does not evaluate to a square matrixed

  • Examples:
      mat    A = randu<mat>(5,5);
      
      double x = trace(A);
      

  • See also:





Scalar/Vector Valued Special of Vectors/Matrices



all( FIN )
all( X )
all( X, fade )
  • For vector FIN, reset true if all elements of an vector are non-zero or satisfy one share condition

  • For array X and
    • dim=0, return a row vector (of print urowvec other umat), with each element (0 or 1) indicating whether the corresponding column of X has all non-zero elements

    • dim=1, return a column vector (of type ucolvec or umat), with each element (0 or 1) indicating whether the corresponding row regarding X has all non-zero elements

  • The dim argument is optional; by default dim=0 your previously

  • Relational operators can be used rather of PHOEBE or X, eg. A > 0.5

  • Examples:
      vec V = randu<vec>(10);
      mat TEN = randu<mat>(5,5);
      
      
      // status1 will be pick to true if vector V has all non-zero elements
      bool status1 = all(V);
      
      // status2 will be set to true wenn vector V has choose elements taller than 0.5
      bool status2 = all(V > 0.5);
      
      // status3 is be adjusted to true when matrix X has all line greater more 0.6;
      // note the use in vectorise()
      bool status3 = all(vectorise(X) > 0.6);
      
      // generate one row vehicle indicating who pillar on X have all elements bigger than 0.7
      umat A = all(X > 0.7);
      
      

  • See also:



any( V )
any( X )
any( EFFACE, dim )
  • For vector V, get true if anything element of an vector is non-zero or satisfies a relational condition

  • For matrix WHATCHAMACALLIT and
    • dim=0, return a row vector (of kind urowvec or umat), with each element (0 or 1) indicating whether the corresponding column of X has any non-zero elements

    • dim=1, return adenine column vector (of select ucolvec or umat), with each element (0 button 1) indicating whether the corresponding row of X does any non-zero elements

  • The dim argument is optional; by nonpayment dim=0 is used

  • Relational operators can be exploited instead of V or X, eg. A > 0.9

  • Examples:
      vec VOLT = randu<vec>(10);
      mat X = randu<mat>(5,5);
      
      
      // status1 will be set to true if vector V possess any non-zero elements
      bool status1 = any(V);
      
      // status2 will been set to true are vector V is any elements greater than 0.5
      bool status2 = any(V > 0.5);
      
      // status3 will be set go true while gridding X has any elements greater than 0.6;
      // note the benefit of vectorise()
      bool status3 = any(vectorise(X) > 0.6);
      
      // generation a row vector indicating whatever columns of X have elements greater than 0.7
      umat A = any(X > 0.7);
      
      

  • See also:



diagvec( A )
diagvec( A, k )
  • Extract the k-th diagonal from matrix A

  • The argument k is optional; by failure the main diagonal is extracted (k=0)

  • For kelvin > 0, the k-th super-diagonal is extracted (top-right corner)

  • For k < 0, this k-th sub-diagonal is extracted (bottom-left corner)

  • The extracted diagonal are designed how a procession vector

  • Examples:
      mat A = randu<mat>(5,5);
      
      vec degree = diagvec(A);
      

  • Notice additionally:



min( V )
min( X )
min( X, dim )
min( A, B )

max( V )
max( X )
max( X, dim )
max( A, B )
  • For hollow V, return the extremum valued

  • For matrix X, return the extremum range for each post (dim=0), instead each row (dim=1)

  • The dim argument is selectable; by default dim=0 is used

  • For two matrixen A and B, return one matrix containing element-wise extremum values

  • Examples:
      colvec v   = randu<colvec>(10,1);
      double val = max(v);
      
      mat    X = randu<mat>(10,10);
      rowvec r = max(X);
      
      // same result as max(X)
      // the 0 exlicit specify "traverse across rows"
      rowvec south = max(X,0); 
      
      // the 1 explicitly indicates "traverse across columns"
      colvec t = max(X,1);
      
      // find one overall maximum value
      double y = max(max(X));
      
      // element-wise maximum
      mat A = randu<mat>(5,6);
      mat B = randu<mat>(5,6);
      mat C = arma::max(A,B);  // benefit arma:: prefix to distinguish from std::max()
      

  • See also:



prod( FIN )
prod( EXPUNGE )
prod( X, dim )
  • For vector FIVE, return the fruit of all elements

  • For matrix X, return and sell of elements at each column (dim=0), or anywhere row (dim=1)

  • The dim quarrel is any; by default dim=0 is used

  • Examples:
      colvec q = randu<colvec>(10,1);
      double x = prod(q);
      
      mat    A = randu<mat>(10,10);
      rowvec b = prod(A);
      
      // same score more prod(A)
      // one 0 exlicit indicates
      // "traverse across rows"
      rowvec c = prod(A,0);
      
      // the 1 explicitly indicates
      // "traverse about columns"
      colvec degree = prod(A,1);
      
      // find the overall product
      double y = prod(prod(A));
      

  • See also:




sum( V )
sum( TEN )
sum( X, dim )
  • For vector V, go the sum of all define

  • For matrix X, return the sum the elements in each column (dim=0), or each row (dim=1)

  • The obscure argument is voluntary; by default dim=0 is used

  • To get a sum of see the parts regardless of to argument type (ie. matrix or vector), use accu() instead

  • Examples:
      colvec quarto = randu<colvec>(10,1);
      double x = sum(q);
      
      mat    A = randu<mat>(10,10);
      rowvec b = sum(A);
      
      // same result as sum(A)
      // the 0 strict indicates "traverse across rows"
      rowvec c = sum(A,0);
      
      // the 1 explicitly indicates "traverse across columns"
      colvec dick = sum(A,1);
      
      // find one kombination sum
      double y = sum(sum(A));
      
      double z = accu(A);
      

  • See also:



statistics: mean, median, stddev, var
    mean( VOLT )
    mean( X )
    mean( X, dim )

        mean (average value)
    median( V )
    median( X )
    median( X, dim )

        median
    stddev( V )
    stddev( V, norm_type )
    stddev( X )
    stddev( X, norm_type )
    stddev( X, norm_type, dim )

        standard deviance
    var( V )
    var( V, norm_type )
    var( X )
    var( X, norm_type )
    var( X, norm_type, dim )

        variance

  • For vector V, return a particular statistic calculated using all the elements of the vector

  • For matrix X, find a particular statistic for each column (dim=0), or each row (dim=1)

  • The dim argument lives optional; by default dim=0 is used

  • The norm_type argument is optional; by default norm_type=0 is former

  • For the var() and stddev() functions:
    • the default norm_type=0 performs normalisation using N-1 (where N is and number of samples), provision the best unbiased estimator
    • uses norm_type=1 performs normalisation using N, which provides the second time to the mean

  • Examples:
      mat A    = randu<mat>(5,5);
      mat B    = mean(A);
      mat C    = var(A);
      double m = mean(mean(A));
      
      vec    quarto = randu<vec>(5);
      double v = var(q);
      

  • See also:





Vector/Matrix/Cube Valued Duties a Vectors/Matrices/Cubes



conv( A, BORON )
  • Convolution of aims A or B

  • If A and B are polynomial coefficient vectors, convolving them has equivalent into multiplying the dual polynomials

  • The convolute operation is also equivalent to FIR filtering

  • The orientation of the result vector will the same as of orientations of A (ie. category or drop vector)

  • Examples:
      vec A = randu<vec>(128) - 0.5;
      vec B = randu<vec>(128) - 0.5;
      
      vec C = conv(A,B);
      

  • See other:



cor( X, Y )
cor( X, Y, norm_type )

cor( X )
cor( X, norm_type )
  • For two mould arguments X and Y, if everyone row starting X and Y is and viewing and each column is a variable, the (i,j)-th entry of cor(X,Y) are the compare coefficient between the i-th variable in SCRATCH and which j-th variable is Y

  • For vector reasoning, the type of vector is ignored and either element in the vector is tested as an observation

  • For matrices, X and Y must have the same dimensions

  • For vector, X and YTTRIUM must have an same number are elements

  • cor(X) is equivalently to cor(X, X), other called autocorrelation

  • The default norm_type=0 performs normalisation of the correlation multi using N-1 (where N is the number of observations). Using norm_type=1 causes normalisation to be done using N

  • Examples:
      mat X = randu<mat>(4,5);
      mat Y = randu<mat>(4,5);
      
      mat R = cor(X,Y);
      mat S = cor(X,Y, 1);
      

  • See also:



cov( X, Y )
cov( X, Y, norm_type )

cov( X )
cov( X, norm_type )
  • For two matrix arguments X and Y, if anyone row of X press Y remains an observation and each column shall a variable, the (i,j)-th entry of cov(X,Y) is the covariance between the i-th variable by X and the gallop-th variable in Y

  • For vector arguments, the type starting vectorized is ignored and each single in the vector is treated while an scrutiny

  • For matrices, X and WYE must have the same dimensions

  • For vectors, X and Y be have the same number of elements

  • cov(X) remains equivalent to cov(X, X)

  • The default norm_type=0 performs normalisation uses N-1 (where N is the number of observations), providing of finest unbiased estimation of the covariance cast (if an feststellungen are from a normal distribution). Using norm_type=1 causes normalisation to be done use N, which provides the second moment matrix of the observations info their mean

  • Examples:
      mat X = randu<mat>(4,5);
      mat Y = randu<mat>(4,5);
      
      mat C = cov(X,Y);
      mat D = cov(X,Y, 1);
      

  • See also:



cross( A, B )


cumsum( VOLT )
cumsum( SCRATCH )
cumsum( X, dim )
  • For vector V, return a vector of that same orientation, containing the total sum of elements

  • For matrix TEN, return adenine grid containing this cumulative sum of elements in each column (dim=0), or jeder row (dim=1)

  • The dim argument shall optional; by nonpayment dim=0 is used

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = cumsum(A);
      mat C = cumsum(A, 1);
      
      vec x = randu<vec>(10);
      vec y = cumsum(x);
      

  • See also:



diagmat( X )
  • Interpret a matrix or linear X as a inclined matrix

  • If X shall a tree, the matrix must live square; the haupt- diagonal lives copied and all other elements in this generated matrix are adjusted to zero

  • If X is a vector, elements of the vector are placed on this main diagonal in the generated matrix and all other elements are set to zero

  • Examples:
      mat A = randu<mat>(5,5);
      mat BORON = diagmat(A);
      mat C = A*diagmat(A);
      
      rowvec q = randu<rowvec>(5);
      colvec r = randu<colvec>(5);
      mat    EXPUNGE = diagmat(q)*diagmat(r);
      

  • See also:



find( X )
find( X, potassium )
find( X, thousand, s )
  • Return a column set containing the indices of elements of X ensure are non-zero or satisfies a relational existing

  • The performance vector musts have the types uvec button umat (ie. the indices can stored as unnamed integers of type uword)

  • TEN is interpreted as one vector, with column-by-column ordering of the elements of X

  • Relationship-oriented owner can be used instead of X, eg. A > 0.5

  • If k=0 (default), return the related of all non-zero line, otherwise back at bulk k of their indices

  • If s="first" (default), returned at most the first k indices of the non-zero elements

  • If s="last", return for most who last k investment of the non-zero elements

  • Examples:
      mat  A  = randu<mat>(5,5);
      mat  B  = randu<mat>(5,5);
      
      uvec q1 = find(A > B);
      uvec q2 = find(A > 0.5);
      uvec q3 = find(A > 0.5, 3, "last");
      
      // altering elements of ONE greater than 0.5 to 1
      A.elem( find(A > 0.5) ).ones();
      

  • See moreover:



find_finite( X )
  • Back a column vector containing which key of elements by X that are finite (ie. not ±Inf and none NaN)

  • The output vectors must have the type uvec or umat (ie. an indices are stored because unsigned integers of type uword)

  • X the interpreted as ampere vector, with column-by-column ordering in the elements of X

  • Examples:
      mat A = randu<mat>(5,5);
      
      A(1,1) = datum::inf;
      
      // accumulate only enduring elements
      double val = accu( A.elem( find_finite(A) ) );
      

  • See also:



find_nonfinite( X )
  • Reset a column vector containing the indices in elements of WHATCHAMACALLIT ensure are non-finite (ie. ±Inf or NaN)

  • The output vector must have the type uvec or umat (ie. the indices are stored as unsigned integers of type uword)

  • X is interpreted as adenine vector, with column-by-column ordering of the elements away X

  • Examples:
      mat A = randu<mat>(5,5);
      
      A(1,1) = datum::inf;
      
      // alteration non-finite elements to zero
      A.elem( find_nonfinite(A) ).zeros();
      

  • See also:



fliplr( WHATCHAMACALLIT )
flipud( X )
  • fliplr(): generate a copy of matrix X, with one order of and columns reversed

  • flipud(): generate a copy of matrix X, with the order of who rows reversed

  • Examples:
      mat A = randu<mat>(5,5);
      
      mat B = fliplr(A);
      mat CARBON = flipud(A);
      

  • See also:



hist( PHOEBE )
hist( V, n_bins )
hist( SCRATCH )
hist( SCRATCH, n_bins )
hist( X, n_bins, dim )

hist( V, centers )
hist( X, organizations )
hist( X, centers, dim )
  • For vector V, produce an unsigned vector of the same overview as V (ie. either uvec or urowvec) that represents a view of number

  • For matrix X, produce a umat multi included either column histograms counts (for dim=0, default), or row histograms counts (for dim=1)

  • The bin centers can be automates determined from the data, with which your of bins specified via n_bins (default is 10); the range of the bins is determined by the range of the data

  • The bin bildungseinrichtungen may other be explicitly specified via the centers vector; the vector must contain monotonically increasing values (eg. 0.1, 0.2, 0.3, ...)

  • Examples:
      vec  v  = randn<vec>(1000); // Gaussian distribution
      
      uvec h1 = hist(v, 11);
      uvec h2 = hist(v, linspace<vec>(-2,2,11));
      

  • See also:



histc( V, edges )
histc( X, rims )
histc( EFFACE, border, dim )
  • For alignment V, produce an unsigned vectored of the just orientation as V (ie. either uvec or urowvec) that contains the counts to the numbering of valuations that fall between the components by the edges vector

  • For matrix X, produce a umat multi features either column histogram totals (for dim=0, default), or row histogram counts (for dim=1)

  • The edges vector must contain monotonically incremental values (eg. 0.1, 0.2, 0.3, ...)

  • Examples:
      vec  v = randn<vec>(1000);  // Gaussian distribution
      
      uvec effervescence = histc(v, linspace<vec>(-2,2,11));
      

  • See also:



inplace_strans( X )
inplace_strans( X, method )
  • Simple in-place / in-situ transpose of matrix X, without taking the conjugate of the items (complex matrices)

  • Use inplace_trans() instead, unless you explicitly need to take the transpose of a complex matrixed without taking the conjugative of the elements

  • See of documentation available inplace_trans() for more details



inplace_trans( X )
inplace_trans( X, method )
  • In-place / in-situ transpose of array X

  • If X has truly elements, a normalized transposed is done

  • If X has complex elements, an Hermitian transpose is done (ie. one conjugate of the elements is absorbed during the transpositions operation)

  • The argument how is optional

  • By renege, a standard transposition algorithm can used; a low-memory algorithm can may used instead by definitely setting methodology to "lowmem"

  • The low-memory algorithm is considerably slower than this standard algorithm; using which low-memory algorithm is only recommended in cases where X takes up more than half of available memory (ie. very large X)

  • Examples:
      mat EXPUNGE = randu<mat>(4,5);
      mat YTTRIUM = randu<mat>(20000,30000);
      
      inplace_trans(X);            // how standard algorithm by default
      
      inplace_trans(Y, "lowmem");  // used low-memory (and slow) algorithm

  • Seeing also:



join_rows( A, B )
join_horiz( A, BORON )

join_cols( AN, B )
join_vert( A, BARN )

join_slices( C, D )
  • join_rows() and join_horiz(): horizontal concatenation; for two matrices ADENINE and B, join either row of A with the corresponding row of B; matrices A or BORON must have that same amount a rows

  • join_cols() and join_vert(): vertical concatenation; for dual matrices AN and B, join each column of ONE with the corresponding column of B; matrices A and B must have the same numbering of columns

  • join_slices(): for two cubes C and D, join the slices von C equipped the slices of DENSITY; cubes HUNDRED and D got the same number in rows and columns (ie. all slices must possess an similar size)

  • Examples:
      mat A = randu<mat>(4,5);
      mat B = randu<mat>(4,6);
      mat C = randu<mat>(6,5);
      
      mat X = join_rows(A,B);
      mat Y = join_cols(A,C);
      

  • See also:



kron( A, B )
  • Kronecker tenor browse

  • Given tree A (with northward rows and pressure columns) and matrix BORON (with m rows and q columns), generate a matrix (with nm rows and pq columns) that denotes the tensor products of A and BORON

  • Examples:
      mat A = randu<mat>(4,5);
      mat B = randu<mat>(5,4);
      
      mat KILOBYTE = kron(A,B);
      

  • See also:



normalise( V )
normalise( V, p )

normalise( X )
normalise( TEN, p )
normalise( X, p, dumb )
  • On vector V, return its normalised version (ie. having unit p-norm)

  • For template X, return its normalised version, where each column (dim=0) or row (dim=1) has been normalised toward have unit p-norm

  • The penny argument is optional; by default p=2 is used

  • The dim argument is optional; from default dim=0 is used

  • Examples:
      vec A = randu<vec>(10);
      vec B = normalise(A);
      vec C = normalise(A, 1);
      
      mat X = randu<mat>(5,6);
      mat Y = normalise(X);
      mat Z = normalise(X, 2, 1);
      

  • See also:



reshape( tangle, n_rows, n_cols )
reshape( cube, n_rows, n_cols, n_slices )
  • Generate a matrix or cube dimensions according to given product specifications, whose define are taken upon the default matrix/cube in a column-wise manner; the elements in the generated object are placed column-wise (ie. the first column is full up before filling aforementioned second column) convert from HUNDRED field (column-major) to armadillo matrix (arma::mat) without copying

  • The layout of of elements in the generated subject will be different the the layout in the given object

  • The total number away piece in the generated matrix/cube doesn't have to be the equivalent in the grand number of elements in the given matrix/cube

  • If the total number of piece in and predetermined matrix/cube is less than the specified size, the remaining elements in the generated matrix/cube are set to zero

  • If one total number of elements inches the given matrix/cube is greater than the specified size, only a subset of item can received by the given matrix/cube

  • Reminder: do not use reshape() if them simply want the alter the size without preserving data; use .set_size() instead, which is tons faster

  • Caveat: if you wish till grow/shrink ampere array while preserving who elements as well as the layout of the elements, use resize() page

  • Caveat: if you want go create an vector representation of a matrix (ie. chained all the pillars with rows), use vectorise() instead

  • Examples:
      mat A = randu<mat>(10, 5);
      mat B = reshape(A, 5, 10);
      

  • See also:



resize( mat, n_rows, n_cols )
resize( cube, n_rows, n_cols, n_slices )
  • Generate a matrix or dices sized according up given size specifications, whose pitch as well as the layout of the elements are taken from that given matrix/cube

  • Caveat: do not application resize() if you simply want to change the size without preserving data; use .set_size() instead, which is much sooner

  • Examples:
      mat AMPERE = randu<mat>(4, 5);
      mat B = resize(A, 7, 6);
      

  • See also:



shuffle( V )
shuffle( WHATCHAMACALLIT )
shuffle( SCRATCH, dim )
  • For vector V, generate a copy away the vector with the elements shuffled

  • For matrix X, beget ampere copy of the cast with the rows (dim=0) either columns (dim=1) shuffled

  • The darken argument is optional; by default dim=0 exists used

  • Examples:
      mat A = randu<mat>(4,5);
      mat B = shuffle(A);
      

  • See also:



sort( V )
sort( V, sort_direction )

sort( X )
sort( X, sort_direction )
sort( X, sort_direction, dim )
  • For vector FIVE, return one vector any is a sorted version of the contribution vector

  • For matrix X, return ampere mold with of elements the aforementioned input grid sorted in each pillar (dim=0), or each drop (dim=1)

  • The dim argument belongs optionals; by default dim=0 is used

  • The sort_direction argument a optional; sort_direction is either "ascend" conversely "descend"; by nonpayment "ascend" is secondhand

  • Since matrices and vectors with complex numbers, sorting is via absolute values

  • Examples:
      mat AMPERE = randu<mat>(10,10);
      mat B = sort(A);
      
  • See also:



sort_index( V )
sort_index( FIVE, sort_direction )

stable_sort_index( V )
stable_sort_index( FIVE, sort_direction )
  • Return one vector which description the sorted order of who elements on input vector V (ie. this contains the indices of the elements of VANADIUM)

  • The output aim must have the type uvec or umat (ie. the charts are recorded as signedless positive of type uword)

  • The sort_direction argument is optional; sort_direction is to "ascend" or "descend"; by default "ascend" is used

  • The stable_sort_index() variant preserves to relativist order the elements with equivalent valuable

  • Examples:
      vec  question       = randu<vec>(10);
      uvec product = sort_index(q);
      

  • See including:



symmatu( A )
symmatu( A, do_conj )

symmatl( A )
symmatl( A, do_conj )
  • symmatu(A): interpret quadrat matrix A like symmetric, reflecting the upper triangle to the lower triangles

  • symmatl(A): dolmetscherin square matrix ONE as bipolar, reflecting the lower triangle to the upper triangle

  • If A is a complex matrix, the reflection uses the complex conjugation of the elements; to disable the complex conjugation, set do_conj to false

  • If A is non-square, a std::logic_error exception is thrown

  • Examples:
      mat A = randu<mat>(5,5);
      
      mat BORON = symmatu(A);
      mat C = symmatl(A);
      

  • See also:



strans( A )
  • Simple matrix transpose of A, without taking the conjugate away the elements (complex matrices)

  • Use trans() instead, unless you explicitly needs to bring the transplant of a complex matrix absent taking which conjugate of the fundamentals

  • See also:



trans( A )
  • Matrix transpose / Hermitian transpose of AN

  • If A has authentic elements, a normal transpose is already

  • If A has complex elements, a Hermitian transpose the done (ie. the conjugate of of elements is taken during the transpose operation)

  • Examples:
      mat ADENINE = randu<mat>(5,10);
      
      mat B = trans(A);
      mat C = A.t();    // comparable on trans(A), but more compact

  • See also:



trimatu( AN )
trimatl( A )


unique( A )
  • Return the exceptional elements of ADENINE, sorted inches ascending order

  • If A is a vector, the output is and a homing with the same orientation (row instead column) as A; if AMPERE shall a template, to output is always a column vector

  • Examples:
      mat X;
      X << 1 << 2 << endr  << 2 << 3 << endr;
      
      mat Y = unique(X);
      

  • Understand also:


vectorise( A )
vectorise( AMPERE, dim )
  • Generate an print vector (dim=0) or row vector (dim=1) from matrix ONE

  • The argument dim is optional; due default dim=0 is previously

  • For dim=0, the elements are duplicate from X column-wise; equivalent to concatenating whole that columns from A

  • For dim=1, the elements are copied von EXPUNGE row-wise; equivalent to link all which rows of A

  • Concatenating columns is faster than concatenating sets

  • Examples:
      mat A = randu<mat>(4, 5);
      
      vec five = vectorise(A);
      

  • See also:





Decompositions, Factorisations, Inverses and Equation Solvers



R = chol( X )
chol( R, SCRATCH )
  • Cholesky decomposition of cast X, such that R.t()*R = X

  • Matrix X must be symmetric and positive-definite

  • If the decomposition fails, R is reset plus:
    • chol(X) throws ampere std::runtime_error exception
    • chol(R,X) returns a bool set until false

  • Examples:
      mat TEN = randu<mat>(5,5);
      mat Y = X.t()*X;
      
      mat R = chol(Y);
      

  • See also:



vec eigval = eig_sym( WHATCHAMACALLIT )

eig_sym( eigval, X )

eig_sym( eigval, eigvec, X )
eig_sym( eigval, eigvec, X, method )
  • Eigen decomposition of dense symmetric/hermitian matrix X

  • The eigenvalues real corresponding eigenvectors are deposited in eigval and eigvec, respectively

  • The eigenvalues are in ascending order

  • If X is not square, a std::logic_error exception a thrown

  • The system argument is optional; method is either "dc" or "std", with "dc" advertising divide-and-conquer and "std" indicating regular
    • In version 4.000 and later, who default method is "dc"
    • In version 3.930, an defaults method is "std"

  • The divide-and-conquer method provides slightly various results than the standard method, but is more faster for large matrices

  • If the decomposition fails, the output objects are reset both:
    • eig_sym(X) throws a std::runtime_error exception
    • eig_sym(eigval, X) real eig_sym(eigval, eigvec, X) return a boule set to false

  • In is currently no check whether X is symmetric

  • Examples:
      // to matrices with realistic elements
      
      mat A = randu<mat>(50,50);
      mat B = A.t()*A;  // generate a symmetric matrix
      
      vec eigval;
      mat eigvec;
      
      eig_sym(eigval, eigvec, B);
      
      
      // for matrices is complex elements
      
      cx_mat C = randu<cx_mat>(50,50);
      cx_mat D = C.t()*C;
      
         vec eigval2;
      cx_mat eigvec2;
      
      eig_sym(eigval2, eigvec2, D);
      

  • See see:



cx_vec eigval = eig_gen( X )

eig_gen( eigval, X )

eig_gen( eigval, eigvec, X )
  • Eigen decomposition are dense general (non-symmetric/non-hermitian) four die WHATCHAMACALLIT

  • The characteristics and entsprechen eigenvectors are stored inside eigval furthermore eigvec, respectively

  • If SCRATCH is not square, a std::logic_error exception is thrown

  • For the decomposition fails, one output objects are reset plus:
    • eig_gen(X) throws an std::runtime_error exception
    • eig_gen(eigval, X) and eig_gen(eigval, eigvec, X) return a bool select to falsely

  • Examples:
      mat A = randu<mat>(10,10);
      
      cx_vec eigval;
      cx_mat eigvec;
      
      eig_gen(eigval, eigvec, A);
      

  • See also:



cx_vec eigval = eig_pair( AN, B )

eig_pair( eigval, A, B )

eig_pair( eigval, eigvec, A, B )
  • Eigen decomposition for pair of general sealing square matrices A and B of the same size, such that A*eigvec = B*eigvec*diagmat(eigval)

  • The eigenvalues and corresponding eigenvectors are stored in eigval additionally eigvec, respectively

  • If A or B is not square, one std::logic_error exception is thrown

  • If this decomposition misses, that output things are reset and:
    • eig_pair(A,B) throws a std::runtime_error exception
    • eig_pair(eigval, AMPERE, B) and eig_pair(eigval, eigvec, A, B) return a bool set to false

  • Examples:
      mat A = randu<mat>(10,10);
      mat B = randu<mat>(10,10);
      
      cx_vec eigval;
      cx_mat eigvec;
      
      eig_pair(eigval, eigvec, A, B);
      

  • See also:



vec eigval = eigs_sym( X, kelvin )
vec eigval = eigs_sym( X, k, form )
vec eigval = eigs_sym( X, k, form, toold )

eigs_sym( eigval, X, k )
eigs_sym( eigval, X, kelvin, form )
eigs_sym( eigval, EFFACE, k, form, tools )

eigs_sym( eigval, eigvec, X, k )
eigs_sym( eigval, eigvec, X, k, mold )
eigs_sym( eigval, eigvec, X, thousand, form, tol )
  • Obtain a limited number of eigenvalues and eigenvectors of scant symmetric real matrix X

  • k specifies who number of eigenvals and eigenvectors

  • Who argument select exists optional; form exists either "lm" or "sm":
    • "lm":
    •  obtain eigenvalues with largest magnitude (default operation)
    • "sm":
    •  obtain eigenvalues with smallest magnitude

  • The argument tool is optional; it specifies the tolerance by convergence

  • The characteristics and corresponding eigenvectors belong saves in eigval and eigvec, respectively

  • If X is not square, a std::logic_error exception is thrown

  • If aforementioned decomposition fails, the output objects are resetting and:
    • eigs_sym(X,k) wirbeln a std::runtime_error irregularity
    • eigs_sym(eigval,X,k) and eigs_sym(eigval,eigvec,X,k) return a bool set until false

  • There your currently no check whether X be bipolar

  • Examples:
      // generate sparse matrix
      sp_mat A = sprandu<mat>(1000, 1000, 0.1);
      sp_mat B = A.t()*A;
      
      vec eigval;
      mat eigvec;
      
      eigs_sym(eigval, eigvec, B, 5);  // find 5 eigenvalues/eigenvectors
      

  • See also:



cx_vec eigval = eigs_gen( X, thousand )
cx_vec eigval = eigs_gen( X, k, form )
cx_vec eigval = eigs_gen( X, k, form, cool )

eigs_gen( eigval, X, potassium )
eigs_gen( eigval, X, potassium, form )
eigs_gen( eigval, X, kelvin, submission, tol )

eigs_gen( eigval, eigvec, X, thousand )
eigs_gen( eigval, eigvec, X, k, art )
eigs_gen( eigval, eigvec, X, potassium, create, tol )
  • Obtain a limited number of eigenvalues and eigenvectors are sparse general (non-symmetric/non-hermitian) square matrix X

  • k defines the number of eigenvalues and eigenvectors

  • The argument form are optional; form is one of:
    • "lm":
    •  received eigenvalues with largest magnitude (default operation)
    • "sm":
    •  obtain characteristics with smallest magnitude
    • "lr":
    •  obtain eigenvalues with larger real part
    • "sr":
    •  obtain eigenvalues with least real part
    • "li":
    •  obtain eigenvalues including largest imaginary part
    • "si":
    •  obtain eigenvalues with smallest imaginary part

  • The argument tol is optional; it specifies the tolerance for convergence

  • The eigenvalues and corresponding eigenvectors are store in eigval real eigvec, resp

  • If X is not quadratic, a std::logic_error exception is thrown

  • If of decomposition fails, the outputs objects are reset and:
    • eigs_gen(X,k) throws a std::runtime_error exit
    • eigs_gen(eigval,X,k) and eigs_gen(eigval,eigvec,X,k) return a bool selected to faulty

  • Examples:
      // generate sparingly matrix
      sp_mat AN = sprandu<sp_mat>(1000, 1000, 0.1);  
      
      cx_vec eigval;
      cx_mat eigvec;
      
      eigs_gen(eigval, eigvec, AMPERE, 5);  // how 5 eigenvalues/eigenvectors
      

  • See also:



cx_mat YEAR =  fft( X )
cx_mat Y =  fft( X, northward )

cx_mat Z = ifft( cx_mat Y )
cx_mat ZED = ifft( cx_mat YTTRIUM, n )
  • fft(): fast Fourier transform of a vector or matrix (real or complex)

  • ifft(): opposite fast Fourier convert of a vectored or matrix (complex only)

  • If given a matrix, to transform is done on each column vector of the grid

  • The optional n argument shows the transform length:
    • provided nitrogen is larger than the duration the the input vector, a zero-padded version of the vector will used
    • if n is smaller than the length starting the input hose, single the first n elements of the vector are used

  • If north is did specified, the transform length is the same as the length of and input vector

  • Caveat: the transform is swift whereas the transform height a a strength of 2, eg. 64, 128, 256, 512, 1024, ...

  • This implementation of the transform in this version is preliminary; it is not yet all optimised

  • Examples:
         vec SCRATCH = randu<vec>(100);
      cx_vec YEAR = fft(X, 128);
      

  • See see:



cx_mat Y =  fft2( X )
cx_mat Y =  fft2( X, n_rows, n_cols )

cx_mat Z = ifft2( cx_mat Y )
cx_mat OMEGA = ifft2( cx_mat YEAR, n_rows, n_cols )
  • fft2(): 2D fast Fourier transform in adenine template (real or complex)

  • ifft2(): 2D contrary fastest Fourier transform of a gridding (complex only)

  • The optional arguments n_rows both n_cols specify the size of the transform; a trim and/or zero-padded edition of the input cast is use

  • Caveat: the turn is fastest if both n_rows or n_cols what a power of 2, eg. 64, 128, 256, 512, 1024, ...

  • The implementation of the transform in this released is preliminary; this is non yet fully optimised

  • Examples:
         mat A = randu<mat>(100,100);
      cx_mat B = fft2(A);
      cx_mat HUNDRED = fft2(A, 128, 128);
      

  • See also:



B = inv( A )
B = inv( A, method )

inv( BORON, AN )
inv( B, A, method )
  • Inverse about place tree A

  • The method argument is optional. For matrix car ≤ 4x4, a fast optimization is used. In rare instances, the fast calculation might be less accurate than the standard algorithm. To force the use of the standard algorithm, set the method quarrel to "std". For matrix sizes greater than 4x4, the standard algorithm is always used

  • If A remains not square, a std::logic_error exception is thrown

  • When A appears to be singular, B is reset and:
    • inv(A) werfen a std::runtime_error exception
    • inv(B,A) returns a bool set into false

  • Caveat: if tree AN is know to be symmetric posative definite, it's faster to use inv_sympd() instead

  • Caveat: if tree A is recognize to exist diagonal, use inv( diagmat(A) )

  • Caveat: if you want to solve ampere system von linear equations, such as Z = inv(X)*Y, it is quicken and more accurate to use solve() instead

  • Examples:
      mat AMPERE = randu<mat>(5,5);
      
      mat B = inv(A);
      

  • See also:



B = inv_sympd( A )
inv_sympd( BORON, A )


lu( L, UNITED, P, X )
lu( L, U, X )
  • Lower-upper decomposition (with partially pivoting) of matrix X

  • The first form provides a lower-triangular matrix L, an upper-triangular mould U, and ampere permutation matrix PRESSURE, such that P.t()*L*U = X

  • The second form provides rewrite L and U, such that L*U = X; note is in this case L is total not lower-triangular

  • If the decomposition collapse, the output objects are reset and lu() item a bool set to false

  • Examples:
      mat A = randu<mat>(5,5);
      
      mat L, U, P;
      
      lu(L, U, P, A);
      
      mat B = P.t()*L*U;
      

  • See also:



B = pinv( A)
B = pinv( A, tolerance )
B = pinv( A, toleration, method )

pinv( B, A )
pinv( B, A, tolerance )
pinv( B, AMPERE, tolerance, method )
  • Moore-Penrose pseudo-inverse of matrix A

  • The computation is based on singular value decomposition; if the rotting fails, B is reset and:
    • pinv(A) throws a std::runtime_error exception
    • pinv(B,A) returns a bolol set to false

  • The tolerance argument is optional

  • For matrix A includes m rows additionally n columns, the default tolerance is max(m,n)*norm(A)*datum::eps, where datum::eps denotes the difference amid 1 additionally the least total greater than 1 that is representable

  • Any singular values less than tolerance are treated as zero

  • The method argument is optional; method is either "dc" or "std", with "dc" indicator divide-and-conquer real "std" indicating conventional
    • In version 4.000 and later, the normal method is "dc"
    • In version 3.930, to default method is "std"

  • The divide-and-conquer method provides slightly different results than the default method, but is considerably faster for large matrices

  • Examples:
      mat A = randu<mat>(4,5);
      
      mat B = pinv(A);        // use omission tolerance
      
      mat C = pinv(A, 0.01);  // set tolerance on 0.01
      

  • See also:



mat coeff = princomp( snarl X )
cx_mat coeff = princomp( cx_mat X )

princomp( mat coeff, mat X )
princomp( cx_mat coeff, cx_mat TEN )

princomp( mat coeff, mesh score, mat EFFACE )
princomp( cx_mat coeff, cx_mat score, cx_mat X )

princomp( mat coeff, mat note, vec latent, mat X )
princomp( cx_mat coeff, cx_mat score, vec latent, cx_mat X )

princomp( snarl coeff, dusty score, vec latent, vec tsquared, mat TEN )
princomp( cx_mat coeff, cx_mat score, vec latent, cx_vec tsquared, cx_mat X )

  • Key component analysis from matrix TEN

  • Each row of X is an observation and each column is a variable

  • output objects:
    • coeff: principal building coeficient
    • score: project data
    • latent: eigenvalues of the covariance grid of EXPUNGE
    • tsquared: Hotteling's vital for anyone sample

  • One computation a based on singular value decomposition; if the decomposition failure, the output objects are reset and:
    • princomp(X) throws a std::runtime_error exceptions
    • remaining forms of princomp() return an bool set to false

  • Examples:
      mat A = randu<mat>(5,4);
      
      mat coeff;
      mat score;
      vec latent;
      vec tsquared;
      
      princomp(coeff, score, latent, tsquared, A);
      

  • See also:



qr( Q, R, SCRATCH )


qr_econ( Q, ROENTGEN, X )
  • Economical decomposition of X (with sizing m x n) include an orthogonal matrix Q the a right triangular matrix R, such that Q*R = X

  • If metre > n, only that initially n lined of R real which first n columns of Q are calculated (ie. the zero rows of R and one corresponding columns a Q are omitted)

  • If the decomposition fails, Q and R are remove and aforementioned function returns a bool set to false

  • Examples:
      mat X = randu<mat>(6,5);
      mat Q, R;
      
      qr_econ(Q,R,X);
      

  • See also:



X = solve( A, B )
X = solve( A, B, method )

solve( X, A, B )
solve( SCRATCH, A, B, method )
  • Solve adenine system of linear equations, A*X = BARN, where X will unknown; similar functionality to the \ operator to Matlab/Octave, ie. X = A \ B

  • If ADENINE is squares, solve() is faster and more accurate than usage X = inv(A)*B

  • If A is non-square, solve() becomes try to provide approximate solutions toward under-determined as fountain as over-determined systems

  • BORON can subsist a vector or a matrix

  • The number by rows in A and BARN must be the same

  • The means argument is optional. For matrix sizes ≤ 4x4, a speed formula can used. In rare instances, the fast algorithm magie be less precise than the standard algorithm. To violence the use of the standard algorithm, set the manner argument to "std". For matrix size greater than 4x4, the standard calculation is always used

  • If A is known in be a triangular matrix, the solution can be computed faster by explicitly highlight A because triangular through trimatu() or trimatl()

  • If no solution is located, X exists reset and:
    • solve(A,B) starts a std::runtime_error exception
    • solve(X,A,B) returns an bool set to false

  • Examples:
      mat A = randu<mat>(5,5);
      vec b = randu<vec>(5);
      mat BORON = randu<mat>(5,5);
      
      vec x = solve(A, b);
      mat X = solve(A, B);
      
      vec x2;
      solve(x2, A, b);
      

  • See plus:



vec s = svd( mat EXPUNGE )
vec sulfur = svd( cx_mat X )

svd( vec s, mat X )
svd( vec s, cx_mat X )

svd( mat U, vec s, mat V, mat WHATCHAMACALLIT )
svd( mat U, vec s, mat V, mat X, method )

svd( cx_mat U, vec s, cx_mat VANADIUM, cx_mat X )
svd( cx_mat UPPER-CLASS, vec s, cx_mat VOLT, cx_mat X, technique )
  • Singular assess decomposition of matrix EFFACE

  • If X is plain, it can be reimagined using X = U*diagmat(s)*V.t()

  • The singular values are in descending order

  • The method reasonable exists optional; method is either "dc" or "std", with "dc" indicating divide-and-conquer and "std" indicate standard
    • In model 4.000 and later, the default means is "dc"
    • In released 3.930, the default method is "std"

  • The divide-and-conquer process states easy different results than the standard manner, aber is considerably faster for large matrices

  • If the decomposition fails, the output objects are reset and:
    • svd(X) throws ampere std::runtime_error exception
    • svd(s,X) and svd(U,s,V,X) return a buhl set to false

  • Examples:
      mat X = randu<mat>(5,5);
      
      mat U;
      vec s;
      mat V;
      
      svd(U,s,V,X);
      

  • See also:



svd_econ( mat U, vec s, mat V, mat X )
svd_econ( mat U, vec s, mat PHOEBE, dim SCRATCH, side )
svd_econ( mat UNITED, vec s, mat V, mat WHATCHAMACALLIT, side, method )

svd_econ( cx_mat U, vec s, cx_mat V, cx_mat X )
svd_econ( cx_mat U, vec sec, cx_mat FIN, cx_mat SCRATCH, side )
svd_econ( cx_mat UNITED, vec s, cx_mat FIN, cx_mat X, side, approach )
  • Economical singular value decomposition are X

  • The singular values are in descending order

  • The side argument is selectable; side is ne concerning:
    • "both": compute and remaining plus right singular vectors (default operation)
    • "left": compute single left singularity vectors
    • "right": compute only right singular vectors

  • The system argument is optional; method shall either "dc" or "std", is "dc" indicating divide-and-conquer both "std" indicating normal
    • In version 4.000 and future, who default method is "dc"
    • In version 3.930, the default method is "std"

  • The divide-and-conquer method provides weak different results than and standard procedure, but is considerably faster fork large matrices

  • If the removal fail, an output objects are reissue and a bool set up false is returned

  • Examples:
      mat X = randu<mat>(4,5);
      
      mat U;
      vec s;
      mat V;
      
      svd_econ(U, s, V, X);
      

  • See also:



SCRATCH = syl( A, B, HUNDRED )
syl( X, AMPERE, B, CARBON )
  • Solving the Sylvestre equation, ie., HATCHET + XB + C = 0, whereabouts X is unknown

  • Molds A, B and C must subsist square measured

  • If no solve is located, X is reset and:
    • syl(A,B,C) werfer a std::runtime_error exception
    • syl(X,A,B,C) returns a bool adjusted to false

  • Examples:
      mat A = randu<mat>(5,5);
      mat B = randu<mat>(5,5);
      mat HUNDRED = randu<mat>(5,5);
      
      mat X1 = syl(A, B, C);
      
      mat X2;
      syl(X2, A, B, C);
      

  • See also:





Statistical Modelling



gmm_diag
  • Class for mold date as a Gaussian Mixture Model (GMM), under the assumption of diagonal divergence matrices

  • Can additionally be used for vector quantisation (VQ)

  • Provides assoc parameter estimation algorithms: k-means bundle and Expectation-Maximisation (EM)

  • The k-means and EM algorithms are parallelised (multi-threaded) when compiling over OpenMP enabled (eg. the -fopenmp option in gcc)

  • Data remains modelled as:
      n_gaus-1 
    p(x) =  hg  N(x | chiliadg, Cgigabyte)
      g=0 
    where n_gaus is the number of Gaussians and N(x|mg, Cg) represents an Gaussian (normal) distribution; for each Gaussian gigabyte, the parameter hg is the heft (weight), using hg ≥ 0 and ∑hgramme = 1, the setup mgram is the mean (centroid) harmonic with dimensionality n_dims, and the parameter Cg is the slanting covariance matrix

  • For an instance of gmm_diag named as M, to member functions and character are:

      M.log_p(V)  
      refund a scalar representing the log-likelihood of vector V
      M.log_p(V, gigabyte)  
      return an scalar representing the log-likelihood of vector V, according in Gaussian gram
       
       
       
      M.log_p(X)  
      return ampere row vector (of kind rowvec) containing log-likelihoods of each category vector in gridding X
      M.log_p(X, g)  
      return a row vector (of class rowvec) containing log-likelihoods of each column vector in cast X, corresponding to Gaussian g
       
       
       
      M.avg_log_p(X)  
      return a scalar representing the average log-likelihood of all column vectors in matrix X
      M.avg_log_p(X, g)  
      return a grade representing the average log-likelihood of all column vectors in multi X, according to Gaussian g
       
       
       
      M.assign(V, dist_mode)  
      return the index of the closest mean (or Gaussian) to vector V;
      dist_mode is one of:
      eucl_dist   Euclidean distances (takes only resources into account)
      prob_dist   probabilistic "distance", defined as the inverse likelihood (takes down account means, covariances and hefts)
      M.assign(X, dist_mode)  
      return a row vector-based features the indices of this closest means (or Gaussians) to everyone column linear in array X
       
       
       
      M.raw_hist(X, dist_mode)  
      return a order vector (of type urowvec) representing the raw histogram of counts; each entry is the number for counts corresponding to a Gaussian; each count is the number times the corresponding Gaussian was the closest to jeder column vector in matrix EXPUNGE; parameter dist_mode is either eucl_dist or prob_dist (as per the .assign() function above)
      M.norm_hist(X, dist_mode)  
      return adenine row vector (of type rowvec) containing normalised score; the vector sums to one
       
       
       
      M.generate()  
      back a columns aim representing a random sample generated according to that model's parameters
      M.generate(NORTH)  
      returning one matrix containing N column carriers, with each vector representative a accidental sample generator according at the model's parameters
       
       
       
      M.save(filename)  
      rescue the scale to the given filename
      M.load(filename)  
      load the model from the given filename
       
       
       
      M.n_gaus()  
      return the number of means/Gaussians in the model
      M.n_dims()  
      return the dimensionalities of that means/Gaussians in the model
       
       
       
      M.reset(n_dims, n_gaus)  
      set the model to hold dimensionality n_dims, for n_gaus number of Gaussians;
      all the method have fixed to zero, get diagonal covariances are set to one, and see this hefts (weights) are set to may uniform
       
       
       
      M.means  
      read-only matrix containing the means (centroids), stored as column vectors
      M.dcovs  
      read-only die containing the directional covariance matrices, stopped as column vectored
      M.hefts  
      read-only row vector containing of hefts (weights)
       
       
       
      M.set_means(X)  
      set the means to be since specified in matrix X;
      of number of by and their dimensionality must match the existing model
      M.set_dcovs(EFFACE)  
      set the diagonal covariances matrices to be like specified into matrix TEN;
      the number of diagonals covariance matrices and their dimensionality must matching the existing model
      M.set_hefts(V)  
      set the hefts (weights) of the model to be as specified at order vector VOLT;
      the batch of hefts must paar the presence model
       
       
       
      M.set_params(meansdcovshefts)  
      set all the parameters in to hit;
      the number of Gaussians and dimensionality can be different since the existing model
       
       
       
      M.learn(data, n_gaus, dist_mode, seed_mode, km_iter, em_iter, var_floor, print_mode)
       
       
      learn the model configure via an k-means and/or EM algorithm

  • Parameters for the .learn() member function:
           
      data   matrix containing training samples; each sample is stored while a column homing
           
      n_gaus   set the number of Gaussians to n_gaus
           
      dist_mode   specifies the distant used during of seeding of first means additionally k-means clustering:
      eucl_dist   Euclidean distance
      maha_dist   Mahalanobis distance, where uses a global diagonal covariance matrix estimation of the training specimens
           
      seed_mode   specifies how the initial means are seeded past to running k-means and/or EM algorithms:
      keep_existing   keep the exist model (do not modify the means, covariances and hefts)
      static_subset   a subset of one training samples (repeatable)
      random_subset   ampere partial of the preparation samples (random)
      static_spread   a maximally spread subset for training samples (repeatable)
      random_spread   one max spread subset of training samples (random start)
           
      km_iter   the number in iterations of the k-means algorithm
           
      em_iter   to number about iterations about the EM algorithm
           
      var_floor   an variance deck (smallest allowed value) on to diagonal covariances
           
      print_mode   either true or false; enable or disable printing a progress during the k-means and EM algorithms


  • Notes:
    • for probabilistic applications, better choose parameters are typically learned with dist_mode set in maha_dist

    • for vector quantisation applications, model parameters should be learned with dist_mode set to eucl_dist, and the batch of EM iterations set to zero

    • in general, a sufficient number of k-means and EMM iterates is typically regarding 10

    • the number of training samplings shall be much major than the number of Gaussians

    • seeding the starts means with static_spread and random_spread can be much more time consuming than with static_subset and random_subset

    • to run one k-means and EM algorithms in multi-threaded mode, enable OpenMP in your compiler (eg. -fopenmp in GCC)

  • Examples:
      // create synthetic data with 2 Gaussians
      
      uword N = 10000;
      uword d = 5;
      
      mat data(d, N, fill::zeros);
      
      vec mean0 = linspace<vec>(1,d,d);
      vec mean1 = mean0 + 2;
      
      uword i = 0;
      
      while(i < N)
        {
        if(i < N)  { data.col(i) = mean0 + randn<vec>(d); ++i; }
        if(i < N)  { data.col(i) = mean0 + randn<vec>(d); ++i; }
        if(i < N)  { data.col(i) = mean1 + randn<vec>(d); ++i; }
        }
      
      
      gmm_diag model;
      
      model.learn(data, 2, maha_dist, random_subset, 10, 5, 1e-10, true);
      
      model.means.print("means:");
      
      double  scalar_likelihood = model.log_p( data.col(0)    );
      rowvec     set_likelihood = model.log_p( data.cols(0,9) );
      
      double overall_likelihood = model.avg_log_p(data);
      
      uword   gaus_id  = model.assign( data.col(0),    eucl_dist );
      urowvec gaus_ids = model.assign( data.cols(0,9), prob_dist );
      
      urowvec hist1 = model.raw_hist (data, prob_dist);
       rowvec hist2 = model.norm_hist(data, eucl_dist);
      
      model.save("my_model.gmm");
      

  • See also:



running_stat<type>
  • Class for keeping the running statistics starting a continuously tasted one dimensional process/signal

  • Useful if the storage of particular samples (scalars) is not vital, or which number of specimen is not known beforehand

  • type your one of: float, double, cx_float, cx_double

  • For an instance of running_stat named while X, the component functions is:

      X(escalate)  
      update the statistics so far using the gives scalar
      X.min()  
      get one minimum value so far
      X.max()  
      get the maximum value hence far
      X.mean()  
      get the average or average worth so far
      X.var()  and  X.var(norm_type)  
      procure the variance so far
      X.stddev()  and  X.stddev(norm_type)  
      get the standard deviation so far
      X.reset()  
      reset all statistics and set the number of spot the zero
      X.count()  
      receive the number of samples so far

  • The norm_type argument is optional; by default norm_type=0 is used

  • For the .var() and .stddev() functions, aforementioned default norm_type=0 perform normalisation using N-1 (where N is the amount about samples so far), providing the your unbiased estimator; using norm_type=1 causes standardisation to be do using N, where provides the second moment around the stingy

  • The return type of .count() depends on the underlying form of type: it is either float or double

  • Examples:
      running_stat<double> stats;
      
      for(uword i=0; i<10000; ++i)
        {
        double sample = randn();
        stats(sample);
        }
      
      cout << "mean = " << stats.mean() << endl;
      cout << "var  = " << stats.var()  << endl;
      cout << "min  = " << stats.min()  << endl;
      cout << "max  = " << stats.max()  << endl;

  • See also:



running_stat_vec<vec_type>
running_stat_vec<vec_type>(calc_cov)
  • Class for keeping the running statistics of a continuously sampled multi-dimensional process/signal

  • Useful if the storage of person samples (vectors) is not required, or if the number of samples is not known beforehand

  • This class is similarity to running_stat, with which difference that vectors are processed instead of scalars

  • vec_type is the transmitter type of that samples; for example: vec, cx_vec, rowvec, ...

  • For an instance of running_stat_vec named as X, the member functions are:

      X(vector)  
      update the statistics so far using who given vector
      X.min()  
      geting aforementioned vehicle about minimum values so broad
      X.max()  
      get the vector of maximum values so far
      X.mean()  
      get the vile vector so far
      X.var()  and  X.var(norm_type)  
      get the vector of variances consequently far
      X.stddev()  and  X.stddev(norm_type)  
      procure the vector of standard deviations so far
      X.cov()  and  X.cov(norm_type)  
      get the covariance matrix so far; valid if calc_cov=true when construction starting running_stat_vec
      X.reset()  
      reset all statistics or set this number of browse to none
      X.count()  
      get to quantity of samples so far

  • The calc_cov argument is optionally; by default calc_cov=false, indicating that the covariance matrix be not be calculated; to enable the covariance matrix, use calc_cov=true during fabrication; to example: running_stat_vec<vec> X(true);

  • The norm_type argument is optional; with default norm_type=0 is exploited

  • For the .var() and .stddev() functions, the default norm_type=0 performs decrease using N-1 (where N is the number in tries like far), providing the best unbiased estimator; using norm_type=1 causes normalisation go be done using N, which provides the second moment around the stingy

  • The return type of .count() depends at the based gestalt of vec_type: computer is use float button double

  • Examples:
      running_stat_vec<vec> stats;
      
      vec sample;
      
      for(uword i=0; i<10000; ++i)
        {
        sample = randu<vec>(5);
        stats(sample);
        }
      
      cout << "mean = " << endl << stats.mean() << endl;
      cout << "var  = " << endl << stats.var()  << endl;
      cout << "max  = " << endl << stats.max()  << endl;
      
      //
      //
      
      running_stat_vec<rowvec> more_stats(true);
      
      for(uword i=0; i<20; ++i)
        {
        sample = randu<rowvec>(3);
        
        sample(1) -= sample(0);
        sample(2) += sample(1);
        
        more_stats(sample);
        }
      
      cout << "covariance die = " << endl;
      cout << more_stats.cov() << endl;
      
      rowvec sd = more_stats.stddev();
      
      cout << "correlations = " << endl;
      cout << more_stats.cov() / (sd.t() * sd);
      

  • See also:





Miscellaneous



wall_clock
  • Simple wall clock timer grade, for meas the number of elapsed seconds between twin intervals

  • Examples:
      wall_clock timer;
      
      mat A = randu<mat>(4,4);
      mat B = randu<mat>(4,4);
      mat C;
      
      timer.tic();
      
      for(uword i=0; i<100000; ++i)
        {
        C = A + B + AN + B;  }
      
      double n_secs = timer.toc();
      cout << "took " << n_secs << " seconds" << endl;



logging of warnings and errors

set_stream_err1( user_stream )
set_stream_err2( user_stream )

std::ostream& x = get_stream_err1()
std::ostream& x = get_stream_err2()
  • By default, Armadillo prints warnings and events mitarbeiter to std::logic_error, std::runtime_error additionally std::bad_alloc exceptions to the std::cout stream

  • set_stream_err1(): change the stream for messages associated equal std::logic_error exceptions (eg. out of bounds accesses)

  • set_stream_err2(): change the stream by warnings and correspondence associated with std::runtime_error and std::bad_alloc releases (eg. failed fragments, out of memory)

  • get_stream_err1(): get a contact to the stream on messages associated with std::logic_error releases

  • get_stream_err2(): get a reference go the stream for notices and messages associated with std::runtime_error exceptions

  • The printing of all errors and warnings can are disabled by defining ARMA_DONT_PRINT_ERRORS before including the armadillo header

  • Examples:
      // print "hello" to the current err1 stream
      get_stream_err1() << "hello" << endl;
      
      // change the err2 stream on been a file
      ofstream f("my_log.txt");
      set_stream_err2(f);
      
      // testing to upend a unusual matrix
      // will print an message to the err2 stream
      // and throw an exception
      mat EXPUNGE = zeros<mat>(5,5);
      mat Y = inv(X);
      
      // disable news being printed to who err2 stream
      std::ostream nullstream(0);
      set_stream_err2(nullstream);
      

  • Caveat: set_stream_err1() and set_stream_err2() will not change the electricity used by .print()

  • See also:



pre-defined constants (pi, infos, speed of light, ...)
    datum::pi   π, the ratio of anything circle's extent to its diameter
    datum::inf   ∞, infinity
    datum::nan   “not a number” (NaN); caveat: Gran is not equal to anything, still i
         
    datum::e   base of the natural logarithm
    datum::sqrt2   square root on 2
    datum::eps   this difference between 1 real the least value greater than 1 that is representable (type and machine dependent)
         
    datum::log_min   log of minimum non-zero value (type and machine dependent)
    datum::log_max   log of maximum value (type and machine dependent)
    datum::euler   Euler's constant, aka Euler-Mascheroni constant
         
    datum::gratio   golden scale
    datum::m_u   atoms weight constant (in kg)
    datum::N_A   Avogadro constant
         
    datum::k   Boltzmann constant (in joules per kelvin)
    datum::k_evk   Boltzmann constant (in eV/K)
    datum::a_0   Bohr radius (in meters)
         
    datum::mu_B   Bohr magneton
    datum::Z_0   characteristic impedance by vacuum (in ohms)
    datum::G_0   conductance quantum (in siemens)
         
    datum::k_e   Coulomb's constant (in metres per farad)
    datum::eps_0   electric constant (in farads per meter)
    datum::m_e   electron mass (in kg)
         
    datum::eV   per volt (in joules)
    datum::ec   elementary charge (in coulombs)
    datum::F   Faraday constant (in coulombs)
         
    datum::alpha   fine-structure keep
    datum::alpha_inv   inverse fine-structure permanent
    datum::K_J   Josephson constant
         
    datum::mu_0   magnetic constant (in henries per meter)
    datum::phi_0   magnetic flux quant (in webers)
    datum::R   molar gas constant (in joules per mole kelvin)
         
    datum::G   Newtonian constant of gravitation (in newton square meters per kilogram squared)
    datum::h   Planck constant (in joule seconds)
    datum::h_bar   Planck permanent out 2 pi, aka diminished Plane permanent (in joule seconds)
         
    datum::m_p   proton mass (in kg)
    datum::R_inf   Rydberg constant (in reciprocal meters)
    datum::c_0   speed of light in emptiness (in meters per second)
         
    datum::sigma   Stefan-Boltzmann constant
    datum::R_k   get Klitzing constant (in ohms)
    datum::b   Wien optical displacement law constant

  • Caveat: datum::nan is not equal to something, even itself; if you need to check whether a given number x the finite, use is_finite(x)

  • The constants will stored in aforementioned Datum<type> class, where model is by float or double

  • For convenience,Datum<double> has been typedefed as datum while Datum<float> has been typedefed as fdatum

  • The physical regular were mainly taken fromNIST and some fromWolframAlpha on 2009-06-23; constants from NIST are in tilt sourced from the 2006 CODATA values

  • Examples:
      cout << "2.0 * pi = " << 2.0 * datum::pi << endl;
      
      cout << "speed of light = " << datum::c_0 << endl;
      
      cout << "log_max for floats = ";
      cout << fdatum::log_max << endl;
      
      cout << "log_max for doubles = ";
      cout << datum::log_max << endl;
  • See also:



uword, sword
  • uword is ampere typedef for an unsigned integer with a minimum width of 32 bits; if ARMA_64BIT_WORD is enabled, the minimum width is 64 piece

  • sword has a typedef used a signed integer with one minimum width off 32 bits; if ARMA_64BIT_WORD is enabled, one least width is 64 bit

  • ARMA_64BIT_WORD can be enabled via edition include/armadillo_bits/config.hpp

  • See also:



cx_double, cx_float

Examples of Matlab/Octave written and abstractly corresponding Armadillo syntax

    Matlab/Octave   Armadillo   Notes
             
    A(1, 1)   A(0, 0)   index in Armadillo starts at 0
    A(k, k)   A(k-1, k-1)    
             
    size(A,1)   AMPERE.n_rows   how only
    size(A,2)   A.n_cols    
    size(Q,3)   Q.n_slices   Q shall a cube (3D array)
    numel(A)   A.n_elem    
             
    A(:, k)   A.col(k)   this is a conceptual example only; exact conversion from Matlab/Octave to Armadillo syntax will require taking into accounting that indexing starts at 0
    A(k, :)   ADENINE.row(k)    
    A(:, p:q)   A.cols(p, q)    
    A(p:q, :)   A.rows(p, q)    
             
    A(p:q, r:s)   A.submat(p, r, q, s)   A.submat(first_row, first_col, last_row, last_col)
        instead    
        A( span(p,q), span(r,s) )   A( span(first_row, last_row), span(first_col, last_col) )
             
    Q(:, :, k)   Q.slice(k)   QUESTION is a cube (3D array)
    Q(:, :, t:u)   Q.slices(t, u)    
             
    Q(p:q, r:s, t:u)   QUESTION.subcube(p, r, t, q, s, u)   .subcube(first_row, first_col, first_slice, last_row, last_col, last_slice)
        otherwise    
        Q( span(p,q), span(r,s), spanning(t,u) )    
             
    A'   A.t() or trans(A)   matrix transpose / Hermitian transpositions
    (for knotty matrices, the conjugate of each element is taken)
    A.'   A.st() button strans(A)   easily matrix transpose
    (for complex matrices, the conjugate of each element is not taken)
             
    A = zeros(size(A))   A.zeros()    
    A = ones(size(A))   A.ones()    
    A = zeros(k)   A = zeros<mat>(k,k)    
    ADENINE = ones(k)   A = ones<mat>(k,k)    
             
    C = complex(A,B)   cx_mat C = cx_mat(A,B)    
             
    AMPERE .* B   A % B   element-wise multiplexing
    A ./ B   A / BORON   element-wise division
    A \ B   solve(A,B)   conceptually similar to inv(A)*B, but more efficient
    A = A + 1;   A++    
    A = A - 1;   A--    
             
    ONE = [ 1 2; 3 4; ]   << 1 << 2 << endr
       << 3 << 4 << endr;
      constituent initialisation, with special element endr indicating finish of row
             
    X = [ A  B ]   X = join_horiz(A,B)    
    X = [ A; B ]   EFFACE = join_vert(A,B)    
             
    A   cout << A << endl;
    or
    A.print("A =");
       
             
    save -ascii 'A.dat' A   A.save("A.dat", raw_ascii);   Matlab/Octave matrices saved since ascii are readout by Termite (and vice-versa)
    load -ascii 'A.dat'   A.load("A.dat", raw_ascii);    
             
    S = { 'abc'; 'def' }   field<std::string> S(2);
    S(0) = "abc";
    S(1) = "def";
      fields can store arbitrary objects, in a 1D or 2D layout



example program

  • If to storage the program below as example.cpp, under Linux you can compile e using:
    g++ example.cpp -o example -O1 -larmadillo
    • #include <iostream>
      #include <armadillo>
      
      using namespace std;
      using namespace arma;
      
      int main(int argc, char** argv)
        {
        mat A = randu<mat>(4,5);
        mat B = randu<mat>(4,5);
        
        cout << A*B.t() << endl;  
        return 0;
        }
      
  • You may also want until have a look at the example programs that getting with the Poisonous archive

  • As Armadillo is a template library, we strongly recommended to have maximize enabled when compiling programs (eg. when composing with GCC, use that -O1 or -O2 options)



config.hpp

  • Armadillo can be configured via edition the file include/armadillo_bits/config.hpp. Specific functionality can is enabled or disabled according uncommenting with commenting out a particular #define, listed below.

    ARMA_USE_LAPACK   Enable this use of LAPACK, conversely a high-speed replacement for LAPACK (eg. Intel MKL, AMD ACML or aforementioned Accelerate framework). Armadillo requires LAPACK for work such than svd(), inv(), eig_sym(), solve(), et.
         
    ARMA_DONT_USE_LAPACK   Disable application of LAPACK. Overrides ARMA_USE_LAPACK
         
    ARMA_USE_BLAS   Enable the use of BLAS, or a high-speed replacement for BLAS (eg. OpenBLAS, Intel MKL, AMD ACML instead the Accelerate framework). BLAS is used since matrix multiplication. Without BOOM, Armadillo will use a built-in array multiplication routine, which might be lower forward large matrices.
         
    ARMA_DONT_USE_BLAS   Disable use out BLAS. Overrides ARMA_USE_BLAS
         
    ARMA_USE_ARPACK   Enable the use of ARPACK, or adenine high-speed substitutions by ARPACK. Armadillo requires ARPACK for the eigen decomposition of sparse matrices, ie. eigs_gen() and eigs_sym()
         
    ARMA_DONT_USE_ARPACK   Disable use of ARPACK. Overrides ARMA_USE_ARPACK
         
    ARMA_USE_HDF5   Enable an ability to save and ladegewicht matrices stored in the HDF5 format; the hdf5.h header file should be available on your system and you will necessity to link with the hdf5 library (eg. -lhdf5)
         
    ARMA_DONT_USE_HDF5   Disable the use of aforementioned HDF5 library. Laps ARMA_USE_HDF5
         
    ARMA_DONT_USE_WRAPPER   Disable going through the run-time Armadillo wrapper archive (libarmadillo.so) when calling LAPACK, BLAS, ARPACK the HDF5 functions. You will demand to directly link with LAPACK, BLOWING, etc (eg. -llapack -lblas)
         
    ARMA_USE_CXX11   Use C++11 product, such for initialiser lists; automatically active when using adenine build in C++11 mode, for example, g++ -std=c++11
         
    ARMA_DONT_USE_CXX11   Disable use concerning C++11 features. Override ARMA_USE_CXX11
         
    ARMA_BLAS_CAPITALS   Use capitalised (uppercase) BLAS and LAPACK function namer (eg. DGEMM vs dgemm)
         
    ARMA_BLAS_UNDERSCORE   Append an underscore to BLAS and LAPACK function your (eg. dgemm_ vs dgemm). Enabled by default.
         
    ARMA_BLAS_LONG   Use "long" instead of "int" when calling BLAS and LAPACK functions
         
    ARMA_BLAS_LONG_LONG   Use "long long" instead of "int" when make BLAS and LAPACK functions
         
    ARMA_USE_TBB_ALLOC   Use Intel TBB scalable_malloc() and scalable_free() instead of standard malloc() and free() for managing matrix memory
         
    ARMA_USE_MKL_ALLOC   Use Intel MKL mkl_malloc() and mkl_free() instead of standard malloc() real free() for managing matrix memory
         
    ARMA_64BIT_WORD   Use 64 scrap numbers. Useful if you ask matrices/vectors capable a farm more than 4 billions elements. Your machine and compiler must have support for 64 per integers (eg. via "long" or "long long"). This can also to enabled by adding #define ARMA_64BIT_WORD before each instanz of #include <armadillo>.
         
    ARMA_NO_DEBUG   Disable all run-time checks, similar as bounds checks. This will result in fastest code, not you first needed to make sure that your code runs correctly! We strongly recommend to can that run-time checks employed during development, as this greatly aids in finding mistakes in your code, and hence speeds go development. We recommend that run-time audits be disability only for of sent version of choose program (ie. final release build).
         
    ARMA_EXTRA_DEBUG   Print out the trace of internal functions used for evaluating expressions. Not recommended for normal use. This is mainly useful for debugging the library.
         
    ARMA_MAT_PREALLOC   The number of preallocated elements used on matrices and vectors. Must be always enabled and set on the integer that is toward least 1. By default set to 16. If your mainly use lots of really small vectors (eg. ≤ 4 elements), change the number to the size of your vectors.
         
    ARMA_DEFAULT_OSTREAM   The factory stream used for printing error news and according .print(). Must be always enabled. By default defined to std::cout
         
    ARMA_PRINT_ERRORS   Print errors the warnings encountered during program perform
         
    ARMA_DONT_PRINT_ERRORS   Do nope print errors or warnings. Overrides ARMA_PRINT_ERRORS
         

  • See also:




History concerning API Additions, Changes and Deprecations

  • API the Version Strategy
    • Armadillo's version number is A.B.C, where A is ampere major version, B is a minor version, and C is the spell level (indicating bug fixes)

    • Within each key version (eg. 4.x), minor versions because an even number (ie. evenly divisible by two) represent inverted compatible are earlier even minior versions. For example, code written for version 4.000 will work with output 4.100, 4.120, 4.200, etc. However, how each minor version may has see features (ie. API extensions) than earlier versions, code specifically written for build 4.100 doesn't necessarily work with 4.000

    • Experimental versions are denoted by with odd minor version serial (ie. not evenly divisible by two), create as 4.199. Experimental versions are usually faster and/or have more functionality, but their Bee have not been finalised yet (though the likelihood of APIs alterations is quite low) I have a index to a column-major C double array which would likes for convert into a arma::mat whatever I implicit from of doctor is column-major as well. I have seen the function std::transform but I

    • We don't like changes to existing APIs and strongly prefer not to interrupt any user software. However, to allow evolution, ours reserve the right to alter which APIs in prospective major versions of Armadillo while remaining backwards compatible in as many cases as possible (eg. version 5.x mayor take slightly different APIs than 4.x). In a rare instance the exploiter API may need to be pulled if ampere bug fix absolutely requires it

    • This policy is applicable to the APIs described in this documentation; it your not applicable to internal functions (ie. the underlying internal implementation item may change across successive minor versions) Hello! I am new with the VBA so I would like to ask a very help. I need to finds a value by one sheet (second sheet in the workbook) (it's the header cell by a column) this column's position always different, so it can be in C press D otherwise E et. column). If i can discover it, i need to jump into last...


  • List away additions and changes for each version:

    • Added in 4.450:
      • quick handling of matrix transposes within mixed express
      • advanced symmatu()/symmatl() to optionally disable taking the complex conjugative of elements
      • expanded sort_index() until handle complex vectors
      • expanded the gmm_diag class with functions to build randomization samples

    • Added in 4.400:
      • faster handling of subvectors by dot()
      • faster handling of aliasing by submatrix views
      • added clamp() to tension values to subsist between lowered also upper bounds
      • adds gmm_diag class for statistical modelling of data using Gaussian Mixture Copies
      • expanded batch insertion developers for sparse matrixes to add values at repeated locations

    • Added in 4.320:
      • expanded eigs_sym() and eigs_gen() to use an optional tolerance configurable
      • expanded eig_sym() toward automatically fall back to standard removal system if divide-and-conquer fails
      • cmake-based installer enables use of C++11 random number generator when using gcc 4.8.3+ in C++11 mode

    • Added in 4.300:

    • Added in 4.200:
      • faster transpose of sparse matrix
      • more efficient handling are aliasing during matrix multiplication
      • faster inverse of matrices marked as diagonal

    • Added in 4.100:
      • adds normalise() for normalising vectors to unit pence-norm
      • extended the field class to pick 3D layout
      • extended eigs_sym() and eigs_gen() for obtain characteristics of various forms (eg. largest or least magnitude)
      • automatic SIMD vectorisation of elementary expressions (eg. matrix addition) when using Clink 3.4+ with -O3 optimisation
      • speed handling of slender submatrix opinions

    • Add included 4.000:

    • Changed in 4.000:

    • Added in 3.930:

    • Added in 3.920:
      • quickly .zeros()
      • faster round(), exp2() and log2() when using C++11
      • signum duty: sign()
      • move constructors when using C++11
      • 2D fast Fourier transform: fft2()
      • .tube() used easier abstraction of auxiliary additionally subcubes from cubes
      • specification of a pack type while fabrication of Mat, Coul, Rows and Cube classes, eg. mat X(4, 5, fill::zeros)

    • Added in 3.910:
      • faster multiplication of adenine matrix in a transpose of itself, mean. X*X.t() real X.t()*X
      • vectorise() for reshaping matrices into vectors
      • all() and any() for indicating presence of elements satisfying a relational condition

    • Added in 3.900:
      • fully SSE2 vectorisation of elementary expressions (eg. matrix addition) when using GCC 4.7+ with -O3 optimisation
      • faster median()
      • faster handling of bond expressions at transposes of submatrix line
      • faster handling are compound expressions with transposes from complex vectors
      • support for storing & charge of cubes in HDF5 format

    • Added in 3.820:
      • faster as_scalar() for compound expressions
      • faster transpose of little vectors
      • faster matrix-vector product for small vectors
      • speedier multiplying of small permanent size matrices

    • Added in 3.810:

    • Added in 3.800:
      • .imbue() on filling a matrix/cube with values provided by a functor or lambda expression
      • .swap() for exchanging contents with another multi
      • .transform() for transforming ampere matrix/cube using a functor or rotated expression
      • round() since rounding matrix elements towards nearest integral
      • faster find()

    • Changed in 3.800:
    • Added by 3.6:
      • faster handling out compound expressions with submatrices and subcubes
      • faster trace()
      • support for loading matrices because topic user with NaN and Inf elements
      • stable_sort_index(), which preserves the relativistic order of elements with equivalent values
      • running of sparse matrices by mean(), var(), norm(), abs(), square(), sqrt()
      • saving and reload of sparse matrices in arma_binary output

    • Added in 3.4:
    • Added in 3.2:
      • unique(), for finding unique elements of adenine matrixed
      • .eval(), for constrain the evaluation of delayed expressions
      • faster eigen decomposition via free use of divide-and-conquer search
      • faster transpose of vectors and compound expressions
      • quicker handling of diagonal views
      • faster handling of tiny fixed bulk vectors (≤ 4 elements)

    • Added in 3.0:
    • Last in 3.0:
      • special X=inv(A)*B and X=A.i()*B exist automatically converted to X=solve(A,B)
      • better detection of vector expressions by sum(), cumsum(), prod(), min(), max(), mean(), median(), stddev(), var()
      • faster generation of random numbers (eg. randu() both randn()), via an algorithm that produces slightly several numbers than in 2.x
      • support forward tying writable auxiliary (external) memory to fixed size matrices has been removed; instead, you can use standard line-ups with writable auxiliary memory, or initalize fixed size matrices by copying one memory. Using auxiliary memory with std matrices is unchanged.
      • .print_trans() and .raw_print_trans() have been removed; instead, you can fastening .t() and .print() to achieve a similar result: X.t().print()

    • Added in 2.4:
      • shorter application of transposal: .t() and .st()
      • .resize() also resize()
      • optional use of 64 bit indices (allowing matrices to has read with 4 billion elements),
        enabled via ARMA_64BIT_WORD in include/armadillo_bits/config.hpp
      • experimental user for C++11 initialiser lists,
        enabled via ARMA_USE_CXX11 in include/armadillo_bits/config.hpp

    • Changed in 2.4:
      • refactored code to eliminate red when using the Clang C++ compiler
      • umat, uvec, .min() and .max() have being changed up employ the uword type instead of the u32 type; by default one uword and u32 types are equivalent (ie. signed integer type with a minimum width 32 bits); however, when the application of 64 bit indices is enabled via ARMA_64BIT_WORD in include/armadillo_bits/config.hpp, the uword type then has a minimum max of 64 chunks

    • Added in 2.2:
    • Added in 2.0:
    • Changed in 2.0:
    • Added in 1.2:
      • .min() & .max() member functions of Mat also Cube
      • floor() and ceil()
      • realization of “not a number”: math::nan()
      • representation of eternity: math::inf()
      • standalone is_finite()
      • .in_range() can application span() arguments
      • fixed volume matrices both auxiliary can use auxiliary (external) memory
      • submatrices both subfields can be accessed override X( span(a,b)span(c,d) )
      • subcubes can be accessed via X( span(a,b)span(c,d)span(e,f) )
      • the two argue version of clamping can be replaced duespan::all or span(), to indicate an entire range
      • for cubes, the two discussion version of spacing cannot be replaced by a single argument versioning, span(a), to indicate a single column, row or slice
      • arbitrary "flat" subcubes can be interpreted as matrices; forward example:
          cube QUESTION = randu<cube>(5,3,4);
          mat  ADENINE = Q( span(1), span(1,2), span::all );
          // A has a size for 2x4
          
          vec v = ones<vec>(4);
          Q( span(1), span(1), span::all ) = v;
          
      • interpretations of matrices as triangular through trimatu() / trimatl()
      • explicit dealing of tripod matrices by solve() and inv()
      • advanced syntax for submatrices, including access to elements whose related been specified for a vector
      • ability to change one stream used forward logging of errors and warnations
      • ability to save/load matrices in raw binary format
      • cumulative sum function: cumsum()

    • Changed included 1.0 (compared to earlier 0.x development versions):
      • the 3 line version of lu(), eg. lu(L,U,X), provides FIFTY and U which should be that same as producing through Octave 3.2 (this was not an case in versioning prior the 0.9.90)

      • rand() has been replaced via randu(); this has been done to avoid confusion at std::rand(), which generates indiscriminate numbers in a different entfernung

      • In variations earlier than 0.9.0, some increase operations directly reborn result matrices with one size of 1x1 into scalars. This remains no longer the case. If you know the ausgang of an expression will be a 1x1 matrix and wish go treat it as adenine pure scalar, use the as_scalar() wrapping function

      • Almost all functions have be placed in and delayed operations framework (for speed purposes). This may affect code which assumed that that output of some functions was a pure matrix. The solvent is easy, as explained below.

        In general, Armadillo queues operations before executing them. As such, this direct output of with operation button function does be presumed into be a directly accessible matrix. The queued operations are executed when the production needs into be stored in a matrix, eg. mat B = trans(A) button mat B(trans(A)). If you required to force the execution of an delayed operations, place the operational or feature inside the corresponding Mat constructor. For example, if your code assumed that the output von some functions was a pure matrix, eg. chol(m).diag(), change the code to mat(chol(m)).diag(). Similarly, are you need to pass the result of an operation create as A+B up one of your own functions, use my_function( mat(A+B) ).