Class: ValueGraphTransformation::Arithmetic::Sub

Inherits:
Function show all
Defined in:
lib/value_graph_transformation/arithmetic.rb

Overview

Subtraction

Instance Attribute Summary

Attributes inherited from Graph::Vertex

#sources, #targets

Instance Method Summary (collapse)

Methods inherited from Graph::Vertex

#initialize, #source_vertices, #target_vertices

Constructor Details

This class inherits a constructor from ValueGraphTransformation::Graph::Vertex

Instance Method Details

- (Class, Array<Vertex>) inverse_to(source)

Returns the inverse function and its parameters

Returns:

  • (Class, Array<Vertex>, Array<Vertex>)

    the inverse function and its parameters



117
118
119
120
121
122
123
124
125
126
# File 'lib/value_graph_transformation/arithmetic.rb', line 117

def inverse_to(source)
  other_source = source_vertices - [source]
  if source == source_vertices[0] then
    [Add, other_source + target_vertices, [source]]
  elsif source == source_vertices[1] then
    [Sub, other_source + target_vertices, [source]]
  else
    fail "Function does not contain given source"
  end
end

- (String) symbol

Returns the symbol that represents this function.

Returns:

  • (String)

    the symbol that represents this function.



112
113
114
# File 'lib/value_graph_transformation/arithmetic.rb', line 112

def symbol
  "-"
end