aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-07 15:35:06 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-07 15:35:06 -0700
commit36117f59ec77784c9ef77801d7c1cbf03a4c4a8b (patch)
tree18a7c3f373c5d9ac11cce320045713550ce674fa /include
parent46da413cf7c9c995842a83cd54b02a17cd9c7289 (diff)
wrap: elementary math functions for libmath
Diffstat (limited to 'include')
-rw-r--r--include/libmath.h147
-rw-r--r--include/libn.h4
2 files changed, 134 insertions, 17 deletions
diff --git a/include/libmath.h b/include/libmath.h
index 03e8e1a..ec15f6f 100644
--- a/include/libmath.h
+++ b/include/libmath.h
@@ -1,20 +1,133 @@
#pragma once
// -----------------------------------------------------------------------
-// Linear algebra
-
-/*
- * Vector (double precision)
- * len : dimension of space
- * inc : stride to access in buffer
- * buf : pointer to start of data
- * NOTE: minimum buffer size MUST be len*inc
- */
-typedef struct math·Vecd
-{
- int len;
- int inc;
- double *buf;
-} math·Vecd;
-
-double linalg·dotd(math·Vecd a, math·Vecd b);
+// 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
diff --git a/include/libn.h b/include/libn.h
index 8e30eae..4efe3c1 100644
--- a/include/libn.h
+++ b/include/libn.h
@@ -286,6 +286,10 @@ error gz·flush(gz·Stream *s);
vlong gz·seek(gz·Stream *s, long off, enum SeekPos whence);
// -----------------------------------------------------------------------------
+// libjson
+// NOTE: Experimental!
+
+// -----------------------------------------------------------------------------
// error handling functions
void errorf(const byte* fmt, ...);