1#ifndef XPED_COMPLEX_VAR_HPP_
2#define XPED_COMPLEX_VAR_HPP_
5#include "stan/math/rev/core/var.hpp"
10class var_value<std::complex<double>, void>
13 using value_type = std::complex<double>;
14 using vari_type = vari_value<value_type>;
34 inline bool is_uninitialized() {
return (vi_ ==
nullptr); }
54 template <
typename S, require_convertible_t<S&, value_type>* =
nullptr>
56 : vi_(new vari_type(x, false))
63 var_value(vari_type* vi)
72 inline const auto& val() const noexcept {
return vi_->val(); }
82 inline auto& adj() const noexcept {
return vi_->adj(); }
92 inline auto& adj() noexcept {
return vi_->adj_; }
103 void grad() { stan::math::grad(vi_); }
119 inline vari_type&
operator*() {
return *vi_; }
131 inline vari_type* operator->() {
return vi_; }
145 inline var_value<value_type>& operator+=(
const var_value<value_type>& b);
157 inline var_value<value_type>& operator+=(value_type b);
170 inline var_value<value_type>& operator-=(
const var_value<value_type>& b);
183 inline var_value<value_type>& operator-=(value_type b);
196 inline var_value<value_type>& operator*=(
const var_value<value_type>& b);
209 inline var_value<value_type>& operator*=(value_type b);
221 inline var_value<value_type>& operator/=(
const var_value<value_type>& b);
234 inline var_value<value_type>& operator/=(value_type b);
244 friend std::ostream&
operator<<(std::ostream& os,
const var_value<value_type>& v)
246 if(v.vi_ ==
nullptr) {
return os <<
"uninitialized"; }
247 return os << v.val();
251inline var_value<std::complex<double>> operator/(
const var_value<std::complex<double>>& dividend,
const var_value<std::complex<double>>& divisor)
253 return make_callback_var(dividend.val() / divisor.val(), [dividend, divisor](
auto&& vi) {
254 dividend.adj() += vi.adj() / divisor.val();
255 divisor.adj() -= vi.adj() * dividend.val() / (divisor.val() * divisor.val());
263stan::math::var_value<double> real(
const stan::math::var_value<std::complex<double>>& z)
265 return stan::math::make_callback_var(z.val().real(), [z](
auto&& vi) { z.adj() += vi.adj(); });
XTensor< TRACK, Scalar, Rank, CoRank, Symmetry > operator*(const Tensor< Scalar, Rank, CoRank, Symmetry, true > &t, Scalar s)
Definition: ADTensor.hpp:452
std::ostream & operator<<(std::ostream &os, const FusionTree< depth, Symmetry > &tree)
Definition: FusionTree.hpp:93