Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 移动到前端变换的快速算法_Algorithm_Optimization_Burrows Wheeler Transform - Fatal编程技术网

Algorithm 移动到前端变换的快速算法

Algorithm 移动到前端变换的快速算法,algorithm,optimization,burrows-wheeler-transform,Algorithm,Optimization,Burrows Wheeler Transform,我正试图找到移动到前端转换的最快算法。例如,与burrows-wheeler变换结合使用的 到目前为止,我管理的最好的处理器在核心i3 2.1GHz上的速度大约为15MB/s。但我确信这不是最优的。这是我迄今为止最大的努力。有更快的吗 class mtf256_x { typedef unsigned char u8;

我正试图找到移动到前端转换的最快算法。例如,与burrows-wheeler变换结合使用的

到目前为止,我管理的最好的处理器在核心i3 2.1GHz上的速度大约为15MB/s。但我确信这不是最优的。这是我迄今为止最大的努力。有更快的吗

class mtf256_x {                                                                            
        typedef unsigned char u8;
        typedef unsigned long long L;
        public:
        L enc[37];
        u8 dec[256];
        mtf256_x() {
                unsigned i;
                for (i=0;i<37;i++) {
                        enc[i]=0;
                }
                for (i=0;i<256;i++) {
                        dec[i]=i;
                        set(i,i);
                }
        }
        u8 decode(u8 in) {
                u8 r = dec[in];                                                             
                if (in) {                                                                   
                        memmove(dec+1,dec,in);                                              
                        dec[0]=r;                                                           
                }                                                                           
                return r;                                                                   
        }                                                                                   
        u8 set(unsigned x, u8 y) {                                                          
                unsigned xl = (x%7)*9;                                                      
                unsigned xh = (x/7);                                                        
                enc[xh] &= ~(0x1FFLLU<<xl);                                                 
                enc[xh] |= ((L)y)<<xl;                                                      
        }                                                                                   
        u8 get(unsigned x) {                                                                
                return enc[x/7] >> (x%7)*9;                                                 
        }                                                                                   
        u8 encode(u8 in) {                                                                  
                u8 r;
                unsigned i;
                r = get(in);
                L m2 = 0x0040201008040201LLU; // 0x01 for each 9 bit int                    
                L m1 = 0x3FDFEFF7FBFDFEFFLLU; // 0xff for each 9 bit int                    
                L Q = (0x100+r)*m2;                                                         
                L a,b,c,d;                                                                  
                L * l= enc;                                                                 
                for (i=0;i<37;i++) {                                                        
                        a=l[i];
                        a+= ((Q-a)>>8)&m2;  // conditional add 1
                        a&=m1;
                        l[i]=a;
                }
                set(in,0);
                return r;
        }
};
类mtf256_x{
typedef无符号字符u8;
typedef无符号长L;
公众:
附件[37];
u8 dec[256];
mtf256_x(){
未签名的i;
对于(i=0;i也许你可以试试这个

intb[uint8Max+2],treshold=0,pivot=-1;
长填充偏移量=0,偏移量=0,t[uint8Max+1];
int秩,c,i,p0,p1;
//初始化列表

对于(i=0;i),这是一个很好的优化!我很想看看这个问题的答案。
int b[ uint8Max + 2 ], treshold = 0, pivot = -1;
long inFileOffst = 0, pOffset = 0, t[ uint8Max + 1 ];
int rank, c, i, p0, p1;

  // initialise list

  for( i = 0; i <= uint8Max; t[ i++ ] = 0 );
  for( i = 1; i <= uint8Max; b[ i - 1 ] = i++ );
  b[ uint8Max ] = b[ uint8Max + 1 ] = 0;

  // read data
  // input  = c; output = rank

  inFileOffst++;

  rank = 0;
  if( ( p1 = b[uint8Max + 1] ) != ( c = data[input] ) )
  {
     if( t[ c ] < pOffset )
     {
        rank += treshold++;
        t[ c ] = inFileOffst;
        p1 = pivot;
     }
     else if( t[ c ] == pOffset )
     {
        pivot = c;
        t[ c ] = pOffset = inFileOffst;
        treshold = 0;
     }
     while( true ) // passing the list
     {
        if( ( p0 = b[ p1 ] ) == c )
        {
           rank++;
           b[ p1 ] = b[ c ];
           break;
        }
        if( ( p1 = b[ p0 ] ) == c )
        {
           rank += 2;
           b[ p0 ] = b[ c ];
           break;
        }
        if( ( p0 = b[ p1 ] ) == c )
        {
           rank += 3;
           b[ p1 ] = b[ c ];
           break;
        }
        if( ( p1 = b[ p0 ] ) == c )
        {
           rank += 4;
           b[ p0 ] = b[ c ];
           break;
        }
        rank += 4;
     }
     b[ c ] = b[ uint8Max + 1 ];
     b[ uint8Max + 1 ] = c;
  }