Sha256: 53713ef2c76c3e2c926a5dfc5055be0b43c9d6615995a0366ee1923ae28d3060

Contents?: true

Size: 588 Bytes

Versions: 9

Compression:

Stored size: 588 Bytes

Contents

module Math

  # Levi-Civita symbol of +i+, +j+, and +k+ - 1 if (+i+, +j+, +k+)
  # is (1, 2, 3), (2, 3, 1), or (3, 1, 2), -1 if it is (1, 3, 2),
  # (2, 1, 3), or (3, 2, 1), 0 as long as +i+, +j+, and +k+ are
  # all elements of {1, 2, 3}, otherwise returns <code>nil</code>.
  def self.epsilon(i, j, k)
    i = Integer(i)
    return nil if i < 1 or i > 3
    j = Integer(j)
    return nil if j < 1 or j > 3
    k = Integer(k)
    return nil if k < 1 or k > 3
    case i * 16 + j * 4 + k
      when 27, 45, 54 then return  1
      when 30, 39, 57 then return -1
    end
    0
  end

end

Version data entries

9 entries across 8 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/standard/facets/math/epsilon.rb
facets-3.1.0 lib/standard/facets/math/epsilon.rb
facets-3.0.0 lib/standard/facets/math/epsilon.rb
facets-2.9.3 lib/standard/facets/math/epsilon.rb
facets-2.9.2 lib/standard/facets/math/epsilon.rb
facets-2.9.2 src/standard/facets/math/epsilon.rb
facets-2.9.1 lib/standard/facets/math/epsilon.rb
facets-2.9.0 lib/more/facets/math/epsilon.rb
facets-2.9.0.pre.2 lib/more/facets/math/epsilon.rb