Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
mdivide_right_tri.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__MATRIX__MDIVIDE_RIGHT_TRI_HPP__
2 #define __STAN__MATH__MATRIX__MDIVIDE_RIGHT_TRI_HPP__
3 
4 #include <stdexcept>
5 #include <boost/math/tools/promotion.hpp>
11 
12 namespace stan {
13  namespace math {
14 
24  template <int TriView, typename T1, typename T2,
25  int R1, int C1, int R2, int C2>
26  inline
27  Eigen::Matrix<typename boost::math::tools::promote_args<T1,T2>::type,R1,C2>
28  mdivide_right_tri(const Eigen::Matrix<T1,R1,C1> &b,
29  const Eigen::Matrix<T2,R2,C2> &A) {
30  stan::math::validate_square(A,"mdivide_left_tri_low");
31  stan::math::validate_multiplicable(b,A,"mdivide_right_tri");
32  // FIXME: This is nice and general but requires some extra memory and copying.
33  if (TriView == Eigen::Lower) {
34  return transpose(mdivide_left_tri<Eigen::Upper>(transpose(A),transpose(b)));
35  }
36  else if (TriView == Eigen::Upper) {
37  return transpose(mdivide_left_tri<Eigen::Lower>(transpose(A),transpose(b)));
38  }
39  else {
40  throw std::domain_error("triangular view must be Eigen::Lower or Eigen::Upper");
41  }
42  }
43 
44  }
45 }
46 #endif

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