Stan  1.0
probability, sampling & optimization
Classes | Namespaces | Macros | Typedefs | Functions
matrix.hpp File Reference
#include <stdarg.h>
#include <stdexcept>
#include <ostream>
#include <vector>
#include <boost/math/tools/promotion.hpp>
#include <Eigen/Dense>
#include <stan/math/boost_error_handling.hpp>

Go to the source code of this file.

Classes

struct  stan::math::promoter< F, T >
 
struct  stan::math::promoter< T, T >
 
struct  stan::math::promoter< std::vector< F >, std::vector< T > >
 
struct  stan::math::promoter< std::vector< T >, std::vector< T > >
 
struct  stan::math::promoter< Eigen::Matrix< F, R, C >, Eigen::Matrix< T, R, C > >
 
struct  stan::math::promoter< Eigen::Matrix< T, R, C >, Eigen::Matrix< T, R, C > >
 
struct  stan::math::common_type< T1, T2 >
 
struct  stan::math::common_type< std::vector< T1 >, std::vector< T2 > >
 
struct  stan::math::common_type< Eigen::Matrix< T1, R, C >, Eigen::Matrix< T2, R, C > >
 
struct  stan::math::array_builder< T >
 Structure for building up arrays in an expression (rather than in statements) using an argumentchaining add() method and a getter method array() to return the result. More...
 

Namespaces

 stan
 Probability, optimization and sampling library.
 
 stan::math
 Matrices and templated mathematical functions.
 

Macros

#define EIGEN_DENSEBASE_PLUGIN   "stan/math/EigenDenseBaseAddons.hpp"
 

Typedefs

typedef Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > stan::math::matrix_d
 Type for matrix of double values. More...
 
typedef Eigen::Matrix< double, Eigen::Dynamic, 1 > stan::math::vector_d
 Type for (column) vector of double values. More...
 
typedef Eigen::Matrix< double, 1, Eigen::Dynamic > stan::math::row_vector_d
 Type for (row) vector of double values. More...
 

Functions

template<typename T1 , typename T2 , typename F >
common_type< T1, T2 >::type stan::math::promote_common (const F &u)
 
template<typename T >
void stan::math::resize (T &x, std::vector< size_t > dims)
 Recursively resize the specified vector of vectors, which must bottom out at scalar values, Eigen vectors or Eigen matrices. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< T > &x, size_t i, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one index. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< T > > &x, size_t i1, size_t i2, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< std::vector< T > > > &x, size_t i1, size_t i2, size_t i3, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< std::vector< std::vector< T > > > > &x, size_t i1, size_t i2, size_t i3, size_t i4, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< std::vector< std::vector< std::vector< T > > > > > &x, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< T > > > > > > &x, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< T > > > > > > > &x, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, size_t i7, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
T & stan::math::get_base1 (std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< std::vector< T > > > > > > > > &x, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, size_t i7, size_t i8, const char *error_msg, size_t idx)
 Return a reference to the value of the specified vector at the specified base-one indexes. More...
 
template<typename T >
Eigen::Matrix< T, 1, Eigen::Dynamic > stan::math::get_base1 (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, size_t m, const char *error_msg, size_t idx)
 Return a copy of the row of the specified vector at the specified base-one row index. More...
 
template<typename T >
T & stan::math::get_base1 (Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x, size_t m, size_t n, const char *error_msg, size_t idx)
 Return a reference to the value of the specified matrix at the specified base-one row and column indexes. More...
 
template<typename T >
T & stan::math::get_base1 (Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, size_t m, const char *error_msg, size_t idx)
 Return a reference to the value of the specified column vector at the specified base-one index. More...
 
template<typename T >
T & stan::math::get_base1 (Eigen::Matrix< T, 1, Eigen::Dynamic > &x, size_t n, const char *error_msg, size_t idx)
 Return a reference to the value of the specified row vector at the specified base-one index. More...
 
template<typename T , int R, int C>
size_t stan::math::rows (const Eigen::Matrix< T, R, C > &m)
 
template<typename T , int R, int C>
size_t stan::math::cols (const Eigen::Matrix< T, R, C > &m)
 
