本文整理汇总了C++中K函数的典型用法代码示例。如果您正苦于以下问题:C++ K函数的具体用法?C++ K怎么用?C++ K使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了K函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OPEN_ARRAY
void OCamlFFlatCodeGen::writeData()
{
if ( redFsm->anyConditions() ) {
OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
COND_KEYS();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpan), CSP() );
COND_KEY_SPANS();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCond), C() );
CONDS();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondIndexOffset), CO() );
COND_INDEX_OFFSET();
CLOSE_ARRAY() <<
L"\n";
}
OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
KEYS();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSpan), SP() );
KEY_SPANS();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxFlatIndexOffset), IO() );
FLAT_INDEX_OFFSET();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() );
INDICIES();
CLOSE_ARRAY() <<
L"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
TRANS_TARGS();
CLOSE_ARRAY() <<
L"\n";
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() );
TRANS_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
if ( redFsm->anyToStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
TO_STATE_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
if ( redFsm->anyFromStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
FROM_STATE_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
if ( redFsm->anyEofActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() );
EOF_ACTIONS();
CLOSE_ARRAY() <<
L"\n";
}
if ( redFsm->anyEofTrans() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() );
EOF_TRANS();
CLOSE_ARRAY() <<
L"\n";
}
STATE_IDS();
out << L"type " << TYPE_STATE() << L" = { mutable keys : int; mutable trans : int; }"
<< TOP_SEP();
out << L"exception Goto_match" << TOP_SEP();
out << L"exception Goto_again" << TOP_SEP();
out << L"exception Goto_eof_trans" << TOP_SEP();
}
示例2: get_projective_equivalent
/**
* @brief Return the projection matrix (interior & exterior) as a simplified projective projection
* @param pose Extrinsic matrix
* @return Concatenation of intrinsic matrix and extrinsic matrix
*/
virtual Mat34 get_projective_equivalent( const geometry::Pose3 & pose ) const
{
Mat34 P;
P_From_KRt( K(), pose.rotation(), pose.translation(), &P );
return P;
}
示例3: OPEN_ARRAY
void CSharpTabCodeGen::writeData()
{
/* If there are any transtion functions then output the array. If there
* are none, don't bother emitting an empty array that won't be used. */
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() );
ACTIONS_ARRAY();
CLOSE_ARRAY() <<
"\n";
}
if ( redFsm->anyConditions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondOffset), CO() );
COND_OFFSETS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondLen), CL() );
COND_LENS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
COND_KEYS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxCondSpaceId), C() );
COND_SPACES();
CLOSE_ARRAY() <<
"\n";
}
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxKeyOffset), KO() );
KEY_OFFSETS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
KEYS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxSingleLen), SL() );
SINGLE_LENS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxRangeLen), RL() );
RANGE_LENS();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset), IO() );
INDEX_OFFSETS();
CLOSE_ARRAY() <<
"\n";
if ( useIndicies ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndex), I() );
INDICIES();
CLOSE_ARRAY() <<
"\n";
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
TRANS_TARGS_WI();
CLOSE_ARRAY() <<
"\n";
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() );
TRANS_ACTIONS_WI();
CLOSE_ARRAY() <<
"\n";
}
}
else {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxState), TT() );
TRANS_TARGS();
CLOSE_ARRAY() <<
"\n";
if ( redFsm->anyActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TA() );
TRANS_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
}
if ( redFsm->anyToStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
TO_STATE_ACTIONS();
CLOSE_ARRAY() <<
"\n";
}
if ( redFsm->anyFromStateActions() ) {
OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
FROM_STATE_ACTIONS();
//.........这里部分代码省略.........
示例4: main
int main(int argc, char **argv)
{
int j, k, t; /**< indices */
int d; /**< number of dimensions */
int N; /**< number of source nodes */
int M; /**< number of target nodes */
int n; /**< expansion degree */
int m; /**< cut-off parameter */
int p; /**< degree of smoothness */
const char *s; /**< name of kernel */
C (*kernel)(R, int, const R *); /**< kernel function */
R c; /**< parameter for kernel */
fastsum_plan my_fastsum_plan; /**< plan for fast summation */
C *direct; /**< array for direct computation */
ticks t0, t1; /**< for time measurement */
R time; /**< for time measurement */
R error = K(0.0); /**< for error computation */
R eps_I; /**< inner boundary */
R eps_B; /**< outer boundary */
FILE *fid1, *fid2;
R temp;
if (argc != 11)
{
printf("\nfastsum_test d N M n m p kernel c\n\n");
printf(" d dimension \n");
printf(" N number of source nodes \n");
printf(" M number of target nodes \n");
printf(" n expansion degree \n");
printf(" m cut-off parameter \n");
printf(" p degree of smoothness \n");
printf(" kernel kernel function (e.g., gaussian)\n");
printf(" c kernel parameter \n");
printf(" eps_I inner boundary \n");
printf(" eps_B outer boundary \n\n");
exit(-1);
}
else
{
d = atoi(argv[1]);
N = atoi(argv[2]);
c = K(1.0) / POW((R)(N), K(1.0) / ((R)(d)));
M = atoi(argv[3]);
n = atoi(argv[4]);
m = atoi(argv[5]);
p = atoi(argv[6]);
s = argv[7];
c = (R)(atof(argv[8]));
eps_I = (R)(atof(argv[9]));
eps_B = (R)(atof(argv[10]));
if (strcmp(s, "gaussian") == 0)
kernel = gaussian;
else if (strcmp(s, "multiquadric") == 0)
kernel = multiquadric;
else if (strcmp(s, "inverse_multiquadric") == 0)
kernel = inverse_multiquadric;
else if (strcmp(s, "logarithm") == 0)
kernel = logarithm;
else if (strcmp(s, "thinplate_spline") == 0)
kernel = thinplate_spline;
else if (strcmp(s, "one_over_square") == 0)
kernel = one_over_square;
else if (strcmp(s, "one_over_modulus") == 0)
kernel = one_over_modulus;
else if (strcmp(s, "one_over_x") == 0)
kernel = one_over_x;
else if (strcmp(s, "inverse_multiquadric3") == 0)
kernel = inverse_multiquadric3;
else if (strcmp(s, "sinc_kernel") == 0)
kernel = sinc_kernel;
else if (strcmp(s, "cosc") == 0)
kernel = cosc;
else if (strcmp(s, "cot") == 0)
kernel = kcot;
else
{
s = "multiquadric";
kernel = multiquadric;
}
}
printf(
"d=%d, N=%d, M=%d, n=%d, m=%d, p=%d, kernel=%s, c=%" __FGS__ ", eps_I=%" __FGS__ ", eps_B=%" __FGS__ " \n",
d, N, M, n, m, p, s, c, eps_I, eps_B);
/** init two dimensional fastsum plan */
fastsum_init_guru(&my_fastsum_plan, d, N, M, kernel, &c, 0, n, m, p, eps_I,
eps_B);
/*fastsum_init_guru(&my_fastsum_plan, d, N, M, kernel, &c, EXACT_NEARFIELD, n, m, p);*/
/** load source knots and coefficients */
fid1 = fopen("x.dat", "r");
fid2 = fopen("alpha.dat", "r");
for (k = 0; k < N; k++)
{
for (t = 0; t < d; t++)
{
fscanf(fid1, __FR__, &my_fastsum_plan.x[k * d + t]);
}
fscanf(fid2, __FR__, &temp);
my_fastsum_plan.alpha[k] = temp;
//.........这里部分代码省略.........
示例5: AnimatedTexture
SpriteStarVlist::SpriteStarVlist(int num, float spread, std::string sysnam, std::string texturenames,float size):StarVlist(spread) {
int curtexture=0;
vector<AnimatedTexture *>animations;
static bool near_stars_alpha=XMLSupport::parse_bool(vs_config->getVariable("graphics","near_stars_alpha","false"));
for (curtexture=0; curtexture<NUM_ACTIVE_ANIMATIONS; ++curtexture) {
std::string::size_type where=texturenames.find(" ");
string texturename=texturenames.substr(0,where);
if (where!=string::npos) {
texturenames=texturenames.substr(where+1);
} else texturenames="";
if (texturename.find(".ani")!=string::npos) {
animations.push_back(new AnimatedTexture(texturename.c_str(),0,near_stars_alpha?NEAREST:BILINEAR));
decal[curtexture]=animations.back();
} else if (texturename.length()==0) {
if (curtexture==0) {
decal[curtexture]= new Texture("white.bmp",0,near_stars_alpha?NEAREST:BILINEAR);
} else {
if (animations.size()) {
AnimatedTexture *tmp= static_cast<AnimatedTexture*>(animations[curtexture%animations.size()]->Clone());
int num= tmp->numFrames();
if (num) {
num = rand()%num;
tmp->setTime(num/tmp->framesPerSecond());
}
decal[curtexture]=tmp;
} else {
decal[curtexture]=decal[rand()%curtexture]->Clone();
}
}
} else {
decal[curtexture] = new Texture(texturename.c_str());
}
}
int numVerticesPer=near_stars_alpha?4:12;
GFXColorVertex * tmpvertex = AllocVerticesForSystem(sysnam,this->spread,&num,numVerticesPer);
for (int LC=0; LC<num; LC+=numVerticesPer) {
int LAST=LC+numVerticesPer-1;
for (int i=LC; i<=LAST; ++i) {
tmpvertex[i].r=tmpvertex[LAST].r;
tmpvertex[i].g=tmpvertex[LAST].g;
tmpvertex[i].b=tmpvertex[LAST].b;
tmpvertex[i].a=tmpvertex[LAST].a;
}
Vector I(rand()*2.0/RAND_MAX-1,
rand()*2.0/RAND_MAX-1,
rand()*2.0/RAND_MAX-1);
Vector J(rand()*2.0/RAND_MAX-1,
rand()*2.0/RAND_MAX-1,
rand()*2.0/RAND_MAX-1);
Vector K(rand()*2.0/RAND_MAX-1,
rand()*2.0/RAND_MAX-1,
rand()*2.0/RAND_MAX-1);
if (I.MagnitudeSquared()<.00001) {
I.i+=.5;
}
if (J.MagnitudeSquared()<.00001) {
J.j+=.5;
}
if (K.MagnitudeSquared()<.00001) {
K.k+=.5;
}
Orthogonize(I,J,K);
I=I*size;
J=J*size;
K=K*size;
tmpvertex[LC+0].SetVertex(GetConstVertex(tmpvertex[LC+0])-I+J);
tmpvertex[LC+0].s=0.15625;
tmpvertex[LC+0].t=.984375;
tmpvertex[LC+1].SetVertex(GetConstVertex(tmpvertex[LC+1])+I+J);
tmpvertex[LC+1].s=.984375;
tmpvertex[LC+1].t=.984375;
tmpvertex[LC+2].SetVertex(GetConstVertex(tmpvertex[LC+2])+I-J);
tmpvertex[LC+2].s=.984375;
tmpvertex[LC+2].t=.015625;
tmpvertex[LC+3].SetVertex(GetConstVertex(tmpvertex[LC+3])-I-J);
tmpvertex[LC+3].s=.015625;
tmpvertex[LC+3].t=.015625;
if (numVerticesPer>4) {
tmpvertex[LC+4].SetVertex(GetConstVertex(tmpvertex[LC+4])-I+K);
tmpvertex[LC+4].s=.015625;
tmpvertex[LC+4].t=.984375;
tmpvertex[LC+5].SetVertex(GetConstVertex(tmpvertex[LC+5])+I+K);
tmpvertex[LC+5].s=.984375;
tmpvertex[LC+5].t=.984375;
tmpvertex[LC+6].SetVertex(GetConstVertex(tmpvertex[LC+6])+I-K);
tmpvertex[LC+6].s=.984375;
tmpvertex[LC+6].t=.015625;
tmpvertex[LC+7].SetVertex(GetConstVertex(tmpvertex[LC+7])-I-K);
tmpvertex[LC+7].s=.015625;
tmpvertex[LC+7].t=.015625;
}
if (numVerticesPer>8) {
tmpvertex[LC+8].SetVertex(GetConstVertex(tmpvertex[LC+8])-J+K);
tmpvertex[LC+8].s=.015625;
tmpvertex[LC+8].t=.984375;
tmpvertex[LC+9].SetVertex(GetConstVertex(tmpvertex[LC+9])+J+K);
//.........这里部分代码省略.........
示例6: meminfo_proc_show
static int meminfo_proc_show(struct seq_file *m, void *v)
{
struct sysinfo i;
unsigned long committed;
unsigned long allowed;
struct vmalloc_info vmi;
long cached;
unsigned long pages[NR_LRU_LISTS];
int lru;
/*
* display in kilobytes.
*/
#define K(x) ((x) << (PAGE_SHIFT - 10))
si_meminfo(&i);
si_swapinfo(&i);
committed = percpu_counter_read_positive(&vm_committed_as);
allowed = ((totalram_pages - hugetlb_total_pages())
* sysctl_overcommit_ratio / 100) + total_swap_pages;
cached = global_page_state(NR_FILE_PAGES) -
total_swapcache_pages - i.bufferram;
if (cached < 0)
cached = 0;
get_vmalloc_info(&vmi);
for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++)
pages[lru] = global_page_state(NR_LRU_BASE + lru);
/*
* Tagged format, for easy grepping and expansion.
*/
seq_printf(m,
"MemTotal: %8lu kB\n"
"MemFree: %8lu kB\n"
"Buffers: %8lu kB\n"
"Cached: %8lu kB\n"
"SwapCached: %8lu kB\n"
"Active: %8lu kB\n"
"Inactive: %8lu kB\n"
"Active(anon): %8lu kB\n"
"Inactive(anon): %8lu kB\n"
"Active(file): %8lu kB\n"
"Inactive(file): %8lu kB\n"
"Unevictable: %8lu kB\n"
"Mlocked: %8lu kB\n"
#ifdef CONFIG_HIGHMEM
"HighTotal: %8lu kB\n"
"HighFree: %8lu kB\n"
"LowTotal: %8lu kB\n"
"LowFree: %8lu kB\n"
#endif
#ifndef CONFIG_MMU
"MmapCopy: %8lu kB\n"
#endif
"SwapTotal: %8lu kB\n"
"SwapFree: %8lu kB\n"
"Dirty: %8lu kB\n"
"Writeback: %8lu kB\n"
"AnonPages: %8lu kB\n"
"Mapped: %8lu kB\n"
"Shmem: %8lu kB\n"
"Slab: %8lu kB\n"
"SReclaimable: %8lu kB\n"
"SUnreclaim: %8lu kB\n"
"KernelStack: %8lu kB\n"
"PageTables: %8lu kB\n"
#ifdef CONFIG_QUICKLIST
"Quicklists: %8lu kB\n"
#endif
"NFS_Unstable: %8lu kB\n"
"Bounce: %8lu kB\n"
"WritebackTmp: %8lu kB\n"
"CommitLimit: %8lu kB\n"
"Committed_AS: %8lu kB\n"
"VmallocTotal: %8lu kB\n"
"VmallocUsed: %8lu kB\n"
"VmallocChunk: %8lu kB\n"
#ifdef CONFIG_MEMORY_FAILURE
"HardwareCorrupted: %5lu kB\n"
#endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
"AnonHugePages: %8lu kB\n"
#endif
,
K(i.totalram),
K(i.freeram),
K(i.bufferram),
K(cached),
K(total_swapcache_pages),
K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]),
K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]),
K(pages[LRU_ACTIVE_ANON]),
K(pages[LRU_INACTIVE_ANON]),
K(pages[LRU_ACTIVE_FILE]),
K(pages[LRU_INACTIVE_FILE]),
K(pages[LRU_UNEVICTABLE]),
K(global_page_state(NR_MLOCK)),
#ifdef CONFIG_HIGHMEM
//.........这里部分代码省略.........
示例7: N
// Collect knight jump flags
#define N(sq) [sq]=(\
dir(sq,jumpNNW,bitNNW) + dir(sq,jumpNNE,bitNNE)+ \
\
dir(sq,jumpWNW,bitWNW) + + + dir(sq,jumpENE,bitENE)\
\
+ + + + + \
\
dir(sq,jumpWSW,bitWSW) + + + dir(sq,jumpESE,bitESE)\
\
+dir(sq,jumpSSW,bitSSW) + dir(sq,jumpSSE,bitSSE))
// 8 bits per square representing which directions a king can step to
const unsigned char kingDirections[] = {
K(a1), K(a2), K(a3), K(a4), K(a5), K(a6), K(a7), K(a8),
K(b1), K(b2), K(b3), K(b4), K(b5), K(b6), K(b7), K(b8),
K(c1), K(c2), K(c3), K(c4), K(c5), K(c6), K(c7), K(c8),
K(d1), K(d2), K(d3), K(d4), K(d5), K(d6), K(d7), K(d8),
K(e1), K(e2), K(e3), K(e4), K(e5), K(e6), K(e7), K(e8),
K(f1), K(f2), K(f3), K(f4), K(f5), K(f6), K(f7), K(f8),
K(g1), K(g2), K(g3), K(g4), K(g5), K(g6), K(g7), K(g8),
K(h1), K(h2), K(h3), K(h4), K(h5), K(h6), K(h7), K(h8),
};
// 8 bits per square representing which directions a knight can jump to
static const unsigned char knightDirections[] = {
N(a1), N(a2), N(a3), N(a4), N(a5), N(a6), N(a7), N(a8),
N(b1), N(b2), N(b3), N(b4), N(b5), N(b6), N(b7), N(b8),
N(c1), N(c2), N(c3), N(c4), N(c5), N(c6), N(c7), N(c8),
N(d1), N(d2), N(d3), N(d4), N(d5), N(d6), N(d7), N(d8),
示例8: meminfo_read_proc
static int meminfo_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct sysinfo i;
int len;
int pg_size, committed;
/*
* display in kilobytes.
*/
#define K(x) ((x) << (PAGE_SHIFT - 10))
#define B(x) ((unsigned long long)(x) << PAGE_SHIFT)
si_meminfo(&i);
si_swapinfo(&i);
pg_size = atomic_read(&page_cache_size) - i.bufferram ;
committed = atomic_read(&vm_committed_space);
len = sprintf(page, " total: used: free: shared: buffers: cached:\n"
"Mem: %8Lu %8Lu %8Lu %8Lu %8Lu %8Lu\n"
"Swap: %8Lu %8Lu %8Lu\n",
B(i.totalram), B(i.totalram-i.freeram), B(i.freeram),
B(i.sharedram), B(i.bufferram),
B(pg_size), B(i.totalswap),
B(i.totalswap-i.freeswap), B(i.freeswap));
/*
* Tagged format, for easy grepping and expansion.
* The above will go away eventually, once the tools
* have been updated.
*/
len += sprintf(page+len,
"MemTotal: %8lu kB\n"
"MemFree: %8lu kB\n"
"MemShared: %8lu kB\n"
"Buffers: %8lu kB\n"
"Cached: %8lu kB\n"
"SwapCached: %8lu kB\n"
"Active: %8u kB\n"
"Inactive: %8u kB\n"
"HighTotal: %8lu kB\n"
"HighFree: %8lu kB\n"
"LowTotal: %8lu kB\n"
"LowFree: %8lu kB\n"
"SwapTotal: %8lu kB\n"
"SwapFree: %8lu kB\n"
"Committed_AS: %8u kB\n",
K(i.totalram),
K(i.freeram),
K(i.sharedram),
K(i.bufferram),
K(pg_size - swapper_space.nrpages),
K(swapper_space.nrpages),
K(nr_active_pages),
K(nr_inactive_pages),
K(i.totalhigh),
K(i.freehigh),
K(i.totalram-i.totalhigh),
K(i.freeram-i.freehigh),
K(i.totalswap),
K(i.freeswap),
K(committed));
return proc_calc_metrics(page, start, off, count, eof, len);
#undef B
#undef K
}
示例9: computeLineDistance
double BasicGeometry :: computeLineDistance(const FloatArray &iP1, const FloatArray &iP2, const FloatArray &iQ1, const FloatArray &iQ2)
{
FloatArray u;
u.beDifferenceOf(iP2, iP1);
const double LengthP = u.computeNorm();
FloatArray v;
v.beDifferenceOf(iQ2, iQ1);
const double LengthQ = v.computeNorm();
// Regularization coefficients (to make it possible to solve when lines are parallel)
const double c1 = (1.0e-14)*LengthP*LengthP;
const double c2 = (1.0e-14)*LengthQ*LengthQ;
const size_t minIter = 2;
const size_t maxIter = 5;
const double absTol = 1.0e-12;
double xi = 0.0, eta = 0.0;
FloatArray d;
d = iP1;
d.add(xi,u);
d.add(-1.0, iQ1);
d.add(-eta, v);
FloatMatrix K(2,2), KInv;
FloatArray dXi;
bool lockXi = false, lockEta = false;
for(size_t iter = 0; iter < maxIter; iter++) {
if(xi < 0.0) {
xi = 0.0;
lockXi = true;
}
if(xi > 1.0) {
xi = 1.0;
lockXi = true;
}
if(eta < 0.0) {
eta = 0.0;
lockEta = true;
}
if(eta > 1.0) {
eta = 1.0;
lockEta = true;
}
FloatArray R = { d.dotProduct(u) + c1*xi,
-d.dotProduct(v) + c2*eta};
if(lockXi) {
R[0] = 0.0;
}
if(lockEta) {
R[1] = 0.0;
}
const double res = R.computeNorm();
// printf("iter: %lu res: %e\n", iter, res);
if(res < absTol && iter >= minIter) {
// printf("xi: %e eta: %e\n", xi, eta);
break;
}
K(0,0) = -u.dotProduct(u)-c1;
K(0,1) = u.dotProduct(v);
K(1,0) = u.dotProduct(v);
K(1,1) = -v.dotProduct(v)-c2;
if(lockXi) {
K(0,0) = -1.0;
K(0,1) = K(1,0) = 0.0;
}
if(lockEta) {
K(0,1) = K(1,0) = 0.0;
K(1,1) = -1.0;
}
KInv.beInverseOf(K);
dXi.beProductOf(KInv, R);
xi += dXi[0];
eta += dXi[1];
d = iP1;
//.........这里部分代码省略.........
示例10: event_loop
void
event_loop(const int *quit)
{
/* TODO: refactor this function event_loop(). */
LOG_FUNC_ENTER;
const wchar_t *const prev_input_buf = curr_input_buf;
const size_t *const prev_input_buf_pos = curr_input_buf_pos;
wchar_t input_buf[128];
size_t input_buf_pos;
int last_result = 0;
int wait_for_enter = 0;
int wait_for_suggestion = 0;
int timeout = cfg.timeout_len;
input_buf[0] = L'\0';
input_buf_pos = 0;
curr_input_buf = &input_buf[0];
curr_input_buf_pos = &input_buf_pos;
/* Make sure to set the working directory once in order to have the
* desired state even before any events are processed. */
(void)vifm_chdir(flist_get_dir(curr_view));
while(!*quit)
{
wint_t c;
size_t counter;
int got_input;
lwin.user_selection = 1;
rwin.user_selection = 1;
modes_pre();
/* Waits for timeout then skips if no key press. Short-circuit if we're not
* waiting for the next key after timeout. */
do
{
const int actual_timeout = wait_for_suggestion
? MIN(timeout, cfg.sug.delay)
: timeout;
if(!ensure_term_is_ready())
{
wait_for_enter = 0;
continue;
}
modes_periodic();
bg_check();
got_input = (get_char_async_loop(status_bar, &c, actual_timeout) != ERR);
/* If suggestion delay timed out, reset it and wait the rest of the
* timeout. */
if(!got_input && wait_for_suggestion)
{
wait_for_suggestion = 0;
timeout -= actual_timeout;
display_suggestion_box(input_buf);
continue;
}
wait_for_suggestion = 0;
if(!got_input && (input_buf_pos == 0 || last_result == KEYS_WAIT))
{
timeout = cfg.timeout_len;
continue;
}
if(got_input && c == K(KEY_RESIZE))
{
modes_redraw();
continue;
}
break;
}
while(1);
suggestions_are_visible = 0;
/* Ensure that current working directory is set correctly (some pieces of
* code rely on this, e.g. %c macro in current directory). */
(void)vifm_chdir(flist_get_dir(curr_view));
if(got_input)
{
if(wait_for_enter)
{
wait_for_enter = 0;
curr_stats.save_msg = 0;
ui_sb_clear();
if(c == WC_CR)
{
//.........这里部分代码省略.........
示例11: bench_openmp
int bench_openmp(FILE *infile, int n, int m, int p,
C (*kernel)(R, int, const R *), R c, R eps_I, R eps_B)
{
fastsum_plan my_fastsum_plan;
int d, L, M;
int t, j;
R re, im;
R r_max = K(0.25) - my_fastsum_plan.eps_B / K(2.0);
ticks t0, t1;
R tt_total;
fscanf(infile, "%d %d %d", &d, &L, &M);
#ifdef _OPENMP
FFTW(import_wisdom_from_filename)("fastsum_benchomp_detail_threads.plan");
#else
FFTW(import_wisdom_from_filename)("fastsum_benchomp_detail_single.plan");
#endif
fastsum_init_guru(&my_fastsum_plan, d, L, M, kernel, &c, NEARFIELD_BOXES, n,
m, p, eps_I, eps_B);
#ifdef _OPENMP
FFTW(export_wisdom_to_filename)("fastsum_benchomp_detail_threads.plan");
#else
FFTW(export_wisdom_to_filename)("fastsum_benchomp_detail_single.plan");
#endif
for (j = 0; j < L; j++)
{
for (t = 0; t < d; t++)
{
R v;
fscanf(infile, __FR__, &v);
my_fastsum_plan.x[d * j + t] = v * r_max;
}
}
for (j = 0; j < L; j++)
{
fscanf(infile, __FR__ " " __FR__, &re, &im);
my_fastsum_plan.alpha[j] = re + II * im;
}
for (j = 0; j < M; j++)
{
for (t = 0; t < d; t++)
{
R v;
fscanf(infile, __FR__, &v);
my_fastsum_plan.y[d * j + t] = v * r_max;
}
}
/** precomputation */
t0 = getticks();
fastsum_precompute(&my_fastsum_plan);
/** fast computation */
fastsum_trafo(&my_fastsum_plan);
t1 = getticks();
tt_total = NFFT(elapsed_seconds)(t1, t0);
#ifndef MEASURE_TIME
my_fastsum_plan.MEASURE_TIME_t[0] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[1] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[2] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[3] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[4] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[5] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[6] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[7] = K(0.0);
my_fastsum_plan.mv1.MEASURE_TIME_t[0] = K(0.0);
my_fastsum_plan.mv1.MEASURE_TIME_t[2] = K(0.0);
my_fastsum_plan.mv2.MEASURE_TIME_t[0] = K(0.0);
my_fastsum_plan.mv2.MEASURE_TIME_t[2] = K(0.0);
#endif
#ifndef MEASURE_TIME_FFTW
my_fastsum_plan.mv1.MEASURE_TIME_t[1] = K(0.0);
my_fastsum_plan.mv2.MEASURE_TIME_t[1] = K(0.0);
#endif
printf(
"%.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ " %.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ "\n",
my_fastsum_plan.MEASURE_TIME_t[0], my_fastsum_plan.MEASURE_TIME_t[1],
my_fastsum_plan.MEASURE_TIME_t[2], my_fastsum_plan.MEASURE_TIME_t[3],
my_fastsum_plan.MEASURE_TIME_t[4], my_fastsum_plan.MEASURE_TIME_t[5],
my_fastsum_plan.MEASURE_TIME_t[6], my_fastsum_plan.MEASURE_TIME_t[7],
tt_total - my_fastsum_plan.MEASURE_TIME_t[0]
- my_fastsum_plan.MEASURE_TIME_t[1]
- my_fastsum_plan.MEASURE_TIME_t[2]
- my_fastsum_plan.MEASURE_TIME_t[3]
- my_fastsum_plan.MEASURE_TIME_t[4]
- my_fastsum_plan.MEASURE_TIME_t[5]
- my_fastsum_plan.MEASURE_TIME_t[6]
- my_fastsum_plan.MEASURE_TIME_t[7], tt_total,
my_fastsum_plan.mv1.MEASURE_TIME_t[0],
my_fastsum_plan.mv1.MEASURE_TIME_t[1],
my_fastsum_plan.mv1.MEASURE_TIME_t[2],
my_fastsum_plan.mv2.MEASURE_TIME_t[0],
//.........这里部分代码省略.........
示例12: get_char_async_loop
/* Sub-loop of the main loop that "asynchronously" queries for the input
* performing the following tasks while waiting for input:
* - checks for new IPC messages;
* - checks whether contents of displayed directories changed;
* - redraws UI if requested.
* Returns KEY_CODE_YES for functional keys (preprocesses *c in this case), OK
* for wide character and ERR otherwise (e.g. after timeout). */
static int
get_char_async_loop(WINDOW *win, wint_t *c, int timeout)
{
const int IPC_F = ipc_enabled() ? 10 : 1;
do
{
int i;
int delay_slice = DIV_ROUND_UP(MIN(cfg.min_timeout_len, timeout), IPC_F);
#ifdef __PDCURSES__
/* pdcurses performs delays in 50 ms intervals (1/20 of a second). */
delay_slice = MAX(50, delay_slice);
#endif
if(should_check_views_for_changes())
{
check_view_for_changes(curr_view);
check_view_for_changes(other_view);
}
process_scheduled_updates();
for(i = 0; i < IPC_F && timeout > 0; ++i)
{
int result;
ipc_check(curr_stats.ipc);
wtimeout(win, delay_slice);
timeout -= delay_slice;
if(suggestions_are_visible)
{
/* Redraw suggestion box as it might have been hidden due to other
* redraws. */
display_suggestion_box(curr_input_buf);
}
/* Update cursor before waiting for input. Modes set cursor correctly
* within corresponding windows, but we need to call refresh on one of
* them to make it active. */
update_hardware_cursor();
result = compat_wget_wch(win, c);
if(result != ERR)
{
if(result == KEY_CODE_YES)
{
*c = K(*c);
}
else if(*c == L'\0')
{
*c = WC_C_SPACE;
}
return result;
}
process_scheduled_updates();
}
}
while(timeout > 0);
return ERR;
}
示例13: D
const Matrix&
FourNodeQuad3d::getInitialStiff()
{
K.Zero();
double dvol;
double DB[3][2];
// Loop over the integration points
for (int i = 0; i < 4; i++) {
// Determine Jacobian for this integration point
dvol = this->shapeFunction(pts[i][0], pts[i][1]);
dvol *= (thickness*wts[i]);
// Get the material tangent
const Matrix &D = theMaterial[i]->getInitialTangent();
double D00 = D(0,0); double D01 = D(0,1); double D02 = D(0,2);
double D10 = D(1,0); double D11 = D(1,1); double D12 = D(1,2);
double D20 = D(2,0); double D21 = D(2,1); double D22 = D(2,2);
// Perform numerical integration
//K = K + (B^ D * B) * intWt(i)*intWt(j) * detJ;
//K.addMatrixTripleProduct(1.0, B, D, intWt(i)*intWt(j)*detJ);
/* **********************************************************************
for (int beta = 0, ib = 0, colIb =0, colIbP1 = 8;
beta < 4;
beta++, ib += 2, colIb += 16, colIbP1 += 16) {
for (int alpha = 0, ia = 0; alpha < 4; alpha++, ia += 2) {
DB[0][0] = dvol * (D00 * shp[0][beta] + D02 * shp[1][beta]);
DB[1][0] = dvol * (D10 * shp[0][beta] + D12 * shp[1][beta]);
DB[2][0] = dvol * (D20 * shp[0][beta] + D22 * shp[1][beta]);
DB[0][1] = dvol * (D01 * shp[1][beta] + D02 * shp[0][beta]);
DB[1][1] = dvol * (D11 * shp[1][beta] + D12 * shp[0][beta]);
DB[2][1] = dvol * (D21 * shp[1][beta] + D22 * shp[0][beta]);
K(ia,ib) += shp[0][alpha]*DB[0][0] + shp[1][alpha]*DB[2][0];
K(ia,ib+diff) += shp[0][alpha]*DB[0][1] + shp[1][alpha]*DB[2][1];
K(ia+diff,ib) += shp[1][alpha]*DB[1][0] + shp[0][alpha]*DB[2][0];
K(ia+diff,ib+diff) += shp[1][alpha]*DB[1][1] + shp[0][alpha]*DB[2][1];
matrixData[colIb + ia] += shp[0][alpha]*DB[0][0] + shp[1][alpha]*DB[2][0];
matrixData[colIbP1 + ia] += shp[0][alpha]*DB[0][1] + shp[1][alpha]*DB[2][1];
matrixData[colIb + ia+1] += shp[1][alpha]*DB[1][0] + shp[0][alpha]*DB[2][0];
matrixData[colIbP1 + ia+1] += shp[1][alpha]*DB[1][1] + shp[0][alpha]*DB[2][1];
}
}
}
Ki = new Matrix(K);
return K;
************************************************************************** */
int diff = dirn[1]-dirn[0];
for (int alpha = 0, ia = dirn[0]; alpha < 4; alpha++, ia += 3) {
for (int beta = 0, ib = dirn[0]; beta < 4; beta++, ib += 3) {
DB[0][0] = dvol * (D00 * shp[0][beta] + D02 * shp[1][beta]);
DB[1][0] = dvol * (D10 * shp[0][beta] + D12 * shp[1][beta]);
DB[2][0] = dvol * (D20 * shp[0][beta] + D22 * shp[1][beta]);
DB[0][1] = dvol * (D01 * shp[1][beta] + D02 * shp[0][beta]);
DB[1][1] = dvol * (D11 * shp[1][beta] + D12 * shp[0][beta]);
DB[2][1] = dvol * (D21 * shp[1][beta] + D22 * shp[0][beta]);
K(ia,ib) += shp[0][alpha]*DB[0][0] + shp[1][alpha]*DB[2][0];
K(ia,ib+diff) += shp[0][alpha]*DB[0][1] + shp[1][alpha]*DB[2][1];
K(ia+diff,ib) += shp[1][alpha]*DB[1][0] + shp[0][alpha]*DB[2][0];
K(ia+diff,ib+diff) += shp[1][alpha]*DB[1][1] + shp[0][alpha]*DB[2][1];
}
}
}
return K;
}
示例14: K_
void Image3D::GenNewViews(){
char fn[128];
static int no = 0;
Eigen::Matrix3d R, R_, K, K_, H;
Eigen::Vector3d t;
cam.GetK(K);
cam.GetRT(R, t);
double scale = 2.0;
double scale_ = 1.0 / scale, scale2_ = scale_ * scale_;
int w_ = cam.W(), w = w_ * scale;
int h_ = cam.H(), h = h_ * scale;
K_(0, 0) = 1.0 / K(0, 0); K_(0, 1) = 0.0; K_(0, 2) = -K(0, 2) / K(0, 0);
K_(1, 0) = 0.0; K_(1, 1) = 1.0 / K(1, 1); K_(1, 2) = -K(1, 2) / K(1, 1);
K_(2, 0) = 0.0; K_(2, 1) = 0.0; K_(2, 2) = 1.0;
//K_ = K.inverse();
//Eigen::Vector3d axis(R(axis, 0), R(axis, 1), R(axis, 2));
Eigen::Vector3d axis(R(ParamParser::axis, 0), R(ParamParser::axis, 1), R(ParamParser::axis, 2));
std::vector<double> angle;
for (int i = ParamParser::view_count / 2; i > 0; --i){ angle.push_back(-ParamParser::rot_angle * i); }
for (int i = 0; i <= ParamParser::view_count / 2; ++i){ angle.push_back(ParamParser::rot_angle * i); }
std::cout << "Generating views#: ";
for (int k = 0; k < ParamParser::view_count; ++k){
std::cout << k << " ";
std::vector<int> texIndex_(w_ * h_, -1);
cv::Mat img(h_, w_, CV_8UC3);
RotationMatrix(angle[k] / 180 * M_PI, axis, R_);
H = K * (R_ * K_);
std::vector<Eigen::Vector2d> xy(w * h);
double minu, minv, maxu, maxv;
minu = minv = 1000000000.0;
maxu = maxv = -1000000000.0;
for (int i = 0; i < w * h; ++i){
int u = i % w - w * scale2_;
int v = i / w - h * scale2_;
double wf = H(2, 0) * u + H(2, 1) * v + H(2, 2);
double uf = (H(0, 0) * u + H(0, 1) * v + H(0, 2)) / wf;
double vf = (H(1, 0) * u + H(1, 1) * v + H(1, 2)) / wf;
if (CheckRange(uf, vf, w_, h_)){
minu = min(minu, u + w * scale2_);
minv = min(minv, v + h * scale2_);
maxu = max(maxu, u + w * scale2_);
maxv = max(maxv, v + h * scale2_);
}
xy[i] = Eigen::Vector2d(uf, vf);
}
double centerx = (maxu + minu) * 0.5;
double centery = (maxv + minv) * 0.5;
double offsetx = centerx - w * scale2_;
double offsety = centery - h * scale2_;
for (int i = 0; i < w * h; ++i){
double uf = xy[i][0];
double vf = xy[i][1];
double u11 = floor(uf), v11 = floor(vf);
double u22 = ceil(uf), v22 = ceil(vf);
int u = int(i % w - offsetx + 0.5);
int v = int(i / w - offsety + 0.5);
if (CheckRange(u11, v11, w_, h_) && CheckRange(u22, v22, w_, h_) && CheckRange(u, v, w_, h_)){
if (fabs(u11 - u22) <= 1e-9 && fabs(v11 - v22) <= 1e-9){
img.at<cv::Vec3b>(v, u) = image.at<cv::Vec3b>(v11, u11);
texIndex_[v * w_ + u] = (v11 * w_ + u11);
}
else{
cv::Vec3b rgb11 = image.at<cv::Vec3b>(v11, u11);
cv::Vec3b rgb12 = image.at<cv::Vec3b>(v22, u11);
cv::Vec3b rgb21 = image.at<cv::Vec3b>(v11, u22);
cv::Vec3b rgb22 = image.at<cv::Vec3b>(v22, u22);
cv::Vec3b rgb;
if (fabs(u11 - u22) <= 1e-9){
double s1 = (vf - v11) / (v22 - v11);
double s2 = 1 - s1;
rgb[0] = uchar(rgb11[0] * s2 + rgb12[0] * s1);
rgb[1] = uchar(rgb11[1] * s2 + rgb12[1] * s1);
rgb[2] = uchar(rgb11[2] * s2 + rgb12[2] * s1);
}
else if (fabs(v11 - v22) <= 1e-9){
double s1 = (uf - u11) / (u22 - u11);
double s2 = 1 - s1;
rgb[0] = uchar(rgb11[0] * s2 + rgb21[0] * s1);
rgb[1] = uchar(rgb11[1] * s2 + rgb21[1] * s1);
rgb[2] = uchar(rgb11[2] * s2 + rgb21[2] * s1);
}
else{
double s1 = (u22 - uf) * (v22 - vf);
double s2 = (uf - u11) * (v22 - vf);
double s3 = (u22 - uf) * (vf - v11);
double s4 = (uf - u11) * (vf - v11);
rgb[0] = uchar(rgb11[0] * s1 + rgb21[0] * s2 + rgb12[0] * s3 + rgb22[0] * s4);
//.........这里部分代码省略.........
示例15: K
/*
* CAST-256 Key Schedule
*/
void CAST_256::key_schedule(const byte key[], size_t length)
{
static const u32bit KEY_MASK[192] = {
0x5A827999, 0xC95C653A, 0x383650DB, 0xA7103C7C, 0x15EA281D, 0x84C413BE,
0xF39DFF5F, 0x6277EB00, 0xD151D6A1, 0x402BC242, 0xAF05ADE3, 0x1DDF9984,
0x8CB98525, 0xFB9370C6, 0x6A6D5C67, 0xD9474808, 0x482133A9, 0xB6FB1F4A,
0x25D50AEB, 0x94AEF68C, 0x0388E22D, 0x7262CDCE, 0xE13CB96F, 0x5016A510,
0xBEF090B1, 0x2DCA7C52, 0x9CA467F3, 0x0B7E5394, 0x7A583F35, 0xE9322AD6,
0x580C1677, 0xC6E60218, 0x35BFEDB9, 0xA499D95A, 0x1373C4FB, 0x824DB09C,
0xF1279C3D, 0x600187DE, 0xCEDB737F, 0x3DB55F20, 0xAC8F4AC1, 0x1B693662,
0x8A432203, 0xF91D0DA4, 0x67F6F945, 0xD6D0E4E6, 0x45AAD087, 0xB484BC28,
0x235EA7C9, 0x9238936A, 0x01127F0B, 0x6FEC6AAC, 0xDEC6564D, 0x4DA041EE,
0xBC7A2D8F, 0x2B541930, 0x9A2E04D1, 0x0907F072, 0x77E1DC13, 0xE6BBC7B4,
0x5595B355, 0xC46F9EF6, 0x33498A97, 0xA2237638, 0x10FD61D9, 0x7FD74D7A,
0xEEB1391B, 0x5D8B24BC, 0xCC65105D, 0x3B3EFBFE, 0xAA18E79F, 0x18F2D340,
0x87CCBEE1, 0xF6A6AA82, 0x65809623, 0xD45A81C4, 0x43346D65, 0xB20E5906,
0x20E844A7, 0x8FC23048, 0xFE9C1BE9, 0x6D76078A, 0xDC4FF32B, 0x4B29DECC,
0xBA03CA6D, 0x28DDB60E, 0x97B7A1AF, 0x06918D50, 0x756B78F1, 0xE4456492,
0x531F5033, 0xC1F93BD4, 0x30D32775, 0x9FAD1316, 0x0E86FEB7, 0x7D60EA58,
0xEC3AD5F9, 0x5B14C19A, 0xC9EEAD3B, 0x38C898DC, 0xA7A2847D, 0x167C701E,
0x85565BBF, 0xF4304760, 0x630A3301, 0xD1E41EA2, 0x40BE0A43, 0xAF97F5E4,
0x1E71E185, 0x8D4BCD26, 0xFC25B8C7, 0x6AFFA468, 0xD9D99009, 0x48B37BAA,
0xB78D674B, 0x266752EC, 0x95413E8D, 0x041B2A2E, 0x72F515CF, 0xE1CF0170,
0x50A8ED11, 0xBF82D8B2, 0x2E5CC453, 0x9D36AFF4, 0x0C109B95, 0x7AEA8736,
0xE9C472D7, 0x589E5E78, 0xC7784A19, 0x365235BA, 0xA52C215B, 0x14060CFC,
0x82DFF89D, 0xF1B9E43E, 0x6093CFDF, 0xCF6DBB80, 0x3E47A721, 0xAD2192C2,
0x1BFB7E63, 0x8AD56A04, 0xF9AF55A5, 0x68894146, 0xD7632CE7, 0x463D1888,
0xB5170429, 0x23F0EFCA, 0x92CADB6B, 0x01A4C70C, 0x707EB2AD, 0xDF589E4E,
0x4E3289EF, 0xBD0C7590, 0x2BE66131, 0x9AC04CD2, 0x099A3873, 0x78742414,
0xE74E0FB5, 0x5627FB56, 0xC501E6F7, 0x33DBD298, 0xA2B5BE39, 0x118FA9DA,
0x8069957B, 0xEF43811C, 0x5E1D6CBD, 0xCCF7585E, 0x3BD143FF, 0xAAAB2FA0,
0x19851B41, 0x885F06E2, 0xF738F283, 0x6612DE24, 0xD4ECC9C5, 0x43C6B566,
0xB2A0A107, 0x217A8CA8, 0x90547849, 0xFF2E63EA, 0x6E084F8B, 0xDCE23B2C,
0x4BBC26CD, 0xBA96126E, 0x296FFE0F, 0x9849E9B0, 0x0723D551, 0x75FDC0F2,
0xE4D7AC93, 0x53B19834, 0xC28B83D5, 0x31656F76, 0xA03F5B17, 0x0F1946B8 };
static const byte KEY_ROT[32] = {
0x13, 0x04, 0x15, 0x06, 0x17, 0x08, 0x19, 0x0A, 0x1B, 0x0C,
0x1D, 0x0E, 0x1F, 0x10, 0x01, 0x12, 0x03, 0x14, 0x05, 0x16,
0x07, 0x18, 0x09, 0x1A, 0x0B, 0x1C, 0x0D, 0x1E, 0x0F, 0x00,
0x11, 0x02 };
m_MK.resize(48);
m_RK.resize(48);
secure_vector<u32bit> K(8);
for(size_t i = 0; i != length; ++i)
K[i/4] = (K[i/4] << 8) + key[i];
u32bit A = K[0], B = K[1], C = K[2], D = K[3],
E = K[4], F = K[5], G = K[6], H = K[7];
for(size_t i = 0; i != 48; i += 4)
{
round1(G, H, KEY_MASK[4*i+ 0], KEY_ROT[(4*i+ 0) % 32]);
round2(F, G, KEY_MASK[4*i+ 1], KEY_ROT[(4*i+ 1) % 32]);
round3(E, F, KEY_MASK[4*i+ 2], KEY_ROT[(4*i+ 2) % 32]);
round1(D, E, KEY_MASK[4*i+ 3], KEY_ROT[(4*i+ 3) % 32]);
round2(C, D, KEY_MASK[4*i+ 4], KEY_ROT[(4*i+ 4) % 32]);
round3(B, C, KEY_MASK[4*i+ 5], KEY_ROT[(4*i+ 5) % 32]);
round1(A, B, KEY_MASK[4*i+ 6], KEY_ROT[(4*i+ 6) % 32]);
round2(H, A, KEY_MASK[4*i+ 7], KEY_ROT[(4*i+ 7) % 32]);
round1(G, H, KEY_MASK[4*i+ 8], KEY_ROT[(4*i+ 8) % 32]);
round2(F, G, KEY_MASK[4*i+ 9], KEY_ROT[(4*i+ 9) % 32]);
round3(E, F, KEY_MASK[4*i+10], KEY_ROT[(4*i+10) % 32]);
round1(D, E, KEY_MASK[4*i+11], KEY_ROT[(4*i+11) % 32]);
round2(C, D, KEY_MASK[4*i+12], KEY_ROT[(4*i+12) % 32]);
round3(B, C, KEY_MASK[4*i+13], KEY_ROT[(4*i+13) % 32]);
round1(A, B, KEY_MASK[4*i+14], KEY_ROT[(4*i+14) % 32]);
round2(H, A, KEY_MASK[4*i+15], KEY_ROT[(4*i+15) % 32]);
m_RK[i ] = (A % 32);
m_RK[i+1] = (C % 32);
m_RK[i+2] = (E % 32);
m_RK[i+3] = (G % 32);
m_MK[i ] = H;
m_MK[i+1] = F;
m_MK[i+2] = D;
m_MK[i+3] = B;
}
}