From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 40A981F461 for ; Fri, 23 Aug 2019 22:35:57 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4AE36120B08; Sat, 24 Aug 2019 07:35:49 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id ECDC9120A77 for ; Sat, 24 Aug 2019 07:35:46 +0900 (JST) Received: by filter0094p3las1.sendgrid.net with SMTP id filter0094p3las1-14716-5D606A46-D 2019-08-23 22:35:50.297108172 +0000 UTC m=+534850.485348981 Received: from herokuapp.com (unknown [3.81.9.76]) by ismtpd0010p1iad1.sendgrid.net (SG) with ESMTP id g4JtHuHbTYSxvJn45wy6GQ for ; Fri, 23 Aug 2019 22:35:50.187 +0000 (UTC) Date: Fri, 23 Aug 2019 22:35:50 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70062 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12356 X-Redmine-Issue-Author: edmorte X-Redmine-Issue-Assignee: marcandre X-Redmine-Sender: jeremyevans0 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BItgWsvx5oVKm=2Fl7arHe6jX9uNFkvkWIKX17q2j?= =?us-ascii?Q?KkBl7QQsLJ0kbMfKxc+OwohF0Zo9KMulZ=2F1q3EX?= =?us-ascii?Q?eOxtQXjgxM4Qq8YKoCEbputaMGSqbUlCnWmNjNk?= =?us-ascii?Q?JaWaP+XCJMQdJX6W2e+uQ4nkRkrGc=2Fi=2FA+g=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94513 Subject: [ruby-core:94513] [Ruby master Bug#12356] Vector covector incorrect multiplication with another vector. X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #12356 has been updated by jeremyevans0 (Jeremy Evans). Assignee set to marcandre (Marc-Andre Lafortune) Status changed from Open to Assigned I don't think this is a bug, but I'll let marcandre make the determination. `Vector` can't be multipled with `Vector`, you get an error. You can multiple a `Vector` by a `Matrix` and vice-versa by design, and `Vector#covector` returns a `Matrix`. You can multiple a `Matrix` by a `Matrix` only if the column_count of the receiver is the row count of the argument. Whether `Vector` is good design or bad design I'm not going to speculate on. However, you could consider using NMatrix (https://rubygems.org/gems/nmatrix), as that represents vectors as matrices. ---------------------------------------- Bug #12356: Vector covector incorrect multiplication with another vector. https://bugs.ruby-lang.org/issues/12356#change-80949 * Author: edmorte (Rafael Silva) * Status: Assigned * Priority: Normal * Assignee: marcandre (Marc-Andre Lafortune) * Target version: * ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Version 2.2.4 v1 = Vector[2,3,4] v2 = Vector[4,5,6] v1.covector.row_size #1 v1.covector.column_size #3 v2.covector.row_size #1 v2.covector.column_size #3 Vector does not have distinction between row and column, there's no column vector notion in the language. v1 * v2.covector #Matrix[[8,10,12],[12,15,18],[16,20,24]] # Should be illegal. But works like if v2.covector is transposed / column vector which it's clearly not. v1.covector * v2.covector #ExceptionForMatrix::ErrDimensionMismatch: Matrix dimension mismatch # Expected v1 * v2 #ExceptionForMatrix::ErrOperationNotDefined: Operation(*) can't be defined: Vector op Vector # No comments, see my observation below. v1.covector * v2 #Vector[47] #Again covector treated like transposed / column vector. Personal observation: Terrible choice to represent Vector like an Array, Vector should be a shortcut to Matrix. -- https://bugs.ruby-lang.org/