Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ check_stochastic_column()

template<typename T , require_matrix_t< T > * = nullptr>
void stan::math::check_stochastic_column ( const char *  function,
const char *  name,
const T &  theta 
)

Throw an exception if the specified matrix is not a column stochastic matrix.

Throw an exception if the specified matrices in a standard vector are not a column stochastic matrix.

To be a column stochastic matrix, all the values in each column must be greater than or equal to 0 and the values must sum to 1. A valid column stochastic matrix is one where the sum of the elements by column is equal to 1. This function tests that the sum is within the tolerance specified by CONSTRAINT_TOLERANCE. This function only accepts Eigen matrices, statically typed vectors, not general matrices with 1 column.

Template Parameters
TA type inheriting from Eigen::EigenBase
Parameters
functionFunction name (for error messages)
nameVariable name (for error messages)
thetaMatrix to test
Exceptions
`std::invalid_argument`if theta is a 0-vector
`std::domain_error`if the vector is not a column stochastic matrix or if any element is NaN

To be a column stochastic matrix, all the values in each column must be greater than or equal to 0 and the values must sum to 1. A valid column stochastic matrix is one where the sum of the elements by column is equal to 1. This function tests that the sum is within the tolerance specified by CONSTRAINT_TOLERANCE. This function only accepts Eigen matrices, statically typed vectors, not general matrices with 1 column.

Template Parameters
TA type inheriting from Eigen::EigenBase
Parameters
functionFunction name (for error messages)
nameVariable name (for error messages)
thetaMatrix to test
Exceptions
`std::invalid_argument`if theta is a 0-vector
`std::domain_error`if the vector's matrices are not column stochastic matrices or if any element is NaN

Definition at line 35 of file check_stochastic_column.hpp.