Approxlog(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 operation
  • dtype is the data type of input x and output y
  • abserror is the required absolute error of the output y


alog₂  = Approxlog(2, abserror=0.1, dtype=Float32);
input  = 5.20f2;
output = alog₂(input);
toclang(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 files
  • funcname is the name of the generated approximate function


alog₂ = Approxlog(2, abserror=0.12, dtype=Float32);
toclang("./cfolder/",  "approxlog", "alog", alog₂);