| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
qr_Q.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_QR_Q_HPP
2 #define STAN_MATH_FWD_MAT_FUN_QR_Q_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <Eigen/QR>
6 #include <stan/math/prim/scal/err/check_nonzero_size.hpp>
7 #include <stan/math/prim/scal/err/check_greater_or_equal.hpp>
8 #include <stan/math/fwd/core.hpp>
9
10 namespace stan {
11 namespace math {
12
13 template <typename T>
14 Eigen::Matrix<fvar<T>, Eigen::Dynamic, Eigen::Dynamic>
15 qr_Q(const Eigen::Matrix<fvar<T>, Eigen::Dynamic, Eigen::Dynamic>& m) {
16 typedef Eigen::Matrix<fvar<T>, Eigen::Dynamic, Eigen::Dynamic>
17 matrix_fwd_t;
18 stan::math::check_nonzero_size("qr_Q", "m", m);
19 stan::math::check_greater_or_equal("qr_Q", "m.rows()", m.rows(),
20 m.cols());
21 Eigen::HouseholderQR< matrix_fwd_t > qr(m.rows(), m.cols());
22 qr.compute(m);
23 matrix_fwd_t Q = qr.householderQ();
24 for (int i = 0; i < m.cols(); i++)
25 if (qr.matrixQR()(i, i) < 0.0)
26 Q.col(i) *= -1.0;
27 return Q;
28 }
29 }
30 }
31 #endif
stan::math::check_greater_or_equal
bool check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low)
Return true if y is greater or equal than low.
Definition: check_greater_or_equal.hpp:84
core.hpp
stan::math::qr_Q
Eigen::Matrix< fvar< T >, Eigen::Dynamic, Eigen::Dynamic > qr_Q(const Eigen::Matrix< fvar< T >, Eigen::Dynamic, Eigen::Dynamic > &m)
Definition: qr_Q.hpp:15
stan::math::check_nonzero_size
bool check_nonzero_size(const char *function, const char *name, const T_y &y)
Return true if the specified matrix/vector is of non-zero size.
Definition: check_nonzero_size.hpp:31
Eigen.hpp
check_greater_or_equal.hpp
check_nonzero_size.hpp
stan::math::fvar
Definition: fvar.hpp:13

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