Automatic Differentiation
 
Loading...
Searching...
No Matches
mdivide_right_ldlt.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MDIVIDE_RIGHT_LDLT_HPP
2#define STAN_MATH_PRIM_FUN_MDIVIDE_RIGHT_LDLT_HPP
3
9
10namespace stan {
11namespace math {
12
24template <typename EigMat, typename T,
25 require_all_matrix_t<EigMat, T>* = nullptr,
26 require_any_not_st_arithmetic<EigMat, T>* = nullptr>
27inline auto mdivide_right_ldlt(const EigMat& b, LDLT_factor<T>& A) {
28 check_multiplicable("mdivide_right_ldlt", "b", b, "A", A.matrix());
29 check_ldlt_factor("mdivide_right_ldlt", "A", A);
30
31 return mdivide_left_ldlt(A, b.transpose()).transpose().eval();
32}
33
47template <typename EigMat, typename T,
50inline Eigen::Matrix<double, EigMat::RowsAtCompileTime, T::ColsAtCompileTime>
51mdivide_right_ldlt(const EigMat& b, LDLT_factor<T>& A) {
52 check_multiplicable("mdivide_right_ldlt", "b", b, "A", A.matrix());
53 check_ldlt_factor("mdivide_right_ldlt", "A", A);
54
55 if (A.matrix().rows() == 0) {
56 return {b.rows(), 0};
57 }
58
59 return A.ldlt().solve(b.transpose()).transpose();
60}
61
62} // namespace math
63} // namespace stan
64
65#endif
LDLT_factor is a structure that holds a matrix of type T and the LDLT of its values.
require_all_t< std::is_arithmetic< scalar_type_t< std::decay_t< Types > > >... > require_all_st_arithmetic
Require all of the scalar types satisfy std::is_arithmetic.
require_all_t< is_matrix< std::decay_t< Types > >... > require_all_matrix_t
Require all of the types satisfy is_matrix.
Definition is_matrix.hpp:38
auto mdivide_right_ldlt(const EigMat &b, LDLT_factor< T > &A)
Returns the solution of the system xA=b given an LDLT_factor of A.
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.
void check_ldlt_factor(const char *function, const char *name, LDLT_factor< T > &A)
Raise domain error if the specified LDLT factor is invalid.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...