⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comblex.h

📁 the FXT library: fast transforms and low level algorithms. The package contains many algorithms for
💻 H
字号:
#if !defined HAVE_COMBLEX_H__#define      HAVE_COMBLEX_H__#include "bitcombination.h"#include "fxttypes.h"#include "newop.h"#include "revbin.h"//#include "fxtio.h"class ostream;class comb_lex{public:    ulong n_;    ulong k_;    ulong bits_;    ulong xbits_;    ulong mask_;  // 111...111000..00 (n zeros)    ulong nmask_;  // ~mask_    ulong *x_;public:    comb_lex(ulong n, ulong k)    {        n_ = (n ? n : 1);  // not zero        k_ = (k ? k : 1);  // not zero        mask_ = ~first_comb(n);        nmask_ = ~mask_;        x_ = NEWOP(ulong, k);        first();    }    ~comb_lex()  { delete [] x_; }    ulong first()    {        xbits_ = first_comb(n_-k_);        sync_x();        return bits_;    }    ulong next()  // return zero if previous comb was the last    {        xbits_ = next_colex_comb(xbits_);        sync_x();        return ( (xbits_ & mask_) ? 0 : xbits_ );    }    const ulong * data()  { return x_; }    const comb_lex &  current()  const  { return *this; }    friend ostream & operator << (ostream &os, const comb_lex &x);//private:    void sync_x()    {        bits_ = nmask_ & ~revbin(xbits_, n_);  // jjnote: revbin is too expensive        ulong tbits = bits_;        ulong xi = 0, bi = 0;        while ( bi < n_ )        {            if ( tbits & 1 )  x_[xi++] = bi;            ++bi;            tbits >>= 1;        }    }};// -------------------------#endif  // !defined HAVE_COMBLEX_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -