Name

SPVM::Math - Mathematical Calculations

Description

Math class in SPVM has methods for mathematical calculations.

Usage

use Math;

my $sin = Math->sin(Math->PI / 4);

my $cos = Math->cos(Math->PI / 4);

my $tan = Math->tan(Math->PI / 4);

# 1 + 2i
my $z = Math->complex(1, 2);

# i
my $i = Math->complex(0, 1);

# Euler's equation
my $euler_left = Math->cexp(Math->cmul($i, $z));
my $euler_right = Math->ccos($z) + Math->cmul($i, Math->csin($z));

Class Methods

abs

static method abs : int ($x : int);

Calculates the abusolute value of $x and return it.

acos

static method acos : double ($x : double);

Calls acos function defined in math.h in the C language and returns its return value.

acosf

static method acosf : float ($x : float);

Calls acosf function defined in math.h in the C language and returns its return value.

acosh

static method acosh : double ($x : double);

Calls acosh function defined in math.h in the C language and returns its return value.

acoshf

static method acoshf : float ($x : float);

Calls acoshf function defined in math.h in the C language and returns its return value.

asin

static method asin : double ($x : double);

Calls asin function defined in math.h in the C language and returns its return value.

asinf

static method asinf : float ($x : float);

Calls asinf function defined in math.h in the C language and returns its return value.

asinh

static method asinh : double ($x : double);

Calls asinh function defined in math.h in the C language and returns its return value.

asinhf

static method asinhf : float ($x : float);

Calls asinhf function defined in math.h in the C language and returns its return value.

atan

static method atan : double ($x : double);

Calls atan function defined in math.h in the C language and returns its return value.

atan2

static method atan2 : double ($y : double, $x : double);

Calls atan2 function defined in math.h in the C language and returns its return value.

atan2f

static method atan2f : float ($y : float, $x : float);

Calls atan2f function defined in math.h in the C language and returns its return value.

atanf

static method atanf : float ($x : float);

Calls atanf function defined in math.h in the C language and returns its return value.

atanh

static method atanh : double ($x : double);

Calls atanh function defined in math.h in the C language and returns its return value.

atanhf

static method atanhf : float ($x : float);

Calls atanhf function defined in math.h in the C language and returns its return value.

cabs

static method cabs : double ($z : Complex_2d);

Calls cabs function defined in complex.h in the C language and returns its return value.

cabsf

static method cabsf : float ($z : Complex_2f);

Calls cabsf function defined in complex.h in the C language and returns its return value.

cacos

static method cacos : Complex_2d ($z : Complex_2d);

Calls cacos function defined in complex.h in the C language and returns its return value.

cacosf

static method cacosf : Complex_2f ($z : Complex_2f);

Calls cacosf function defined in complex.h in the C language and returns its return value.

cacosh

static method cacosh : Complex_2d ($z : Complex_2d);

Calls cacosh function defined in complex.h in the C language and returns its return value.

cacoshf

static method cacoshf : Complex_2f ($z : Complex_2f);

Calls cacoshf function defined in complex.h in the C language and returns its return value.

cadd

static method cadd : Complex_2d ($z1 : Complex_2d, $z2 : Complex_2d);

Performs the addition operation on $z1 and $z2, and returns the resulting value.

caddf

static method caddf : Complex_2f ($z1 : Complex_2f, $z2 : Complex_2f);

Performs the addition operation on $z1 and $z2, and returns the resulting value.

carg

static method carg : double ($z : Complex_2d);

Calls carg function defined in complex.h in the C language and returns its return value.

cargf

static method cargf : float ($z : Complex_2f);

Calls cargf function defined in complex.h in the C language and returns its return value.

casin

static method casin : Complex_2d ($z : Complex_2d);

Calls casin function defined in complex.h in the C language and returns its return value.

casinf

static method casinf : Complex_2f ($z : Complex_2f);

Calls casinf function defined in complex.h in the C language and returns its return value.

casinh

static method casinh : Complex_2d ($z : Complex_2d);

Calls casinh function defined in complex.h in the C language and returns its return value.

casinhf

static method casinhf : Complex_2f ($z : Complex_2f);

Calls casinhf function defined in complex.h in the C language and returns its return value.

catan

