diff options
Diffstat (limited to 'p-spin.cpp')
-rw-r--r-- | p-spin.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/p-spin.cpp b/p-spin.cpp new file mode 100644 index 0000000..3691ed6 --- /dev/null +++ b/p-spin.cpp @@ -0,0 +1,25 @@ +#include "p-spin.hpp" + +inline Real fP(unsigned p, Real q) { + return 0.5 * pow(q, p); +} + +inline Real dfP(unsigned p, Real q) { + return 0.5 * p * pow(q, p - 1); +} + +inline Real ddfP(unsigned p, Real q) { + return 0.5 * p * (p - 1) * pow(q, p - 2); +} + +Real f(Real λ, unsigned p, unsigned s, Real q) { + return (1 - λ) * fP(p, q) + λ * fP(s, q); +} + +Real df(Real λ, unsigned p, unsigned s, Real q) { + return (1 - λ) * dfP(p, q) + λ * dfP(s, q); +} + +Real ddf(Real λ, unsigned p, unsigned s, Real q) { + return (1 - λ) * ddfP(p, q) + λ * ddfP(s, q); +} |