[index] [finite-set] Algebra::Map
Map Class
The class which represents maps.
::[[x0 => y0, [x1 => y1, [x2 => y2, ...]]]]
Returns the map which has values y0 at x0, y1 at x1, y2 at x2...
Exampel:
require "finite-map" include Algebra p Map[0 => 10, 1 => 11, 2 => 12] #=> {0 => 10, 1 => 11, 2 => 12} p Map[{0 => 10, 1 => 11, 2 => 12}] #=> {0 => 10, 1 => 11, 2 => 12} p Map.new(0 => 10, 1 => 11, 2 => 12) #=> {0 => 10, 1 => 11, 2 => 12} p Map.new({0 => 10, 1 => 11, 2 => 12}) #=> {0 => 10, 1 => 11, 2 => 12} p Map.new_a([0, 10, 1, 11, 2, 12]) #=> {0 => 10, 1 => 11, 2 => 12}
::new([x0 => y0, [x1 => y1, [x2 => y2, ...]]])
::new_a(a)
::phi([t])
Return the empty map (having empty set as domain). If t is given, target= is set by t.
Exampel:
p Map.phi #=> {} p Map.phi(Set[0, 1]) #=> {} p Map.phi(Set[0, 1]).target #=> {0, 1}
::empty_set
::singleton(x, y)
{x}
and having value y
on it.target=(s)
codomain=(s)
target
codomain
source
Returns the domain of self.
Example:
require "finite-map" include Algebra m = Map[0 => 10, 1 => 11, 2 => 12] p m.source #=> {0, 1, 2} p m.target #=> nil m.target = Set[10, 11, 12, 13] p m.target #=> {10, 11, 12, 13}
domain
phi([t])
empty_set
null
call(x)
act
[]
each
Iterates for each [point, image]
of the map.
Example:
require "finite-map" include Algebra Map[0 => 10, 1 => 11, 2 => 12].each do |x, y| p [x, y] #=> [1, 11], [0, 10], [2, 12] end
compose(other)
Returns the composition map of self and other.
Example:
require "finite-map" include Algebra f = Map.new(0 => 10, 1 => 11, 2 => 12) g = Map.new(10 => 20, 11 => 21, 12 => 22) p g * f #=> {0 => 20, 1 => 21, 2 => 22}
*
dup
append!(x, y)
Let the value of x be y.
Example:
require "finite-map" include Algebra m = Map[0 => 10, 1 => 11] m.append!(2, 12) p m #=> {0 => 10, 1 => 11, 2 => 12}
[x] = y
append(x, y)
include?(x)
contains?(x)
member?(a)
Returns true if there is [x, y]
s.t. the value of x
is y and [x, y] == a
.
Example:
require "finite-map" include Algebra m = Map[0 => 10, 1 => 11] p m.include?(1) #=> true p m.member?([1, 11]) #=> true
has?
image([s])
inv_image(s)
map_s
Returns the set given by evaluation of the block, iterating over each pair
of [point, image]
.
Example:
require "finite-map" include Algebra p Map.new(0 => 10, 1 => 11, 2 => 12).map_s{|x, y| y - 2*x} #=> Set[10, 9, 8]
map_m
Returns the map given by evaluation of the block, iterating over each pair
of [point, image]
. The value of the block must be
the two-dimensional array [x, y]
.
Example:
require "finite-map" include Algebra p Map.new(0 => 10, 1 => 11, 2 => 12).map_m{|x, y| [y, x]} #=> {10 => 0, 11 => 1, 12 => 2}
inverse
inv_coset
Reterns the map corresponding each point to its set of inverse images.
Examepe:
require "finite-map" include Algebra m = Map[0=>0, 1=>0, 2=>2, 3=>2, 4=>0] p m.inv_coset #=> {0=>{0, 1, 4}, 2=>{2, 3}} m.codomain = Set[0, 1, 2, 3] p m.inv_coset #=> {0=>{0, 1, 4}, 1=>{}, 2=>{2, 3}, 3=>{}}
identity?
surjective?
injective?
bijective?