static method catan : Complex_2d ($z : Complex_2d);

Calls catan function defined in complex.h in the C language and returns its return value.

catanf

static method catanf : Complex_2f ($z : Complex_2f);

Calls catanf function defined in complex.h in the C language and returns its return value.

catanh

static method catanh : Complex_2d ($z : Complex_2d);

Calls catanh function defined in complex.h in the C language and returns its return value.

catanhf

static method catanhf : Complex_2f ($z : Complex_2f);

Calls catanhf function defined in complex.h in the C language and returns its return value.

cbrt

static method cbrt : double ($x : double);

Calls cbrt function defined in math.h in the C language and returns its return value.

cbrtf

static method cbrtf : float ($x : float);

Calls cbrtf function defined in math.h in the C language and returns its return value.

ccos

static method ccos : Complex_2d ($z : Complex_2d);

Calls ccos function defined in complex.h in the C language and returns its return value.

ccosf

static method ccosf : Complex_2f ($z : Complex_2f);

Calls ccosf function defined in complex.h in the C language and returns its return value.

ccosh

static method ccosh : Complex_2d ($z : Complex_2d);

Calls ccosh function defined in complex.h in the C language and returns its return value.

ccoshf

static method ccoshf : Complex_2f ($z : Complex_2f);

Calls ccoshf function defined in complex.h in the C language and returns its return value.

cdiv

static method cdiv : Complex_2d ($z1 : Complex_2d, $z2 : Complex_2d);

Performs the divison operation on $z1 and $z2, and returns the resulting value.

cdivf

static method cdivf : Complex_2f ($z1 : Complex_2f, $z2 : Complex_2f);

Performs the divison operation on $z1 and $z2, and returns the resulting value.

ceil

static method ceil : double ($x : double);

Calls ceil function defined in math.h in the C language and returns its return value.

ceilf

static method ceilf : float ($x : float);

Calls ceilf function defined in math.h in the C language and returns its return value.

cexp

static method cexp : Complex_2d ($z : Complex_2d);

Calls cexp function defined in complex.h in the C language and returns its return value.

cexpf

static method cexpf : Complex_2f ($z : Complex_2f);

Calls cexpf function defined in complex.h in the C language and returns its return value.

clog

static method clog : Complex_2d ($z : Complex_2d);

Calls clog function defined in complex.h in the C language and returns its return value.

clogf

static method clogf : Complex_2f ($z : Complex_2f);

Calls clogf function defined in complex.h in the C language and returns its return value.

cmul

static method cmul : Complex_2d ($z1 : Complex_2d, $z2 : Complex_2d);

Performs the multiplication operation on $z1 and $z2, and returns the resulting value.

cmulf

static method cmulf : Complex_2f ($z1 : Complex_2f, $z2 : Complex_2f);

Performs the multiplication operation on $z1 and $z2, and returns the resulting value.

complex

static method complex : Complex_2d ($re : double, $im : double);

Creates a double complex value given the real number $re and the imaginary number $im and returns it.

complexf

static method complexf : Complex_2f ($re : float, $im : float);

Creates a float complex value given the real number $re and the imaginary number $im and returns it.

conj

static method conj : Complex_2d ($z : Complex_2d);

Calls conj function defined in complex.h in the C language and returns its return value.

conjf

static method conjf : Complex_2f ($z : Complex_2f);

Calls conjf function defined in complex.h in the C language and returns its return value.

copysign

static method copysign : double ($x : double, $y : double);

Calls copysign function defined in math.h in the C language and returns its return value.

copysignf

static method copysignf : float ($x : float, $y : float);

Calls copysignf function defined in math.h in the C language and returns its return value.

cos

static method cos : double ($x : double);

Calls cos function defined in math.h in the C language and returns its return value.

cosf

static method cosf : float ($x : float);

Calls cosf function defined in math.h in the C language and returns its return value.

cosh

static method cosh : double ($x : double);

Calls cosh function defined in math.h in the C language and returns its return value.

coshf

static method coshf : float ($x : float);

Calls coshf function defined in math.h in the C language and returns its return value.

cpow

static method cpow : Complex_2d ($z1 : Complex_2d, $z2 : Complex_2d);

Calls cpow function defined in complex.h in the C language and returns its return value.

