Stan  1.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Classes | Namespaces | Typedefs | Functions
matrix.hpp File Reference
#include <sstream>
#include <stan/agrad/agrad.hpp>
#include <stan/agrad/special_functions.hpp>
#include <stan/math/boost_error_handling.hpp>
#include <stan/math/matrix.hpp>
#include <stan/math/matrix_error_handling.hpp>

Go to the source code of this file.

Classes

class  stan::agrad::gevv_vvv_vari
 
struct  Eigen::NumTraits< stan::agrad::var >
 Numerical traits template override for Eigen for automatic gradient variables. More...
 
struct  Eigen::internal::significant_decimals_default_impl< stan::agrad::var, false >
 Implemented this for printing to stream. More...
 
struct  Eigen::internal::scalar_product_traits< stan::agrad::var, double >
 Scalar product traits override for Eigen for automatic gradient variables. More...
 
struct  Eigen::internal::scalar_product_traits< double, stan::agrad::var >
 Scalar product traits override for Eigen for automatic gradient variables. More...
 
struct  Eigen::internal::general_matrix_vector_product< Index, stan::agrad::var, ColMajor, ConjugateLhs, stan::agrad::var, ConjugateRhs >
 Override matrix-vector and matrix-matrix products to use more efficient implementation. More...
 
struct  Eigen::internal::general_matrix_vector_product< Index, stan::agrad::var, RowMajor, ConjugateLhs, stan::agrad::var, ConjugateRhs >
 
struct  Eigen::internal::general_matrix_matrix_product< Index, stan::agrad::var, LhsStorageOrder, ConjugateLhs, stan::agrad::var, RhsStorageOrder, ConjugateRhs, ColMajor >
 
struct  stan::agrad::needs_promotion< LHS, RHS >
 
struct  stan::agrad::assigner< PromoteRHS, LHS, RHS >
 
struct  stan::agrad::assigner< false, LHS, RHS >
 
struct  stan::agrad::assigner< true, LHS, RHS >
 

Namespaces

namespace  stan
 Probability, optimization and sampling library.
 
namespace  stan::agrad
 Function gradients via reverse-mode automatic differentiation.
 
namespace  Eigen
 (Expert) Numerical traits for algorithmic differentiation variables.
 
namespace  Eigen::internal
 (Expert) Product traits for algorithmic differentiation variables.
 

Typedefs

typedef stan::math::EigenType
< var >::matrix 
stan::agrad::matrix_v
 The type of a matrix holding stan::agrad::var values.
 
typedef stan::math::EigenType
< var >::vector 
stan::agrad::vector_v
 The type of a (column) vector holding stan::agrad::var values.
 
typedef stan::math::EigenType
< var >::row_vector 
stan::agrad::row_vector_v
 The type of a row vector holding stan::agrad::var values.
 

Functions

void stan::agrad::initialize_variable (var &variable, const var &value)
 Initialize variable to value.
 
template<int R, int C>
void stan::agrad::initialize_variable (Eigen::Matrix< var, R, C > &matrix, const var &value)
 Initialize every cell in the matrix to the specified value.
 
template<typename T >
void stan::agrad::initialize_variable (std::vector< T > &variables, const var &value)
 Initialize the variables in the standard vector recursively.
 
var stan::agrad::to_var (const double &x)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const double &x, var &var_x)
 Converts argument to an automatic differentiation variable.
 
var stan::agrad::to_var (const var &x)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const var &var_in, var &var_out)
 Converts argument to an automatic differentiation variable.
 
matrix_v stan::agrad::to_var (const stan::math::matrix_d &m)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const stan::math::matrix_d &m, matrix_v &m_v)
 Converts argument to an automatic differentiation variable.
 
matrix_v stan::agrad::to_var (const matrix_v &m)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const matrix_v &m_in, matrix_v &m_out)
 Converts argument to an automatic differentiation variable.
 
vector_v stan::agrad::to_var (const stan::math::vector_d &v)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const stan::math::vector_d &v, vector_v &v_v)
 Converts argument to an automatic differentiation variable.
 
vector_v stan::agrad::to_var (const vector_v &v)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const vector_v &v_in, vector_v &v_out)
 Converts argument to an automatic differentiation variable.
 
