[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #66652] Element power operator causes numerica
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #66652] Element power operator causes numerical error but only if broadcasting vector |
Date: |
Fri, 10 Jan 2025 11:39:24 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?66652>
Summary: Element power operator causes numerical error but
only if broadcasting vector
Group: GNU Octave
Submitter: None
Submitted: Fri 10 Jan 2025 04:39:20 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 9.3.0
Operating System: GNU/Linux
Fixed Release: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Fri 10 Jan 2025 04:39:20 PM UTC By: Anonymous
Broadcasting with element power operator causes small but unnecessary
numerical error.
Problem is only with broadcasting different sizes, not scalar or equal size
matrix.
# exponent vector
p = [2 1 0]
# scalar .^ vector is correct
x = i .^ p, x - round(x)
x = (2i) .^ p, x - round(x)
x = (3i) .^ p, x - round(x)
# column vector .^ row vector has numerical error
x = [i; 2i; 3i] .^ p, x - round(x)
# expanding vectors to full matrix is correct again
x = [i i i; 2i 2i 2i; 3i 3i 3i] .^ [2 1 0; 2 1 0; 2 1 0]
x - round (x)
Full matrix result:
>> x = [i i i; 2i 2i 2i; 3i 3i 3i] .^ [2 1 0; 2 1 0; 2 1 0], x - round (x)
x =
-1 + 0i 0 + 1i 1 + 0i
-4 + 0i 0 + 2i 1 + 0i
-9 + 0i 0 + 3i 1 + 0i
ans =
0 0 0
0 0 0
0 0 0
Vector broadcast error result:
>> x = [i; 2i; 3i] .^ [2 1 0], x - round (x)
x =
-1.0000 + 0.0000i 0.0000 + 1.0000i 1.0000 + 0i
-4.0000 + 0.0000i 0.0000 + 2.0000i 1.0000 + 0i
-9.0000 + 0.0000i 0.0000 + 3.0000i 1.0000 + 0i
ans =
0 + 1.2246e-16i 6.1232e-17 + 0i 0 +
0i
0 + 4.8986e-16i 1.2246e-16 + 0i 0 +
0i
-1.7764e-15 + 1.1022e-15i 1.8370e-16 + 4.4409e-16i 0 +
0i
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66652>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
- [Octave-bug-tracker] [bug #66652] Element power operator causes numerical error but only if broadcasting vector,
anonymous <=