Automatic Differentiation
 
Loading...
Searching...
No Matches
mdivide_left_tri.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MDIVIDE_LEFT_TRI_HPP
2#define STAN_MATH_PRIM_FUN_MDIVIDE_LEFT_TRI_HPP
3
8
9namespace stan {
10namespace math {
11
26template <Eigen::UpLoType TriView, typename T1, typename T2,
27 require_all_eigen_t<T1, T2> * = nullptr,
28 require_all_not_eigen_vt<is_var, T1, T2> * = nullptr>
29inline auto mdivide_left_tri(const T1 &A, const T2 &b) {
30 using T_return = return_type_t<T1, T2>;
31 using ret_type = Eigen::Matrix<T_return, Eigen::Dynamic, Eigen::Dynamic>;
32 check_square("mdivide_left_tri", "A", A);
33 check_multiplicable("mdivide_left_tri", "A", A, "b", b);
34 if (A.rows() == 0) {
35 return ret_type(0, b.cols());
36 }
37
38 return ret_type(A)
39 .template triangularView<TriView>()
40 .solve(ret_type(b))
41 .eval();
42}
43
53template <Eigen::UpLoType TriView, typename T, require_eigen_t<T> * = nullptr>
55 check_square("mdivide_left_tri", "A", A);
56 if (A.rows() == 0) {
57 return {};
58 }
59
60 int n = A.rows();
62 A.template triangularView<TriView>().solveInPlace(b);
63 return b;
64}
65
66} // namespace math
67} // namespace stan
68
69#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.
auto mdivide_left_tri(const T1 &A, const T2 &b)
Returns the solution of the system Ax=b when A is triangular.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...