Automatic Differentiation
 
Loading...
Searching...
No Matches
mdivide_right_spd.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MDIVIDE_RIGHT_SPD_HPP
2#define STAN_MATH_PRIM_FUN_MDIVIDE_RIGHT_SPD_HPP
3
9
10namespace stan {
11namespace math {
12
26template <typename EigMat1, typename EigMat2,
27 require_all_eigen_t<EigMat1, EigMat2>* = nullptr>
28inline Eigen::Matrix<return_type_t<EigMat1, EigMat2>,
29 EigMat1::RowsAtCompileTime, EigMat2::ColsAtCompileTime>
30mdivide_right_spd(const EigMat1& b, const EigMat2& A) {
31 static constexpr const char* function = "mdivide_right_spd";
32 check_multiplicable(function, "b", b, "A", A);
33 const auto& A_ref = to_ref(A);
34 check_symmetric(function, "A", A_ref);
35 check_not_nan(function, "A", A_ref);
36 if (A.size() == 0) {
37 return {b.rows(), 0};
38 }
39
40 return mdivide_left_spd(A_ref, b.transpose()).transpose();
41}
42
43} // namespace math
44} // namespace stan
45
46#endif
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
Eigen::Matrix< return_type_t< EigMat1, EigMat2 >, EigMat1::RowsAtCompileTime, EigMat2::ColsAtCompileTime > mdivide_right_spd(const EigMat1 &b, const EigMat2 &A)
Returns the solution of the system xA=b where A is symmetric positive definite.
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< return_type_t< EigMat1, EigMat2 >, EigMat1::RowsAtCompileTime, EigMat2::ColsAtCompileTime > mdivide_left_spd(const EigMat1 &A, const EigMat2 &b)
Returns the solution of the system Ax=b where A is symmetric positive definite.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9