armadillo
Armadillo
C++ library for linear algebra & scientific computing
[top] API Documentation for Armadillo 15.2


Preamble

 


Overview
Matrix, Vector, Cube and Field Classes
Member Functions & Variables
Generated Vectors / Matrices / Cubes
Functions of Vectors / Matrices / Cubes
Decompositions, Factorisations, Inverses and Equation Solvers (Dense Matrices)
Decompositions, Factorisations and Equation Solvers (Sparse Matrices)
Signal & Image Processing
Statistics & Clustering
Miscellaneous




Matrix, Vector, Cube and Field Classes



Mat<type>
mat
cx_mat
  • See also:



  • Col<type>
    vec
    cx_vec
  • See also:



  • Row<type>
    rowvec
    cx_rowvec
  • See also:



  • Cube<type>
    cube
    cx_cube
  • Notes:

  • See also:



  • field<object_type>
  • See also:



  • SpMat<type>
    sp_mat
    sp_cx_mat
  • See also:



  • operators:  +    *  %  /  ==  !=  <=  >=  <  >  &&  ||
  • See also:





  • Member Functions & Variables



    attributes
  • See also:



  • element/object access via (), [] and .at()
  • See also:



  • element initialisation
  • See also:



  • .zeros()
      (member function of Mat, Col, Row, SpMat, Cube)
    .zeros( n_elem )
      (member function of Col and Row)
    .zeros( n_rows, n_cols )
      (member function of Mat and SpMat)
    .zeros( n_rows, n_cols, n_slices )
      (member function of Cube)
    .zeros( size(X) )
      (member function of Mat, Col, Row, Cube, SpMat)

  • See also:



  • .ones()
      (member function of Mat, Col, Row, Cube)
    .ones( n_elem )
      (member function of Col and Row)
    .ones( n_rows, n_cols )
      (member function of Mat)
    .ones( n_rows, n_cols, n_slices )
      (member function of Cube)
    .ones( size(X) )
      (member function of Mat, Col, Row, Cube)

  • See also:



  • .eye()
    .eye( n_rows, n_cols )
    .eye( size(X) )
  • See also:



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

    .randn()
      (member function of Mat, Col, Row, Cube)
    .randn( n_elem )
      (member function of Col and Row)
    .randn( n_rows, n_cols )
      (member function of Mat)
    .randn( n_rows, n_cols, n_slices )
      (member function of Cube)
    .randn( size(X) )
      (member function of Mat, Col, Row, Cube)

  • See also:



  • .fill( value )
  • Note: to set all elements to zero during matrix construction, use the following more compact form:
    mat A(5, 6, fill::zeros);
    

  • See also:



  • .imbue( functor )
    .imbue( lambda_function )

  • See also:



  • .clean( threshold )

  • See also:



  • .replace( old_value, new_value )
  • See also:



  • .clamp( min_value, max_value )
  • See also:



  • .transform( functor )
    .transform( lambda_function )

  • See also:



  • .for_each( functor )
    .for_each( lambda_function )

  • See also:



  • .set_size( n_elem )
      (member function of Col, Row, field)
    .set_size( n_rows, n_cols )
      (member function of Mat, SpMat, field)
    .set_size( n_rows, n_cols, n_slices )
      (member function of Cube and field)
    .set_size( size(X) )
      (member function of Mat, Col, Row, Cube, SpMat, field)

  • See also:



  • .reshape( n_rows, n_cols )
      (member function of Mat, SpMat, field)
    .reshape( n_rows, n_cols, n_slices )
      (member function of Cube, field)
    .reshape( size(X) )
      (member function of Mat, Cube, SpMat, field)

  • See also:



  • .resize( n_elem )
      (member function of Col, Row)
    .resize( n_rows, n_cols )
      (member function of Mat, SpMat, field)
    .resize( n_rows, n_cols, n_slices )
      (member function of Cube, field)
    .resize( size(X) )
      (member function of Mat, Col, Row, Cube, SpMat, field)

  • See also:



  • .copy_size( A )
  • See also:



  • .reset()
  • See also:



  • submatrix views
  • See also:



  • subcube views and slices
  • See also:



  • subfield views


    .diag()
    .diag( k )
  • See also:



  • .each_col()    .each_row()    (form 1)
    .each_col( vector_of_indices )   .each_row( vector_of_indices )   (form 2)
    .each_col( lambda_function )    .each_row( lambda_function )    (form 3)

  • See also:



  • .each_slice()   (form 1)
    .each_slice( vector_of_indices )   (form 2)
    .each_slice( lambda_function )   (form 3)
    .each_slice( lambda_function, use_mp )   (form 4)

  • See also:



  • .set_imag( X )
    .set_real( X )

  • Caveat: to directly construct a complex matrix out of two real matrices, the following code is faster:
       mat A(4, 5, fill::randu);
       mat B(4, 5, fill::randu);
    
    cx_mat C = cx_mat(A,B);
    

  • See also:



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

  • See also:



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

  • See also:



  • .swap_rows( row1, row2 )
    .swap_cols( col1, col2 )

  • See also:



  • .swap( X )
  • See also:



  • .memptr()
  • See also:



  • .colptr( col_number )
  • See also:



  • iterators (dense matrices & vectors)
  • See also:



  • iterators (cubes)
  • See also:



  • iterators (sparse matrices)
  • See also:



  • iterators (dense submatrices & subcubes)
  • See also:



  • compatibility container functions
  • See also:



  • .as_col()
    .as_row()

  • See also:



  • .col_as_mat( col_number )
    .row_as_mat( row_number )
  • See also:



  • .as_dense()
  • See also:



  • .t()
    .st()

  • See also:



  • .i()
  • See also:



  • .min()
    .max()
  • See also:



  • .index_min()
    .index_max()
  • See also:



  • .eval()

  • See also:



  • .in_range( i )
      (member of Mat, Col, Row, Cube, SpMat, field)
    .in_range( span(start, end) )
      (member of Mat, Col, Row, Cube, SpMat, field)
     
    .in_range( row, col )
      (member of Mat, Col, Row, SpMat, field)
    .in_range( span(start_row, end_row), span(start_col, end_col) )
      (member of Mat, Col, Row, SpMat, 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 matrix or field)
      (member of Mat, Col, Row, SpMat, field)
    .in_range( first_row, first_col, size(n_rows, n_cols) )
      (member of Mat, Col, Row, SpMat, field)
     
    .in_range( first_row, first_col, first_slice, size(Q) )   (Q is a cube or 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)

  • See also:



  • .is_empty()
  • See also:



  • .is_vec()
    .is_colvec()
    .is_rowvec()
  • See also:



  • .is_sorted()
    .is_sorted( sort_direction )
    .is_sorted( sort_direction, dim )
  • See also:



  • .is_trimatu()
    .is_trimatl()
  • See also:



  • .is_diagmat()
  • See also:



  • .is_square()
  • See also:



  • .is_symmetric()
    .is_symmetric( tol )
  • See also:



  • .is_hermitian()
    .is_hermitian( tol )
  • See also:



  • .is_sympd()
    .is_sympd( tol )
  • See also:



  • .is_zero()
    .is_zero( tolerance )
  • See also:



  • .is_finite()
  • See also:



  • .has_inf()
  • See also:



  • .has_nan()
  • See also:



  • .print()
    .print( header )

    .print( stream )
    .print( stream, header )
  • See also:



  • .raw_print()
    .raw_print( header )

    .raw_print( stream )
    .raw_print( stream, header )
  • See also:



  • .brief_print()
    .brief_print( header )

    .brief_print( stream )
    .brief_print( stream, header )
  • See also:



  • saving / loading matrices & cubes

    .save( filename )
    .save( filename, file_type )

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

    .save( hdf5_name(filename, dataset) )
    .save( hdf5_name(filename, dataset, settings) )

    .save( csv_name(filename, header) )
    .save( csv_name(filename, header, settings) )
           .load( filename )
    .load( filename, file_type )

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

    .load( hdf5_name(filename, dataset) )
    .load( hdf5_name(filename, dataset, settings) )

    .load( csv_name(filename, header) )
    .load( csv_name(filename, header, settings) )


  • See also:



  • saving / loading fields

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

    .save( stream )
    .save( stream, file_type )
           .load( name )
    .load( name, file_type )

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





    Generated Vectors / Matrices / Cubes



    linspace( start, end )
    linspace( start, end, N )
  • See also:



  • logspace( A, B )
    logspace( A, B, N )
  • See also:



  • regspace( start, end )
    regspace( start, delta, end )
  • Caveat: do not use regspace() to specify ranges for contiguous submatrix views; use span() instead

  • See also:



  • randperm( N )
    randperm( N, M )
  • See also:



  • eye( n_rows, n_cols )
    eye( size(X) )
  • See also:



  • ones( n_elem )
    ones( n_rows, n_cols )
    ones( n_rows, n_cols, n_slices )
    ones( size(X) )

  • See also:



  • zeros( n_elem )
    zeros( n_rows, n_cols )
    zeros( n_rows, n_cols, n_slices )
    zeros( size(X) )
  • See also:



  • randu( )
    randu( distr_param(a,b) )

    randu( n_elem )
    randu( n_elem, distr_param(a,b) )

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

    randu( n_rows, n_cols, n_slices )
    randu( n_rows, n_cols, n_slices, distr_param(a,b) )

    randu( size(X) )
    randu( size(X), distr_param(a,b) )
  • See also:



  • randn( )
    randn( distr_param(mu,sd) )

    randn( n_elem )
    randn( n_elem, distr_param(mu,sd) )

    randn( n_rows, n_cols )
    randn( n_rows, n_cols, distr_param(mu,sd) )

    randn( n_rows, n_cols, n_slices )
    randn( n_rows, n_cols, n_slices, distr_param(mu,sd) )

    randn( size(X) )
    randn( size(X), distr_param(mu,sd) )
  • See also:



  • rande( )
    rande( distr_param( λ ) )

    rande( n_elem )
    rande( n_elem, distr_param( λ ) )

    rande( n_rows, n_cols )
    rande( n_rows, n_cols, distr_param( λ ) )

    rande( n_rows, n_cols, n_slices )
    rande( n_rows, n_cols, n_slices, distr_param( λ ) )

    rande( size(X) )
    rande( size(X), distr_param( λ ) )
  • See also:



  • randg( )
    randg( distr_param(a,b) )

    randg( n_elem )
    randg( n_elem, distr_param(a,b) )

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

    randg( n_rows, n_cols, n_slices )
    randg( n_rows, n_cols, n_slices, distr_param(a,b) )

    randg( size(X) )
    randg( size(X), distr_param(a,b) )
  • See also:



  • randi( )
    randi( distr_param(a,b) )

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

    randi( size(X) )
    randi( size(X), distr_param(a,b) )
  • See also:



  • speye( n_rows, n_cols )
    speye( size(X) )
  • See also:



  • spones( A )
  • See also:



  • sprandu( n_rows, n_cols, density )
    sprandn( n_rows, n_cols, density )

    sprandu( size(X), density )
    sprandn( size(X), density )
  • See also:



  • toeplitz( A )
    toeplitz( A, B )
  • See also:





  • Functions of Vectors / Matrices / Cubes



    abs( X )
  • See also:



  • accu( X )
  • See also:



  • all( V )
    all( X )
    all( X, dim )
  • See also:



  • any( V )
    any( X )
    any( X, dim )
  • See also:



  • approx_equal( A, B, method, tol )
    approx_equal( A, B, method, abs_tol, rel_tol )
  • See also:



  • arg( X )
  • See also:



  • as_scalar( expression )
  • See also:



  • B = balance( A )
    B = balance( A, method )

    balance( B, A )
    balance( B, A, method )

    balance( S, P, B, A )
    balance( S, P, B, A, method )
  • See also:



  • circshift( V, N )
    circshift( X, N )
    circshift( X, N, dim )
  • See also:



  • clamp( X, min_val, max_val )
  • See also:



  • c = cond( X )   (form 1)
    cond( c, X )   (form 2)

  • See also:



  • conj( X )
  • See also:



  • conv_to< type >::from( X )
  • See also:



  • cross( A, B )
  • See also:



  • cumsum( V )
    cumsum( X )
    cumsum( X, dim )
  • See also:



  • cumprod( V )
    cumprod( X )
    cumprod( X, dim )
  • See also:



  • val = det( A )   (form 1)
    det( val, A )   (form 2)

  • See also:



  • diagmat( V )
    diagmat( V, k )

    diagmat( X )
    diagmat( X, k )
  • See also:



  • diagvec( X )
    diagvec( X, k )
  • See also:



  • diags( V, D, n_rows, n_cols )
    spdiags( V, D, n_rows, n_cols )

  • See also:



  • diff( V )
    diff( V, k )

    diff( X )
    diff( X, k )
    diff( X, k, dim )
  • See also:



  • dot( A, B )
    cdot( A, B )
    norm_dot( A, B )
  • See also:



  • eps( X )
  • See also:



  • B = expmat( A )
    expmat( B, A )
  • See also:



  • B = expmat_sym( A )
    expmat_sym( B, A )
  • See also:



  • find( X )
    find( X, k )
    find( X, k, s )
  • See also:



  • find_finite( X )
    find_nonfinite( X )
  • See also:



  • find_nan( X )
    find_nonnan( X )
  • Caveat: to replace instances of NaN values, it is more efficient to use replace()

  • See also:



  • find_unique( X )
    find_unique( X, ascending_indices )
  • See also:



  • fliplr( X )
    flipud( X )
  • See also:



  • imag( X )
    real( X )
  • See also:



  • uvec sub = ind2sub( size(X), index )   (form 1)
    umat sub = ind2sub( size(X), vector_of_indices )   (form 2)

  • See also:



  • index_min( V )
    index_min( M )
    index_min( M, dim )
    index_min( Q )
    index_min( Q, dim )
           index_max( V )
    index_max( M )
    index_max( M, dim )
    index_max( Q )
    index_max( Q, dim )

  • See also:



  • inplace_trans( X )
    inplace_trans( X, method )

    inplace_strans( X )
    inplace_strans( X, method )

  • See also:



  • C = intersect( A, B )   (form 1)
    intersect( C, iA, iB, A, B )   (form 2)

  • See also:



  • join_rows( A, B )
    join_rows( A, B, C )
    join_rows( A, B, C, D )
     
    join_cols( A, B )
    join_cols( A, B, C )
    join_cols( A, B, C, D )
           join_horiz( A, B )
    join_horiz( A, B, C )
    join_horiz( A, B, C, D )
     
    join_vert( A, B )
    join_vert( A, B, C )
    join_vert( A, B, C, D )

  • See also:



  • join_slices( cube C, cube D )
    join_slices( mat M, mat N )

    join_slices( mat M, cube C )
    join_slices( cube C, mat M )
  • See also:



  • kron( A, B )
  • See also:



  • complex result = log_det( A )   (form 1)
    log_det( val, sign, A )   (form 2)

  • See also:



  • result = log_det_sympd( A )   (form 1)
    log_det_sympd( result, A )   (form 2)

  • See also:



  • B = logmat( A )
    logmat( B, A )
  • See also:



  • B = logmat_sympd( A )
    logmat_sympd( B, A )
  • See also:



  • min( V )
    min( M )
    min( M, dim )
    min( Q )
    min( Q, dim )
    min( A, B )
           max( V )
    max( M )
    max( M, dim )
    max( Q )
    max( Q, dim )
    max( A, B )

  • See also:



  • norm( X )
    norm( X, p )
  • See also:



  • norm2est( X )
    norm2est( X, tol )
    norm2est( X, tol, max_iter )
  • See also:



  • normalise( V )
    normalise( V, p )

    normalise( X )
    normalise( X, p )
    normalise( X, p, dim )
  • See also:



  • nonzeros( X )
  • See also:



  • omit_nan( X )
    omit_nonfinite( X )
  • See also:



  • pow( A, scalar )   (form 1)
    pow( A, B )   (form 2)

  • See also:



  • B = powmat( A, n )
    powmat( B, A, n )
  • See also:



  • prod( V )
    prod( M )
    prod( M, dim )
  • See also:



  • r = rank( X )   (form 1)
    r = rank( X, tolerance )    
      
    rank( r, X )   (form 2)
    rank( r, X, tolerance )    

  • See also:



  • rcond( A )
  • See also:



  • repelem( A, num_copies_per_row, num_copies_per_col )
  • See also:



  • replace( A, old_value, new_value )
  • See also:



  • repmat( A, num_copies_per_row, num_copies_per_col )
  • See also:



  • repcube( C, num_copies_per_row, num_copies_per_col, num_copies_per_slice )
  • See also:



  • reshape( X, n_rows, n_cols )    (X is a vector or matrix)
    reshape( X, size(Y) )

    reshape( Q, n_rows, n_cols, n_slices )    (Q is a cube)
    reshape( Q, size(R) )
  • See also:



  • resize( X, n_rows, n_cols )    (X is a vector or matrix)
    resize( X, size(Y) )

    resize( Q, n_rows, n_cols, n_slices )    (Q is a cube)
    resize( Q, size(R) )
  • See also:



  • reverse( V )
    reverse( X )
    reverse( X, dim )
  • See also:



  • R = roots( P )
    roots( R, P )
  • See also:



  • shuffle( V )
    shuffle( X )
    shuffle( X, dim )
  • See also:



  • size( X )
    size( n_rows, n_cols )
    size( n_rows, n_cols, n_slices )
  • See also:



  • sort( V )
    sort( V, sort_direction )

    sort( X )
    sort( X, sort_direction )
    sort( X, sort_direction, dim )
  • See also:



  • sort_index( X )
    sort_index( X, sort_direction )
  • See also:



  • B = sqrtmat( A )
    sqrtmat( B, A )
  • See also:



  • B = sqrtmat_sympd( A )
    sqrtmat_sympd( B, A )
  • See also:



  • sum( V )
    sum( M )
    sum( M, dim )
    sum( Q )
    sum( Q, dim )
  • See also:



  • uword index = sub2ind( size(M), row, col )(M is a matrix)
    uvec indices = sub2ind( size(M), matrix_of_subscripts )
        
    uword index = sub2ind( size(Q), row, col, slice )(Q is a cube)
    uvec indices = sub2ind( size(Q), matrix_of_subscripts )

  • See also:



  • symmatu( A )
    symmatu( A, do_conj )

    symmatl( A )
    symmatl( A, do_conj )
  • See also:



  • trace( X )
  • See also:



  • trans( A )
    strans( A )
  • See also:



  • trapz( X, Y )
    trapz( X, Y, dim )

    trapz( Y )
    trapz( Y, dim )
  • See also:



  • trimatu( A )
    trimatu( A, k )

    trimatl( A )
    trimatl( A, k )
  • See also:



  • trimatu_ind( size(A) )
    trimatu_ind( size(A), k )

    trimatl_ind( size(A) )
    trimatl_ind( size(A), k )
  • See also:



  • unique( A )

  • See also:



  • vecnorm( X )
    vecnorm( X, p )
    vecnorm( X, p, dim )
  • See also:



  • vectorise( X )
    vectorise( X, dim )
    vectorise( Q )
  • See also:



  • miscellaneous element-wise functions:
  • See also:



  • trigonometric element-wise functions (cos, sin, tan, ...)
  • See also:





  • Decompositions, Factorisations, Inverses and Equation Solvers (Dense Matrices)



    R = chol( X )   (form 1)
    R = chol( X, layout )   (form 2)
       
    chol( R, X )   (form 3)
    chol( R, X, layout )   (form 4)
       
    chol( R, P, X, layout, "vector" )   (form 5)
    chol( R, P, X, layout, "matrix" )   (form 6)

  • See also:



  • vec eigval = eig_sym( X )

    eig_sym( eigval, X )

    eig_sym( eigval, eigvec, X )
    eig_sym( eigval, eigvec, X, method )
  • See also:



  • cx_vec eigval = eig_gen( X )
    cx_vec eigval = eig_gen( X, bal )

    eig_gen( eigval, X )
    eig_gen( eigval, X, bal )

    eig_gen( eigval, eigvec, X )
    eig_gen( eigval, eigvec, X, bal )

    eig_gen( eigval, leigvec, reigvec, X )
    eig_gen( eigval, leigvec, reigvec, X, bal )
  • See also:



  • cx_vec eigval = eig_pair( A, B )

    eig_pair( eigval, A, B )

    eig_pair( eigval, eigvec, A, B )

    eig_pair( eigval, leigvec, reigvec, A, B )
  • See also:



  • H = hess( X )

    hess( H, X )

    hess( U, H, X )
  • See also:



  • B = inv( A )
    B = inv( A, settings )

    inv( B, A )
    inv( B, A, settings )

    inv( B, rcond, A )
  • See also:



  • B = inv_sympd( A )
    B = inv_sympd( A, settings )

    inv_sympd( B, A )
    inv_sympd( B, A, settings )

    inv_sympd( B, rcond, A )
  • See also:



  • lu( L, U, P, X )
    lu( L, U, X )
  • See also:



  • B = null( A )
    B = null( A, tolerance )

    null( B, A )
    null( B, A, tolerance )
  • See also:



  • B = orth( A )
    B = orth( A, tolerance )

    orth( B, A )
    orth( B, A, tolerance )
  • See also:



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

    pinv( B, A )
    pinv( B, A, tolerance )
    pinv( B, A, tolerance, method )
  • See also:



  • qr( Q, R, X )   (form 1)
    qr( Q, R, P, X, "vector" )   (form 2)
    qr( Q, R, P, X, "matrix" )   (form 3)

  • See also:



  • qr_econ( Q, R, X )
  • See also:



  • qz( AA, BB, Q, Z, A, B )
    qz( AA, BB, Q, Z, A, B, select )
  • See also:



  • S = schur( X )

    schur( S, X )

    schur( U, S, X )
  • See also:



  • X = solve( A, B )
    X = solve( A, B, settings )

    solve( X, A, B )
    solve( X, A, B, settings )
  • See also:



  • vec s = svd( X )

    svd( vec s, X )

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

    svd( cx_mat U, vec s, cx_mat V, cx_mat X )
    svd( cx_mat U, vec s, cx_mat V, cx_mat X, method )
  • See also:



  • svd_econ( mat U, vec s, mat V, mat X )
    svd_econ( mat U, vec s, mat V, mat X, mode )
    svd_econ( mat U, vec s, mat V, mat X, mode, method )

    svd_econ( cx_mat U, vec s, cx_mat V, cx_mat X )
    svd_econ( cx_mat U, vec s, cx_mat V, cx_mat X, mode )
    svd_econ( cx_mat U, vec s, cx_mat V, cx_mat X, mode, method )
  • See also:



  • X = sylvester( A, B, C )
    sylvester( X, A, B, C )
  • See also:





  • Decompositions, Factorisations and Equation Solvers (Sparse Matrices)



    vec eigval = eigs_sym( X, k )
    vec eigval = eigs_sym( X, k, form )
    vec eigval = eigs_sym( X, k, form, opts )
    vec eigval = eigs_sym( X, k, sigma )
    vec eigval = eigs_sym( X, k, sigma, opts )

    eigs_sym( eigval, X, k )
    eigs_sym( eigval, X, k, form )
    eigs_sym( eigval, X, k, form, opts )
    eigs_sym( eigval, X, k, sigma )
    eigs_sym( eigval, X, k, sigma, opts )

    eigs_sym( eigval, eigvec, X, k )
    eigs_sym( eigval, eigvec, X, k, form )
    eigs_sym( eigval, eigvec, X, k, form, opts )
    eigs_sym( eigval, eigvec, X, k, sigma )
    eigs_sym( eigval, eigvec, X, k, sigma, opts )
  • The eigenvalues and corresponding eigenvectors are stored in eigval and eigvec, respectively

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

  • If the decomposition fails:

  • Caveats:

  • NOTE: the implementation in Armadillo 12.6 is considerably faster than earlier versions; further speedups can be obtained by enabling OpenMP in your compiler (eg. -fopenmp in GCC and clang)

  • Examples:
    // generate sparse matrix
    sp_mat A = sprandu<sp_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
    
    eigs_opts opts;
    opts.maxiter = 10000;            // increase max iterations to 10000
    
    eigs_sym(eigval, eigvec, B, 5, "lm", opts);
    

  • See also:



  • cx_vec eigval = eigs_gen( X, k )
    cx_vec eigval = eigs_gen( X, k, form )
    cx_vec eigval = eigs_gen( X, k, sigma )
    cx_vec eigval = eigs_gen( X, k, form, opts )
    cx_vec eigval = eigs_gen( X, k, sigma, opts )

    eigs_gen( eigval, X, k )
    eigs_gen( eigval, X, k, form )
    eigs_gen( eigval, X, k, sigma )
    eigs_gen( eigval, X, k, form, opts )
    eigs_gen( eigval, X, k, sigma, opts )

    eigs_gen( eigval, eigvec, X, k )
    eigs_gen( eigval, eigvec, X, k, form )
    eigs_gen( eigval, eigvec, X, k, sigma )
    eigs_gen( eigval, eigvec, X, k, form, opts )
    eigs_gen( eigval, eigvec, X, k, sigma, opts )
  • The eigenvalues and corresponding eigenvectors are stored in eigval and eigvec, respectively

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

  • If the decomposition fails:

  • Caveats:

  • NOTE: the implementation in Armadillo 12.6 is considerably faster than earlier versions; further speedups can be obtained by enabling OpenMP in your compiler (eg. -fopenmp in GCC and clang)

  • Examples:
    // generate sparse matrix
    sp_mat A = sprandu<sp_mat>(1000, 1000, 0.1);  
    
    cx_vec eigval;
    cx_mat eigvec;
    
    eigs_gen(eigval, eigvec, A, 5);  // find 5 eigenvalues/eigenvectors
    
    eigs_opts opts;
    opts.maxiter = 10000;            // increase max iterations to 10000
    
    eigs_gen(eigval, eigvec, A, 5, "lm", opts);
    

  • See also:



  • vec s = svds( X, k )
    vec s = svds( X, k, tol )

    svds( vec s, X, k )
    svds( vec s, X, k, tol )

    svds( mat U, vec s, mat V, sp_mat X, k )
    svds( mat U, vec s, mat V, sp_mat X, k, tol )

    svds( cx_mat U, vec s, cx_mat V, sp_cx_mat X, k )
    svds( cx_mat U, vec s, cx_mat V, sp_cx_mat X, k, tol )
  • See also:



  • X = spsolve( A, B )
    X = spsolve( A, B, solver )
    X = spsolve( A, B, solver, opts )

    spsolve( X, A, B )
    spsolve( X, A, B, solver )
    spsolve( X, A, B, solver, opts )

  • Examples:
    sp_mat A = sprandu<sp_mat>(1000, 1000, 0.1);
    
    vec b(1000,    fill::randu);
    mat B(1000, 5, fill::randu);
    
    vec x = spsolve(A, b);  // solve one system
    mat X = spsolve(A, B);  // solve several systems
    
    bool status = spsolve(x, A, b);  // use default solver
    if(status == false)  { cout << "no solution" << endl; }
    
    spsolve(x, A, b, "lapack" );  // use LAPACK  solver
    spsolve(x, A, b, "superlu");  // use SuperLU solver
    
    superlu_opts opts;
    
    opts.allow_ugly  = true;
    opts.equilibrate = true;
    
    spsolve(x, A, b, "superlu", opts);
    

  • See also:



  • spsolve_factoriser

  • See also:





  • Signal & Image Processing



    affmul( A, B )
    ⎡ C0 ⎤   ⎡ A00 A01 A02 ⎤   ⎡ B0 ⎤
    ⎢ C1 ⎥ = ⎢ A10 A11 A12 ⎥ x ⎢ B1 ⎥
    ⎣ C2 ⎦   ⎣ A20 A21 A22 ⎦   ⎣ 1 
  • If A is 2x3 and B is 2x1, the equivalent matrix multiplication is:
  • ⎡ C0 ⎤   ⎡ A00 A01 A02 ⎤   ⎡ B0 ⎤
    ⎣ C1 ⎦ = ⎣ A10 A11 A12 ⎦ x ⎢ B1 ⎥
                              ⎣ 1 
  • Examples:
    mat A(2, 3, fill::randu);
    vec B(2,    fill::randu);
    
    vec C = affmul(A,B);
    

  • See also:



  • conv( A, B )
    conv( A, B, shape )
  • See also:



  • conv2( A, B )
    conv2( A, B, shape )
  • See also:



  • cx_mat Y =  fft( X )
    cx_mat Y =  fft( X, n )

    cx_mat Z = ifft( cx_mat Y )
    cx_mat Z = ifft( cx_mat Y, n )

  • See also:



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

    cx_mat Z = ifft2( cx_mat Y )
    cx_mat Z = ifft2( cx_mat Y, n_rows, n_cols )

  • See also:



  • interp1( X, Y, XI, YI )
    interp1( X, Y, XI, YI, method )
    interp1( X, Y, XI, YI, method, extrapolation_value )
  • See also:



  • interp2( X, Y, Z, XI, YI, ZI )
    interp2( X, Y, Z, XI, YI, ZI, method )
    interp2( X, Y, Z, XI, YI, ZI, method, extrapolation_value )
  • See also:



  • P = polyfit( X, Y, N )
    polyfit( P, X, Y, N )
  • See also:



  • Y = polyval( P, X )
  • See also:





  • Statistics & Clustering



    mean, median, stddev, var, range
  • See also:



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

    cov( X )
    cov( X, norm_type )
  • See also:



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

    cor( X )
    cor( X, norm_type )
  • See also:



  • hist( V )
    hist( V, n_bins )
    hist( V, centers )

    hist( X, centers )
    hist( X, centers, dim )
  • See also:



  • histc( V, edges )
    histc( X, edges )
    histc( X, edges, dim )
  • See also:



  • quantile( V, P )
    quantile( X, P )
    quantile( X, P, dim )
  • See also:



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

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

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

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

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

  • See also:



  • normpdf( X )
    normpdf( X, M, S )
  • See also:



  • log_normpdf( X )
    log_normpdf( X, M, S )
  • See also:



  • normcdf( X )
    normcdf( X, M, S )
  • See also:



  • X = mvnrnd( M, C )
    X = mvnrnd( M, C, N )

    mvnrnd( X, M, C )
    mvnrnd( X, M, C, N )
  • See also:



  • chi2rnd( DF )
    chi2rnd( DF_scalar )
    chi2rnd( DF_scalar, n_elem )
    chi2rnd( DF_scalar, n_rows, n_cols )
    chi2rnd( DF_scalar, size(X) )

  • See also:



  • W = wishrnd( S, df )
    W = wishrnd( S, df, D )

    wishrnd( W, S, df )
    wishrnd( W, S, df, D )
  • See also:



  • W = iwishrnd( T, df )
    W = iwishrnd( T, df, Dinv )

    iwishrnd( W, T, df )
    iwishrnd( W, T, df, Dinv )
  • See also:



  • running_stat<type>
  • See also:



  • running_stat_vec<vec_type>
    running_stat_vec<vec_type>(calc_cov)
  • See also:



  • kmeans( means, data, k, seed_mode, n_iter, print_mode )
  • See also:



  • gmm_diag
    gmm_full
  • See also:





  • Miscellaneous



    constants (pi, inf, eps, ...)
  • See also:



  • wall_clock
  • See also:



  • RNG seed setting


    output streams


    uword, sword


    cx_double, cx_float
  • See also:



  • fp16, cx_fp16
  • See also:



  • Examples of Matlab/Octave syntax and conceptually corresponding Armadillo syntax




    example program
    #include <iostream>
    #include <armadillo>
    
    using namespace std;
    using namespace arma;
    
    int main()
      {
      mat A(4, 5, fill::randu);
      mat B(4, 5, fill::randu);
      
      cout << A*B.t() << endl;
      
      return 0;
      }
    
  • If the above program is stored as example.cpp, under Linux and macOS it can be compiled using:

  • Armadillo extensively uses template meta-programming, so it's recommended to enable optimisation when compiling programs (eg. use the -O2 or -O3 options for GCC or clang)

  • See the Questions page for more info on compiling and linking

  • See also the example program that comes with the Armadillo archive



  • config.hpp


    History of API Additions and Changes



    sourceforge