Automatic Differentiation
 
Loading...
Searching...
No Matches
mdivide_left_ldlt.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MDIVIDE_LEFT_LDLT_HPP
2#define STAN_MATH_PRIM_FUN_MDIVIDE_LEFT_LDLT_HPP
3
8#include <type_traits>
9
10namespace stan {
11namespace math {
12
24template <typename T, typename EigMat, require_eigen_t<EigMat>* = nullptr,
25 require_all_not_st_var<T, EigMat>* = nullptr,
26 require_any_not_t<std::is_arithmetic<value_type_t<T>>,
27 is_fvar<value_type_t<EigMat>>>* = nullptr>
28inline Eigen::Matrix<return_type_t<T, EigMat>, Eigen::Dynamic,
29 EigMat::ColsAtCompileTime>
30mdivide_left_ldlt(LDLT_factor<T>& A, const EigMat& b) {
31 check_multiplicable("mdivide_left_ldlt", "A", A.matrix(), "b", b);
32
33 if (A.matrix().cols() == 0) {
34 return {0, b.cols()};
35 }
36
37 return A.ldlt().solve(
38 Eigen::Matrix<return_type_t<T, EigMat>, EigMat::RowsAtCompileTime,
39 EigMat::ColsAtCompileTime>(b));
40}
41
42} // namespace math
43} // namespace stan
44
45#endif
LDLT_factor is a structure that holds a matrix of type T and the LDLT of its values.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
void check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the matrices can be multiplied.
Eigen::Matrix< value_type_t< EigMat >, Eigen::Dynamic, EigMat::ColsAtCompileTime > mdivide_left_ldlt(LDLT_factor< T > &A, const EigMat &b)
Returns the solution of the system Ax=b given an LDLT_factor of A.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...