https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112019-08-23T22:35:49ZRuby Issue Tracking SystemRuby master - Bug #12356: Vector covector incorrect multiplication with another vector.https://redmine.ruby-lang.org/issues/12356?journal_id=809492019-08-23T22:35:49Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>marcandre (Marc-Andre Lafortune)</i></li></ul><p>I don't think this is a bug, but I'll let marcandre make the determination. <code>Vector</code> can't be multipled with <code>Vector</code>, you get an error. You can multiple a <code>Vector</code> by a <code>Matrix</code> and vice-versa by design, and <code>Vector#covector</code> returns a <code>Matrix</code>. You can multiple a <code>Matrix</code> by a <code>Matrix</code> only if the column_count of the receiver is the row count of the argument.</p>
<p>Whether <code>Vector</code> is good design or bad design I'm not going to speculate on. However, you could consider using NMatrix (<a href="https://rubygems.org/gems/nmatrix" class="external">https://rubygems.org/gems/nmatrix</a>), as that represents vectors as matrices.</p> Ruby master - Bug #12356: Vector covector incorrect multiplication with another vector.https://redmine.ruby-lang.org/issues/12356?journal_id=810252019-08-26T14:54:22Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p>Thanks Jeremy for updating this issue. I double checked and never received the original email notification...</p>
<blockquote>
<p><code>Vector</code> does not have distinction between row and column, there's no column vector notion in the language.</p>
</blockquote>
<p>Actually, in the library <code>Vector</code> is a column vector. You can see this for example with:</p>
<pre><code>Vector[1, 2].to_matrix # => Matrix[[1], [2]]
</code></pre>
<p>So I believe that it is correct that <code>v.covector * v</code> or <code>v * v.covector</code> returns some result while other combinations should raise.</p>
<p>I'll close this but will reopen if there's more discussion to be had.</p>