lib/unitwise/unit.rb in unitwise-0.5.1 vs lib/unitwise/unit.rb in unitwise-0.6.0

- old
+ new

@@ -33,23 +33,28 @@ def special? terms.count == 1 && terms.all?(&:special?) end - def functional(x = scalar, forward = true) - terms.first.functional(x, forward) - end def depth terms.map(&:depth).max + 1 end def root_terms terms.flat_map(&:root_terms) end - def scalar - terms.map(&:scalar).reduce(&:*) + def scalar(x = 1) + terms.reduce(1) do |prod, term| + prod * term.scalar(x) + end + end + + def inverse_scalar(x = 1) + terms.reduce(1) do |prod, term| + prod * term.inverse_scalar(x) + end end def *(other) if other.respond_to?(:terms) self.class.new(terms + other.terms)