Module:Mediants: Difference between revisions

Ganaram inukshuk (talk | contribs)
Added ratios that formed the mediant to mediant data, for search functions that need that information
Ganaram inukshuk (talk | contribs)
m Updated todo
Line 3: Line 3:
local p = {}
local p = {}


-- Module for finding mediants, either by search depth or by search function.
-- Module for finding mediants, either by search depth, int limit, or by a
 
-- custom search function.
-- TODO: Add int-limit search


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 13: Line 12:
-- Search functions determine whether a mediant meets a specific criteria for
-- Search functions determine whether a mediant meets a specific criteria for
-- being added to a set of mediants, be it based on something about the mediant,
-- being added to a set of mediants, be it based on something about the mediant,
-- its search depth, or both.
-- its search depth, the ratios that produced the mediant, or any combination
-- thereof.
-- NOTE: some search criteria, such as prime limit, are considered unsuitable,
-- NOTE: some search criteria, such as prime limit, are considered unsuitable,
-- since mediants not within a prime limit are used to find ratios within a
-- since mediants not within a prime limit are used to find ratios within a
Line 27: Line 27:
-- finer control.
-- finer control.


-- Int limit search determines whether a ratio is within an int limit. Does not
-- Int limit search determines whether a ratio is within an int limit. Only uses
-- use depth. Meant for use with searching for JI ratios.
-- information about the mediant. Meant for use with searching for JI ratios.
function p.int_limit_search(mediant_data, int_limit)
function p.int_limit_search(mediant_data, int_limit)
local mediant = mediant_data["mediant"]
local mediant = mediant_data["mediant"]
Line 34: Line 34:
end
end


-- Depth search determines whether a ratio is within a target depth. Does not
-- Depth search determines whether a ratio is within a target depth. Only uses
-- use the mediant itself. Meant for use with searching for step ratios.
-- the depth it was found at. Meant for use with searching for step ratios.
function p.depth_search(mediant_data, search_depth)
function p.depth_search(mediant_data, search_depth)
local depth = mediant_data["depth"]
local depth = mediant_data["depth"]
Line 113: Line 113:
-- it's a common enough operation.
-- it's a common enough operation.


-- Find mediants by depth, how many times mediants are found in a set of ratios.
-- Find mediants by depth of its search tree.
function p.find_mediants(init_ratios, depth)
function p.find_mediants(init_ratios, depth)
local init_ratios = init_ratios or {{1,1}, {1,0}}
local init_ratios = init_ratios or {{1,1}, {1,0}}
Line 124: Line 124:
end
end


-- Find mediants by depth, how many times mediants are found in a set of ratios.
-- Find mediants by depth of its search tree. Does not return depths.
-- Does not return depths.
function p.find_only_mediants(init_ratios, depth)
function p.find_only_mediants(init_ratios, depth)
local init_ratios = init_ratios or {{1,1}, {1,0}}
local init_ratios = init_ratios or {{1,1}, {1,0}}
Line 144: Line 143:
-- alone function under the reasoning that it's a common enough operation.
-- alone function under the reasoning that it's a common enough operation.


-- Find mediants within an int limit.
function p.find_mediants_by_int_limit(init_ratios, int_limit)
function p.find_mediants_by_int_limit(init_ratios, int_limit)
local init_ratios = init_ratios or {{1,1}, {1,0}}
local init_ratios = init_ratios or {{1,1}, {1,0}}
Line 154: Line 154:
end
end


-- Find mediants within an int limit. Does not return depth.
function p.find_only_mediants_by_int_limit(init_ratios, int_limit)
function p.find_only_mediants_by_int_limit(init_ratios, int_limit)
local init_ratios = init_ratios or {{1,1}, {1,0}}
local init_ratios = init_ratios or {{1,1}, {1,0}}