Stan  1.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Typedefs | Functions
matrix.hpp File Reference
#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::EigenType< T >
 This is a traits structure for Eigen matrix types. More...
 

Namespaces

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

Macros

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

Typedefs

typedef EigenType< double >::matrix stan::math::matrix_d
 Type for matrix of double values.
 
typedef EigenType< double >::vector stan::math::vector_d
 Type for (column) vector of double values.
 
typedef EigenType< double >
::row_vector 
stan::math::row_vector_d
 Type for (row) vector of double values.
 

Functions

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
size_t stan::math::rows (const vector_d &v)
 Return the number of rows in the specified column vector.
 
size_t stan::math::rows (const row_vector_d &rv)
 Return the number of rows in the specified row vector.
 
size_t stan::math::rows (const matrix_d &m)
 Return the number of rows in the specified matrix.
 
size_t stan::math::cols (const vector_d &v)
 Return the number of columns in the specified column vector.
 
size_t stan::math::cols (const row_vector_d &rv)
 Return the number of columns in the specified row vector.
 
size_t stan::math::cols (const matrix_d &m)
 Return the number of columns in the specified matrix.
 
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 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)
 
double stan::math::determinant (const matrix_d &m)
 Returns the determinant of the specified square matrix.
 
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.
 
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.
 
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.
 
double stan::math::dot_product (const double *v1, const double *v2, size_t length)
 Returns the dot product of the specified arrays of doubles.
 
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.
 
int stan::math::min (const std::vector< int > &x)
 Returns the minimum coefficient in the specified column vector.
 
template<typename T >
T stan::math::min (const std::vector< T > &x)
 Returns the minimum coefficient in the specified column vector.
 
template<typename T , int R, int C>
T stan::math::min (const Eigen::Matrix< T, R, C > &m)
 Returns the minimum coefficient in the specified matrix, vector, or row vector.
 
int stan::math::max (const std::vector< int > &x)
 Returns the maximum coefficient in the specified column vector.
 
template<typename T >
T stan::math::max (const std::vector< T > &x)
 Returns the maximum coefficient in the specified column vector.
 
template<typename T , int R, int C>
T stan::math::max (const Eigen::Matrix< T, R, C > &m)
 Returns the maximum coefficient in the specified vector, row vector, or matrix.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
template<typename T >
T stan::math::sum (const std::vector< T > &xs)
 Return the sum of the values in the specified standard vector.
 
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.
 
template<typename T >
T stan::math::prod (const std::vector< T > &v)
 Returns the product of the coefficients of the specified standard vector.
 
template<typename T , int R, int C>
T stan::math::prod (const Eigen::Matrix< T, R, C > &v)
 Returns the product of the coefficients of the specified column vector.
 
