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(); }
/** * @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; }
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(); CLOSE_ARRAY() << "\n"; } if ( redFsm->anyEofActions() ) { OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), EA() ); EOF_ACTIONS(); CLOSE_ARRAY() << "\n"; } if ( redFsm->anyEofTrans() ) { OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() ); EOF_TRANS(); CLOSE_ARRAY() << "\n"; } STATE_IDS(); }
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; fscanf(fid2, __FR__, &temp); my_fastsum_plan.alpha[k] += temp * II; } fclose(fid1); fclose(fid2); /** load target knots */ fid1 = fopen("y.dat", "r"); for (j = 0; j < M; j++) { for (t = 0; t < d; t++) { fscanf(fid1, __FR__, &my_fastsum_plan.y[j * d + t]); } } fclose(fid1); /** direct computation */ printf("direct computation: "); fflush(NULL); t0 = getticks(); fastsum_exact(&my_fastsum_plan); t1 = getticks(); time = NFFT(elapsed_seconds)(t1, t0); printf(__FI__ "sec\n", time); /** copy result */ direct = (C *) NFFT(malloc)((size_t)(my_fastsum_plan.M_total) * (sizeof(C))); for (j = 0; j < my_fastsum_plan.M_total; j++) direct[j] = my_fastsum_plan.f[j]; /** precomputation */ printf("pre-computation: "); fflush(NULL); t0 = getticks(); fastsum_precompute(&my_fastsum_plan); t1 = getticks(); time = NFFT(elapsed_seconds)(t1, t0); printf(__FI__ "sec\n", time); /** fast computation */ printf("fast computation: "); fflush(NULL); t0 = getticks(); fastsum_trafo(&my_fastsum_plan); t1 = getticks(); time = NFFT(elapsed_seconds)(t1, t0); printf(__FI__ "sec\n", time); /** compute max error */ error = K(0.0); for (j = 0; j < my_fastsum_plan.M_total; j++) { if (CABS(direct[j] - my_fastsum_plan.f[j]) / CABS(direct[j]) > error) error = CABS(direct[j] - my_fastsum_plan.f[j]) / CABS(direct[j]); } printf("max relative error: " __FE__ "\n", error); /** write result to file */ fid1 = fopen("f.dat", "w+"); fid2 = fopen("f_direct.dat", "w+"); if (fid1 == NULL) { printf("Fehler!\n"); exit(EXIT_FAILURE); } for (j = 0; j < M; j++) { temp = CREAL(my_fastsum_plan.f[j]); fprintf(fid1, " % .16" __FES__ "", temp); temp = CIMAG(my_fastsum_plan.f[j]); fprintf(fid1, " % .16" __FES__ "\n", temp); temp = CREAL(direct[j]); fprintf(fid2, " % .16" __FES__ "", temp); temp = CIMAG(direct[j]); fprintf(fid2, " % .16" __FES__ "\n", temp); } fclose(fid1); fclose(fid2); /** finalise the plan */ fastsum_finalize(&my_fastsum_plan); return EXIT_SUCCESS; }
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); tmpvertex[LC+9].s=.984375; tmpvertex[LC+9].t=.984375; tmpvertex[LC+10].SetVertex(GetConstVertex(tmpvertex[LC+10])+J-K); tmpvertex[LC+10].s=.984375; tmpvertex[LC+10].t=.015625; tmpvertex[LC+11].SetVertex(GetConstVertex(tmpvertex[LC+11])-J-K); tmpvertex[LC+11].s=.015625; tmpvertex[LC+11].t=.015625; } } { int start=0; int inc = num/NUM_ACTIVE_ANIMATIONS; inc-=inc%numVerticesPer; for (int i=0; i<NUM_ACTIVE_ANIMATIONS; ++i,start+=inc) { int later=start+inc; if (i==NUM_ACTIVE_ANIMATIONS-1) later=num; vlist[i]= new GFXVertexList (GFXQUAD,later-start,tmpvertex+start, later-start, true,0); } } delete []tmpvertex; }
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 K(i.totalhigh), K(i.freehigh), K(i.totalram-i.totalhigh), K(i.freeram-i.freehigh), #endif #ifndef CONFIG_MMU K((unsigned long) atomic_long_read(&mmap_pages_allocated)), #endif K(i.totalswap), K(i.freeswap), K(global_page_state(NR_FILE_DIRTY)), K(global_page_state(NR_WRITEBACK)), K(global_page_state(NR_ANON_PAGES) #ifdef CONFIG_TRANSPARENT_HUGEPAGE + global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR #endif ), K(global_page_state(NR_FILE_MAPPED)), K(global_page_state(NR_SHMEM)), K(global_page_state(NR_SLAB_RECLAIMABLE) + global_page_state(NR_SLAB_UNRECLAIMABLE)), K(global_page_state(NR_SLAB_RECLAIMABLE)), K(global_page_state(NR_SLAB_UNRECLAIMABLE)), global_page_state(NR_KERNEL_STACK) * THREAD_SIZE / 1024, K(global_page_state(NR_PAGETABLE)), #ifdef CONFIG_QUICKLIST K(quicklist_total_size()), #endif K(global_page_state(NR_UNSTABLE_NFS)), K(global_page_state(NR_BOUNCE)), K(global_page_state(NR_WRITEBACK_TEMP)), K(allowed), K(committed), (unsigned long)VMALLOC_TOTAL >> 10, vmi.used >> 10, vmi.largest_chunk >> 10 #ifdef CONFIG_MEMORY_FAILURE ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10) #endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR) #endif ); hugetlb_report_meminfo(m); arch_report_meminfo(m); return 0; #undef K }
// 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),
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 }
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; d.add(xi,u); d.add(-1.0, iQ1); d.add(-eta, v); } if(xi < 0.0) { xi = 0.0; } if(xi > 1.0) { xi = 1.0; } if(eta < 0.0) { eta = 0.0; } if(eta > 1.0) { eta = 1.0; } d = iP1; d.add(xi,u); d.add(-1.0, iQ1); d.add(-eta, v); const double dist = d.computeNorm(); return dist; }
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) { continue; } } if(c == WC_C_z) { ui_shutdown(); stop_process(); continue; } if(input_buf_pos < ARRAY_LEN(input_buf) - 2) { input_buf[input_buf_pos++] = c; input_buf[input_buf_pos] = L'\0'; } else { /* Recover from input buffer overflow by resetting its contents. */ reset_input_buf(input_buf, &input_buf_pos); clear_input_bar(); continue; } } counter = vle_keys_counter(); if(!got_input && last_result == KEYS_WAIT_SHORT) { hide_suggestion_box(); last_result = vle_keys_exec_timed_out(input_buf); counter = vle_keys_counter() - counter; assert(counter <= input_buf_pos); if(counter > 0) { memmove(input_buf, input_buf + counter, (wcslen(input_buf) - counter + 1)*sizeof(wchar_t)); } } else { if(got_input) { curr_stats.save_msg = 0; } if(last_result == KEYS_WAIT || last_result == KEYS_WAIT_SHORT) { hide_suggestion_box(); } last_result = vle_keys_exec(input_buf); counter = vle_keys_counter() - counter; assert(counter <= input_buf_pos); if(counter > 0) { input_buf_pos -= counter; memmove(input_buf, input_buf + counter, (wcslen(input_buf) - counter + 1)*sizeof(wchar_t)); } if(last_result == KEYS_WAIT || last_result == KEYS_WAIT_SHORT) { if(should_display_suggestion_box()) { wait_for_suggestion = 1; } if(got_input) { modupd_input_bar(input_buf); } if(last_result == KEYS_WAIT_SHORT && wcscmp(input_buf, L"\033") == 0) { timeout = 1; } if(counter > 0) { clear_input_bar(); } if(!curr_stats.save_msg && curr_view->selected_files && !vle_mode_is(CMDLINE_MODE)) { print_selected_msg(); } continue; } } timeout = cfg.timeout_len; process_scheduled_updates(); reset_input_buf(input_buf, &input_buf_pos); clear_input_bar(); if(ui_sb_multiline()) { wait_for_enter = 1; update_all_windows(); continue; } /* Ensure that current working directory is set correctly (some pieces of * code rely on this). PWD could be changed during command execution, but * it should be correct for modes_post() in case of preview modes. */ (void)vifm_chdir(flist_get_dir(curr_view)); modes_post(); } curr_input_buf = prev_input_buf; curr_input_buf_pos = prev_input_buf_pos; }
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], my_fastsum_plan.mv2.MEASURE_TIME_t[1], my_fastsum_plan.mv2.MEASURE_TIME_t[2]); fastsum_finalize(&my_fastsum_plan); return 0; }
/* 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; }
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; }
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); rgb[1] = uchar(rgb11[1] * s1 + rgb21[1] * s2 + rgb12[1] * s3 + rgb22[1] * s4); rgb[2] = uchar(rgb11[2] * s1 + rgb21[2] * s2 + rgb12[2] * s3 + rgb22[2] * s4); } img.at<cv::Vec3b>(v, u) = rgb; texIndex_[v * w_ + u] = (int(vf + 0.5) * w_ + int(uf + 0.5)); } } } texIndex.push_back(texIndex_); sprintf_s(fn, "%s/proj%d_%d.jpg", path.c_str(), frmNo, k); cv::imwrite(fn, img); } std::cout << std::endl; }
/* * 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; } }
QString Fixture::status() const { QString info; QString t; QString title("<TR><TD CLASS='hilite' COLSPAN='3'>%1</TD></TR>"); QString subTitle("<TR><TD CLASS='subhi' COLSPAN='3'>%1</TD></TR>"); QString genInfo("<TR><TD CLASS='emphasis'>%1</TD><TD COLSPAN='2'>%2</TD></TR>"); /******************************************************************** * General info ********************************************************************/ info += "<TABLE COLS='3' WIDTH='100%'>"; // Fixture title info += title.arg(name()); // Manufacturer if (isDimmer() == false) { info += genInfo.arg(tr("Manufacturer")).arg(m_fixtureDef->manufacturer()); info += genInfo.arg(tr("Model")).arg(m_fixtureDef->model()); info += genInfo.arg(tr("Mode")).arg(m_fixtureMode->name()); info += genInfo.arg(tr("Type")).arg(m_fixtureDef->type()); } else { info += genInfo.arg(tr("Type")).arg(tr("Generic Dimmer")); } // Universe info += genInfo.arg(tr("Universe")).arg(universe() + 1); // Address QString range = QString("%1 - %2").arg(address() + 1).arg(address() + channels()); info += genInfo.arg(tr("Address Range")).arg(range); // Channels info += genInfo.arg(tr("Channels")).arg(channels()); // Binary address QString binaryStr = QString("%1").arg(address() + 1, 10, 2, QChar('0')); QString dipTable("<TABLE COLS='33' cellspacing='0'><TR><TD COLSPAN='33'><IMG SRC=\"" ":/ds_top.png\"></TD></TR>"); dipTable += "<TR><TD><IMG SRC=\"" ":/ds_border.png\"></TD><TD><IMG SRC=\"" ":/ds_border.png\"></TD>"; for (int i = 9; i >= 0; i--) { if (binaryStr.at(i) == '0') dipTable += "<TD COLSPAN='3'><IMG SRC=\"" ":/ds_off.png\"></TD>"; else dipTable += "<TD COLSPAN='3'><IMG SRC=\"" ":/ds_on.png\"></TD>"; } dipTable += "<TD><IMG SRC=\"" ":/ds_border.png\"></TD></TR>"; dipTable += "<TR><TD COLSPAN='33'><IMG SRC=\"" ":/ds_bottom.png\"></TD></TR>"; dipTable += "</TABLE>"; info += genInfo.arg(tr("Binary Address (DIP)")) .arg(QString("%1").arg(dipTable)); /******************************************************************** * Channels ********************************************************************/ // Title row info += QString("<TR><TD CLASS='subhi'>%1</TD>").arg(tr("Channel")); info += QString("<TD CLASS='subhi'>%1</TD>").arg(tr("DMX")); info += QString("<TD CLASS='subhi'>%1</TD></TR>").arg(tr("Name")); // Fill table with the fixture's channels for (quint32 ch = 0; ch < channels(); ch++) { QString chInfo("<TR><TD>%1</TD><TD>%2</TD><TD>%3</TD></TR>"); info += chInfo.arg(ch + 1).arg(address() + ch + 1) .arg(channel(ch)->name()); } /******************************************************************** * Extended device information for non-dimmers ********************************************************************/ if (isDimmer() == false) { QLCPhysical physical = m_fixtureMode->physical(); info += title.arg(tr("Physical")); float mmInch = 0.0393700787; float kgLbs = 2.20462262; QString mm("%1mm (%2\")"); QString kg("%1kg (%2 lbs)"); QString W("%1W"); info += genInfo.arg(tr("Width")).arg(mm.arg(physical.width())) .arg(physical.width() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Height")).arg(mm.arg(physical.height())) .arg(physical.height() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Depth")).arg(mm.arg(physical.depth())) .arg(physical.depth() * mmInch, 0, 'g', 4); info += genInfo.arg(tr("Weight")).arg(kg.arg(physical.weight())) .arg(physical.weight() * kgLbs, 0, 'g', 4); info += genInfo.arg(tr("Power consumption")).arg(W.arg(physical.powerConsumption())); info += genInfo.arg(tr("DMX Connector")).arg(physical.dmxConnector()); // Bulb QString K("%1K"); QString lm("%1lm"); info += subTitle.arg(tr("Bulb")); info += genInfo.arg(tr("Type")).arg(physical.bulbType()); info += genInfo.arg(tr("Luminous Flux")).arg(lm.arg(physical.bulbLumens())); info += genInfo.arg(tr("Colour Temperature")).arg(K.arg(physical.bulbColourTemperature())); // Lens QString angle1("%1°"); QString angle2("%1° – %2°"); info += subTitle.arg(tr("Lens")); info += genInfo.arg(tr("Name")).arg(physical.lensName()); if (physical.lensDegreesMin() == physical.lensDegreesMax()) { info += genInfo.arg(tr("Beam Angle")) .arg(angle1.arg(physical.lensDegreesMin())); } else { info += genInfo.arg(tr("Beam Angle")) .arg(angle2.arg(physical.lensDegreesMin()) .arg(physical.lensDegreesMax())); } // Focus QString range("%1°"); info += subTitle.arg(tr("Focus")); info += genInfo.arg(tr("Type")).arg(physical.focusType()); info += genInfo.arg(tr("Pan Range")).arg(range.arg(physical.focusPanMax())); info += genInfo.arg(tr("Tilt Range")).arg(range.arg(physical.focusTiltMax())); } // HTML document & table closure info += "</TABLE>"; if (isDimmer() == false) { info += "<HR>"; info += "<DIV CLASS='author' ALIGN='right'>"; info += tr("Fixture definition author: ") + fixtureDef()->author(); info += "</DIV>"; } return info; }
inline TR sysperm(const T1& rho1, const arma::uvec& sys, const arma::uvec& dim) { const auto& p = as_Mat(rho1); const arma::uword n = dim.n_elem; bool checkV = true; if (p.n_cols == 1) checkV = false; #ifndef QICLIB_NO_DEBUG if (p.n_elem == 0) throw Exception("qic::sysperm", Exception::type::ZERO_SIZE); if (checkV) if (p.n_rows != p.n_cols) throw Exception("qic::sysperm", Exception::type::MATRIX_NOT_SQUARE_OR_CVECTOR); if (dim.n_elem == 0 || arma::any(dim == 0)) throw Exception("qic::sysperm", Exception::type::INVALID_DIMS); if (arma::prod(dim) != p.n_rows) throw Exception("qic::sysperm", Exception::type::DIMS_MISMATCH_MATRIX); if (n != sys.n_elem || arma::any(sys == 0) || arma::any(sys > n) || sys.n_elem != arma::unique(sys).eval().n_elem) throw Exception("qic::sysperm", Exception::type::PERM_INVALID); #endif arma::uword product[_internal::MAXQDIT]; product[n-1] = 1; for (arma::sword i = n - 2; i >= 0; --i) product[i] = product[i + 1] * dim.at(i + 1); arma::uword productr[_internal::MAXQDIT]; productr[n-1] = 1; for (arma::sword i = n - 2; i >= 0; --i) productr[i] = productr[i + 1] * dim.at(sys.at(i + 1) - 1); if (checkV) { arma::Mat<trait::eT<T1> > p_r(p.n_rows, p.n_cols, arma::fill::zeros); const arma::uword loop_no = 2 * n; constexpr auto loop_no_buffer = 2 * _internal::MAXQDIT + 1; arma::uword loop_counter[loop_no_buffer] = {0}; arma::uword MAX[loop_no_buffer]; for (arma::uword i = 0; i < n; ++i) { MAX[i] = dim.at(i); MAX[i + n] = dim.at(i); } MAX[loop_no] = 2; arma::uword p1 = 0; while (loop_counter[loop_no] == 0) { arma::uword I(0), J(0), K(0), L(0); for (arma::uword i = 0; i < n; ++i) { I += product[i] * loop_counter[i]; J += product[i] * loop_counter[i + n]; K += productr[i] * loop_counter[sys.at(i) - 1]; L += productr[i] * loop_counter[sys.at(i) + n - 1]; } p_r.at(K, L) = p.at(I, J); ++loop_counter[0]; while (loop_counter[p1] == MAX[p1]) { loop_counter[p1] = 0; loop_counter[++p1]++; if (loop_counter[p1] != MAX[p1]) p1 = 0; } } return p_r; } else { arma::Col<trait::eT<T1> > p_r(p.n_rows, arma::fill::zeros); const arma::uword loop_no = n; constexpr auto loop_no_buffer = _internal::MAXQDIT + 1; arma::uword loop_counter[loop_no_buffer] = {0}; arma::uword MAX[loop_no_buffer]; for (arma::uword i = 0; i < n; ++i) MAX[i] = dim.at(i); MAX[loop_no] = 2; for (arma::uword i = 0; i < loop_no + 1; ++i) loop_counter[i] = 0; arma::uword p1 = 0; while (loop_counter[loop_no] == 0) { arma::uword I(0), K(0); for (arma::uword i = 0; i < n; ++i) { I += product[i] * loop_counter[i]; K += productr[i] * loop_counter[sys.at(i) - 1]; } p_r.at(K) = p.at(I); ++loop_counter[0]; while (loop_counter[p1] == MAX[p1]) { loop_counter[p1] = 0; loop_counter[++p1]++; if (loop_counter[p1] != MAX[p1]) p1 = 0; } } return p_r; } }
static void sha1_step(struct sha1_ctxt * ctxt) { uint32 a, b, c, d, e; size_t t, s; uint32 tmp; #if BYTE_ORDER == LITTLE_ENDIAN struct sha1_ctxt tctxt; memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64); ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2]; ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[3] = tctxt.m.b8[0]; ctxt->m.b8[4] = tctxt.m.b8[7]; ctxt->m.b8[5] = tctxt.m.b8[6]; ctxt->m.b8[6] = tctxt.m.b8[5]; ctxt->m.b8[7] = tctxt.m.b8[4]; ctxt->m.b8[8] = tctxt.m.b8[11]; ctxt->m.b8[9] = tctxt.m.b8[10]; ctxt->m.b8[10] = tctxt.m.b8[9]; ctxt->m.b8[11] = tctxt.m.b8[8]; ctxt->m.b8[12] = tctxt.m.b8[15]; ctxt->m.b8[13] = tctxt.m.b8[14]; ctxt->m.b8[14] = tctxt.m.b8[13]; ctxt->m.b8[15] = tctxt.m.b8[12]; ctxt->m.b8[16] = tctxt.m.b8[19]; ctxt->m.b8[17] = tctxt.m.b8[18]; ctxt->m.b8[18] = tctxt.m.b8[17]; ctxt->m.b8[19] = tctxt.m.b8[16]; ctxt->m.b8[20] = tctxt.m.b8[23]; ctxt->m.b8[21] = tctxt.m.b8[22]; ctxt->m.b8[22] = tctxt.m.b8[21]; ctxt->m.b8[23] = tctxt.m.b8[20]; ctxt->m.b8[24] = tctxt.m.b8[27]; ctxt->m.b8[25] = tctxt.m.b8[26]; ctxt->m.b8[26] = tctxt.m.b8[25]; ctxt->m.b8[27] = tctxt.m.b8[24]; ctxt->m.b8[28] = tctxt.m.b8[31]; ctxt->m.b8[29] = tctxt.m.b8[30]; ctxt->m.b8[30] = tctxt.m.b8[29]; ctxt->m.b8[31] = tctxt.m.b8[28]; ctxt->m.b8[32] = tctxt.m.b8[35]; ctxt->m.b8[33] = tctxt.m.b8[34]; ctxt->m.b8[34] = tctxt.m.b8[33]; ctxt->m.b8[35] = tctxt.m.b8[32]; ctxt->m.b8[36] = tctxt.m.b8[39]; ctxt->m.b8[37] = tctxt.m.b8[38]; ctxt->m.b8[38] = tctxt.m.b8[37]; ctxt->m.b8[39] = tctxt.m.b8[36]; ctxt->m.b8[40] = tctxt.m.b8[43]; ctxt->m.b8[41] = tctxt.m.b8[42]; ctxt->m.b8[42] = tctxt.m.b8[41]; ctxt->m.b8[43] = tctxt.m.b8[40]; ctxt->m.b8[44] = tctxt.m.b8[47]; ctxt->m.b8[45] = tctxt.m.b8[46]; ctxt->m.b8[46] = tctxt.m.b8[45]; ctxt->m.b8[47] = tctxt.m.b8[44]; ctxt->m.b8[48] = tctxt.m.b8[51]; ctxt->m.b8[49] = tctxt.m.b8[50]; ctxt->m.b8[50] = tctxt.m.b8[49]; ctxt->m.b8[51] = tctxt.m.b8[48]; ctxt->m.b8[52] = tctxt.m.b8[55]; ctxt->m.b8[53] = tctxt.m.b8[54]; ctxt->m.b8[54] = tctxt.m.b8[53]; ctxt->m.b8[55] = tctxt.m.b8[52]; ctxt->m.b8[56] = tctxt.m.b8[59]; ctxt->m.b8[57] = tctxt.m.b8[58]; ctxt->m.b8[58] = tctxt.m.b8[57]; ctxt->m.b8[59] = tctxt.m.b8[56]; ctxt->m.b8[60] = tctxt.m.b8[63]; ctxt->m.b8[61] = tctxt.m.b8[62]; ctxt->m.b8[62] = tctxt.m.b8[61]; ctxt->m.b8[63] = tctxt.m.b8[60]; #endif a = H(0); b = H(1); c = H(2); d = H(3); e = H(4); for (t = 0; t < 20; t++) { s = t & 0x0f; if (t >= 16) W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 20; t < 40; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 40; t < 60; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 60; t < 80; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } H(0) = H(0) + a; H(1) = H(1) + b; H(2) = H(2) + c; H(3) = H(3) + d; H(4) = H(4) + e; memset(&ctxt->m.b8[0], 0, 64); }
static void simple_test_nfsft(void) { const int N = 4; /* bandwidth/maximum degree */ const int M = 8; /* number of nodes */ nfsft_plan plan; /* transform plan */ int j, k, n; /* loop variables */ /* precomputation (for fast polynomial transform) */ nfsft_precompute(N,1000.0,0U,0U); /* Initialize transform plan using the guru interface. All input and output * arrays are allocated by nfsft_init_guru(). Computations are performed with * respect to L^2-normalized spherical harmonics Y_k^n. The array of spherical * Fourier coefficients is preserved during transformations. The NFFT uses a * cut-off parameter m = 6. See the NFFT 3 manual for details. */ nfsft_init_guru(&plan, N, M, NFSFT_MALLOC_X | NFSFT_MALLOC_F | NFSFT_MALLOC_F_HAT | NFSFT_NORMALIZED | NFSFT_PRESERVE_F_HAT, PRE_PHI_HUT | PRE_PSI | FFTW_INIT | FFT_OUT_OF_PLACE, 6); /* pseudo-random nodes */ for (j = 0; j < plan.M_total; j++) { plan.x[2*j]= nfft_drand48() - K(0.5); plan.x[2*j+1]= K(0.5) * nfft_drand48(); } /* precomputation (for NFFT, node-dependent) */ nfsft_precompute_x(&plan); /* pseudo-random Fourier coefficients */ for (k = 0; k <= plan.N; k++) for (n = -k; n <= k; n++) plan.f_hat[NFSFT_INDEX(k,n,&plan)] = nfft_drand48() - K(0.5) + _Complex_I*(nfft_drand48() - K(0.5)); /* Direct transformation, display result. */ nfsft_trafo_direct(&plan); printf("Vector f (NDSFT):\n"); for (j = 0; j < plan.M_total; j++) printf("f[%+2d] = %+5.3" __FES__ " %+5.3" __FES__ "*I\n",j, creal(plan.f[j]), cimag(plan.f[j])); printf("\n"); /* Fast approximate transformation, display result. */ nfsft_trafo(&plan); printf("Vector f (NFSFT):\n"); for (j = 0; j < plan.M_total; j++) printf("f[%+2d] = %+5.3" __FES__ " %+5.3" __FES__ "*I\n",j, creal(plan.f[j]), cimag(plan.f[j])); printf("\n"); /* Direct adjoint transformation, display result. */ nfsft_adjoint_direct(&plan); printf("Vector f_hat (NDSFT):\n"); for (k = 0; k <= plan.N; k++) for (n = -k; n <= k; n++) fprintf(stdout,"f_hat[%+2d,%+2d] = %+5.3" __FES__ " %+5.3" __FES__ "*I\n",k,n, creal(plan.f_hat[NFSFT_INDEX(k,n,&plan)]), cimag(plan.f_hat[NFSFT_INDEX(k,n,&plan)])); printf("\n"); /* Fast approximate adjoint transformation, display result. */ nfsft_adjoint(&plan); printf("Vector f_hat (NFSFT):\n"); for (k = 0; k <= plan.N; k++) { for (n = -k; n <= k; n++) { fprintf(stdout,"f_hat[%+2d,%+2d] = %+5.3" __FES__ " %+5.3" __FES__ "*I\n",k,n, creal(plan.f_hat[NFSFT_INDEX(k,n,&plan)]), cimag(plan.f_hat[NFSFT_INDEX(k,n,&plan)])); } } /* Finalize the plan. */ nfsft_finalize(&plan); /* Destroy data precomputed for fast polynomial transform. */ nfsft_forget(); }
/** * The optimal community structure is a subdivision of the network into * nonoverlapping groups of nodes in a way that maximizes the number of * within-group edges, and minimizes the number of between-group edges. * The modularity is a statistic that quantifies the degree to which the * network may be subdivided into such clearly delineated groups. * * The Louvain algorithm is a fast and accurate community detection * algorithm (as of writing). The algorithm may also be used to detect * hierarchical community structure. * * Input: W undirected (weighted or binary) connection matrix. * gamma, modularity resolution parameter (optional) * gamma>1 detects smaller modules * 0<=gamma<1 detects larger modules * gamma=1 (default) classic modularity * * Outputs: Ci, community structure * Q, modularity * Note: Ci and Q may vary from run to run, due to heuristics in the * algorithm. Consequently, it may be worth to compare multiple runs. * * Reference: Blondel et al. (2008) J. Stat. Mech. P10008. * Reichardt and Bornholdt (2006) Phys Rev E 74:016110. */ urowvec Connectome::modularity_louvain(mat W, double *Qopt, double gamma) { uint N = W.n_rows, h = 1, n = N, u =0, ma =0, mb =0; double s = accu(W), wm = 0, max_dQ = -1; uvec M, t; rowvec dQ; field<urowvec> Ci(20); Ci(0) = urowvec(); Ci(1) = linspace<urowvec>(0,n-1,n); rowvec Q = "-1,0"; while (Q(h)-Q(h-1) > 1e-10) { rowvec K = sum(W,0), Km = K; mat Knm = W; M = linspace<uvec>(0,n-1,n); bool flag = true; while (flag) { flag = false; arma_rng::set_seed_random(); t = shuffle(linspace<uvec>(0,n-1,n)); for (uint i =0;i<n;++i) { u = t(i); ma = M(u); dQ = Knm.row(u) - Knm(u,ma)+W(u,u)- gamma*K(u)*(Km-Km(ma)+K(u))/s; dQ(ma) = 0; max_dQ = dQ.max(); mb = as_scalar(find(dQ == max_dQ,1)); if (max_dQ > 1e-10) { flag = true; M(u) = mb; Knm.col(mb) += W.col(u); Knm.col(ma) -= W.col(u); Km(mb) += K(u); Km(ma) -= K(u); } } } Ci(++h) = zeros<urowvec>(1,N); M = matlabUnique(M); for (uint u=0;u<n;++u) { Ci(h)(find(Ci(h-1) == u)).fill(M(u)); } n = M.max()+1; mat w = zeros(n,n); for (uint u =0;u<n;++u) for (uint v=u;v<n;++v) { wm = accu(W(find(M==u),find(M==v))); w(u,v) = wm; w(v,u) = wm; } W = w; Q.resize(h+1); Q(h) = trace(W)/s - gamma*accu((W*W)/(s*s)); } *Qopt = Q(h); return Ci(h); }
void ThickPlateMesh::solve(void) { int sys_dim = TP_NDOF*nNodes; Matrix K(sys_dim , sys_dim ); #pragma omp parallel for num_threads(FEM_NUM_THREADS) for(int i=0; i<nElements; i++) elements[i]->getStiffnessMatrix(K, BftDBf, BctBc, L); #pragma omp parallel for num_threads(FEM_NUM_THREADS) for(int i=0; i<nNodes; i++) { if(nodes[i]->lockStatus[2]) K.setUnit(TP_NDOF*nodes[i]->index + 0); if(nodes[i]->lockStatus[3]) K.setUnit(TP_NDOF*nodes[i]->index + 1); if(nodes[i]->lockStatus[4]) K.setUnit(TP_NDOF*nodes[i]->index + 2); } Matrix f(sys_dim); #pragma omp parallel for num_threads(FEM_NUM_THREADS) for(int i=0; i<nNodes; i++) { f(TP_NDOF*nodes[i]->index + 0) = nodes[i]->loadValues[2]; f(TP_NDOF*nodes[i]->index + 1) = nodes[i]->loadValues[3]; f(TP_NDOF*nodes[i]->index + 2) = nodes[i]->loadValues[4]; } Matrix x(sys_dim); K.solve(f, x); // Polynomial2D Bf[3][npt]; // Polynomial2D **Bc= new Polynomial2D*[2]; // for(int i=0; i<2; i++) // Bc[i] = new Polynomial2D[npt]; // for(int i=0; i<npx*npy; i++) // { // Bf[0][3*i+2] = -1.0*L->D1[i]; // Bf[1][3*i+1] = L->D2[i]; // Bf[2][3*i+1] = L->D1[i]; // Bf[2][3*i+2] = -1.0*L->D2[i]; // Bc[0][3*i] = GKt * L->D1[i]; // Bc[0][3*i+2] = GKt * L->N[i]; // Bc[1][3*i] = GKt * L->D2[i]; // Bc[1][3*i+1] = -GKt * L->N[i]; // } // Polynomial2D **DBf= new Polynomial2D*[3]; // for(int i=0; i<npt; i++) // DBf[i] = new Polynomial2D[npt]; // for(int i=0; i<3; i++) // for(int j=0; j<npt; j++) // DBf[i][j] = Bf[0][j]*D(i,0) + Bf[1][j]*D(i,1) + Bf[2][j]*D(i,2); // Matrix M(sys_dim); // Matrix Q(2*nNodes); //#pragma omp parallel for num_threads(FEM_NUM_THREADS) // for(int i=0; i<nElements; i++) // elements[i]->evalResults(M, Q, x, DBf, Bc); results = new double*[2*TP_NDOF+2]; for(int i=0; i<2*TP_NDOF+2; i++) results[i] = new double[nNodes]; #pragma omp parallel for num_threads(FEM_NUM_THREADS) for(int i=0; i<nNodes; i++) { results[0][i] = x(TP_NDOF*i + 0); results[1][i] = x(TP_NDOF*i + 1); results[2][i] = x(TP_NDOF*i + 2); // results[3][i] = M(TP_NDOF*i + 0); // results[4][i] = M(TP_NDOF*i + 1); // results[5][i] = M(TP_NDOF*i + 2); // results[6][i] = Q(2*i + 0); // results[7][i] = Q(2*i + 1); } }
void C(_*a, _**b, _**c, _**d) { K(b, **a); }
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() { if (updated()) { return; } // Get the coupling information from the directMappedPatchBase const directMappedPatchBase& mpp = refCast<const directMappedPatchBase> ( patch().patch() ); const polyMesh& nbrMesh = mpp.sampleMesh(); const fvPatch& nbrPatch = refCast<const fvMesh> ( nbrMesh ).boundary()[mpp.samplePolyPatch().index()]; // Force recalculation of mapping and schedule const mapDistribute& distMap = mpp.map(); tmp<scalarField> intFld = patchInternalField(); const solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField = refCast<const solidWallMixedTemperatureCoupledFvPatchScalarField> ( nbrPatch.lookupPatchField<volScalarField, scalar> ( neighbourFieldName_ ) ); // Swap to obtain full local values of neighbour internal field scalarField nbrIntFld = nbrField.patchInternalField(); mapDistribute::distribute ( Pstream::defaultCommsType, distMap.schedule(), distMap.constructSize(), distMap.subMap(), // what to send distMap.constructMap(), // what to receive nbrIntFld ); // Swap to obtain full local values of neighbour K*delta scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); mapDistribute::distribute ( Pstream::defaultCommsType, distMap.schedule(), distMap.constructSize(), distMap.subMap(), // what to send distMap.constructMap(), // what to receive nbrKDelta ); tmp<scalarField> myKDelta = K()*patch().deltaCoeffs(); // Both sides agree on // - temperature : (myKDelta*fld + nbrKDelta*nbrFld)/(myKDelta+nbrKDelta) // - gradient : (temperature-fld)*delta // We've got a degree of freedom in how to implement this in a mixed bc. // (what gradient, what fixedValue and mixing coefficient) // Two reasonable choices: // 1. specify above temperature on one side (preferentially the high side) // and above gradient on the other. So this will switch between pure // fixedvalue and pure fixedgradient // 2. specify gradient and temperature such that the equations are the // same on both sides. This leads to the choice of // - refGradient = zero gradient // - refValue = neighbour value // - mixFraction = nbrKDelta / (nbrKDelta + myKDelta()) this->refValue() = nbrIntFld; this->refGrad() = 0.0; this->valueFraction() = nbrKDelta / (nbrKDelta + myKDelta()); mixedFvPatchScalarField::updateCoeffs(); if (debug) { scalar Q = gSum(K()*patch().magSf()*snGrad()); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' << this->dimensionedInternalField().name() << " <- " << nbrMesh.name() << ':' << nbrPatch.name() << ':' << this->dimensionedInternalField().name() << " :" << " heat[W]:" << Q << " walltemperature " << " min:" << gMin(*this) << " max:" << gMax(*this) << " avg:" << gAverage(*this) << endl; } }
main () { term x, n; type t; term plus_omega, omega_2, plus_omega_2, plus_omega_n, omega_n, omega_omega, plus_omega_omega; term f, p; param_out.fd = stdout; param_err.fd = stderr; init (); /* Exemple : construction de l'ordinal omega * 2 */ x = ap (LIM, ap (ap (S(ORD,ORD,ORD), ap (ap (S(ORD,fnc(ORD,ORD),fnc(ORD,ORD)),rep(ORD)), ap(K(fnc(ORD,ORD),ORD),SUC))), ap(K(ORD,ORD),ap(LIM,I(ORD))))); sput ("x = ", out); write_term (x, out); t = type_term (x); sput ("\nt = ", out); write_type (t, out); sput ("\n", out); n = var ("n", ORD); /* x = ap (LIM, lambda (n, ap (ap (ap (rep(ORD), n), SUC), ap (LIM, I(ORD))) )); */ x = ap (ap (ap (rep(ORD), n), SUC), ap (LIM, I(ORD))); /* x = ap (rep(ORD), n); */ sput ("x = ", out); write_term (x, out); t = type_term (x); sput ("\nt = ", out); write_type (t, out); sput ("\n", out); x = lambda (n, x); sput ("x = ", out); write_term (x, out); t = type_term (x); sput ("\nt = ", out); write_type (t, out); sput ("\n", out); x = ap (LIM, x); sput ("x = ", out); write_term (x, out); t = type_term (x); sput ("\nt = ", out); write_type (t, out); sput ("\n", out); x = var ("x", ORD); plus_omega = lambda (x, lim (lambda (n, rpt (ORD, n, SUC, x) ))); omega_2 = lim (lambda (n, rpt (ORD, n, plus_omega, ZERO))); t = type_term (omega_2); sput ("Type of omega_2 = ", out); write_type (t, out); sput ("\n", out); plus_omega_2 = lambda (x, lim (lambda (n, rpt (ORD, n, plus_omega, x)))); t = type_term (plus_omega_2); sput ("Type of plus_omega_2 is ", out); write_type (t, out); f = var ("f", fnc(ORD,ORD)); p = var ("p", ORD); plus_omega_n = lambda (n, rpt (fnc(ORD,ORD), n, lambda (f, lambda (x, lim (lambda (p, rpt (ORD, p, f, x)))) ), SUC)); /* next_power = lambda (f, lambda (x, lim (lambda (p, rpt (ORD, p, f, x))))); plus_omega_n = lambda (n, rpt (fnc(ORD,ORD), n, */ t = type_term (plus_omega_n); sput ("\nType of plus_omega_n is ", out); write_type (t, out); omega_n = lambda (n, ap (ap (plus_omega_n, n), ZERO)); t = type_term (omega_n); sput ("\nType of omega_n is ", out); write_type (t, out); omega_omega = lim (omega_n); t = type_term (omega_omega); sput ("\nType of omega_omega is ", out); write_type (t, out); plus_omega_omega = lambda (x, lim (lambda (n, ap (ap (plus_omega_n, n), x) ))); t = type_term (plus_omega_omega); sput ("\nType of plus_omega_omega is ", out); write_type (t, out); sput ("\n", out); }
int test_vec4_ctor() { int Error = 0; { glm::ivec4 A(1, 2, 3, 4); glm::ivec4 B(A); Error += glm::all(glm::equal(A, B)) ? 0 : 1; } # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible<glm::vec4>::value ? 0 : 1; // Error += std::is_trivially_copy_assignable<glm::vec4>::value ? 0 : 1; Error += std::is_trivially_copyable<glm::vec4>::value ? 0 : 1; Error += std::is_trivially_copyable<glm::dvec4>::value ? 0 : 1; Error += std::is_trivially_copyable<glm::ivec4>::value ? 0 : 1; Error += std::is_trivially_copyable<glm::uvec4>::value ? 0 : 1; Error += std::is_copy_constructible<glm::vec4>::value ? 0 : 1; # endif #if GLM_HAS_INITIALIZER_LISTS { glm::vec4 a{ 0, 1, 2, 3 }; std::vector<glm::vec4> v = { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 0, 1}}; } { glm::dvec4 a{ 0, 1, 2, 3 }; std::vector<glm::dvec4> v = { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 0, 1}}; } #endif #if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_SWIZZLE) { glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); glm::vec4 B = A.xyzw; glm::vec4 C(A.xyzw); glm::vec4 D(A.xyzw()); glm::vec4 E(A.x, A.yzw); glm::vec4 F(A.x, A.yzw()); glm::vec4 G(A.xyz, A.w); glm::vec4 H(A.xyz(), A.w); glm::vec4 I(A.xy, A.zw); glm::vec4 J(A.xy(), A.zw()); glm::vec4 K(A.x, A.y, A.zw); glm::vec4 L(A.x, A.yz, A.w); glm::vec4 M(A.xy, A.z, A.w); Error += glm::all(glm::equal(A, B)) ? 0 : 1; Error += glm::all(glm::equal(A, C)) ? 0 : 1; Error += glm::all(glm::equal(A, D)) ? 0 : 1; Error += glm::all(glm::equal(A, E)) ? 0 : 1; Error += glm::all(glm::equal(A, F)) ? 0 : 1; Error += glm::all(glm::equal(A, G)) ? 0 : 1; Error += glm::all(glm::equal(A, H)) ? 0 : 1; Error += glm::all(glm::equal(A, I)) ? 0 : 1; Error += glm::all(glm::equal(A, J)) ? 0 : 1; Error += glm::all(glm::equal(A, K)) ? 0 : 1; Error += glm::all(glm::equal(A, L)) ? 0 : 1; Error += glm::all(glm::equal(A, M)) ? 0 : 1; } #endif// GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_SWIZZLE) { glm::vec4 A(1); glm::vec4 B(1, 1, 1, 1); Error += A == B ? 0 : 1; } { std::vector<glm::vec4> Tests; Tests.push_back(glm::vec4(glm::vec2(1, 2), 3, 4)); Tests.push_back(glm::vec4(1, glm::vec2(2, 3), 4)); Tests.push_back(glm::vec4(1, 2, glm::vec2(3, 4))); Tests.push_back(glm::vec4(glm::vec3(1, 2, 3), 4)); Tests.push_back(glm::vec4(1, glm::vec3(2, 3, 4))); Tests.push_back(glm::vec4(glm::vec2(1, 2), glm::vec2(3, 4))); Tests.push_back(glm::vec4(1, 2, 3, 4)); Tests.push_back(glm::vec4(glm::vec4(1, 2, 3, 4))); for(std::size_t i = 0; i < Tests.size(); ++i) Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1; } return Error; }
static void s_video_helper_kbd_keymap_init (void) { int i; int map; struct kbentry entry = {0, 0, 0}; for (map = 0; map < NUM_VGAKEYMAPS; ++map) { memset(s_video_helper_keybd_keymap[map], 0, NR_KEYS * sizeof(unsigned short)); for (i = 0; i < NR_KEYS; ++i) { entry.kb_table = map; entry.kb_index = i; if (ioctl(s_video_helper_keybd.fd, KDGKBENT, &entry) == 0) { if (entry.kb_value == K_ENTER) { entry.kb_value = K(KT_ASCII,13); } if (KTYP(entry.kb_value) == KT_PAD) { switch (entry.kb_value) { case K_P0: case K_P1: case K_P2: case K_P3: case K_P4: case K_P5: case K_P6: case K_P7: case K_P8: case K_P9: s_video_helper_keybd_keymap[map][i] = entry.kb_value; s_video_helper_keybd_keymap[map][i] += '0'; break; case K_PPLUS: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, '+'); break; case K_PMINUS: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, '-'); break; case K_PSTAR: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, '*'); break; case K_PSLASH: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, '/'); break; case K_PENTER: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, '\r'); break; case K_PCOMMA: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, ','); break; case K_PDOT: s_video_helper_keybd_keymap[map][i] = K(KT_ASCII, '.'); break; default: break; } } if ((KTYP(entry.kb_value) == KT_LATIN) || (KTYP(entry.kb_value) == KT_ASCII) || (KTYP(entry.kb_value) == KT_LETTER) ) { s_video_helper_keybd_keymap[map][i] = entry.kb_value; } } } } }
inline void cal_campose(Eigen::MatrixXf XXc,Eigen::MatrixXf XXw, int n,Eigen::MatrixXf &R2,Eigen::VectorXf &t2) { //A Eigen::MatrixXf X = XXw; //B Eigen::MatrixXf Y = XXc; Eigen::MatrixXf eyen(n,n); eyen = Eigen::MatrixXf::Identity(n,n); Eigen::MatrixXf ones(n,n); ones.setOnes(); Eigen::MatrixXf K(n,n); K = eyen - ones/n; vfloat3 ux; for(int i =0; i < n; i++) { ux = ux + X.col(i); } ux = ux/n; vfloat3 uy; for(int i =0; i < n; i++) { uy = uy + Y.col(i); } uy = uy/n; Eigen::MatrixXf XK(3,n); XK = X*K; Eigen::MatrixXf XKarre(3,n); for(int i = 0 ; i < n ; i++) { XKarre(0,i) = XK(0,i)*XK(0,i); XKarre(1,i) = XK(1,i)*XK(1,i); XKarre(2,i) = XK(2,i)*XK(2,i); } Eigen::VectorXf sumXKarre(n); float sigmx2 = 0; for(int i = 0 ; i < n ; i++) { sumXKarre[i] = XKarre(0,i) + XKarre(1,i) + XKarre(2,i); sigmx2 += sumXKarre[i]; } sigmx2 /=n; Eigen::MatrixXf SXY(3,3); SXY = Y*K*(X.transpose())/n; JacobiSVD<MatrixXf> svd(SXY, ComputeThinU | ComputeThinV); Eigen::MatrixXf S(3,3); S = Eigen::MatrixXf::Identity(3,3); if(SXY.determinant() < 0) { S(3,3) = -1; } R2 = svd.matrixU() * S * (svd.matrixV()).transpose(); Eigen::MatrixXf D(3,3); D.setZero(); for(int i = 0 ; i < svd.singularValues().size() ; i++) { D(i,i) = (svd.singularValues())[i]; } float c2 = (D*S).trace()/sigmx2; t2 = uy - c2*R2*ux; vfloat3 Xx = R2.col(0); vfloat3 Yy = R2.col(1); vfloat3 Zz = R2.col(2); if((x_cross(Xx,Yy)-Zz).norm()>2e-2) { R2.col(2) = -Zz; } }
/* Evaluate the cardinal B-Spline B_{n-1} supported on [0,n]. */ R Y(bsplines)(const INT k, const R _x) { const R kk = (R)k; R result_value; INT r; INT g1, g2; /* boundaries */ INT j, idx, ug, og; /* indices */ R a; /* Alpha of de Boor scheme*/ R x = _x; R scratch[k]; result_value = K(0.0); if (K(0.0) < x && x < kk) { /* Exploit symmetry around k/2, maybe. */ if ( (kk - x) < x) { x = kk - x; } r = (INT)LRINT(CEIL(x) - K(1.0)); /* Do not use the explicit formula x^k / k! for first interval! De Boor's * algorithm is more accurate. See https://github.com/NFFT/nfft/issues/16. */ for (idx = 0; idx < k; idx++) scratch[idx] = K(0.0); scratch[k-r-1] = K(1.0); /* Bounds of the algorithm. */ g1 = r; g2 = k - 1 - r; ug = g2; /* g1 <= g2 */ for (j = 1, og = g2 + 1; j <= g1; j++, og++) { a = (x + (R)(k - r - og - 1)) / ((R)(k - j)); scratch[og] = (K(1.0) - a) * scratch[og-1]; bspline_help(k, x, scratch, j, ug + 1, og - 1, r); a = (x + (R)(k - r - ug - 1)) / ((R)(k - j)); scratch[ug] = a * scratch[ug]; } for (og-- ; j <= g2; j++) { bspline_help(k, x, scratch, j, ug + 1, og, r); a = (x + (R)(k - r - ug - 1)) / ((R)(k - j)); scratch[ug] = a * scratch[ug]; } for(; j < k; j++) { ug++; bspline_help(k, x, scratch, j, ug, og, r); } result_value = scratch[k-1]; } return(result_value); }
static ssize_t node_read_meminfo(struct device *dev, struct device_attribute *attr, char *buf) { int n; int nid = dev->id; struct sysinfo i; si_meminfo_node(&i, nid); n = sprintf(buf, "Node %d MemTotal: %8lu kB\n" "Node %d MemFree: %8lu kB\n" "Node %d MemUsed: %8lu kB\n" "Node %d Active: %8lu kB\n" "Node %d Inactive: %8lu kB\n" "Node %d Active(anon): %8lu kB\n" "Node %d Inactive(anon): %8lu kB\n" "Node %d Active(file): %8lu kB\n" "Node %d Inactive(file): %8lu kB\n" "Node %d Unevictable: %8lu kB\n" "Node %d Mlocked: %8lu kB\n", nid, K(i.totalram), nid, K(i.freeram), nid, K(i.totalram - i.freeram), nid, K(node_page_state(nid, NR_ACTIVE_ANON) + node_page_state(nid, NR_ACTIVE_FILE)), nid, K(node_page_state(nid, NR_INACTIVE_ANON) + node_page_state(nid, NR_INACTIVE_FILE)), nid, K(node_page_state(nid, NR_ACTIVE_ANON)), nid, K(node_page_state(nid, NR_INACTIVE_ANON)), nid, K(node_page_state(nid, NR_ACTIVE_FILE)), nid, K(node_page_state(nid, NR_INACTIVE_FILE)), nid, K(node_page_state(nid, NR_UNEVICTABLE)), nid, K(node_page_state(nid, NR_MLOCK))); #ifdef CONFIG_HIGHMEM n += sprintf(buf + n, "Node %d HighTotal: %8lu kB\n" "Node %d HighFree: %8lu kB\n" "Node %d LowTotal: %8lu kB\n" "Node %d LowFree: %8lu kB\n", nid, K(i.totalhigh), nid, K(i.freehigh), nid, K(i.totalram - i.totalhigh), nid, K(i.freeram - i.freehigh)); #endif n += sprintf(buf + n, "Node %d Dirty: %8lu kB\n" "Node %d Writeback: %8lu kB\n" "Node %d FilePages: %8lu kB\n" "Node %d Mapped: %8lu kB\n" "Node %d AnonPages: %8lu kB\n" "Node %d Shmem: %8lu kB\n" "Node %d KernelStack: %8lu kB\n" "Node %d PageTables: %8lu kB\n" "Node %d NFS_Unstable: %8lu kB\n" "Node %d Bounce: %8lu kB\n" "Node %d WritebackTmp: %8lu kB\n" "Node %d Slab: %8lu kB\n" "Node %d SReclaimable: %8lu kB\n" "Node %d SUnreclaim: %8lu kB\n" #ifdef CONFIG_TRANSPARENT_HUGEPAGE "Node %d AnonHugePages: %8lu kB\n" #endif , nid, K(node_page_state(nid, NR_FILE_DIRTY)), nid, K(node_page_state(nid, NR_WRITEBACK)), nid, K(node_page_state(nid, NR_FILE_PAGES)), nid, K(node_page_state(nid, NR_FILE_MAPPED)), #ifdef CONFIG_TRANSPARENT_HUGEPAGE nid, K(node_page_state(nid, NR_ANON_PAGES) + node_page_state(nid, NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR), #else nid, K(node_page_state(nid, NR_ANON_PAGES)), #endif nid, K(node_page_state(nid, NR_SHMEM)), nid, node_page_state(nid, NR_KERNEL_STACK) * THREAD_SIZE / 1024, nid, K(node_page_state(nid, NR_PAGETABLE)), nid, K(node_page_state(nid, NR_UNSTABLE_NFS)), nid, K(node_page_state(nid, NR_BOUNCE)), nid, K(node_page_state(nid, NR_WRITEBACK_TEMP)), nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE) + node_page_state(nid, NR_SLAB_UNRECLAIMABLE)), nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE)), #ifdef CONFIG_TRANSPARENT_HUGEPAGE nid, K(node_page_state(nid, NR_SLAB_UNRECLAIMABLE)) , nid, K(node_page_state(nid, NR_ANON_TRANSPARENT_HUGEPAGES) * HPAGE_PMD_NR)); #else nid, K(node_page_state(nid, NR_SLAB_UNRECLAIMABLE))); #endif n += hugetlb_report_node_meminfo(nid, buf + n); return n; }
Foam::tmp<Foam::surfaceScalarField> Foam::dragModels::segregated::Kf() const { return fvc::interpolate(K()); }