All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
mdivide_right_tri.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_MDIVIDE_RIGHT_TRI_HPP
#define STAN_MATH_PRIM_MAT_FUN_MDIVIDE_RIGHT_TRI_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat/fun/mdivide_left_tri.hpp>
#include <stan/math/prim/mat/fun/transpose.hpp>
#include <stan/math/prim/mat/err/check_multiplicable.hpp>
#include <stan/math/prim/mat/err/check_square.hpp>
#include <boost/math/tools/promotion.hpp>
#include <stdexcept>
namespace stan {
namespace math {
template <int TriView, typename T1, typename T2,
int R1, int C1, int R2, int C2>
inline
Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
R1, C2>
mdivide_right_tri(const Eigen::Matrix<T1, R1, C1> &b,
const Eigen::Matrix<T2, R2, C2> &A) {
stan::math::check_square("mdivide_right_tri", "A", A);
stan::math::check_multiplicable("mdivide_right_tri",
"b", b,
"A", A);
// FIXME: This is nice and general but requires some extra memory
// and copying.
if (TriView == Eigen::Lower) {
return transpose(mdivide_left_tri<Eigen::Upper>(transpose(A),
transpose(b)));
} else if (TriView == Eigen::Upper) {
return transpose(mdivide_left_tri<Eigen::Lower>(transpose(A),
transpose(b)));
} else {
throw std::domain_error("triangular view must be Eigen::Lower or "
"Eigen::Upper");
}
}
}
}
#endif
stan::math::mdivide_right_tri
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > mdivide_right_tri(const Eigen::Matrix< T1, R1, C1 > &b, const Eigen::Matrix< T2, R2, C2 > &A)
Returns the solution of the system Ax=b when A is triangular.
Definition: mdivide_right_tri.hpp:29
check_multiplicable.hpp
mdivide_left_tri.hpp
transpose.hpp
stan::math::check_multiplicable
bool check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Return true if the matrices can be multiplied.
Definition: check_multiplicable.hpp:33
stan::math::domain_error
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
Definition: domain_error.hpp:32
Eigen.hpp
stan::math::transpose
Eigen::Matrix< T, C, R > transpose(const Eigen::Matrix< T, R, C > &m)
Definition: transpose.hpp:12
stan::math::check_square
bool check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is square.
Definition: check_square.hpp:28
check_square.hpp

[ Stan Home Page ] © 2011–2015, Stan Development Team.