blob: 40ae4eeb303a72d4845d952ceec2827e467b9abc (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#pragma once
// -----------------------------------------------------------------------
// basic macros
#define math·abs(x) (((x) > 0) ? (x) : (-(x)))
#define math·sgn(x) (((x) > 0) ? (+1) : (((x) == 0) ? (0) : (-1) ))
// -----------------------------------------------------------------------
// elementary functions
double math·acos(double);
float math·acosf(float);
double math·acosh(double);
float math·acoshf(float);
double math·asin(double);
float math·asinf(float);
double math·asinh(double);
float math·asinhf(float);
double math·atan(double);
float math·atanf(float);
double math·atan2(double, double);
float math·atan2f(float, float);
double math·atanh(double);
float math·atanhf(float);
double math·cbrt(double);
float math·cbrtf(float);
double math·ceil(double);
float math·ceilf(float);
double math·cos(double);
float math·cosf(float);
double math·cosh(double);
float math·coshf(float);
double math·erf(double);
float math·erff(float);
double math·erfc(double);
float math·erfcf(float);
double math·exp(double);
float math·expf(float);
double math·exp2(double);
float math·exp2f(float);
double math·expm1(double);
float math·expm1f(float);
double math·floor(double);
float math·floorf(float);
int math·ilogb(double);
int math·ilogbf(float);
double math·lgamma(double);
float math·lgammaf(float);
long long math·llrint(double);
long long math·llrintf(float);
long long math·llround(double);
long long math·llroundf(float);
double math·log(double);
float math·logf(float);
double math·log10(double);
float math·log10f(float);
double math·log1p(double);
float math·log1pf(float);
double math·log2(double);
float math·log2f(float);
double math·logb(double);
float math·logbf(float);
long math·lrint(double);
long math·lrintf(float);
long math·lround(double);
long math·lroundf(float);
double math·nan(const char *);
float math·nanf(const char *);
double math·nearbyint(double);
float math·nearbyintf(float);
double math·pow(double, double);
float math·powf(float, float);
double math·rint(double);
float math·rintf(float);
double math·round(double);
float math·roundf(float);
double math·sin(double);
float math·sinf(float);
double math·sinh(double);
float math·sinhf(float);
double math·sqrt(double);
float math·sqrtf(float);
double math·tan(double);
float math·tanf(float);
double math·tanh(double);
float math·tanhf(float);
double math·tgamma(double);
float math·tgammaf(float);
double math·trunc(double);
float math·truncf(float);
// -----------------------------------------------------------------------
// linear algebra
typedef struct math·Vector
{
double *data;
int len;
} math·Vector;
#define math·slicev(vec, lo, hi) (struct math·Vector){.len=((hi)-(lo)), .data=((vec).data + (lo))}
typedef struct math·Matrix
{
double *data;
uint32 kind;
int dim[2];
} math·Matrix;
// TODO: tensor ala numpy
|