row_vector_v stan::agrad::to_var (const stan::math::row_vector_d &rv)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const stan::math::row_vector_d &rv, row_vector_v &rv_v)
 Converts argument to an automatic differentiation variable.
 
row_vector_v stan::agrad::to_var (const row_vector_v &rv)
 Converts argument to an automatic differentiation variable.
 
void stan::agrad::to_var (const row_vector_v &rv_in, row_vector_v &rv_out)
 Converts argument to an automatic differentiation variable.
 
size_t stan::agrad::rows (const vector_v &v)
 Return number of rows.
 
size_t stan::agrad::rows (const row_vector_v &rv)
 Return number of rows.
 
size_t stan::agrad::rows (const matrix_v &m)
 Return number of rows.
 
size_t stan::agrad::cols (const vector_v &v)
 Return number of columns.
 
size_t stan::agrad::cols (const row_vector_v &rv)
 Return number of columns.
 
size_t stan::agrad::cols (const matrix_v &m)
 Return number of columns.
 
var stan::agrad::determinant (const Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > &m)
 Determinant of the matrix.
 
template<int R, int C>
var stan::agrad::dot_self (const Eigen::Matrix< var, R, C > &v)
 Returns the dot product of a vector with itself.
 
template<int R1, int C1, int R2, int C2>
var stan::agrad::dot_product (const Eigen::Matrix< var, R1, C1 > &v1, const Eigen::Matrix< var, R2, C2 > &v2)
 Returns the dot product.
 
template<int R1, int C1, int R2, int C2>
var stan::agrad::dot_product (const Eigen::Matrix< var, R1, C1 > &v1, const Eigen::Matrix< double, R2, C2 > &v2)
 Returns the dot product.
 
template<int R1, int C1, int R2, int C2>
var stan::agrad::dot_product (const Eigen::Matrix< double, R1, C1 > &v1, const Eigen::Matrix< var, R2, C2 > &v2)
 Returns the dot product.
 
var stan::agrad::dot_product (const var *v1, const var *v2, size_t length)
 Returns the dot product.
 
var stan::agrad::dot_product (const var *v1, const double *v2, size_t length)
 Returns the dot product.
 
var stan::agrad::dot_product (const double *v1, const var *v2, size_t length)
 Returns the dot product.
 
var stan::agrad::dot_product (const std::vector< var > &v1, const std::vector< var > &v2)
 Returns the dot product.
 
var stan::agrad::dot_product (const std::vector< var > &v1, const std::vector< double > &v2)
 Returns the dot product.
 
var stan::agrad::dot_product (const std::vector< double > &v1, const std::vector< var > &v2)
 Returns the dot product.
 
template<int R, int C>
var stan::agrad::sum (const Eigen::Matrix< var, R, C > &m)
 Returns the sum of the coefficients of the specified matrix, column vector or row vector.
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename
boost::math::tools::promote_args
< T1, T2 >::type, R, C > 
stan::agrad::add (const Eigen::Matrix< T1, R, C > &v1, const Eigen::Matrix< T2, R, C > &v2)
 Return the sum of the specified column vectors.
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename
boost::math::tools::promote_args
< T1, T2 >::type, R, C > 
stan::agrad::add (const Eigen::Matrix< T1, R, C > &m, const T2 &c)
 Return the sum of a matrix or vector and a scalar.
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename
boost::math::tools::promote_args
< T1, T2 >::type, R, C > 
stan::agrad::add (const T1 &c, const Eigen::Matrix< T2, R, C > &m)
 Return the sum of a scalar and a matrix or vector.
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename
boost::math::tools::promote_args
< T1, T2 >::type, R, C > 
stan::agrad::subtract (const Eigen::Matrix< T1, R, C > &v1, const Eigen::Matrix< T2, R, C > &v2)
 Return the difference between the first specified column vector and the second.
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename
boost::math::tools::promote_args
< T1, T2 >::type, R, C > 
stan::agrad::subtract (const Eigen::Matrix< T1, R, C > &m, const T2 &c)
 Return the difference between a matrix or vector and a scalar.
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< typename
boost::math::tools::promote_args
< T1, T2 >::type, R, C > 
stan::agrad::subtract (const T1 &c, const Eigen::Matrix< T2, R, C > &m)
 Return the difference between a scalar and a matrix or vector.
 
