librime: dynamics.h Source File

| librime 1.2 Rime Input Method Engine, the core library

dynamics.h
Go to the documentation of this file.
1#include <cmath>
2
3namespace rime {
4 namespace algo {
5
6 inline double formula_d(double d, double t, double da, double ta) {
7 return d + da * exp((ta - t) / 200);
8}
9
10 inline double formula_p(double s, double u, double t, double d) {
11 const double kM = 1 / (1 - exp(-0.005));
12 double m = s - (s - u) * pow((1 - exp(-t / 10000)), 10);
13 return (d < 20) ? m + (0.5 - m) * (d / kM)
14 : m + (1 - m) * (pow(4, (d / kM)) - 1) / 3;
15}
16
17} // namespace algo
18} // namespace rime
rime
Definition algebra.cc:12
rime::algo
Definition dynamics.h:4
rime::algo::formula_p
double formula_p(double s, double u, double t, double d)
Definition dynamics.h:10
rime::algo::formula_d
double formula_d(double d, double t, double da, double ta)
Definition dynamics.h:6