-- | Mathematical Functions module CsoundExpr.Opcodes.Math.Matfunc (abs', ceil, exp', floor', frac, int, log', log10, logbtwo, powA, powI, powK, powoftwo, round', sqrt') where import CsoundExpr.Base.Types import CsoundExpr.Base.MultiOut import CsoundExpr.Base.SideEffect import CsoundExpr.Base.UserDefined -- | * opcode : abs -- -- -- * syntax : -- -- > abs(x) (no rate restriction) -- -- -- * description : -- -- Returns the absolute value of x. -- -- -- * url : abs' :: (X x0) => x0 -> x0 abs' x0sig = prefixOperation "abs" args where args = [to x0sig] -- | * opcode : ceil -- -- -- * syntax : -- -- > ceil(x) (init-, control-, or audio-rate arg allowed) -- -- -- * description : -- -- Returns the smallest integer not less than x -- -- -- * url : ceil :: (X x0) => x0 -> x0 ceil x0sig = prefixOperation "ceil" args where args = [to x0sig] -- | * opcode : exp -- -- -- * syntax : -- -- > exp(x) (no rate restriction) -- -- -- * description : -- -- Returns e raised to the xth power. -- -- -- * url : exp' :: (X x0) => x0 -> x0 exp' x0sig = prefixOperation "exp" args where args = [to x0sig] -- | * opcode : floor -- -- -- * syntax : -- -- > floor(x) (init-, control-, or audio-rate arg allowed) -- -- -- * description : -- -- Returns the largest integer not greater than x -- -- -- * url : floor' :: (X x0) => x0 -> x0 floor' x0sig = prefixOperation "floor" args where args = [to x0sig] -- | * opcode : frac -- -- -- * syntax : -- -- > frac(x) (init-rate or control-rate args; also works at audio rate in Csound5) -- -- -- * description : -- -- Returns the fractional part of x. -- -- -- * url : frac :: (K k0) => k0 -> k0 frac k0sig = prefixOperation "frac" args where args = [to k0sig] -- | * opcode : int -- -- -- * syntax : -- -- > int(x) (init-rate or control-rate; also works at audio rate in Csound5) -- -- -- * description : -- -- Returns the integer part of x. -- -- -- * url : int :: (K k0) => k0 -> k0 int k0sig = prefixOperation "int" args where args = [to k0sig] -- | * opcode : log -- -- -- * syntax : -- -- > log(x) (no rate restriction) -- -- -- * description : -- -- Returns the natural log of x (x positive only). -- -- -- * url : log' :: (X x0) => x0 -> x0 log' x0sig = prefixOperation "log" args where args = [to x0sig] -- | * opcode : log10 -- -- -- * syntax : -- -- > log10(x) (no rate restriction) -- -- -- * description : -- -- Returns the base 10 log of x (x positive only). -- -- -- * url : log10 :: (X x0) => x0 -> x0 log10 x0sig = prefixOperation "log10" args where args = [to x0sig] -- | * opcode : logbtwo -- -- -- * syntax : -- -- > logbtwo(x) (init-rate or control-rate args only) -- -- -- * description : -- -- Performs a logarithmic base two calculation. -- -- -- * url : logbtwo :: (K k0) => k0 -> k0 logbtwo k0sig = prefixOperation "logbtwo" args where args = [to k0sig] -- | * opcode : pow -- -- -- * syntax : -- -- > ares pow aarg, kpow [, inorm] -- > ires pow iarg, ipow [, inorm] -- > kres pow karg, kpow [, inorm] -- -- -- * description : -- -- Computes xarg to the power of kpow (or ipow) and scales the -- result by inorm. -- -- -- * url : powA :: (K k0) => [Irate] -> Arate -> k0 -> Arate powA i0init a1arg k2pow = opcode "pow" args where args = [to a1arg, to k2pow] ++ map to i0init -- | * opcode : pow -- -- -- * syntax : -- -- > ares pow aarg, kpow [, inorm] -- > ires pow iarg, ipow [, inorm] -- > kres pow karg, kpow [, inorm] -- -- -- * description : -- -- Computes xarg to the power of kpow (or ipow) and scales the -- result by inorm. -- -- -- * url : powI :: [Irate] -> Irate -> Irate -> Irate powI i0init i1arg i2pow = opcode "pow" args where args = [to i1arg, to i2pow] ++ map to i0init -- | * opcode : pow -- -- -- * syntax : -- -- > ares pow aarg, kpow [, inorm] -- > ires pow iarg, ipow [, inorm] -- > kres pow karg, kpow [, inorm] -- -- -- * description : -- -- Computes xarg to the power of kpow (or ipow) and scales the -- result by inorm. -- -- -- * url : powK :: (K k0, K k1) => [Irate] -> k0 -> k1 -> Krate powK i0init k1arg k2pow = opcode "pow" args where args = [to k1arg, to k2pow] ++ map to i0init -- | * opcode : powoftwo -- -- -- * syntax : -- -- > powoftwo(x) (init-rate or control-rate args only) -- -- -- * description : -- -- Performs a power-of-two calculation. -- -- -- * url : powoftwo :: (K k0) => k0 -> k0 powoftwo k0sig = prefixOperation "powoftwo" args where args = [to k0sig] -- | * opcode : round -- -- -- * syntax : -- -- > round(x) (init-, control-, or audio-rate arg allowed) -- -- -- * description : -- -- The integer value nearest to x ; if the fractional part of x is -- exactly 0.5, the direction of rounding is undefined. -- -- -- * url : round' :: (X x0) => x0 -> x0 round' x0sig = prefixOperation "round" args where args = [to x0sig] -- | * opcode : sqrt -- -- -- * syntax : -- -- > sqrt(x) (no rate restriction) -- -- -- * description : -- -- Returns the square root of x (x non-negative). -- -- -- * url : sqrt' :: (X x0) => x0 -> x0 sqrt' x0sig = prefixOperation "sqrt" args where args = [to x0sig]