cpowf

static method cpowf : Complex_2f ($z1 : Complex_2f, $z2 : Complex_2f);

Calls cpowf function defined in complex.h in the C language and returns its return value.

csin

static method csin : Complex_2d ($z : Complex_2d);

Calls csin function defined in complex.h in the C language and returns its return value.

csinf

static method csinf : Complex_2f ($z : Complex_2f);

Calls csinf function defined in complex.h in the C language and returns its return value.

csinh

static method csinh : Complex_2d ($z : Complex_2d);

Calls csinh function defined in complex.h in the C language and returns its return value.

csinhf

static method csinhf : Complex_2f ($z : Complex_2f);

Calls csinhf function defined in complex.h in the C language and returns its return value.

csqrt

static method csqrt : Complex_2d ($z : Complex_2d);

Calls csqrt function defined in complex.h in the C language and returns its return value.

csqrtf

static method csqrtf : Complex_2f ($z : Complex_2f);

Calls csqrtf function defined in complex.h in the C language and returns its return value.

csub

static method csub : Complex_2d ($z1 : Complex_2d, $z2 : Complex_2d);

Performs the subtraction operation on $z1 and $z2, and returns the resulting value.

csubf

static method csubf : Complex_2f ($z1 : Complex_2f, $z2 : Complex_2f);

Performs the subtraction operation on $z1 and $z2, and returns the resulting value.

cneg

static method cneg : Complex_2d ($z : Complex_2d);

Negates the sign of $z and returns it.

cnegf

static method cnegf : Complex_2f ($z : Complex_2f);

Negates the sign of $z and returns it.

ctan

static method ctan : Complex_2d ($z : Complex_2d);

Calls ctan function defined in complex.h in the C language and returns its return value.

ctanf

static method ctanf : Complex_2f ($z : Complex_2f);

Calls ctanf function defined in complex.h in the C language and returns its return value.

ctanh

static method ctanh : Complex_2d ($z : Complex_2d);

Calls ctanh function defined in complex.h in the C language and returns its return value.

ctanhf

static method ctanhf : Complex_2f ($z : Complex_2f);

Calls ctanhf function defined in complex.h in the C language and returns its return value.

E

static method E : double ();

Returns the Euler's number e. This value is 0x1.5bf0a8b145769p+1.

erf

static method erf : double ($x : double);

Calls erf function defined in math.h in the C language and returns its return value.

erfc

static method erfc : double ($x : double);

Calls erfc function defined in math.h in the C language and returns its return value.

erfcf

static method erfcf : float ($x : float);

Calls erfcf function defined in math.h in the C language and returns its return value.

erff

static method erff : float ($x : float);

Calls erff function defined in math.h in the C language and returns its return value.

exp

static method exp : double ($x : double);

Calls exp function defined in math.h in the C language and returns its return value.

exp2

static method exp2 : double ($x : double);

Calls exp2 function defined in math.h in the C language and returns its return value.

exp2f

static method exp2f : float ($x : float);

Calls exp2f function defined in math.h in the C language and returns its return value.

expf

static method expf : float ($x : float);

Calls expf function defined in math.h in the C language and returns its return value.

expm1

static method expm1 : double ($x : double);

Calls expm1 function defined in math.h in the C language and returns its return value.

expm1f

static method expm1f : float ($x : float);

Calls expm1f function defined in math.h in the C language and returns its return value.

fabs

static method fabs : double ($x : double);

Calls fabs function defined in math.h in the C language and returns its return value.

fabsf

static method fabsf : float ($x : float);

Calls fabsf function defined in math.h in the C language and returns its return value.

fdim

static method fdim : double ($x : double, $y : double);

Calls fdim function defined in math.h in the C language and returns its return value.

fdimf

static method fdimf : float ($x : float, $y : float);

Calls fdimf function defined in math.h in the C language and returns its return value.

FE_DOWNWARD

static method FE_DOWNWARD : int ();

Returns the value of FE_DOWNWARD macro defined in fenv.h in the C language.

FE_TONEAREST

static method FE_TONEAREST : int ();

Returns the value of FE_TONEAREST macro defined in fenv.h in the C language.

FE_TOWARDZERO

static method FE_TOWARDZERO : int ();

