From: usa@... Date: 2015-02-18T07:31:04+00:00 Subject: [ruby-core:68169] [Ruby trunk - Bug #10840] documentation for Vector#cross_product in module 'matrix' is inconsistent Issue #10840 has been updated by Usaku NAKAMURA. Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED ---------------------------------------- Bug #10840: documentation for Vector#cross_product in module 'matrix' is inconsistent https://bugs.ruby-lang.org/issues/10840#change-51546 * Author: Ana Johnson * Status: Closed * Priority: Low * Assignee: * ruby -v: http://ruby-doc.org/stdlib-2.1.0/ * Backport: 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED ---------------------------------------- the documentation of cross_product is inconsistent. The doc says: Vector[1, 0, 0].cross_product Vector[0, 1, 0] => Vector[0, 0, 1] which seems good to me, but the definition given in the "click to toggle source" actually produces: Vector[0,0,-1], which according to a closed bug report seems to be what the function actually once produced. The documented code is still wrong. this would be correct and clear: def cross_product(v) Vector.Raise ErrDimensionMismatch unless size == v.size && v.size == 3 Vector[ @elements[1]*v[2] - @elements[2]*v[1], @elements[2]*v[0] - @elements[0]*v[2], @elements[0]*v[1] - @elements[1]*v[0] ] end I recommend also altering the demonstration code so that a reasonably complete test case is shown: Vector[1, 0, 0].cross_product Vector[0, 1, 0] => Vector[0, 0, 1] Vector[0, 1, 0].cross_product Vector[0, 0, 1] => Vector[1, 0, 0] Vector[0, 0, 1].cross_product Vector[1, 0, 0] => Vector[0, 1, 0] -- https://bugs.ruby-lang.org/