All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
qr_Q.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_QR_Q_HPP
#define STAN_MATH_PRIM_MAT_FUN_QR_Q_HPP
#include <stan/math/prim/scal/err/check_greater_or_equal.hpp>
#include <stan/math/prim/scal/err/check_nonzero_size.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <Eigen/QR>
namespace stan {
namespace math {
template <typename T>
Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
qr_Q(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& m) {
typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> matrix_t;
stan::math::check_nonzero_size("qr_Q", "m", m);
stan::math::check_greater_or_equal("qr_Q", "m.rows()",
static_cast<size_t>(m.rows()),
static_cast<size_t>(m.cols()));
Eigen::HouseholderQR<matrix_t> qr(m.rows(), m.cols());
qr.compute(m);
matrix_t Q = qr.householderQ();
for (int i = 0; i < m.cols(); i++)
if (qr.matrixQR()(i, i) < 0)
Q.col(i) *= -1.0;
return Q;
}
}
}
#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
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 Home Page ] © 2011–2015, Stan Development Team.