Returns the value of FE_TOWARDZERO macro defined in fenv.h in the C language.

FE_UPWARD

static method FE_UPWARD : int ();

Returns the value of FE_UPWARD macro defined in fenv.h in the C language.

fesetround

static method fesetround : int ($round : int);

Calls fesetround function defined in math.h in the C language and returns its return value.

floor

static method floor : double ($x : double);

Calls floor function defined in math.h in the C language and returns its return value.

floorf

static method floorf : float ($x : float);

Calls floorf function defined in math.h in the C language and returns its return value.

fma

static method fma : double ($x : double, $y : double, $x3 : double);

Calls fma function defined in math.h in the C language and returns its return value.

fmaf

static method fmaf : float ($x : float, $y : float, $x3 : float);

Calls fmaf function defined in math.h in the C language and returns its return value.

fmax

static method fmax : double ($x : double, $y : double);

Calls fmax function defined in math.h in the C language and returns its return value.

fmaxf

static method fmaxf : float ($x : float, $y : float);

Calls fmaxf function defined in math.h in the C language and returns its return value.

fmin

static method fmin : double ($x : double, $y : double);

Calls fmin function defined in math.h in the C language and returns its return value.

fminf

static method fminf : float ($x : float, $y : float);

Calls fminf function defined in math.h in the C language and returns its return value.

fmod

static method fmod : double ($x : double, $y : double);

Calls fmod function defined in math.h in the C language and returns its return value.

fmodf

static method fmodf : float ($x : float, $y : float);

Calls fmodf function defined in math.h in the C language and returns its return value.

FP_ILOGB0

static method FP_ILOGB0 : int ();

Return the value of FP_ILOGB0 macro defined in fenv.h in the C language.

FP_ILOGBNAN

static method FP_ILOGBNAN : int ();

Return the value of FP_ILOGBNAN macro defined in fenv.h in the C language.

FP_INFINITE

static method FP_INFINITE : int ();

Return the value of FP_INFINITE macro defined in fenv.h in the C language.

FP_NAN

static method FP_NAN : int ();

Return the value of FP_NAN macro defined in fenv.h in the C language.

FP_ZERO

static method FP_ZERO : int ();

Return the value of FP_ZERO macro defined in fenv.h in the C language.

fpclassify

static method fpclassify : int ($x : double);

Calls fpclassify function defined in math.h in the C language.

fpclassifyf

static method fpclassifyf : int ($x : float);

Calls fpclassify function defined in math.h in the C language.

frexp

static method frexp : double ($x : double, $exp : int*);

Calls frexp function defined in math.h in the C language and returns its return value.

frexpf

static method frexpf : float ($x : float, $exp : int*);

Calls frexpf function defined in math.h in the C language and returns its return value.

HUGE_VAL

static method HUGE_VAL : double ();

Returns the value of HUGE_VAL macro defined in math.h in the C language and returns its return value.

HUGE_VALF

static method HUGE_VALF : float ();

Returns the value of HUGE_VALF macro defined in math.h in the C language and returns its return value.

hypot

static method hypot : double ($x : double, $y : double);

Calls hypot function defined in math.h in the C language and returns its return value.

hypotf

static method hypotf : float ($x : float, $y : float);

Calls hypotf function defined in math.h in the C language and returns its return value.

ilogb

static method ilogb : int ($x : double);

Calls ilogb function defined in math.h in the C language and returns its return value.

ilogbf

static method ilogbf : int ($x : float);

Calls ilogbf function defined in math.h in the C language and returns its return value.

INFINITY

static method INFINITY : double ();

Returns the value of INFINITY macro defined in math.h in the C language, and returns the return value as a dobule value.

INFINITYF

static method INFINITYF : float ();

Returns the value of INFINITY macro defined in math.h in the C language, and the return value as a float value.

isfinite

static method isfinite : int ($x : double);

Calls isfinite function defined in math.h in the C language.

isfinitef

static method isfinitef : int ($x : float);

Calls isfinite function defined in math.h in the C language.

isgreater

static method isgreater : int ($x : double, $y : double);

Calls isgreater function defined in math.h in the C language.

isgreaterequal

static method isgreaterequal : int ($x : double, $y : double);

