ApproxLogFunction.Approxlog
— MethodApproxlog(base::Real; dtype::Type{<:AbstractFloat}, abserror::Real)
A lookup table based method to calculate y
= log(base, x
) with controllable error
base
is the radix of logarithm operationdtype
is the data type of inputx
and outputy
abserror
is the required absolute error of the outputy
Example
alog₂ = Approxlog(2, abserror=0.1, dtype=Float32);
input = 5.20f2;
output = alog₂(input);
ApproxLogFunction.toclang
— Methodtoclang(dstdir::String, filename::String, funcname::String, f::Approxlog)
generate C language .h
and .c
files for an Approxlog
functor f
.
dstdir
is the directory to save the C language files (dir
would be made if it doesn't exist before)filename
is the name of the generated.c
and.h
filesfuncname
is the name of the generated approximate function
Example
alog₂ = Approxlog(2, abserror=0.12, dtype=Float32);
toclang("./cfolder/", "approxlog", "alog", alog₂);