Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erf causes error in Visual C++ #5

Closed
stefanofiorentino opened this issue Aug 11, 2016 · 3 comments
Closed

Erf causes error in Visual C++ #5

stefanofiorentino opened this issue Aug 11, 2016 · 3 comments

Comments

@stefanofiorentino
Copy link

Robin,
while compiling under VS2012 Update 5 I'm experiencing the follwing issue:
adept.h(1474): error C2784: 'adept::Erf<A> erf(const adept::Expression<A> &)' : could not deduce template argument for 'const adept::Expression<A> &' from 'adept::Real'

Have you any idea on how I can overtake this without update the VS version?
I guess I can avoid the #define ADEPT_DEFINE_UNARY_FUNCTION in the case of Erf and define it separately.

@stefanofiorentino
Copy link
Author

It looks like VC++ has no a compatible erf function version.

@stefanofiorentino
Copy link
Author

I won't pull request as I added a "too big to link" dependence.
Solved thanks to boost::math::special_functions and the following #define

#define ADEPT_DEFINE_UNARY_FUNCTION_BOOST(OP,FUNC,DERIVATIVE)       \
  namespace adept {                     \
    template <class A>                      \
    struct OP : public Expression<OP<A> > {         \
      OP(const Expression<A>& a)                \
    : a_(a.cast()), result_(boost::math::FUNC(a_.value())) { }      \
      void calc_gradient(Stack& stack) const {          \
    a_.calc_gradient(stack, DERIVATIVE);            \
      }                             \
      void calc_gradient(Stack& stack,              \
             const Real& multiplier) const {    \
    a_.calc_gradient(stack, (DERIVATIVE)*multiplier);   \
      }                             \
      ADEPT_VALUE_RETURN_TYPE value() const {           \
    return result_;                     \
      }                             \
    private:                            \
    const A& a_;                        \
    Real result_;                       \
    };                              \
  }                             \
  template <class A>                        \
  inline                            \
  adept:: OP<A> FUNC(const adept::Expression<A>& a) {       \
    return adept:: OP<A>(a.cast());             \
  }

@stefanofiorentino
Copy link
Author

The extensive list of functions not supported "natively" under VS 2012 Update 5 is:

  • log2
  • expm1
  • exp2
  • log1p
  • asinh
  • acosh
  • atanh
  • erf
  • erfc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant