10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-12-22 12:23:31 +01:00
QCaml/Utils/math_functions.c

74 lines
1021 B
C

#include <math.h>
#include <caml/mlvalues.h>
#include <caml/alloc.h>
CAMLprim value erf_float_bytecode(value x)
{
return copy_double(erf(Double_val(x)));
}
CAMLprim double erf_float(double x)
{
return erf(x);
}
CAMLprim value erfc_float_bytecode(value x)
{
return copy_double(erfc(Double_val(x)));
}
CAMLprim double erfc_float(double x)
{
return erfc(x);
}
CAMLprim value gamma_float_bytecode(value x)
{
return copy_double(tgamma(Double_val(x)));
}
CAMLprim double gamma_float(double x)
{
return tgamma(x);
}
CAMLprim int32_t popcnt(int64_t i)
{
return __builtin_popcountll (i);
}
CAMLprim value popcnt_bytecode(value i)
{
return copy_int32(__builtin_popcountll (i));
}
CAMLprim int32_t trailz(int64_t i)
{
return __builtin_ctzll (i);
}
CAMLprim value trailz_bytecode(value i)
{
return copy_int32(__builtin_ctzll (i));
}
CAMLprim int32_t leadz(int64_t i)
{
return __builtin_clzll(i);
}
CAMLprim value leadz_bytecode(value i)
{
return copy_int32(__builtin_clzll (i));
}