octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63291] var sparse matrix error with vector we


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #63291] var sparse matrix error with vector weighting, and fails to preserve sparseness on scalar weighting
Date: Sat, 29 Oct 2022 22:59:37 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?63291>

                 Summary: var sparse matrix error with vector weighting, and
fails to preserve sparseness on scalar weighting
                 Project: GNU Octave
               Submitter: nrjank
               Submitted: Sat 29 Oct 2022 10:59:35 PM EDT
                Category: Octave Function
                Severity: 2 - Minor
                Priority: 5 - Normal
              Item Group: Unexpected Error or Warning
                  Status: None
             Assigned to: None
         Originator Name: Nicholas Jankowski
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Sat 29 Oct 2022 10:59:35 PM EDT By: Nicholas Jankowski <nrjank>
noticed two things about var (shared by std since that's mainly a passthrough)
and sparse matrices - 

1 - because it calls center for the simpler, scalar weighting path, the output
for a sparse input is always a full matrix. This is because center was
rewritten to use bsxfun until sparse/diagonal arrays stop throwing errors at
automatic broadcasting (bug #51249), and it uses functions in bsxfun that
always return full (bug #63281). Matlab preserves sparseness in both outputs
from std and var regardless of size.

e.g.:


[v,m]=var (sparse([1,2,3]))
v = 1
m = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1 [100%])

  (1, 1) -> 2


2 - the path with vector weights uses automatic broadcasting, and will throw
an error for sparse or diag inputs:


[v,m]=var (sparse([1,2,3;4,5,6]),1:2)
error: product: nonconformant arguments (op1 is 2x1, op2 is 2x3)
error: called from
    var at line 227 column 10



#2 should be able to be solved with a switch to bsxfun like was done in center
to avoid the error.

#1 as noted in bug #63281, sparseness could be preserved in both var and
center by replacing the current bsxfun call with an anonymous function, and
using a try/catch block to mitigate the performance hit. 









    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63291>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]