mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Added pow macros to math module.
This commit is contained in:
committed by
Christoffer Lerno
parent
b086c85d9f
commit
e070bf22ee
@@ -123,6 +123,8 @@ macro bool is_subarray_convertable($Type)
|
||||
$endswitch;
|
||||
}
|
||||
|
||||
macro bool is_int($Type) = $Type.kindof == TypeKind.SIGNED_INT || $Type.kindof == TypeKind.UNSIGNED_INT;
|
||||
|
||||
macro bool is_intlike($Type)
|
||||
{
|
||||
$switch ($Type.kindof):
|
||||
|
||||
@@ -163,6 +163,19 @@ macro min(x, y) = $$min(x, y);
|
||||
**/
|
||||
macro muladd(a, b, c) = $$fmuladd(a, b, c);
|
||||
|
||||
/**
|
||||
* @require types::is_floatlike($typeof(x)) `The input must be a floating point value or float vector`
|
||||
* @require types::is_floatlike($typeof(exp)) || types::is_int($typeof(exp)) `The input must be an integer, a floating point value or float vector`
|
||||
**/
|
||||
macro pow(x, exp)
|
||||
{
|
||||
$if (types::is_floatlike($typeof(exp))):
|
||||
return $$pow(x, exp);
|
||||
$else:
|
||||
return $$pow_int(x, exp);
|
||||
$endif;
|
||||
}
|
||||
|
||||
macro sec(x) = 1 / cos(x);
|
||||
|
||||
macro sech(x) = 2 / (exp(x) + exp(-x));
|
||||
@@ -201,7 +214,7 @@ macro float float.floor(float x) = $$floor(x);
|
||||
macro float float.fma(float a, float b, float c) = $$fma(a, b, c);
|
||||
macro float float.muladd(float a, float b, float c) = $$fmuladd(a, b, c);
|
||||
macro float float.nearbyint(float x) = $$nearbyint(x);
|
||||
macro float float.pow(float x, float exp) = $$pow(x, exp);
|
||||
macro float float.pow(float x, exp) = pow(x, exp);
|
||||
macro float float.rint(float x) = $$rint(x);
|
||||
macro float float.round(float x) = $$round(x);
|
||||
macro float float.roundeven(float x) = $$roundeven(x);
|
||||
@@ -213,7 +226,7 @@ macro float[<*>] float[<*>].copysign(float[<*>] mag, float[<*>] sgn) = $$copysig
|
||||
macro float[<*>] float[<*>].fma(float[<*>] a, float[<*>] b, float[<*>] c) = $$fma(a, b, c);
|
||||
macro float[<*>] float[<*>].floor(float[<*>] x) = $$floor(x);
|
||||
macro float[<*>] float[<*>].nearbyint(float[<*>] x) = $$nearbyint(x);
|
||||
macro float[<*>] float[<*>].pow(float[<*>] x, float[<*>] exp) = $$pow(x, exp);
|
||||
macro float[<*>] float[<*>].pow(float[<*>] x, exp) = pow(x, exp);
|
||||
macro float[<*>] float[<*>].rint(float[<*>] x) = $$rint(x);
|
||||
macro float[<*>] float[<*>].round(float[<*>] x) = $$round(x);
|
||||
macro float[<*>] float[<*>].roundeven(float[<*>] x) = $$roundeven(x);
|
||||
@@ -226,7 +239,7 @@ macro double double.floor(double x) = $$floor(x);
|
||||
macro double double.fma(double a, double b, double c) = $$fma(a, b, c);
|
||||
macro double double.muladd(double a, double b, double c) = $$fmuladd(a, b, c);
|
||||
macro double double.nearbyint(double x) = $$nearbyint(x);
|
||||
macro double double.pow(double x, double exp) = $$pow(x, exp);
|
||||
macro double double.pow(double x, exp) = pow(x, exp);
|
||||
macro double double.rint(double x) = $$rint(x);
|
||||
macro double double.round(double x) = $$round(x);
|
||||
macro double double.roundeven(double x) = $$roundeven(x);
|
||||
@@ -238,7 +251,7 @@ macro double[<*>] double[<*>].copysign(double[<*>] mag, double[<*>] sgn) = $$cop
|
||||
macro double[<*>] double[<*>].floor(double[<*>] x) = $$floor(x);
|
||||
macro double[<*>] double[<*>].fma(double[<*>] a, double[<*>] b, double[<*>] c) = $$fma(a, b, c);
|
||||
macro double[<*>] double[<*>].nearbyint(double[<*>] x) = $$nearbyint(x);
|
||||
macro double[<*>] double[<*>].pow(double[<*>] x, double[<*>] exp) = $$pow(x, exp);
|
||||
macro double[<*>] double[<*>].pow(double[<*>] x, exp) = pow(x, exp);
|
||||
macro double[<*>] double[<*>].rint(double[<*>] x) = $$rint(x);
|
||||
macro double[<*>] double[<*>].round(double[<*>] x) = $$round(x);
|
||||
macro double[<*>] double[<*>].roundeven(double[<*>] x) = $$roundeven(x);
|
||||
|
||||
Reference in New Issue
Block a user