1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "p-spin.hpp"
inline Real fₚ(unsigned p, Real q) {
return 0.5 * pow(q, p);
}
inline Real ∂fₚ(unsigned p, Real q) {
return 0.5 * p * pow(q, p - 1);
}
inline Real ∂∂fₚ(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 - λ) * fₚ(p, q) + λ * fₚ(s, q);
}
Real ∂f(Real λ, unsigned p, unsigned s, Real q) {
return (1 - λ) * ∂fₚ(p, q) + λ * ∂fₚ(s, q);
}
Real ∂∂f(Real λ, unsigned p, unsigned s, Real q) {
return (1 - λ) * ∂∂fₚ(p, q) + λ * ∂∂fₚ(s, q);
}
|