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
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?
C Zeng
C Zeng 2013-8-6
Hi, Jan, it has been two months, and now I found a method to solve this problem. No need to be a stack. What I did is simply create another array to record the subset number and its order.
Thanks all the same.

请先登录,再进行评论。

采纳的回答

C Zeng
C Zeng 2013-6-20
编辑:C Zeng 2013-6-20
  3 个评论
Jan
Jan 2013-8-5
@C Zhend: You have accepted the answer, which means, that the problem is solved. Now you are asking for an advice?
C Zeng
C Zeng 2013-8-6
Hi, Jan, yes I posted a potential answer but not necessary to be true.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by