help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to extract sequenced data from an array?


From: Przemek Klosowski
Subject: Re: How to extract sequenced data from an array?
Date: Wed, 22 Dec 2010 13:56:20 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b2 Thunderbird/3.1.6

On 12/22/2010 09:49 AM, new_user wrote:

Maybe I should have said about amount of data in question: 10^7 to 10^8 
elements, and unique sequence consists of maximum 10^6 elements, usually less 
like 10^5

I run the function on array with 3071488 rows and after half hour I terminated 
octave process :D

Is the unique sub-sequence guaranteed to repeat in its entirety an integer number of times? because if that's the case, then you shouldn't seek the period by incrementing by one, but rather check the factors of the original length in decreasing order, somehow like this:

function y = period (x)
 p=factor(rows(x)); a=[];
 while(p)
  p(end)=[]; seg=prod(p);
  y=repmat(x(1:seg,:),rows(x)/seg,1);
  if(isequal(x,y)) ;
   x=x(1:seg,:);
  endif
 endwhile
 y=x;
 endfunction

If you can make this assumption then the runtime would dramatically shortened.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]