template<typename T >
T stan::math::trace (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
 Returns the trace of the specified matrix.
 
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.
 
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.
 
vector_d stan::math::add (const vector_d &v1, const vector_d &v2)
 Return the sum of the specified column vectors.
 
row_vector_d stan::math::add (const row_vector_d &rv1, const row_vector_d &rv2)
 Return the sum of the specified row vectors.
 
matrix_d stan::math::add (const matrix_d &m1, const matrix_d &m2)
 Return the sum of the specified matrices.
 
template<int Rows, int Cols>
Eigen::Matrix< double, Rows, Cols > stan::math::add (const Eigen::Matrix< double, Rows, Cols > &m, const double &c)
 Return the sum of a matrix or vector and a scalar.
 
template<int Rows, int Cols>
Eigen::Matrix< double, Rows, Cols > stan::math::add (const double &c, const Eigen::Matrix< double, Rows, Cols > &m)
 Return the sum of a scalar and a matrix or vector.
 
vector_d stan::math::subtract (const vector_d &v1, const vector_d &v2)
 Return the difference between the first specified column vector and the second.
 
row_vector_d stan::math::subtract (const row_vector_d &rv1, const row_vector_d &rv2)
 Return the difference between the first specified row vector and the second.
 
matrix_d stan::math::subtract (const matrix_d &m1, const matrix_d &m2)
 Return the difference between the first specified matrix and the second.
 
template<int Rows, int Cols>
Eigen::Matrix< double, Rows, Cols > stan::math::subtract (const Eigen::Matrix< double, Rows, Cols > &m, double c)
 Return the difference between a matrix or vector and a scalar.
 
template<int Rows, int Cols>
Eigen::Matrix< double, Rows, Cols > stan::math::subtract (double c, const Eigen::Matrix< double, Rows, Cols > &m)
 Return the difference between a scalar and a matrix or vector.
 
vector_d stan::math::minus (const vector_d &v)
 Return the negation of the specified column vector.
 
row_vector_d stan::math::minus (const row_vector_d &rv)
 Return the negation of the specified row vector.
 
matrix_d stan::math::minus (const matrix_d &m)
 Return the negation of the specified matrix.
 
vector_d stan::math::divide (const vector_d &v, double c)
 Return the division of the specified column vector by the specified scalar.
 
row_vector_d stan::math::divide (const row_vector_d &rv, double c)
 Return the division of the specified row vector by the specified scalar.
 
matrix_d stan::math::divide (const matrix_d &m, double c)
 Return the division of the specified matrix by the specified scalar.
 
vector_d stan::math::elt_multiply (const vector_d &v1, const vector_d &v2)
 Return the element-wise product of the specified vectors.
 
row_vector_d stan::math::elt_multiply (const row_vector_d &v1, const row_vector_d &v2)
 Return the element-wise product of the specified row vectors.
 
matrix_d stan::math::elt_multiply (const matrix_d &m1, const matrix_d &m2)
 Return the element-wise product of the specified matrices.
 
vector_d stan::math::elt_divide (const vector_d &v1, const vector_d &v2)
 Return the element-wise divsion of the specified vectors.
 
row_vector_d stan::math::elt_divide (const row_vector_d &v1, const row_vector_d &v2)
 Return the element-wise division of the specified row vectors.
 
matrix_d stan::math::elt_divide (const matrix_d &m1, const matrix_d &m2)
 Return the element-wise division of the specified matrices.
 
vector_d stan::math::multiply (const vector_d &v, double c)
 Return the product of the of the specified column vector and specified scalar.
 
row_vector_d stan::math::multiply (const row_vector_d &rv, double c)
 Return the product of the of the specified row vector and specified scalar.
 
matrix_d stan::math::multiply (const matrix_d &m, double c)
 Return the product of the of the specified matrix and specified scalar.
 
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.
 
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.
 
vector_d stan::math::multiply (double c, const vector_d &v)
 Return the product of the specified scalar and vector.
 
row_vector_d stan::math::multiply (double c, const row_vector_d &rv)
 Return the product of the specified scalar and row vector.
 
matrix_d stan::math::multiply (double c, const matrix_d &m)
 Return the product of the specified scalar and matrix.
 
matrix_d stan::math::multiply_lower_tri_self_transpose (const matrix_d &L)
 Returns the result of multiplying the lower triangular portion of the square input matrix by its own transpose.
 
matrix_d stan::math::tcrossprod (const matrix_d &M)
 Returns the result of post-multiplying a matrix by its own transpose.
 
matrix_d stan::math::crossprod (const matrix_d &M)
 Returns the result of pre-multiplying a matrix by its own transpose.
 
row_vector_d stan::math::row (const matrix_d &m, size_t i)
 Return the specified row of the specified matrix, using start-at-1 indexing.
 
vector_d stan::math::col (const matrix_d &m, size_t j)
 Return the specified column of the specified matrix using start-at-1 indexing.
 
vector_d stan::math::diagonal (const matrix_d &m)
 Return a column vector of the diagonal elements of the specified matrix.
 
matrix_d stan::math::diag_matrix (const vector_d &v)
 Return a square diagonal matrix with the specified vector of coefficients as the diagonal values.
 
row_vector_d stan::math::transpose (const vector_d &v)
 Return the transposition of the specified column vector.
 
vector_d stan::math::transpose (const row_vector_d &rv)
 Return the transposition of the specified row vector.
 
matrix_d stan::math::transpose (const matrix_d &m)
 Return the transposition of the specified matrix.
 
matrix_d stan::math::inverse (const matrix_d &m)
 Returns the inverse of the specified matrix.
 
vector_d stan::math::softmax (const vector_d &y)
 Return the softmax of the specified vector.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::mdivide_left_tri_low (const Eigen::Matrix< double, R1, C1 > &A, const Eigen::Matrix< double, R2, C2 > &b)
 
Eigen::MatrixXd stan::math::mdivide_left_tri_low (const Eigen::MatrixXd &A)
 
template<int TriView, int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::mdivide_left_tri (const Eigen::Matrix< double, R1, C1 > &A, const Eigen::Matrix< double, R2, C2 > &b)
 Returns the solution of the system Ax=b when A is triangular.
 
template<int TriView>
Eigen::Matrix< double,
Eigen::Dynamic, Eigen::Dynamic > 
stan::math::mdivide_left_tri (const Eigen::MatrixXd &A)
 Returns the solution of the system Ax=b when A is triangular and b=I.
 
template<int TriView, int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::mdivide_right_tri (const Eigen::Matrix< double, R1, C1 > &b, const Eigen::Matrix< double, R2, C2 > &A)
 Returns the solution of the system Ax=b when A is triangular.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::mdivide_right_tri_low (const Eigen::Matrix< double, R1, C1 > &b, const Eigen::Matrix< double, 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.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::mdivide_left (const Eigen::Matrix< double, R1, C1 > &A, const Eigen::Matrix< double, R2, C2 > &b)
 Returns the solution of the system Ax=b.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< double, R1, C2 > stan::math::mdivide_right (const Eigen::Matrix< double, R1, C1 > &b, const Eigen::Matrix< double, R2, C2 > &A)
 Returns the solution of the system Ax=b.
 
vector_d stan::math::eigenvalues (const matrix_d &m)
 Return the real component of the eigenvalues of the specified matrix in descending order of magnitude.
 
matrix_d stan::math::eigenvectors (const matrix_d &m)
 Return a matrix whose columns are the real components of the eigenvectors of the specified matrix.
 
void stan::math::eigen_decompose (const matrix_d &m, vector_d &eigenvalues, matrix_d &eigenvectors)
 Assign the real components of the eigenvalues and eigenvectors of the specified matrix to the specified references.
 
vector_d stan::math::eigenvalues_sym (const matrix_d &m)
 Return the eigenvalues of the specified symmetric matrix in descending order of magnitude.
 
matrix_d stan::math::eigenvectors_sym (const matrix_d &m)
 Return a matrix whose rows are the real components of the eigenvectors of the specified symmetric matrix.
 
void stan::math::eigen_decompose_sym (const matrix_d &m, vector_d &eigenvalues, matrix_d &eigenvectors)
 Assign the real components of the eigenvalues and eigenvectors of the specified symmetric matrix to the specified references.
 
matrix_d stan::math::cholesky_decompose (const matrix_d &m)
 Return the lower-triangular Cholesky factor (i.e., matrix square root) of the specified square, symmetric matrix.
 
vector_d stan::math::singular_values (const matrix_d &m)
 Return the vector of the singular values of the specified matrix in decreasing order of magnitude.
 
void stan::math::svd (const matrix_d &m, matrix_d &u, matrix_d &v, vector_d &s)
 Assign the real components of a singular value decomposition of the specified matrix to the specified references.
 
template<typename T >
void stan::math::stan_print (std::ostream *o, const T &x)
 
template<typename T >
void stan::math::stan_print (std::ostream *o, const std::vector< T > &x)
 
template<typename T >
void stan::math::stan_print (std::ostream *o, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x)
 
template<typename T >
void stan::math::stan_print (std::ostream *o, const Eigen::Matrix< T, 1, Eigen::Dynamic > &x)
 
template<typename T >
void stan::math::stan_print (std::ostream *o, const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &x)
 

Macro Definition Documentation

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

Definition at line 10 of file matrix.hpp.


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