Cody

# Problem 1051. Exact binary matrix factorization

Solution 168301

Submitted on 26 Nov 2012 by Andrei Bobrov
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% C = [1 1 1 0 0 0 0 0 0 1 0 1]; K = 2; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

L = 1 0 0 0 0 1 0 1 0 U = 1 1 1 0 0 1 0 1 0 0 0 0 ii = 1 2 1 3 2 3 i1 = 1 1 1 2 2 2 3 3 3 j1 = 1 2 3 1 2 3 1 2 3

2   Pass
%% C = [1 0 0 1 0 0 1 1 0]; K = 3; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

L = 1 0 0 1 0 1 1 1 0 U = 1 0 0 0 1 0 0 0 0 ii = 1 2 3 i1 = 1 j1 = 1

3   Pass
%% C = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; K = 1; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B'),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

L = 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 U = 1 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ii = 1 2 3 4 5 6 7 8 9 10 i1 = 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 j1 = 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

4   Pass
%% Added another small test case C = [1 0 1 1 1 1 0 1 0]; K = 2; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B'),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

L = 1 0 0 1 1 0 0 1 1 U = 1 0 1 0 1 0 0 0 0 ii = 1 2 1 3 2 3 i1 = 1 1 1 2 2 2 3 3 3 j1 = 1 2 3 1 2 3 1 2 3

5   Pass
%% A degenerate problem C = [0 0 1 0 0 0 0 0 1]; K = 2; [A,B] = ebmf(C,K); assert(isequal(A*B,C)) assert(isequal(unique(A),[0; 1])) assert(isequal(unique(B'),[0; 1])) assert(all(size(A)==[size(C,1),K])) assert(all(size(B)==[K,size(C,2)]))

L = 1 0 0 0 1 0 0 0 1 U = 0 0 1 0 0 0 0 0 1 ii = 1 2 1 3 2 3 i1 = 1 1 1 2 2 2 3 3 3 j1 = 1 2 3 1 2 3 1 2 3

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!