to=eps2
to : | rounding limit for square problems |
eps2
VL=rand(100,3); VL=normr(VL); dp=bsxfun(@dot,VL',VL')'; a=real(acos(dp)); [a roundz(a,eps2)]
dp-1
This function, named eps2
, is designed to return a specific rounding limit for triangular or quadratic problems. It is part of the SolidGeometry library and was introduced in version 4.1. The function is authored by Tim Lueth and is classified under auxiliary procedures.
The function eps2
does not take any input parameters. It is called without arguments.
The function returns a single output:
to
: This is the rounding limit for square problems. It is calculated based on the machine epsilon, which is the smallest number that can be added to 1 to give a result different from 1 in floating-point arithmetic.The function uses a persistent variable t
to store the calculated rounding limit. The persistent variable ensures that the value of t
is retained between function calls, avoiding recalculation.
t
is empty. If it is, the function calculates t
using the formula: t = 10^-(floor((log10(1/sqrt(eps)))))
.eps
is the machine epsilon, representing the smallest difference between 1 and the next larger floating-point number.sqrt(eps)
computes the square root of the machine epsilon.1/sqrt(eps)
calculates the reciprocal of the square root of the machine epsilon.log10(1/sqrt(eps))
computes the base-10 logarithm of the reciprocal value.floor(log10(1/sqrt(eps)))
rounds down the logarithm to the nearest integer.10^-(floor(log10(1/sqrt(eps))))
raises 10 to the power of the negative rounded-down logarithm, resulting in the desired rounding limit.t
is then assigned to the output variable to
.An example provided in the comments demonstrates the use of eps2
in conjunction with other functions:
VL = rand(100,3); VL = normr(VL); dp = bsxfun(@dot, VL', VL')'; a = real(acos(dp)); [a roundz(a, eps2)] dp - 1
This example generates random vectors, normalizes them, computes dot products, and uses eps2
to round the results of the acos
function.