release 0.1.15
[liba.git] / python / test / mf.py
blobe8e165b020d8973e0593aa8afb181b8a49692d68
1 #!/usr/bin/env python
2 from __future__ import print_function
3 import os, sys
5 path = os.path.dirname(__file__)
6 path = os.path.dirname(path)
7 sys.path.insert(0, path)
8 if len(sys.argv) > 1:
9 sys.stdout = open(sys.argv[1], "w")
11 import liba # type: ignore
13 N = 1000
14 T = 6 / N
15 x = liba.new_num(N)
16 for i in range(N):
17 x[i] = (i - N / 2) * T
19 liba.mf.gauss(x, 1, 0)
20 liba.mf.gauss2(x, 1, -1, 1, +1)
21 liba.mf.gbell(x, 2, 4, 0)
22 liba.mf.sig(x, 2, 0)
23 liba.mf.dsig(x, 5, -2, +5, 2)
24 liba.mf.psig(x, 5, -2, -5, 2)
25 liba.mf.tri(x, 0, 1, 2)
26 liba.mf.trap(x, 0, 1, 2, 3)
27 liba.mf.lins(x, 1, 2)
28 liba.mf.linz(x, 1, 2)
29 liba.mf.s(x, 1, 2)
30 liba.mf.z(x, 1, 2)
31 liba.mf.pi(x, 0, 1, 2, 3)
33 S = 1
34 params = [
35 liba.new_num((liba.mf.TRI, -3 * S, -3 * S, -2 * S)),
36 liba.new_num((liba.mf.TRI, -3 * S, -2 * S, -1 * S)),
37 liba.new_num((liba.mf.TRI, -2 * S, -1 * S, +0 * S)),
38 liba.new_num((liba.mf.TRI, -1 * S, +0 * S, +1 * S)),
39 liba.new_num((liba.mf.TRI, +0 * S, +1 * S, +2 * S)),
40 liba.new_num((liba.mf.TRI, +1 * S, +2 * S, +3 * S)),
41 liba.new_num((liba.mf.TRI, +2 * S, +3 * S, +3 * S)),
43 for param in params:
44 liba.mf.mf(param[0], x, param[1:])