Module:Rational: Difference between revisions

Plumtree (talk | contribs)
m is_harmonic(), is_subharmonic() implemented
Plumtree (talk | contribs)
mNo edit summary
Line 444: Line 444:


-- determine whether a rational number represents a harmonic
-- determine whether a rational number represents a harmonic
function p.is_harmonic(a, reduced)
function p.is_harmonic(a, reduced, large)
if type(a) == 'number' then
if type(a) == 'number' then
a = p.new(a)
a = p.new(a)
Line 461: Line 461:
end
end
if reduced then
if reduced then
if p.lt(a, 1) or p.geq(a, 2) then
if large then
return false
-- an approximation
local cents = p.cents(a)
if cents < 0 or cents >= 1200 then
return false
end
else
if p.lt(a, 1) or p.geq(a, 2) then
return false
end
end
end
end
end