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

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

[Octave-bug-tracker] [bug #40105] Logical diagonal matrices are not supp


From: David Spies
Subject: [Octave-bug-tracker] [bug #40105] Logical diagonal matrices are not supported
Date: Mon, 21 Oct 2013 23:25:39 +0000
User-agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/28.0.1500.71 Chrome/28.0.1500.71 Safari/537.36

Follow-up Comment #3, bug #40105 (project octave):

Logical matrix multiplication comes up quite a lot.  Of course, I could just
convert to a matrix of doubles, but that would be a workaround.

As an example, suppose I have a logical matrix A where each row represents a
set (and all sets are unique).  Now suppose I want to remove any set which is
a subset of another row (such as when finding all maximal cliques in an
undirected graph).

cardinality = sum(A,2);
coincidence = A * A'; %Logical matrix multiplication
subsets = any(coincidence == cardinality, 2); % Using automatic broadcasting
with ==
A = A(~subsets,:);

As an example of where logical diagonal matrix multiplication comes in handy,
suppose I want to mux the rows from matrices A and B according to a logical
column vector s

res = (diag(~s) * A) | (diag(s) * B);


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?40105>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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