template<typename T >
T stan::agrad::minus (const T &v)
 Return the negation of the specified variable.
 
template<typename T , int R, int C>
Eigen::Matrix< T, R, C > stan::agrad::minus (const Eigen::Matrix< T, R, C > &v)
 Return the negation of the specified column vector.
 
double stan::agrad::divide (double x, double y)
 Return the division of the first scalar by the second scalar.
 
template<typename T1 , typename T2 >
var stan::agrad::divide (const T1 &v, const T2 &c)
 
template<typename T1 , typename T2 , int R, int C>
Eigen::Matrix< var, R, C > stan::agrad::divide (const Eigen::Matrix< T1, R, C > &v, const T2 &c)
 Return the division of the specified column vector by the specified scalar.
 
template<typename T1 , typename T2 >
Eigen::Matrix
< stan::agrad::var,
Eigen::Dynamic, Eigen::Dynamic > 
stan::agrad::elt_multiply (const Eigen::Matrix< T1, Eigen::Dynamic, Eigen::Dynamic > &m1, const Eigen::Matrix< T2, Eigen::Dynamic, Eigen::Dynamic > &m2)
 Return the elementwise product of the specified matrices.
 
template<typename T1 , typename T2 >
Eigen::Matrix
< stan::agrad::var,
Eigen::Dynamic, 1 > 
stan::agrad::elt_multiply (const Eigen::Matrix< T1, Eigen::Dynamic, 1 > &v1, const Eigen::Matrix< T2, Eigen::Dynamic, 1 > &v2)
 Return the elementwise product of the specified vectors.
 
template<typename T1 , typename T2 >
Eigen::Matrix
< stan::agrad::var,
1, Eigen::Dynamic > 
stan::agrad::elt_multiply (const Eigen::Matrix< T1, 1, Eigen::Dynamic > &v1, const Eigen::Matrix< T2, 1, Eigen::Dynamic > &v2)
 Return the elementwise product of the specified row vectors.
 
template<typename T1 , typename T2 >
Eigen::Matrix
< stan::agrad::var,
Eigen::Dynamic, Eigen::Dynamic > 
stan::agrad::elt_divide (const Eigen::Matrix< T1, Eigen::Dynamic, Eigen::Dynamic > &m1, const Eigen::Matrix< T2, Eigen::Dynamic, Eigen::Dynamic > &m2)
 Return the elementwise division of the specified matrices.
 
template<typename T1 , typename T2 >
Eigen::Matrix
< stan::agrad::var,
Eigen::Dynamic, 1 > 
stan::agrad::elt_divide (const Eigen::Matrix< T1, Eigen::Dynamic, 1 > &v1, const Eigen::Matrix< T2, Eigen::Dynamic, 1 > &v2)
 Return the elementwise division of the specified vectors.
 
template<typename T1 , typename T2 >
Eigen::Matrix
< stan::agrad::var,
1, Eigen::Dynamic > 
stan::agrad::elt_divide (const Eigen::Matrix< T1, 1, Eigen::Dynamic > &v1, const Eigen::Matrix< T2, 1, Eigen::Dynamic > &v2)
 Return the elementwise division of the specified row vectors.
 
template<typename T1 , typename T2 >
boost::math::tools::promote_args
< T1, T2 >::type 
stan::agrad::multiply (const T1 &v, const T2 &c)
 Return the product of two scalars.
 
template<typename T1 , typename T2 , int R2, int C2>
Eigen::Matrix< var, R2, C2 > stan::agrad::multiply (const T1 &c, const Eigen::Matrix< T2, R2, C2 > &m)
 Return the product of scalar and matrix.
 
template<typename T1 , int R1, int C1, typename T2 >
Eigen::Matrix< var, R1, C1 > stan::agrad::multiply (const Eigen::Matrix< T1, R1, C1 > &m, const T2 &c)
 Return the product of scalar and matrix.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::multiply (const Eigen::Matrix< var, R1, C1 > &m1, const Eigen::Matrix< var, R2, C2 > &m2)
 Return the product of the specified matrices.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::multiply (const Eigen::Matrix< double, R1, C1 > &m1, const Eigen::Matrix< var, R2, C2 > &m2)
 Return the product of the specified matrices.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::multiply (const Eigen::Matrix< var, R1, C1 > &m1, const Eigen::Matrix< double, R2, C2 > &m2)
 Return the product of the specified matrices.
 