template<typename T1 , typename T2 >
void stan::math::validate_less_or_equal (const T1 &x, const T2 &y, const char *x_name, const char *y_name, const char *fun_name)
 
template<typename T1 , typename T2 >
void stan::math::validate_less (const T1 &x, const T2 &y, const char *x_name, const char *y_name, const char *fun_name)
 
template<typename T1 , typename T2 >
void stan::math::validate_greater_or_equal (const T1 &x, const T2 &y, const char *x_name, const char *y_name, const char *fun_name)
 
template<typename T1 , typename T2 >
void stan::math::validate_greater (const T1 &x, const T2 &y, const char *x_name, const char *y_name, const char *fun_name)
 
template<typename T , int R, int C>
void stan::math::validate_column_index (const Eigen::Matrix< T, R, C > &m, size_t j, const char *msg)
 
template<typename T , int R, int C>
void stan::math::validate_row_index (const Eigen::Matrix< T, R, C > &m, size_t i, const char *msg)
 
template<typename T , int R, int C>
void stan::math::validate_square (const Eigen::Matrix< T, R, C > &x, const char *msg)
 
template<typename T , int R, int C>
void stan::math::validate_symmetric (const Eigen::Matrix< T, R, C > &x, const char *msg)
 
template<typename T1 , int R1, int C1, typename T2 , int R2, int C2>
void stan::math::validate_matching_dims (const Eigen::Matrix< T1, R1, C1 > &x1, const Eigen::Matrix< T2, R2, C2 > &x2, const char *msg)
 
template<typename T1 , typename T2 >
void stan::math::validate_matching_sizes (const std::vector< T1 > &x1, const std::vector< T2 > &x2, const char *msg)
 
template<typename T1 , int R1, int C1, typename T2 , int R2, int C2>
void stan::math::validate_matching_sizes (const Eigen::Matrix< T1, R1, C1 > &x1, const Eigen::Matrix< T2, R2, C2 > &x2, const char *msg)
 
template<typename T1 , int R1, int C1, typename T2 , int R2, int C2>
void stan::math::validate_multiplicable (const Eigen::Matrix< T1, R1, C1 > &x1, const Eigen::Matrix< T2, R2, C2 > &x2, const char *msg)
 
template<typename T >
void stan::math::validate_nonzero_size (const T &x, const char *msg)
 
template<typename T , int R, int C>
void stan::math::validate_vector (const Eigen::Matrix< T, R, C > &x, const char *msg)
 
