xref: /inferno-os/module/math.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1Math: module
2{
3	PATH:	con	"$Math";
4
5	Infinity:	con 1e400;
6	NaN:		con 0./0.;
7	MachEps:	con 2.2204460492503131e-16;
8	Pi:		con 3.14159265358979323846;
9	Degree:		con Pi/180.;
10	INVAL:		con (1<<0);
11	ZDIV:		con (1<<1);
12	OVFL:		con (1<<2);
13	UNFL:		con (1<<3);
14	INEX:		con (1<<4);
15	RND_NR:		con (0<<8);
16	RND_NINF:	con (1<<8);
17	RND_PINF:	con (2<<8);
18	RND_Z:		con (3<<8);
19	RND_MASK:	con (3<<8);
20	acos:		fn(x: real): real;	# arccos(x) in [0,pi]
21	acosh:		fn(x: real): real;
22	asin:		fn(x: real): real;	# arcsin(x) in [-pi/2,pi/2]
23	asinh:		fn(x: real): real;
24	atan:		fn(x: real): real;	# arctan(x) in [-pi/2,pi/2]
25	atan2:		fn(y, x: real): real;	# arctan(y/x) in [-pi,pi]
26	atanh:		fn(x: real): real;
27	cbrt:		fn(x: real): real;
28	ceil:		fn(x: real): real;
29	copysign:	fn(x, s: real): real;
30	cos:		fn(x: real): real;
31	cosh:		fn(x: real): real;
32	dot:		fn(x, y: array of real): real;
33	erf:		fn(x: real): real;
34	erfc:		fn(x: real): real;
35	exp:		fn(x: real): real;
36	expm1:		fn(x: real): real;
37	fabs:		fn(x: real): real;
38	fdim, fmin, fmax: fn(x, y: real): real;
39	finite:		fn(x: real): int;
40	floor:		fn(x: real): real;
41	fmod:		fn(x, y: real): real;
42	gemm:		fn(transa, transb: int,  # upper case N or T
43			m, n, k: int, alpha: real,
44			a: array of real, lda: int,
45			b: array of real, ldb: int, beta: real,
46			c: array of real, ldc: int);
47	getFPcontrol, getFPstatus: fn(): int;
48	FPcontrol, FPstatus: fn(r, mask: int): int;
49	hypot:		fn(x, y: real): real;
50	iamax:		fn(x: array of real): int;
51	ilogb:		fn(x: real): int;
52	isnan:		fn(x: real): int;
53	j0:		fn(x: real): real;
54	j1:		fn(x: real): real;
55	jn:		fn(n: int, x: real): real;
56	lgamma:		fn(x: real): (int,real);
57	log:		fn(x: real): real;
58	log10:		fn(x: real): real;
59	log1p:		fn(x: real): real;
60	modf:		fn(x: real): (int,real);
61	nextafter:	fn(x, y: real): real;
62	norm1, norm2:	fn(x: array of real): real;
63	pow:		fn(x, y: real): real;
64	pow10:		fn(p: int): real;
65	remainder:	fn(x, p: real): real;
66	rint:		fn(x: real): real;
67	scalbn:		fn(x: real, n: int): real;
68	sin:		fn(x: real): real;
69	sinh:		fn(x: real): real;
70	sort:		fn(x: array of real, pi: array of int);
71	sqrt:		fn(x: real): real;
72	tan:		fn(x: real): real;
73	tanh:		fn(x: real): real;
74	y0:		fn(x: real): real;
75	y1:		fn(x: real): real;
76	yn:		fn(n: int, x: real): real;
77
78
79	import_int:	fn(b: array of byte, x: array of int);
80	import_real32:	fn(b: array of byte, x: array of real);
81	import_real:	fn(b: array of byte, x: array of real);
82	export_int:	fn(b: array of byte, x: array of int);
83	export_real32:	fn(b: array of byte, x: array of real);
84	export_real:	fn(b: array of byte, x: array of real);
85
86	# undocumented, of specialized interest only    DEPRECATED
87	bits32real:	fn(b: int): real; # IEEE 32-bit format to real
88	bits64real:	fn(b: big): real; # IEEE 64-bit format to real
89	realbits32:	fn(x: real): int; # real to IEEE 32-bit format
90	realbits64:	fn(x: real): big; # real to IEEE 64-bit format
91};
92