Automatic Differentiation
 
Loading...
Searching...
No Matches
mdivide_left.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MDIVIDE_LEFT_HPP
2#define STAN_MATH_PRIM_FUN_MDIVIDE_LEFT_HPP
3
7
8namespace stan {
9namespace math {
10
23template <typename T1, typename T2,
24 require_all_eigen_vt<std::is_arithmetic, T1, T2>* = nullptr>
25inline Eigen::Matrix<return_type_t<T1, T2>, T1::RowsAtCompileTime,
26 T2::ColsAtCompileTime>
27mdivide_left(const T1& A, const T2& b) {
28 check_square("mdivide_left", "A", A);
29 check_multiplicable("mdivide_left", "A", A, "b", b);
30 if (A.size() == 0) {
31 return {0, b.cols()};
32 }
33
34 return Eigen::Matrix<return_type_t<T1, T2>, T1::RowsAtCompileTime,
35 T1::ColsAtCompileTime>(A)
36 .lu()
37 .solve(Eigen::Matrix<return_type_t<T1, T2>, T2::RowsAtCompileTime,
38 T2::ColsAtCompileTime>(b));
39}
40
41} // namespace math
42} // namespace stan
43
44#endif
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
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< T1 >, T1::RowsAtCompileTime, T2::ColsAtCompileTime > mdivide_left(const T1 &A, const T2 &b)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9