Skip to content

Commit 4be0758

Browse files
committed
Add inverse hyperbolic funcs
1 parent c51f528 commit 4be0758

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/blosc2/lazyexpr.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,12 +1276,6 @@ def fast_eval( # noqa: C901
12761276
# Check whether we can use miniexpr
12771277
# Miniexpr only supports a subset of functions - disable for unsupported ones
12781278
unsupported_funcs = [
1279-
"acosh",
1280-
"arccosh",
1281-
"arcsinh",
1282-
"arctanh",
1283-
"asinh",
1284-
"atanh",
12851279
"clip",
12861280
"conj",
12871281
"expm1",

src/blosc2/miniexpr.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,19 @@ static const me_variable functions[] = {
523523
/* Format: {name, dtype, address, type, context} */
524524
{"abs", 0, fabs, ME_FUNCTION1 | ME_FLAG_PURE, 0},
525525
{"acos", 0, acos, ME_FUNCTION1 | ME_FLAG_PURE, 0},
526+
{"acosh", 0, acosh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
526527
{"arccos", 0, acos, ME_FUNCTION1 | ME_FLAG_PURE, 0},
528+
{"arccosh", 0, acosh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
527529
{"arcsin", 0, asin, ME_FUNCTION1 | ME_FLAG_PURE, 0},
530+
{"arcsinh", 0, asinh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
528531
{"arctan", 0, atan, ME_FUNCTION1 | ME_FLAG_PURE, 0},
529532
{"arctan2", 0, atan2, ME_FUNCTION2 | ME_FLAG_PURE, 0},
533+
{"arctanh", 0, atanh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
530534
{"asin", 0, asin, ME_FUNCTION1 | ME_FLAG_PURE, 0},
535+
{"asinh", 0, asinh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
531536
{"atan", 0, atan, ME_FUNCTION1 | ME_FLAG_PURE, 0},
532537
{"atan2", 0, atan2, ME_FUNCTION2 | ME_FLAG_PURE, 0},
538+
{"atanh", 0, atanh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
533539
{"ceil", 0, ceil, ME_FUNCTION1 | ME_FLAG_PURE, 0},
534540
{"cos", 0, cos, ME_FUNCTION1 | ME_FLAG_PURE, 0},
535541
{"cosh", 0, cosh, ME_FUNCTION1 | ME_FLAG_PURE, 0},
@@ -1835,6 +1841,7 @@ DEFINE_VEC_CONVERT(u32, bool, uint32_t, bool)
18351841
DEFINE_VEC_CONVERT(u64, bool, uint64_t, bool)
18361842
DEFINE_VEC_CONVERT(f32, bool, float, bool)
18371843
DEFINE_VEC_CONVERT(f64, bool, double, bool)
1844+
DEFINE_VEC_CONVERT(f64, f32, double, float)
18381845

18391846
DEFINE_VEC_CONVERT(i8, i16, int8_t, int16_t)
18401847
DEFINE_VEC_CONVERT(i8, i32, int8_t, int32_t)
@@ -1876,7 +1883,6 @@ DEFINE_VEC_CONVERT(u32, f64, uint32_t, double)
18761883
DEFINE_VEC_CONVERT(u64, f64, uint64_t, double)
18771884

18781885
DEFINE_VEC_CONVERT(f32, f64, float, double)
1879-
DEFINE_VEC_CONVERT(f64, f32, double, float)
18801886
DEFINE_VEC_CONVERT(f32, c64, float, float complex)
18811887
DEFINE_VEC_CONVERT(f32, c128, float, double complex)
18821888

@@ -1956,10 +1962,10 @@ static convert_func_t get_convert_func(me_dtype from, me_dtype to) {
19561962
CONV_CASE(ME_UINT64, ME_FLOAT64, u64, f64)
19571963

19581964
CONV_CASE(ME_FLOAT32, ME_FLOAT64, f32, f64)
1959-
CONV_CASE(ME_FLOAT64, ME_FLOAT32, f64, f32)
19601965
CONV_CASE(ME_FLOAT32, ME_COMPLEX64, f32, c64)
19611966
CONV_CASE(ME_FLOAT32, ME_COMPLEX128, f32, c128)
19621967

1968+
CONV_CASE(ME_FLOAT64, ME_FLOAT32, f64, f32)
19631969
CONV_CASE(ME_FLOAT64, ME_COMPLEX128, f64, c128)
19641970

19651971
CONV_CASE(ME_COMPLEX64, ME_COMPLEX128, c64, c128)

src/blosc2/miniexpr.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ typedef struct me_variable {
118118
* var_count: Number of variables
119119
* dtype: Data type handling:
120120
* - ME_AUTO: All variables must specify their dtypes, output is inferred
121-
* - Specific type: All variables must be ME_AUTO, this type is used for all
121+
* - Specific type: Either all variables are ME_AUTO (homogeneous, all use this type),
122+
* OR all variables have explicit dtypes (heterogeneous, result cast to this type)
122123
* error: Optional pointer to receive error position (0 on success, >0 on error)
123124
*
124125
* Returns: Compiled expression ready for chunked evaluation, or NULL on error
@@ -127,10 +128,15 @@ typedef struct me_variable {
127128
* me_variable vars[] = {{"x"}, {"y"}}; // Both ME_AUTO
128129
* me_expr *expr = me_compile("x + y", vars, 2, ME_FLOAT64, &err);
129130
*
130-
* Example 2 (mixed types):
131+
* Example 2 (mixed types with ME_AUTO):
131132
* me_variable vars[] = {{"x", ME_INT32}, {"y", ME_FLOAT64}};
132133
* me_expr *expr = me_compile("x + y", vars, 2, ME_AUTO, &err);
133134
*
135+
* Example 3 (mixed types with explicit output):
136+
* me_variable vars[] = {{"x", ME_INT32}, {"y", ME_FLOAT64}};
137+
* me_expr *expr = me_compile("x + y", vars, 2, ME_FLOAT32, &err);
138+
* // Variables keep their types, result is cast to FLOAT32
139+
*
134140
* // Later, provide data in same order as variable definitions
135141
* const void *data[] = {x_array, y_array}; // x first, y second
136142
* me_eval(expr, data, 2, output, nitems);

0 commit comments

Comments
 (0)