Calls isgreaterequal function defined in math.h in the C language.

isgreaterequalf

static method isgreaterequalf : int ($x : float, $y : float);

Calls isgreaterequal function defined in math.h in the C language.

isgreaterf

static method isgreaterf : int ($x : float, $y : float);

Calls isgreater function defined in math.h in the C language.

isinf

static method isinf : int ($x : double);

Calls isinf function defined in math.h in the C language.

isinff

static method isinff : int($x : float);

Calls isinf function defined in math.h in the C language.

isless

static method isless : int ($x : double, $y : double);

Calls isless function defined in math.h in the C language.

islessequal

static method islessequal : int ($x : double, $y : double);

Calls islessequal function defined in math.h in the C language.

islessequalf

static method islessequalf : int ($x : float, $y : float);

Calls islessequal function defined in math.h in the C language.

islessf

static method islessf : int ($x : float, $y : float);

Calls isless function defined in math.h in the C language.

islessgreater

static method islessgreater : int ($x : double, $y : double);

Calls islessgreater function defined in math.h in the C language.

islessgreaterf

static method islessgreaterf : int ($x : float, $y : float);

Calls islessgreater function defined in math.h in the C language.

isnan

static method isnan : int ($x : double);

Calls isnan function defined in math.h in the C language.

isnanf

static method isnanf : int ($x : float);

Calls isnanf function defined in math.h in the C language.

isunordered

static method isunordered : int ($x : double, $y : double);

Calls isunordered function defined in math.h in the C language.

isunorderedf

static method isunorderedf : int ($x : float, $y : float);

Calls isunordered function defined in math.h in the C language.

labs

static method labs : long ($x : long);

Returns the abusolute value of $x.

ldexp

static method ldexp : double ($x : double, $exp : int);

Calls ldexp function defined in math.h in the C language and returns its return value.

ldexpf

static method ldexpf : float ($x : float, $exp : int);

Calls ldexpf function defined in math.h in the C language and returns its return value.

lgamma

static method lgamma : double ($x : double);

Calls lgamma function defined in math.h in the C language and returns its return value.

lgammaf

static method lgammaf : float ($x : float);

Calls lgammaf function defined in math.h in the C language and returns its return value.

log

static method log : double ($x : double);

Calls log function defined in math.h in the C language and returns its return value.

log10

static method log10 : double ($x : double);

Calls log10 function defined in math.h in the C language and returns its return value.

log10f

static method log10f : float ($x : float);

Calls log10f function defined in math.h in the C language and returns its return value.

log1p

static method log1p : double ($x : double);

Calls log1p function defined in math.h in the C language and returns its return value.

log1pf

static method log1pf : float ($x : float);

Calls log1pf function defined in math.h in the C language and returns its return value.

log2

static method log2 : double ($x : double);

Calls log2 function defined in math.h in the C language and returns its return value.

log2f

static method log2f : float ($x : float);

Calls log2f function defined in math.h in the C language and returns its return value.

logb

static method logb : double ($x : double);

Calls logb function defined in math.h in the C language and returns its return value.

logbf

static method logbf : float ($x : float);

Calls logbf function defined in math.h in the C language and returns its return value.

logf

static method logf : float ($x : float);

Calls logf function defined in math.h in the C language and returns its return value.

lround

static method lround : long ($x : double);

Calls llround function defined in math.h in the C language and returns its return value.

lroundf

static method lroundf : long ($x : float);

Calls llroundf function defined in math.h in the C language and returns its return value.

modf

static method modf : double ($x : double, $intpart : double*);

Calls modf function defined in math.h in the C language and returns its return value.

modff

static method modff : float ($x : float, $intpart : float*);

Calls modff function defined in math.h in the C language and returns its return value.

NAN

static method NAN : double ();

Returns the value of NAN macro defined in math.h in the C language.

nan

static method nan : double ($string : string);

Calls nan function defined in math.h in the C language and returns its return value.

Exceptions:

The $string must be defined. Otherwise an exception is thrown.

NANF

static method NANF : float ();

Returns the value of NAN macro defined in math.h in the C language, and return the return value as a float type.

nanf

static method nanf : float ($string : string);

Calls nanf function defined in math.h in the C language and returns its return value.

Exceptions:

