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.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 653601F4B4 for ; Thu, 15 Apr 2021 03:10:46 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E7405120CB8; Thu, 15 Apr 2021 12:09:42 +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 E4D1A120A72 for ; Thu, 15 Apr 2021 12:09:39 +0900 (JST) Received: by filterdrecv-5d6974ffbb-pnnp7 with SMTP id filterdrecv-5d6974ffbb-pnnp7-14-6077AEAE-32 2021-04-15 03:10:38.688694792 +0000 UTC m=+198411.901919669 Received: from herokuapp.com (unknown) by ismtpd0199p1mdw1.sendgrid.net (SG) with ESMTP id myutQdmdRnuIhH94r9obIQ for ; Thu, 15 Apr 2021 03:10:38.510 +0000 (UTC) Date: Thu, 15 Apr 2021 03:10:38 +0000 (UTC) From: marcandre-ruby-core@marc-andre.ca Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17521 X-Redmine-Issue-Author: Kache X-Redmine-Issue-Assignee: marcandre X-Redmine-Sender: marcandre 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-Redmine-MailingListIntegration-Message-Ids: 79506 X-SG-EID: =?us-ascii?Q?6=2FIMxCQLDposcQf5wmbDAtfaKduBAO0bKyhL3BGZtMQ5q7K2TvpbN6A7JIyt9E?= =?us-ascii?Q?aOeVJxftsAwgVcQCKLoSia9j05kvlM226x9EOsf?= =?us-ascii?Q?2W4RF2jnePuzburjhY5JOqCKwRQRXdelsfOZyW0?= =?us-ascii?Q?tk5zi3IlSHb5K055bSqFGn3OHMoXVdP=2FWqwsKeh?= =?us-ascii?Q?444Uag3AZLvY6RkoJRdDEg6yPk8BxOZONcJw8MR?= =?us-ascii?Q?NdMJmCZ1kiLA13ytU=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 103460 Subject: [ruby-core:103460] [Ruby master Bug#17521] [Matrix stdlib] Zero matrix to the power of zero 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 #17521 has been updated by marcandre (Marc-Andre Lafortune). Since `matrix` is a gem that can be updated independently from Ruby, I think backports are not required. In addition, this bug is very minor. ---------------------------------------- Bug #17521: [Matrix stdlib] Zero matrix to the power of zero https://bugs.ruby-lang.org/issues/17521#change-91555 * Author: Kache (Kevin Cheng) * Status: Closed * Priority: Normal * Assignee: marcandre (Marc-Andre Lafortune) * ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-msys] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: WONTFIX ---------------------------------------- Just like `0**0 == 1`, `Matrix.zero(n)**0 == Matrix.identity(n)` should be true for all `n`: https://math.stackexchange.com/questions/699740/zero-matrix-to-the-power-of-0 However: ``` $ ruby -e "require 'matrix'; Matrix.zero(1)**0" Traceback (most recent call last): 5: from -e:1:in `
' 4: from /usr/lib/ruby/2.7.0/matrix.rb:1227:in `**' 3: from /usr/lib/ruby/2.7.0/matrix.rb:1165:in `inverse' 2: from /usr/lib/ruby/2.7.0/matrix.rb:1173:in `inverse_from' 1: from /usr/lib/ruby/2.7.0/matrix.rb:1173:in `upto' /usr/lib/ruby/2.7.0/matrix.rb:1183:in `block in inverse_from': Not Regular Matrix (ExceptionForMatrix::ErrNotRegular) ``` `Matrix.zero(n)**0.0` happens to work properly, but it should work for integers as well. Wasn't able to test in Ruby 3.0, but its source code suggests it also behaves this way. For comparison, [Python's numpy](https://numpy.org/doc/stable/reference/generated/numpy.linalg.matrix_power.html): ``` Python 3.8.2 (default, Feb 26 2020, 02:56:10) >> import numpy as np >> np.linalg.matrix_power(np.array([[0,0],[0,0]]), 0) array([[1, 0], [0, 1]]) ``` -- https://bugs.ruby-lang.org/