Stan Math Library
5.0.0
Automatic Differentiation
Loading...
Searching...
No Matches
matrix_vari.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_REV_CORE_MATRIX_VARI_HPP
2
#define STAN_MATH_REV_CORE_MATRIX_VARI_HPP
3
4
#include <
stan/math/prim/fun/Eigen.hpp
>
5
#include <
stan/math/rev/core/Eigen_NumTraits.hpp
>
6
#include <
stan/math/rev/core/typedefs.hpp
>
7
#include <
stan/math/rev/meta.hpp
>
8
#include <
stan/math/rev/core/var.hpp
>
9
#include <
stan/math/rev/core/vari.hpp
>
10
#include <
stan/math/prim/meta.hpp
>
11
12
namespace
stan
{
13
namespace
math {
14
15
class
op_matrix_vari
:
public
vari
{
16
protected
:
17
const
size_t
size_
;
18
vari
**
vis_
;
19
20
public
:
21
template
<
typename
T, require_eigen_vt<is_var, T>* =
nullptr
>
22
op_matrix_vari
(
double
f,
const
T& vs) :
vari
(f),
size_
(vs.
size
()) {
23
vis_
=
ChainableStack::instance_
->
memalloc_
.
alloc_array
<
vari
*>(
size_
);
24
Eigen::Map<Eigen::Matrix<
vari
*, -1, -1>>(
vis_
, vs.rows(), vs.cols())
25
= vs.vi();
26
}
27
vari
*
operator[]
(
size_t
n)
const
{
return
vis_
[n]; }
28
size_t
size
() {
return
size_
; }
29
};
30
31
}
// namespace math
32
}
// namespace stan
33
#endif
Eigen.hpp
stan::math::op_matrix_vari::op_matrix_vari
op_matrix_vari(double f, const T &vs)
Definition
matrix_vari.hpp:22
stan::math::op_matrix_vari::size
size_t size()
Definition
matrix_vari.hpp:28
stan::math::op_matrix_vari::vis_
vari ** vis_
Definition
matrix_vari.hpp:18
stan::math::op_matrix_vari::size_
const size_t size_
Definition
matrix_vari.hpp:17
stan::math::op_matrix_vari::operator[]
vari * operator[](size_t n) const
Definition
matrix_vari.hpp:27
stan::math::op_matrix_vari
Definition
matrix_vari.hpp:15
stan::math::stack_alloc::alloc_array
T * alloc_array(size_t n)
Allocate an array on the arena of the specified size to hold values of the specified template paramet...
Definition
stack_alloc.hpp:193
stan::math::vari_value
Definition
vari.hpp:17
stan
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition
unit_vector_constrain.hpp:15
meta.hpp
Eigen_NumTraits.hpp
typedefs.hpp
vari.hpp
meta.hpp
stan::math::AutodiffStackSingleton::AutodiffStackStorage::memalloc_
stack_alloc memalloc_
Definition
autodiffstackstorage.hpp:107
stan::math::AutodiffStackSingleton::instance_
static thread_local AutodiffStackStorage * instance_
Definition
autodiffstackstorage.hpp:118
var.hpp
stan
math
rev
core
matrix_vari.hpp
[
Stan Home Page
]
© 2011–2019, Stan Development Team.