Cody

# Problem 1051. Exact binary matrix factorization

Solution 170390

Submitted on 29 Nov 2012 by Freddy
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)]))

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)]))

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)]))

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)]))

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)]))

### Community Treasure Hunt

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

Start Hunting!