template<int C1, int R2>
var stan::agrad::multiply (const Eigen::Matrix< var, 1, C1 > &rv, const Eigen::Matrix< var, R2, 1 > &v)
 Return the scalar product of the specified row vector and specified column vector.
 
template<int C1, int R2>
var stan::agrad::multiply (const Eigen::Matrix< double, 1, C1 > &rv, const Eigen::Matrix< var, R2, 1 > &v)
 Return the scalar product of the specified row vector and specified column vector.
 
template<int C1, int R2>
var stan::agrad::multiply (const Eigen::Matrix< var, 1, C1 > &rv, const Eigen::Matrix< double, R2, 1 > &v)
 Return the scalar product of the specified row vector and specified column vector.
 
matrix_v stan::agrad::multiply_lower_tri_self_transpose (const matrix_v &L)
 
matrix_v stan::agrad::tcrossprod (const matrix_v &M)
 Returns the result of post-multiplying a matrix by its own transpose.
 
matrix_v stan::agrad::crossprod (const matrix_v &M)
 Returns the result of pre-multiplying a matrix by its own transpose.
 
row_vector_v stan::agrad::row (const matrix_v &m, size_t i)
 Return the specified row minus 1 of the specified matrix.
 
vector_v stan::agrad::col (const matrix_v &m, size_t j)
 Return the specified column minus 1 of the specified matrix.
 
vector_v stan::agrad::diagonal (const matrix_v &m)
 Return a column vector of the diagonal elements of the specified matrix.
 
matrix_v stan::agrad::diag_matrix (const vector_v &v)
 Return a square diagonal matrix with the specified vector of coefficients as the diagonal values.
 
row_vector_v stan::agrad::transpose (const vector_v &v)
 Return the transposition of the specified column vector.
 
vector_v stan::agrad::transpose (const row_vector_v &rv)
 Return the transposition of the specified row vector.
 
matrix_v stan::agrad::transpose (const matrix_v &m)
 Return the transposition of the specified matrix.
 
matrix_v stan::agrad::inverse (const matrix_v &m)
 Returns the inverse of the specified matrix.
 
vector_v stan::agrad::softmax (const vector_v &v)
 Return the softmax of the specified vector.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left_tri_low (const Eigen::Matrix< var, R1, C1 > &A, const Eigen::Matrix< var, R2, C2 > &b)
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left_tri_low (const Eigen::Matrix< var, R1, C1 > &A, const Eigen::Matrix< double, R2, C2 > &b)
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left_tri_low (const Eigen::Matrix< double, R1, C1 > &A, const Eigen::Matrix< var, R2, C2 > &b)
 
Eigen::Matrix< var,
Eigen::Dynamic, Eigen::Dynamic > 
stan::agrad::mdivide_left_tri_low (const Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > &A)
 
template<int TriView, int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left_tri (const Eigen::Matrix< var, R1, C1 > &A, const Eigen::Matrix< var, R2, C2 > &b)
 Returns the solution of the system Ax=b when A is triangular.
 
