Stan  2.14.0
probability, sampling & optimization
infer_type_indexing_def.hpp
Go to the documentation of this file.
1 #ifndef STAN_LANG_AST_FUN_INFER_TYPE_INDEXING_DEF_HPP
2 #define STAN_LANG_AST_FUN_INFER_TYPE_INDEXING_DEF_HPP
3 
4 #include <stan/lang/ast.hpp>
5 #include <vector>
6 
7 namespace stan {
8  namespace lang {
9 
11  size_t num_expr_dims,
12  size_t num_index_dims) {
13  if (num_index_dims <= num_expr_dims)
14  return expr_type(expr_base_type, num_expr_dims - num_index_dims);
15  if (num_index_dims == (num_expr_dims + 1)) {
16  if (expr_base_type == VECTOR_T || expr_base_type == ROW_VECTOR_T)
17  return expr_type(DOUBLE_T, 0U);
18  if (expr_base_type == MATRIX_T)
19  return expr_type(ROW_VECTOR_T, 0U);
20  }
21  if (num_index_dims == (num_expr_dims + 2))
22  if (expr_base_type == MATRIX_T)
23  return expr_type(DOUBLE_T, 0U);
24 
25  // error condition, result expr_type has is_ill_formed() = true
26  return expr_type();
27  }
28 
30  size_t num_index_dims) {
32  expr.expression_type().num_dims(),
33  num_index_dims);
34  }
35 
36 
37 
38 
39  }
40 }
41 #endif
const int ROW_VECTOR_T
Row vector type; scalar type is real.
Probability, optimization and sampling library.
std::size_t num_dims() const
Return the number of dimensions for this type.
const int DOUBLE_T
Real scalar type.
expr_type infer_type_indexing(const base_expr_type &base_type, std::size_t dims, std::size_t num_indexes)
Return the expression type resulting from indexing an expression of the specified base type and numbe...
int base_expr_type
The type of a base expression.
Structure of the type of an expression, which consists of a base type and a number of dimensions...
Definition: expr_type.hpp:14
expr_type expression_type() const
base_expr_type base_type_
The base expression type.
Definition: expr_type.hpp:18
const int VECTOR_T
Column vector type; scalar type is real.
const int MATRIX_T
Matrix type; scalar type is real.

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