1 /* 2 * Copyright (c) 2019-2021 Kevin Townsend (KTOWN) 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief API header file for zscilib. 10 * 11 * This file contains the entry points to the zscilib APIs. 12 */ 13 14 #ifndef ZEPHYR_INCLUDE_ZSL_H_ 15 #define ZEPHYR_INCLUDE_ZSL_H_ 16 17 #include <math.h> 18 #include <stdbool.h> 19 #include <stddef.h> 20 #include <stdint.h> 21 #include <zsl/consts.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* 28 * Version numbers take the form of "MAJOR.MINOR.REVISION-STATUS". 29 * 30 * ZSL_VERSION_STATUS should be one of: 31 * 32 * o "-prerelease" 33 * o "-alpha" 34 * o "-beta" 35 * o "-rc0", "-rc1", etc. 36 * o "-release" 37 */ 38 39 #define ZSL_VERSION "0.2.0-rc1" 40 #define ZSL_VERSION_MAJOR 0 41 #define ZSL_VERSION_MINOR 2 42 #define ZSL_VERSION_REVISION 0 43 #define ZSL_VERSION_STATUS "-rc1" 44 #define ZSL_VERSION_DATE __DATE__ 45 46 extern const char *zsl_version; 47 48 #if CONFIG_ZSL_SINGLE_PRECISION 49 typedef float zsl_real_t; 50 #else 51 typedef double zsl_real_t; 52 #endif 53 54 /* Map math functions based on single or double precision. */ 55 /* TODO: Add an option for fast approximations of trig operations. */ 56 #if CONFIG_ZSL_SINGLE_PRECISION 57 #define ZSL_CEIL ceilf 58 #define ZSL_FLOOR floorf 59 #define ZSL_ROUND roundf 60 #define ZSL_ABS fabsf 61 #define ZSL_MIN fminf 62 #define ZSL_MAX fmaxf 63 #define ZSL_POW powf 64 #define ZSL_EXP expf 65 #define ZSL_LOG logf 66 #define ZSL_LOG10 log10f 67 #define ZSL_SQRT sqrtf 68 #define ZSL_SIN sinf 69 #define ZSL_COS cosf 70 #define ZSL_TAN tanf 71 #define ZSL_ASIN asinf 72 #define ZSL_ACOS acosf 73 #define ZSL_ATAN atanf 74 #define ZSL_ATAN2 atan2f 75 #define ZSL_SINH sinhf 76 #define ZSL_COSH coshf 77 #define ZSL_TANH tanhf 78 #define ZSL_ERF erff 79 #define ZSL_FMA fmaf 80 #else 81 #define ZSL_CEIL ceil 82 #define ZSL_FLOOR floor 83 #define ZSL_ROUND round 84 #define ZSL_ABS fabs 85 #define ZSL_MIN fmin 86 #define ZSL_MAX fmax 87 #define ZSL_POW pow 88 #define ZSL_EXP exp 89 #define ZSL_LOG log 90 #define ZSL_LOG10 log10 91 #define ZSL_SQRT sqrt 92 #define ZSL_SIN sin 93 #define ZSL_COS cos 94 #define ZSL_TAN tan 95 #define ZSL_ASIN asin 96 #define ZSL_ACOS acos 97 #define ZSL_ATAN atan 98 #define ZSL_ATAN2 atan2 99 #define ZSL_SINH sinh 100 #define ZSL_COSH cosh 101 #define ZSL_TANH tanh 102 #define ZSL_ERF erf 103 #define ZSL_FMA fma 104 #endif 105 106 107 /* TODO: Define common errors like shape mismatch, etc. */ 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #endif /* ZEPHYR_INCLUDE_ZSL_H_ */ 114