[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #59718] Workaround for operators involving a s
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #59718] Workaround for operators involving a sparse matrix and broadcasting |
Date: |
Fri, 18 Dec 2020 02:46:11 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0 |
URL:
<https://savannah.gnu.org/bugs/?59718>
Summary: Workaround for operators involving a sparse matrix
and broadcasting
Project: GNU Octave
Submitted by: None
Submitted on: Fri 18 Dec 2020 07:46:09 AM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Unexpected Error or Warning
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: 6.1.0
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Details:
The following has been a bug for over 6 years
bug #41441
bug #55126
bug #55141
q=rand(2);
w=rand(2,1);
q+w;%works fine
sparse(q)+w;%error: mx_el_eq: nonconformant arguments (op1 is 2x2, op2 is
2x1)
sparse(q)+sparse(w);%error: mx_el_eq: nonconformant arguments (op1 is 2x2, op2
is 2x1)
q+sparse(w);%error: mx_el_eq: nonconformant arguments (op1 is 2x2, op2 is
2x1)
The same issue is also present for:
.*
./
.\
.^
==
<=
>=
<
>
!=
|
&
I have attached an incomplete workaround as a proof of concept which could be
completed with a few more days work. However,I believe fixing the underlying
problem will be a much better solution. I expect to fix the underlying problem
the existing sparse class will need to be updated with code which does the
same thing as my workaround. Unless the underlying implementation is the worst
mess ever written it will probably be quicker to fix it than to finish the
attached workaround.
The workaround creates a new class called sparse. The constructor calls the
builtin sparse and saves the result into a field. I then overloaded + .* ./
and .\ to perform the operators correctly. The code is almost identical for
each operator so a copy and past changing the operator will fix the remaining
unimplemented ones.
This workaround then breaks every other built in function. So they all also
need to be overridden. I have implemented * to demonstrate this. This task
would be much less involved if there was an override for a generic function,
something like:
function varargout=fornothingwrongwithexistingsparsefunction(varargin)
for k=1:nargin()
if isa(varargin{k},"sparse")
varargin{k}=varargin{k}.value;
end
end
varargout=nthargout(1:nargout(),f,varargin{:});
end
I do not know how to get the function f that was called or how to get this
function to be called for all functions I have not specifically overridden.
See line 100 of the attached code for a working implementation of the above
for mtimes.
If overriding everything is the only option, this workaround will require lots
of copy and pasting to finish. This task will be difficult to complete without
introducing bugs and will break every time a new function is added or renamed.
It also introduces unnecessary overhead on all function calls.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Fri 18 Dec 2020 07:46:09 AM UTC Name: sparse.m Size: 4KiB By: None
<http://savannah.gnu.org/bugs/download.php?file_id=50507>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?59718>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #59718] Workaround for operators involving a sparse matrix and broadcasting,
anonymous <=