template<int TriView, int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left_tri (const Eigen::Matrix< var, 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, int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left_tri (const Eigen::Matrix< double, R1, C1 > &A, const Eigen::Matrix< var, R2, C2 > &b)
 Returns the solution of the system Ax=b when A is triangular.
 
template<int TriView>
Eigen::Matrix< var,
Eigen::Dynamic, Eigen::Dynamic > 
stan::agrad::mdivide_left_tri (const Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > &A)
 Returns the solution of the system Ax=b when A is triangular and b = I.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left (const Eigen::Matrix< var, R1, C1 > &A, const Eigen::Matrix< var, R2, C2 > &b)
 Returns the solution of the system Ax=b.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left (const Eigen::Matrix< double, R1, C1 > &A, const Eigen::Matrix< var, R2, C2 > &b)
 Returns the solution of the system Ax=b.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_left (const Eigen::Matrix< var, 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< var, R1, C2 > stan::agrad::mdivide_right (const Eigen::Matrix< var, R1, C1 > &b, const Eigen::Matrix< var, R2, C2 > &A)
 Returns the solution x of the system xA = b.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_right (const Eigen::Matrix< double, R1, C1 > &b, const Eigen::Matrix< var, R2, C2 > &A)
 Returns the solution x of the system xA = b.
 
template<int R1, int C1, int R2, int C2>
Eigen::Matrix< var, R1, C2 > stan::agrad::mdivide_right (const Eigen::Matrix< var, R1, C1 > &b, const Eigen::Matrix< double, R2, C2 > &A)
 Returns the solution x of the system xA = b.
 
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::agrad::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.
 
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::agrad::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 triangular view of A.
 
vector_v stan::agrad::eigenvalues (const matrix_v &m)
 Return the real component of the eigenvalues of the specified matrix in descending order of magnitude.
 
matrix_v stan::agrad::eigenvectors (const matrix_v &m)
 Return a matrix whose columns are the real components of the eigenvectors of the specified matrix.
 
void stan::agrad::eigen_decompose (const matrix_v &m, vector_v &eigenvalues, matrix_v &eigenvectors)
 Assign the real components of the eigenvalues and eigenvectors of the specified matrix to the specified references.
 
vector_v stan::agrad::eigenvalues_sym (const matrix_v &m)
 Return the eigenvalues of the specified symmetric matrix in descending order of magnitude.
 
matrix_v stan::agrad::eigenvectors_sym (const matrix_v &m)
 Return a matrix whose rows are the real components of the eigenvectors of the specified symmetric matrix.
 
void stan::agrad::eigen_decompose_sym (const matrix_v &m, vector_v &eigenvalues, matrix_v &eigenvectors)
 Assign the real components of the eigenvalues and eigenvectors of the specified symmetric matrix to the specified references.
 
matrix_v stan::agrad::cholesky_decompose (const matrix_v &m)
 Return the lower-triangular Cholesky factor (i.e., matrix square root) of the specified square, symmetric matrix.
 
vector_v stan::agrad::singular_values (const matrix_v &m)
 Return the vector of the singular values of the specified matrix in decreasing order of magnitude.
 
void stan::agrad::svd (const matrix_v &m, matrix_v &u, matrix_v &v, vector_v &s)
 Assign the real components of a singular value decomposition of the specified matrix to the specified references.
 
void stan::agrad::assign_to_var (stan::agrad::var &var, const double &val)
 
void stan::agrad::assign_to_var (stan::agrad::var &var, const stan::agrad::var &val)
 
void stan::agrad::assign_to_var (int &n_lhs, const int &n_rhs)
 
void stan::agrad::assign_to_var (double &n_lhs, const double &n_rhs)
 
template<typename T_result , class Policy >
bool stan::agrad::check_pos_definite (const char *function, const Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result, const Policy &)
 
template<typename LHS , typename RHS >
void stan::agrad::assign_to_var (std::vector< LHS > &x, const std::vector< RHS > &y)
 
template<typename LHS , typename RHS >
void stan::agrad::assign_to_var (Eigen::Matrix< LHS, Eigen::Dynamic, 1 > &x, const Eigen::Matrix< RHS, Eigen::Dynamic, 1 > &y)
 
template<typename LHS , typename RHS >
void stan::agrad::assign_to_var (Eigen::Matrix< LHS, 1, Eigen::Dynamic > &x, const Eigen::Matrix< RHS, 1, Eigen::Dynamic > &y)
 
template<typename LHS , typename RHS >
void stan::agrad::assign_to_var (Eigen::Matrix< LHS, Eigen::Dynamic, Eigen::Dynamic > &x, const Eigen::Matrix< RHS, Eigen::Dynamic, Eigen::Dynamic > &y)
 
template<typename LHS , typename RHS >
void stan::agrad::assign (LHS &var, const RHS &val)
 
void stan::agrad::stan_print (std::ostream *o, const var &x)
 

Variable Documentation

size_t length_

Definition at line 627 of file matrix.hpp.

size_t size_

Definition at line 590 of file matrix.hpp.

vari** v1_

Definition at line 670 of file matrix.hpp.

double* v2_

Definition at line 671 of file matrix.hpp.

vari** v_
static

Definition at line 589 of file matrix.hpp.


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