The $string must be defined. Otherwise an exception is thrown.

nearbyint

static method nearbyint : double ($x : double);

Calls nearbyint function defined in math.h in the C language and returns its return value.

nearbyintf

static method nearbyintf : float ($x : float);

Calls nearbyintf function defined in math.h in the C language and returns its return value.

nextafter

static method nextafter : double ($x : double, $y : double);

Calls nextafter function defined in math.h in the C language and returns its return value.

nextafterf

static method nextafterf : float ($x : float, $y : float);

Calls nextafterf function defined in math.h in the C language and returns its return value.

nexttoward

static method nexttoward : double ($x : double, $y : double);

Calls nexttoward function defined in math.h in the C language and returns its return value.

nexttowardf

static method nexttowardf : float ($x : float, $y : double);

Calls nexttowardf function defined in math.h in the C language and returns its return value.

PI

static method PI : double ();

Returns pi. This value is 0x1.921fb54442d18p+1.

pow

static method pow : double ($x : double, $y : double);

Calls pow function defined in math.h in the C language and returns its return value.

powf

static method powf : float ($x : float, $y : float);

Calls powf function defined in math.h in the C language and returns its return value.

remainder

static method remainder : double ($x : double, $y : double);

Calls remainder function defined in math.h in the C language and returns its return value.

remainderf

static method remainderf : float ($x : float, $y : float);

Calls remainderf function defined in math.h in the C language and returns its return value.

remquo

static method remquo : double ($x : double, $y : double, $quo : int*);

Calls remquo function defined in math.h in the C language and returns its return value.

remquof

static method remquof : float ($x : float, $y : float, $quo : int*);

Calls remquof function defined in math.h in the C language and returns its return value.

round

static method round : double ($x : double);

Calls round function defined in math.h in the C language and returns its return value.

roundf

static method roundf : float ($x : float);

Calls roundf function defined in math.h in the C language and returns its return value.

scalbln

static method scalbln : double ($x : double, $exp : long);

Calls scalbln function defined in math.h in the C language and returns its return value.

scalblnf

static method scalblnf : float ($x : float, $exp : long);

Calls scalblnf function defined in math.h in the C language and returns its return value.

scalbn

static method scalbn : double ($x : double, $exp : int);

Calls scalbn function defined in math.h in the C language and returns its return value.

scalbnf

static method scalbnf : float ($x : float, $exp : int);

Calls scalbnf function defined in math.h in the C language and returns its return value.

signbit

static method signbit : int ($x : double);

Calls signbit function defined in math.h in the C language and returns its return value.

signbitf

static method signbitf : int ($x : float);

Calls signbit function defined in math.h in the C language and returns its return value.

sin

static method sin : double ($x : double);

Calls sin function defined in math.h in the C language and returns its return value.

sinf

static method sinf : float ($x : float);

Calls sinf function defined in math.h in the C language and returns its return value.

sinh

static method sinh : double ($x : double);

Calls sinh function defined in math.h in the C language and returns its return value.

sinhf

static method sinhf : float ($x : float);

Calls sinhf function defined in math.h in the C language and returns its return value.

sqrt

static method sqrt : double ($x : double);

Calls sqrt function defined in math.h in the C language and returns its return value.

sqrtf

static method sqrtf : float ($x : float);

Calls sqrtf function defined in math.h in the C language and returns its return value.

tan

static method tan : double ($x : double);

Calls tan function defined in math.h in the C language and returns its return value.

tanf

static method tanf : float ($x : float);

Calls tanf function defined in math.h in the C language and returns its return value.

tanh

static method tanh : double ($x : double);

Calls tanh function defined in math.h in the C language and returns its return value.

tanhf

static method tanhf : float ($x : float);

Calls tanhf function defined in math.h in the C language and returns its return value.

tgamma

static method tgamma : double ($x : double);

Calls tgamma function defined in math.h in the C language and returns its return value.

tgammaf

static method tgammaf : float ($x : float);

Calls tgammaf function defined in math.h in the C language and returns its return value.

trunc

static method trunc : double ($x : double);

Calls trunc function defined in math.h in the C language and returns its return value.

truncf

static method truncf : float ($x : float);

Calls truncf function defined in math.h in the C language and returns its return value.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License