I have a matrix multiplication P*C, where these two matrices change their values and their matrix dimensions during each step of the "while" loop.
The P matrix is a double matrix, while the C matrix is a logical matrix, with all values equal to 1 or 0.
The code is the following:
NU=2000;NC=100;P = rand(NU,NU);C = zeros(NU,NC);UFL = false(NU,1);ID_vector = [1:NU]';C(1,1) =1;UFL(1) =1;while ne(sum(UFL),NU) ID_NA = ID_vector(not(UFL)); ID_AS = ID_vector(UFL); A = P(ID_NA,ID_AS)*C(ID_AS,:); %matrix multiplication to speed up
[~,IDX] = max(max(A,[],2)); USX = ID_NA(IDX); [~,COX] = min(A(IDX,:)); C(USX,COX) = 1; UFL(USX) = true;end
There is a way to speed up this matrix multiplication?
Considering that binary nature of the matrix C, I think that the matrix multiplication should be speed up interpreting the multiplication as a selective sum, but I am unable to write the correct code.
Best Answer