About changing the size of array
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, it is a follow up of a previous question, but I have not successfully solved it.
Assume I have a large matrix(many rows), and try to remove as many rows as I want. The criterion of removing a row j is that if there is a row i in lower row# (i<j) and row i<=row j and then we call row i dominates row j rand remove row j(while keep row i).
To do a complete removal, I need to check to every row, check if any of its row above it can dominates it. When the size of matrix is very large (in my case) the program is very slow.
Now I think of a method that can avoid wasting time on dominated rows. Whenever I find 1000 rows that are dominated, I delete them from the matrix and continue the work. In such a way, the size of matrix can get smaller and smaller. However I am aware that changing the size of a variable also costs time. There is a tradeoff.
Last week Walter Roberson communicated with me about if there is opportunity of speedup if keeping the size of variable smaller. It seems that not very possible unless we need additional memory on hard drive. Otherwise if in the RAM, there might not be a difference on large of small size of your data.
If so, let me go back to my problem, changing the variable may not be good. How about keep a linked array that it only contains non-dominated rows but in reverse order and it likes "10->8->5->2->1" I would like to save it as a stack, i.e., Whenever I push a number number, it shows up in the first entry.
How to define and make a stack happen? Note I have to define the size, but I do not know it yet.
Thanks.
댓글 수: 3
Jan
2013년 8월 5일
I do not understand the question completely. How large is your matrix? "Very large" could mean 2000 or 20'000'000 rows. "Very slow" can mean seconds or weeks. Do you want to improve the performance of your code? Then post it here. Operating on rows must be slower than on columns due to accessing neighboring elements of the memory.
I cannot follow at these points:
It seems that not very possible unless we need additional memory on hard drive. Otherwise if in the RAM, there might not be a difference on large of small size of your data.
What is a "linked array" in your case or what does "saving as a stack" exactly mean?
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!