template<typename T >
stan::math::determinant (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Returns the determinant of the specified square matrix. More...
 
template<int R, int C>
double stan::math::dot_self (const Eigen::Matrix< double, R, C > &v)
 Returns the dot product of the specified vector with itself. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > stan::math::columns_dot_self (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x)
 Returns the dot product of each column of a matrix with itself. More...
 
template<int R1, int C1, int R2, int C2>
double stan::math::dot_product (const Eigen::Matrix< double, R1, C1 > &v1, const Eigen::Matrix< double, R2, C2 > &v2)
 Returns the dot product of the specified vectors. More...
 
double stan::math::dot_product (const double *v1, const double *v2, size_t length)
 Returns the dot product of the specified arrays of doubles. More...
 
double stan::math::dot_product (const std::vector< double > &v1, const std::vector< double > &v2)
 Returns the dot product of the specified arrays of doubles. More...
 
int stan::math::min (const std::vector< int > &x)
 Returns the minimum coefficient in the specified column vector. More...
 
template<typename T >
stan::math::min (const std::vector< T > &x)
 Returns the minimum coefficient in the specified column vector. More...
 
template<typename T , int R, int C>
stan::math::min (const Eigen::Matrix< T, R, C > &m)
 Returns the minimum coefficient in the specified matrix, vector, or row vector. More...
 
int stan::math::max (const std::vector< int > &x)
 Returns the maximum coefficient in the specified column vector. More...
 
template<typename T >
stan::math::max (const std::vector< T > &x)
 Returns the maximum coefficient in the specified column vector. More...
 
template<typename T , int R, int C>
stan::math::max (const Eigen::Matrix< T, R, C > &m)
 Returns the maximum coefficient in the specified vector, row vector, or matrix. More...
 
template<typename T >
boost::math::tools::promote_args< T >::type stan::math::mean (const std::vector< T > &v)
 Returns the sample mean (i.e., average) of the coefficients in the specified standard vector. More...
 
template<typename T , int R, int C>
boost::math::tools::promote_args< T >::type stan::math::mean (const Eigen::Matrix< T, R, C > &m)
 Returns the sample mean (i.e., average) of the coefficients in the specified vector, row vector, or matrix. More...
 
template<typename T >
boost::math::tools::promote_args< T >::type stan::math::variance (const std::vector< T > &v)
 Returns the sample variance (divide by length - 1) of the coefficients in the specified standard vector. More...
 
template<typename T , int R, int C>
boost::math::tools::promote_args< T >::type stan::math::variance (const Eigen::Matrix< T, R, C > &m)
 Returns the sample variance (divide by length - 1) of the coefficients in the specified column vector. More...
 
template<typename T >
boost::math::tools::promote_args< T >::type stan::math::sd (const std::vector< T > &v)
 Returns the unbiased sample standard deviation of the coefficients in the specified column vector. More...
 
template<typename T , int R, int C>
boost::math::tools::promote_args< T >::type stan::math::sd (const Eigen::Matrix< T, R, C > &m)
 Returns the unbiased sample standard deviation of the coefficients in the specified vector, row vector, or matrix. More...
 
template<typename T >
stan::math::sum (const std::vector< T > &xs)
 Return the sum of the values in the specified standard vector. More...
 
template<typename T , int R, int C>
double stan::math::sum (const Eigen::Matrix< T, R, C > &v)
 Returns the sum of the coefficients of the specified column vector. More...
 
template<typename T >
stan::math::prod (const std::vector< T > &v)
 Returns the product of the coefficients of the specified standard vector. More...
 
template<typename T , int R, int C>
stan::math::prod (const Eigen::Matrix< T, R, C > &v)
 Returns the product of the coefficients of the specified column vector. More...
 
template<typename T >
stan::math::trace (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Returns the trace of the specified matrix. More...
 
template<typename T , int Rows, int Cols>
Eigen::Matrix< T, Rows, Cols > stan::math::log (const Eigen::Matrix< T, Rows, Cols > &m)
 Return the element-wise logarithm of the matrix or vector. More...
 
template<typename T , int Rows, int Cols>
Eigen::Matrix< T, Rows, Cols > stan::math::exp (const Eigen::Matrix< T, Rows, Cols > &m)
 Return the element-wise exponentiation of the matrix or vector. More...
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::add (const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
 Return the sum of the specified matrices. More...
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::add (const Eigen::Matrix< T1, R, C > &m, const T2 &c)
 Return the sum of the specified matrix and specified scalar. More...
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::add (const T1 &c, const Eigen::Matrix< T2, R, C > &m)
 Return the sum of the specified scalar and specified matrix. More...
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::subtract (const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
 Return the result of subtracting the second specified matrix from the first specified matrix. More...
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::subtract (const T1 &c, const Eigen::Matrix< T2, R, C > &m)
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::subtract (const Eigen::Matrix< T1, R, C > &m, const T2 &c)
 
template<typename T >
stan::math::minus (const T &x)
 Returns the negation of the specified scalar or matrix. More...
 
template<int R, int C>
Eigen::Matrix< double, R, C > stan::math::divide (const Eigen::Matrix< double, R, C > &m, double c)
 Return specified matrix divided by specified scalar. More...
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::elt_multiply (const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
 Return the elementwise multiplication of the specified matrices. More...
 
template<typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R2, C2 > stan::math::diag_pre_multiply (const Eigen::Matrix< T1, R1, C1 > &m1, const Eigen::Matrix< T2, R2, C2 > &m2)
 
template<typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C1 > stan::math::diag_post_multiply (const Eigen::Matrix< T1, R1, C1 > &m1, const Eigen::Matrix< T2, R2, C2 > &m2)
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > stan::math::elt_divide (const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
 Return the elementwise division of the specified matrices matrices. More...
 
template<int R, int C>
Eigen::Matrix< double, R, C > stan::math::multiply (const Eigen::Matrix< double, R, C > &m, double c)
 Return specified matrix multiplied by specified scalar. More...
 
template<int R, int C>
Eigen::Matrix< double, R, C > stan::math::multiply (double c, const Eigen::Matrix< double, R, C > &m)
 Return specified scalar multiplied by specified matrix. More...
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::multiply (const Eigen::Matrix< double, R1, C1 > &m1, const Eigen::Matrix< double, R2, C2 > &m2)
 Return the product of the specified matrices. More...
 
template<int C1, int R2>
double stan::math::multiply (const Eigen::Matrix< double, 1, C1 > &rv, const Eigen::Matrix< double, R2, 1 > &v)
 Return the scalar product of the specified row vector and specified column vector. More...
 
matrix_d stan::math::multiply_lower_tri_self_transpose (const matrix_d &L)
 Returns the result of multiplying the lower triangular portion of the input matrix by its own transpose. More...
 
matrix_d stan::math::tcrossprod (const matrix_d &M)
 Returns the result of post-multiplying a matrix by its own transpose. More...
 
matrix_d stan::math::crossprod (const matrix_d &M)
 Returns the result of pre-multiplying a matrix by its own transpose. More...
 
template<typename T >
Eigen::Matrix< T, 1, Eigen::Dynamic > stan::math::row (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m, size_t i)
 Return the specified row of the specified matrix, using start-at-1 indexing. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > stan::math::col (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m, size_t j)
 Return the specified column of the specified matrix using start-at-1 indexing. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::block (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m, size_t i, size_t j, size_t nrows, size_t ncols)
 Return a nrows x ncols submatrix starting at (i,j). More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > stan::math::diagonal (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Return a column vector of the diagonal elements of the specified matrix. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::diag_matrix (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v)
 Return a square diagonal matrix with the specified vector of coefficients as the diagonal values. More...
 
template<typename T , int R, int C>
Eigen::Matrix< T, C, R > stan::math::transpose (const Eigen::Matrix< T, R, C > &m)
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::inverse (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Returns the inverse of the specified matrix. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > stan::math::softmax (const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v)
 Return the softmax of the specified vector. More...
 
template<typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > stan::math::mdivide_left_tri_low (const Eigen::Matrix< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &b)
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::mdivide_left_tri_low (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &A)
 
template<int TriView, typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > stan::math::mdivide_left_tri (const Eigen::Matrix< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &b)
 Returns the solution of the system Ax=b when A is triangular. More...
 
template<int TriView, typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::mdivide_left_tri (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &A)
 Returns the solution of the system Ax=b when A is triangular and b=I. More...
 
template<typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > stan::math::mdivide_left (const Eigen::Matrix< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &b)
 Returns the solution of the system Ax=b. More...
 
template<int TriView, typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > stan::math::mdivide_right_tri (const Eigen::Matrix< T1, R1, C1 > &b, const Eigen::Matrix< T2, R2, C2 > &A)
 Returns the solution of the system Ax=b when A is triangular. More...
 
template<typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > stan::math::mdivide_right_tri_low (const Eigen::Matrix< T1, R1, C1 > &b, const Eigen::Matrix< T2, R2, C2 > &A)
 Returns the solution of the system tri(A)x=b when tri(A) is a lower triangular view of the matrix A. More...
 
template<typename T1 , typename T2 , int R1, int C1, int R2, int C2>
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > stan::math::mdivide_right (const Eigen::Matrix< T1, R1, C1 > &b, const Eigen::Matrix< T2, R2, C2 > &A)
 Returns the solution of the system Ax=b. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > stan::math::eigenvalues_sym (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Return the eigenvalues of the specified symmetric matrix in descending order of magnitude. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::eigenvectors_sym (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > stan::math::cholesky_decompose (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Return the lower-triangular Cholesky factor (i.e., matrix square root) of the specified square, symmetric matrix. More...
 
template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > stan::math::singular_values (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Return the vector of the singular values of the specified matrix in decreasing order of magnitude. More...
 

Macro Definition Documentation

◆ EIGEN_DENSEBASE_PLUGIN

#define EIGEN_DENSEBASE_PLUGIN   "stan/math/EigenDenseBaseAddons.hpp"

Definition at line 11 of file matrix.hpp.


     [ Stan Home Page ] © 2011–2012, Stan Development Team.