All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
promote_scalar.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_PROMOTE_SCALAR_HPP
#define STAN_MATH_PRIM_MAT_FUN_PROMOTE_SCALAR_HPP
#include <stan/math/prim/scal/fun/promote_scalar.hpp>
#include <stan/math/prim/mat/fun/promote_scalar_type.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
namespace stan {
namespace math {
template <typename T, typename S>
struct promote_scalar_struct<T, Eigen::Matrix<S, -1, -1> > {
static Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, -1>
apply(const Eigen::Matrix<S, -1, -1>& x) {
Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, -1>
y(x.rows(), x.cols());
for (int i = 0; i < x.size(); ++i)
y(i) = promote_scalar_struct<T, S>::apply(x(i));
return y;
}
};
template <typename T, typename S>
struct promote_scalar_struct<T, Eigen::Matrix<S, 1, -1> > {
static Eigen::Matrix<typename promote_scalar_type<T, S>::type, 1, -1>
apply(const Eigen::Matrix<S, 1, -1>& x) {
Eigen::Matrix<typename promote_scalar_type<T, S>::type, 1, -1>
y(x.rows(), x.cols());
for (int i = 0; i < x.size(); ++i)
y(i) = promote_scalar_struct<T, S>::apply(x(i));
return y;
}
};
template <typename T, typename S>
struct promote_scalar_struct<T, Eigen::Matrix<S, -1, 1> > {
static Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, 1>
apply(const Eigen::Matrix<S, -1, 1>& x) {
Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, 1>
y(x.rows(), x.cols());
for (int i = 0; i < x.size(); ++i)
y(i) = promote_scalar_struct<T, S>::apply(x(i));
return y;
}
};
}
}
#endif
promote_scalar_type.hpp
stan::math::promote_scalar_struct
General struct to hold static function for promoting underlying scalar types.
Definition: promote_scalar.hpp:22
Eigen.hpp
stan::math::promote_scalar_struct< T, Eigen::Matrix< S, 1,-1 > >::apply
static Eigen::Matrix< typename promote_scalar_type< T, S >::type, 1,-1 > apply(const Eigen::Matrix< S, 1,-1 > &x)
Return the column vector consisting of the recursive promotion of the elements of the input column ve...
Definition: promote_scalar.hpp:60
promote_scalar.hpp
stan::math::promote_scalar_struct::apply
static T apply(S x)
Return the value of the input argument promoted to the type specified by the template parameter...
Definition: promote_scalar.hpp:34
stan::math::promote_scalar_struct< T, Eigen::Matrix< S,-1,-1 > >::apply
static Eigen::Matrix< typename promote_scalar_type< T, S >::type,-1,-1 > apply(const Eigen::Matrix< S,-1,-1 > &x)
Return the matrix consisting of the recursive promotion of the elements of the input matrix to the sc...
Definition: promote_scalar.hpp:31
stan::math::promote_scalar_struct< T, Eigen::Matrix< S,-1, 1 > >::apply
static Eigen::Matrix< typename promote_scalar_type< T, S >::type,-1, 1 > apply(const Eigen::Matrix< S,-1, 1 > &x)
Return the row vector consisting of the recursive promotion of the elements of the input row vector t...
Definition: promote_scalar.hpp:89

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