# bug #55141: sparse matrix/vector comparison

 Submitter: Ray Zimmerman Submitted: Fri 30 Nov 2018 08:49:46 PM UTC Category: Interpreter Severity: 3 - Normal Priority: 5 - Normal Item Group: Unexpected Error or Warning Status: Duplicate Assigned to: None Originator Name: rdzman Open/Closed:  * Closed Release:  * 4.4.1 Operating System:  * Any Fixed Release: None Planned Release: None
* Mandatory Fields

Add a New Comment Rich Markup

## Discussion

Sat 01 Dec 2018 04:47:31 AM UTC, comment #1:

Unfortunately this is a known bug involving broadcasting.  See bug #41441.

For the time being, you should use repmat to create a comparison array from the single column vector.  Along the lines of

A = [1 3; 7 5]; b = [2; 6];
b = repmat (b, [1, columns(A)]);
sparse (A) < sparse (b)

This will work in Octave or Matlab.

Marking as a duplicate and keeping the original report at bug #41441 open.

Rik <rik5>
Fri 30 Nov 2018 08:49:46 PM UTC, original submission:

Comparing a matrix with a vector works fine for full and sparse matrices on Matlab, but on Octave it gives an error for sparse matrices.

octave:1> A = [1 3; 7 5]; b = [2; 6];
octave:2> A < b
ans =

1  0
0  1

octave:3> sparse(A) < sparse(b)
error: mx_el_lt: nonconformant arguments (op1 is 2x2, op2 is 2x1)

On Matlab, however, it works fine ...

>> A = [1 3; 7 5]; b = [2; 6];
>> A < b

ans =

2x2 logical array

1   0
0   1

>> sparse(A) < sparse(b)

ans =

2x2 sparse logical array

(1,1)      1
(2,2)      1

Ray Zimmerman <rdzman>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items

Digest:
bug dependencies.

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by rik5 (Posted a comment)
• -email is unavailable- added by rdzman (Submitted the item)
•

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only project members can vote.