File: hello.cc

package info (click to toggle)
fityk 1.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,772 kB
  • sloc: cpp: 34,595; ansic: 4,676; python: 963; makefile: 384; sh: 119; xml: 91; java: 31; ruby: 27; perl: 25
file content (28 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (2)
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
26
27
28

#include <iostream>
#include <cmath>

#include <fityk/fityk.h>

using namespace std;
using namespace fityk;

int main()
{
    Fityk *f = new Fityk;
    cout << f->get_info("version") << endl;
    cout << "ln(2) = " << f->calculate_expr("ln(2)") << endl;
    const double mu = 12.345;
    for (int i = 0; i != 500; ++i) {
        double x = i / 100. + 10;
        double y = ceil(100 * exp(-(x-mu)*(x-mu)/2));
        f->add_point(x, y, sqrt(y));
    }
    f->execute("Y = randnormal(y, s)");
    f->execute("guess %gauss = Gaussian");
    f->execute("fit");
    cout << "peak center: " << f->calculate_expr("%gauss.Center") << endl;
    cout << "value at x=12: " << f->get_function("gauss")->value_at(12) << endl;
    delete f;
    return 0;
}