1 #ifndef STAN_MATH_REV_MAT_FUN_EIGEN_NUMTRAITS_HPP
2 #define STAN_MATH_REV_MAT_FUN_EIGEN_NUMTRAITS_HPP
16 struct NumTraits<
stan::math::var> {
45 return std::numeric_limits<double>::epsilon();
83 RequireInitialization = 0,
96 struct significant_decimals_default_impl<
stan::math::var, false> {
97 static inline int run() {
100 return cast<double, int>(
ceil(-
log(std::numeric_limits<double>
111 struct scalar_product_traits<
stan::math::var, double> {
120 struct scalar_product_traits<double,
stan::math::var> {
127 template<
typename Index,
bool ConjugateLhs,
bool ConjugateRhs>
128 struct general_matrix_vector_product<Index,
stan::math::var, ColMajor,
133 typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType
135 enum { LhsStorageOrder = ColMajor };
137 EIGEN_DONT_INLINE
static void run(
139 const LhsScalar* lhs, Index lhsStride,
140 const RhsScalar* rhs, Index rhsIncr,
143 for (Index i = 0; i <
rows; i++) {
148 (static_cast<int>(LhsStorageOrder) == static_cast<int>(ColMajor))
149 ?(&lhs[i]):(&lhs[i*lhsStride]),
150 (static_cast<int>(LhsStorageOrder) == static_cast<int>(ColMajor))
152 rhs, rhsIncr, cols));
156 template<
typename Index,
bool ConjugateLhs,
bool ConjugateRhs>
157 struct general_matrix_vector_product<Index,
stan::math::var,
158 RowMajor, ConjugateLhs,
162 typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType
164 enum { LhsStorageOrder = RowMajor };
166 EIGEN_DONT_INLINE
static void
168 const LhsScalar* lhs, Index lhsStride,
169 const RhsScalar* rhs, Index rhsIncr,
170 ResScalar* res, Index resIncr,
const RhsScalar &alpha) {
171 for (Index i = 0; i <
rows; i++) {
176 (static_cast<int>(LhsStorageOrder) == static_cast<int>(ColMajor))
177 ? (&lhs[i]) : (&lhs[i*lhsStride]),
178 (static_cast<int>(LhsStorageOrder) == static_cast<int>(ColMajor))
180 rhs, rhsIncr, cols));
184 template<
typename Index,
int LhsStorageOrder,
bool ConjugateLhs,
185 int RhsStorageOrder,
bool ConjugateRhs>
186 struct general_matrix_matrix_product<Index,
stan::math::var,
187 LhsStorageOrder, ConjugateLhs,
189 ConjugateRhs, ColMajor> {
192 typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType
195 const LhsScalar* _lhs, Index lhsStride,
196 const RhsScalar* _rhs, Index rhsStride,
199 level3_blocking<LhsScalar, RhsScalar>& ,
200 GemmParallelInfo<Index>* ) {
201 for (Index i = 0; i <
cols; i++) {
202 general_matrix_vector_product<Index, LhsScalar, LhsStorageOrder,
203 ConjugateLhs, RhsScalar, ConjugateRhs>
204 ::run(rows, depth, _lhs, lhsStride,
205 &_rhs[(static_cast<int>(RhsStorageOrder)
206 == static_cast<int>(ColMajor))
207 ? (i*rhsStride) :(i) ],
208 (static_cast<int>(RhsStorageOrder)
209 == static_cast<int>(ColMajor)) ? (1) : (rhsStride),
210 &res[i*resStride], 1, alpha);
static Real lowest()
Return standard library's lowest for double-precision floating point, -std::numeric_limitsmax...
int rows(const Eigen::Matrix< T, R, C > &m)
Return the number of rows in the specified matrix, vector, or row vector.
static EIGEN_DONT_INLINE void run(Index rows, Index cols, const LhsScalar *lhs, Index lhsStride, const RhsScalar *rhs, Index rhsIncr, ResScalar *res, Index resIncr, const ResScalar &alpha)
stan::math::var LhsScalar
fvar< T > log(const fvar< T > &x)
static Real dummy_precision()
Return dummy precision.
scalar_product_traits< LhsScalar, RhsScalar >::ReturnType ResScalar
stan::math::var NonInteger
Non-integer valued variables.
scalar_product_traits< LhsScalar, RhsScalar >::ReturnType ResScalar
Independent (input) and dependent (output) variables for gradients.
static Real highest()
Return standard library's highest for double-precision floating point, std::numeric_limitsmax...
(Expert) Numerical traits for algorithmic differentiation variables.
stan::math::var ReturnType
stan::math::var RhsScalar
stan::math::var LhsScalar
stan::math::var Real
Real-valued variables.
static Real epsilon()
Return standard library's epsilon for double-precision floating point, std::numeric_limits::e...
int cols(const Eigen::Matrix< T, R, C > &m)
Return the number of columns in the specified matrix, vector, or row vector.
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.
double e()
Return the base of the natural logarithm.
stan::math::var LhsScalar
stan::math::var Nested
Nested variables.
scalar_product_traits< LhsScalar, RhsScalar >::ReturnType ResScalar
static void run(Index rows, Index cols, Index depth, const LhsScalar *_lhs, Index lhsStride, const RhsScalar *_rhs, Index rhsStride, ResScalar *res, Index resStride, const ResScalar &alpha, level3_blocking< LhsScalar, RhsScalar > &, GemmParallelInfo< Index > *)
static EIGEN_DONT_INLINE void run(Index rows, Index cols, const LhsScalar *lhs, Index lhsStride, const RhsScalar *rhs, Index rhsIncr, ResScalar *res, Index resIncr, const RhsScalar &alpha)
stan::math::var RhsScalar
stan::math::var RhsScalar
fvar< T > ceil(const fvar< T > &x)
stan::math::var ReturnType