| MATLAB Central > MATLAB Newsreader > FAST algorithm to jenga matrix? |
|
|
|
Subject: FAST algorithm to jenga matrix? From: Hoi Wong Date: 29 Mar, 2009 02:17:01 Message: 1 of 11 |
|
I have a GIANT sparse matrix with scattered non-trivial elements ranging from 1:N, then I need to remove a M non-trivial elements and maintain the cardinality from 1:N-M. Is there a fast way to do it? Here's an example to illustrate what I'm trying to do (N=8, M=2): |
|
Subject: FAST algorithm to jenga matrix? From: Roger Stafford Date: 29 Mar, 2009 07:11:03 Message: 2 of 11 |
|
"Hoi Wong" <wonghoi.ee@gmailNOSPAM.com> wrote in message <gqmlmt$6tp$1@fred.mathworks.com>... |
|
Subject: FAST algorithm to jenga matrix? From: Bruno Luong Date: 29 Mar, 2009 09:33:02 Message: 3 of 11 |
|
Here is a five-liner solution, but not much fundamentally different to Roger's solution: |
|
Subject: FAST algorithm to jenga matrix? From: Bruno Luong Date: 29 Mar, 2009 10:32:45 Message: 4 of 11 |
|
Here is a four-liner solution. I could merge the 2nd and 3rd lines but it does not bring any advantage beside having less lines: |
|
Subject: FAST algorithm to jenga matrix? From: Bruno Luong Date: 29 Mar, 2009 10:48:01 Message: 5 of 11 |
|
For fun, two-liner solution: |
|
Subject: FAST algorithm to jenga matrix? From: Bruno Luong Date: 29 Mar, 2009 12:13:02 Message: 6 of 11 |
|
> |
|
Subject: FAST algorithm to jenga matrix? From: Bruno Luong Date: 29 Mar, 2009 13:29:01 Message: 7 of 11 |
|
Sorry there is a bug in the previous code, it should be this: |
|
Subject: FAST algorithm to jenga matrix? From: Bruno Luong Date: 29 Mar, 2009 15:35:01 Message: 8 of 11 |
|
% Another one-liner solution !!! |
|
Subject: FAST algorithm to jenga matrix? From: Roger Stafford Date: 29 Mar, 2009 16:22:01 Message: 9 of 11 |
|
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gqn6u7$1s2$1@fred.mathworks.com>... |
|
Subject: FAST algorithm to jenga matrix? From: Hoi Wong Date: 29 Mar, 2009 22:35:03 Message: 10 of 11 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqo4f5$qf8$1@fred.mathworks.com>... |
|
Subject: FAST algorithm to jenga matrix? From: Hoi Wong Date: 30 Mar, 2009 02:33:01 Message: 11 of 11 |
|
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gqo779$d3g$1@fred.mathworks.com>... |
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
