All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
head.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_HEAD_HPP
#define STAN_MATH_PRIM_MAT_FUN_HEAD_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat/err/check_column_index.hpp>
#include <stan/math/prim/mat/err/check_row_index.hpp>
#include <stan/math/prim/mat/err/check_std_vector_index.hpp>
#include <vector>
namespace stan {
namespace math {
template <typename T>
inline
Eigen::Matrix<T, Eigen::Dynamic, 1>
head(const Eigen::Matrix<T, Eigen::Dynamic, 1>& v,
size_t n) {
if (n != 0)
stan::math::check_row_index("head", "n", v, n);
return v.head(n);
}
template <typename T>
inline
Eigen::Matrix<T, 1, Eigen::Dynamic>
head(const Eigen::Matrix<T, 1, Eigen::Dynamic>& rv,
size_t n) {
if (n != 0)
stan::math::check_column_index("head", "n", rv, n);
return rv.head(n);
}
template <typename T>
std::vector<T> head(const std::vector<T>& sv,
size_t n) {
if (n != 0)
stan::math::check_std_vector_index("head", "n", sv, n);
std::vector<T> s;
for (size_t i = 0; i < n; ++i)
s.push_back(sv[i]);
return s;
}
}
}
#endif
check_column_index.hpp
check_std_vector_index.hpp
stan::math::head
Eigen::Matrix< T, Eigen::Dynamic, 1 > head(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, size_t n)
Return the specified number of elements as a vector from the front of the specified vector...
Definition: head.hpp:24
stan::math::check_row_index
bool check_row_index(const char *function, const char *name, const Eigen::Matrix< T_y, R, C > &y, size_t i)
Return true if the specified index is a valid row of the matrix.
Definition: check_row_index.hpp:32
check_row_index.hpp
stan::math::check_std_vector_index
bool check_std_vector_index(const char *function, const char *name, const std::vector< T > &y, int i)
Return true if the specified index is valid in std vector.
Definition: check_std_vector_index.hpp:30
Eigen.hpp
stan::math::check_column_index
bool check_column_index(const char *function, const char *name, const Eigen::Matrix< T_y, R, C > &y, const size_t i)
Return true if the specified index is a valid column of the matrix.
Definition: check_column_index.hpp:37

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