Select dominated columns in a large matrix

조회 수: 2 (최근 30일)
valentino dardanoni
valentino dardanoni 2023년 12월 18일
댓글: Image Analyst 2023년 12월 19일
Consider a MxN real valued matrix F with nonnegative elements. I say that a column Fn is dominated if there is another column which has all elements greater than Fn.
A simple way to find the set of dominated columns is
z=zeros(1,size(F,2));
for j=1:size(F,2);
z(j)=max(min((F-F(:,j)))>0);
end
However, I need to do it for very large F (say 10,000 x 500,000). What is a more efficient way to do it?
  댓글 수: 2
Matt J
Matt J 2023년 12월 18일
편집: Matt J 2023년 12월 18일
(say 10,000 x 500,000)
If so, then this would be a sparse matrix?
If not, then you have 37 GB to hold such a matrix in double floats?
And if it is sparse, what is the sparsity? And are the zero-elements to be included in the determination of whether a column is dominated?
valentino dardanoni
valentino dardanoni 2023년 12월 18일
Unfortunately it is not sparse, but I have 128 GB of memory

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2023년 12월 18일
How about (untested)
[rows, columns] = size(F)
itsDominated = false(1, columns); % Keep track of which columns are dominated.
for col = 1 : columns
% Get one columns to check.
thisColumn = F(:, col);
% Check it against all other columns.
for col2 = 1 : columns
if col2 == col
continue; % Don't check column against itself.
end
fprintf('Checking column %d against column %d.\n', col, col2);
% See if all the values of column2 are greater than the column
% we're checking on.
thisColumn2 = F(:, col2);
isDom = all(thisColumn2 > thisColumn);
if isDom
% It's dominated. Log this fact and then skip on to the next
% reference column.
itsDominated(col) = true;
fprintf(' Column %d dominates column %d.\n', col2, col);
% Break out of the col2 loop.
break; % Don't bother checking any other columns against this one.
end
end
end
  댓글 수: 4
valentino dardanoni
valentino dardanoni 2023년 12월 19일
Thank you very much Image Analiyst... Yes, it works perfectly, I run it and timed it, now I am timing my naive method, I am acceptingbyour answer and I will let you know later the psedd inv=crease
Image Analyst
Image Analyst 2023년 12월 19일
OK, thanks. I tought my method was "naive". It's not particularly clever. It's basically just a brute force comparison method. About the only clever things about it might be bailing out after the first dominant row is found, and the use of all().
You could speed it up quite a bit by getting rid of the fprintf() statements.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by