repo_name
stringlengths
6
101
path
stringlengths
4
300
text
stringlengths
7
1.31M
Li-YangZhong/professional-javascript-for-web-developers
Chapter5BasicReferenceTypes/TheRegExpType/TheRegExpTypeExample01.js
<reponame>Li-YangZhong/professional-javascript-for-web-developers let expression = /pattern/flags;
KenAJoh/pam-stillingsok
src/externalStyleSheets.js
<filename>src/externalStyleSheets.js import 'pam-frontend-header/dist/style.css'; import '@navikt/arbeidsplassen-knapper/dist/style.css';
stetre/moonfonts
src/fonts/stb_font_arial_45_usascii.inl
// Font generated by stb_font_inl_generator.c (4/1 bpp) // // Following instructions show how to use the only included font, whatever it is, in // a generic way so you can replace it with any other font by changing the include. // To use multiple fonts, replace STB_SOMEFONT_* below with STB_FONT_arial_45_usascii_*, // and separately install each font. Note that the CREATE function call has a // totally different name; it's just 'stb_font_arial_45_usascii'. // /* // Example usage: static stb_fontchar fontdata[STB_SOMEFONT_NUM_CHARS]; static void init(void) { // optionally replace both STB_SOMEFONT_BITMAP_HEIGHT with STB_SOMEFONT_BITMAP_HEIGHT_POW2 static unsigned char fontpixels[STB_SOMEFONT_BITMAP_HEIGHT][STB_SOMEFONT_BITMAP_WIDTH]; STB_SOMEFONT_CREATE(fontdata, fontpixels, STB_SOMEFONT_BITMAP_HEIGHT); ... create texture ... // for best results rendering 1:1 pixels texels, use nearest-neighbor sampling // if allowed to scale up, use bilerp } // This function positions characters on integer coordinates, and assumes 1:1 texels to pixels // Appropriate if nearest-neighbor sampling is used static void draw_string_integer(int x, int y, char *str) // draw with top-left point x,y { ... use texture ... ... turn on alpha blending and gamma-correct alpha blending ... glBegin(GL_QUADS); while (*str) { int char_codepoint = *str++; stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR]; glTexCoord2f(cd->s0, cd->t0); glVertex2i(x + cd->x0, y + cd->y0); glTexCoord2f(cd->s1, cd->t0); glVertex2i(x + cd->x1, y + cd->y0); glTexCoord2f(cd->s1, cd->t1); glVertex2i(x + cd->x1, y + cd->y1); glTexCoord2f(cd->s0, cd->t1); glVertex2i(x + cd->x0, y + cd->y1); // if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct x += cd->advance_int; } glEnd(); } // This function positions characters on float coordinates, and doesn't require 1:1 texels to pixels // Appropriate if bilinear filtering is used static void draw_string_float(float x, float y, char *str) // draw with top-left point x,y { ... use texture ... ... turn on alpha blending and gamma-correct alpha blending ... glBegin(GL_QUADS); while (*str) { int char_codepoint = *str++; stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR]; glTexCoord2f(cd->s0f, cd->t0f); glVertex2f(x + cd->x0f, y + cd->y0f); glTexCoord2f(cd->s1f, cd->t0f); glVertex2f(x + cd->x1f, y + cd->y0f); glTexCoord2f(cd->s1f, cd->t1f); glVertex2f(x + cd->x1f, y + cd->y1f); glTexCoord2f(cd->s0f, cd->t1f); glVertex2f(x + cd->x0f, y + cd->y1f); // if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct x += cd->advance; } glEnd(); } */ #ifndef STB_FONTCHAR__TYPEDEF #define STB_FONTCHAR__TYPEDEF typedef struct { // coordinates if using integer positioning float s0,t0,s1,t1; signed short x0,y0,x1,y1; int advance_int; // coordinates if using floating positioning float s0f,t0f,s1f,t1f; float x0f,y0f,x1f,y1f; float advance; } stb_fontchar; #endif #define STB_FONT_arial_45_usascii_BITMAP_WIDTH 256 #define STB_FONT_arial_45_usascii_BITMAP_HEIGHT 218 #define STB_FONT_arial_45_usascii_BITMAP_HEIGHT_POW2 256 #define STB_FONT_arial_45_usascii_FIRST_CHAR 32 #define STB_FONT_arial_45_usascii_NUM_CHARS 95 #define STB_FONT_arial_45_usascii_LINE_SPACING 29 static unsigned int stb__arial_45_usascii_pixels[]={ 0x26a2a980,0x0aaa2001,0xa98d4cc0,0x10000002,0x00003353,0x3bbbbba2, 0xddddd33e,0x3ba605dd,0x00aa000e,0x9a988000,0x26200000,0x0aaa0000, 0x4cc40000,0x05550000,0x7ff10000,0x401ffffc,0x75405ff9,0x7ff13fff, 0xdb880000,0xfffffffe,0x98000adf,0x4fffffff,0xfffffff3,0x03ffea07, 0x0000ff80,0x3ffff6a0,0x0002dfff,0x05dffff7,0x005ff880,0xfffb9500, 0x0017dfff,0x00003ff6,0xfff8dfb0,0x7fcc06ff,0x3fffea05,0x003fee3f, 0x3fff2600,0xffffffff,0x001dffff,0x3fffffe6,0xfffff34f,0x3fea07ff, 0x7edcc00f,0x20001bdf,0xfffffffb,0x03ffffff,0x3fffff60,0x3f2004ff, 0x7440001f,0xffffffff,0x400cffff,0x00002ffb,0xffd0bfea,0x7cc05fff, 0xffff105f,0x05ff85df,0x3fff6200,0xcccdefff,0xffffffed,0x3ffe0004, 0x003fff34,0x5403ffea,0xfffffffe,0x362001ef,0xffffffff,0xdfffffff, 0x67ffd400,0x802fffc9,0x40005ff8,0xfffffffb,0xffffffff,0x13fe601e, 0x37fc4000,0x40bffd10,0xff305ff9,0x1ffd405f,0x7fffcc00,0xfb5001df, 0x0001dfff,0x3fe69fff,0x3331001f,0x3ffffee0,0x2fffffff,0xffffe980, 0x3aa60abd,0x201effff,0x7fcc1ffe,0x01ffd806,0xffffb100,0x6d4c159d, 0x202fffff,0xb00006ff,0xffb805ff,0x417fe607,0xfe805ffb,0x3fea000f, 0x10000bff,0x003ffff9,0xff34fff8,0x2600003f,0xffaeffff,0x01ffffeb, 0x0fffffa2,0x7ffffd40,0xb05ff980,0x7fcc03ff,0x3ff20005,0xfd3004ff, 0x3f203fff,0x7c40001f,0xfff8806f,0x20bff300,0xfb804ffd,0xfff7004f, 0x2a00001d,0x2000efff,0xfff34fff,0xff100003,0xb87fc7ff,0x3f206fff, 0x44000eff,0xfb84fffe,0x05ff904f,0x80007fec,0x001efff9,0x506fffd8, 0xc80007ff,0xff8803ff,0x0bff300f,0x2200fff6,0x7cc00fff,0x800004ff, 0x2005ffe8,0xfff34fff,0xff500003,0x3a0ff87f,0xffa81fff,0xf10000ff, 0xffc85fff,0x207ff703,0x20004ff9,0x0002fffe,0x2213fffa,0x220005ff, 0xf8800fff,0xbff301ff,0x400fff60,0x7f403ffd,0x0098804f,0x01fffcc0, 0xff34fff8,0x3ba6003f,0x03fff20e,0x7ffd41ff,0x03fffd83,0x37ffd400, 0x7dc0fff2,0x01ffb04f,0x17ffee00,0xffff3000,0x000ffd01,0x88037fdc, 0xff301fff,0x00fff60b,0xf7037fdc,0xffea80df,0x3bae0cef,0x8037fd45, 0xfff34fff,0x3ffea003,0x3e17ffa0,0x20de6c0f,0x0006fff8,0x5c1fffd0, 0x7ff703ff,0x0009ff30,0x0007fffc,0x417ffe40,0xf0001ffb,0x3e2007ff, 0xbff301ff,0x400fffa0,0xf882fff8,0xffd100ff,0x21dfffff,0xffe85ffd, 0x34fff802,0x2a003fff,0x3ffa0fff,0x2000ff85,0x0002fffb,0x547fff70, 0x5ff904ff,0x0001ffb0,0x0013ffe6,0x42fffcc0,0x98004ff9,0x3e000fff, 0xbff301ff,0x800fffa0,0xffd85ffd,0xffffd302,0xf1dffdbb,0xbff507ff, 0x269fff00,0xf5001fff,0x7ffe41ff,0xb0007fc0,0x00003fff,0xf89bffe2, 0x81fff06f,0x20004ff9,0x0003fffa,0x7c1fffe0,0xffb8006f,0x0fffc006, 0xfd05ff98,0x7fdc005f,0x8837fc47,0x540bffff,0x02ffffff,0xfff00fff, 0x007ffe69,0xf507ffd4,0x00ff85ff,0x003fffe0,0x47ffe800,0xf910cffd, 0x01ffd0bf,0x17ffdc00,0xfffb0000,0x001ffb03,0x4005ffe8,0xff302ffe, 0x00bffe0b,0x2e1fffa8,0xfffb04ff,0x7fffd407,0x01ffb00f,0xff34fff8, 0x3fea003f,0x3fffe60f,0xf8003fe1,0x400007ff,0x3e60fffe,0xffffcfff, 0x0027fd40,0x007fff20,0x1fffc800,0x2002ffa8,0x4004fff8,0xff303ffd, 0x007ffe0b,0x363fff98,0xfffa81ff,0x6fffe803,0xf007ff20,0x3ffe69ff, 0x1fff5001,0x9dffffc8,0xff1000ff,0xd80000df,0x7fcc0fff,0xe81effff, 0x740000ff,0x00000fff,0x220bffee,0x3e6005ff,0x7dc003ff,0x0bff306f, 0x8800dff5,0xdff14fff,0x003fffa0,0xb817ffee,0x7ffc02ff,0x003fff34, 0x3203ffea,0xbfffffff,0x5fff9801,0x7fe40000,0xdedb881f,0x04ffa80b, 0x3ffe0022,0x7dc00007,0x0ffd03ff,0x01fffcc0,0x20fffe60,0x7fc45ff9, 0xfff8003f,0xf309ff55,0x3ea009ff,0x3ff203ff,0x9a7ffc02,0xf5001fff, 0x3fee01ff,0xcfffffff,0x0bfff100,0xfffd8000,0x7ff40000,0xceffec80, 0x00ffff00,0x2fffb800,0x2003ff90,0x8002fffa,0x261cfffb,0xffd715ff, 0xfff0001d,0x360ffeeb,0xf5000fff,0x7ff403ff,0x9a7ffc00,0xf5001fff, 0xfda801ff,0x2fffffff,0x000ffff0,0x007fff80,0x221ffd40,0xeffffffd, 0x00fffe81,0x3fff2000,0x007ff502,0x0007ffee,0x98ffffe4,0xbfffd5ff, 0x3ffa0001,0xff05ff96,0x7fdc00df,0x01ffe00f,0x7fcd3ffe,0xfff5001f, 0x3ffe2001,0xf83fffff,0x200007ff,0x0006fff8,0x3f607ff4,0x6fffbcff, 0x001fffd8,0x07fffa00,0xf7006ff8,0x540001ff,0xbff31fff,0x00017ffa, 0x3ff2fffb,0x027ffc41,0x4c0dffb0,0xfff806ff,0x003fff34,0x8003ffea, 0xfffea8ff,0x0ffff40f,0xfff98000,0x3fee0004,0x2077fcc3,0x7fe43ffc, 0x3e00002f,0x3f600fff,0xfffb800f,0xffd30000,0x757fe63f,0x0000dfff, 0x3ff6dffb,0x01fffcc0,0x5c09ffd0,0xfff804ff,0x003fff34,0x8003ffea, 0x3fff20ff,0x017ffdc5,0x3fffa800,0x21ffe000,0xff883ffc,0x027ffd47, 0x6fff8800,0x4017fdc0,0x8001fffa,0x263dfffa,0xfff935ff,0x3ffa000d, 0xf983ffb5,0xff1002ff,0x17ff407f,0xf9a7ffc0,0xff5001ff,0x07fc001f, 0xf983fffa,0xd00006ff,0x20005fff,0xffd83ffb,0xff0ffd01,0x900001ff, 0xf9807fff,0xfff9804f,0x3fff8001,0x7c45ff98,0xfe8003ff,0xf05ff94f, 0x3f6007ff,0xbff701ff,0x4d3ffe00,0xf5001fff,0x7fc001ff,0x20fffe40, 0xb803fffe,0x6fffb81c,0x41ffe000,0xffd00ffe,0x04fffc83,0x7fffcc00, 0x807ff800,0x4002fff9,0xff306ffa,0x00dff70b,0x3f29fff0,0x04ffe83f, 0x107fff98,0x3e001fff,0x3fff34ff,0x83ffea00,0x81ff04a9,0x7d43fff9, 0x7f400fff,0xffff11ef,0x3fee0003,0x201fff03,0x7fc41ffd,0x3a0001ff, 0xf9005fff,0xfff8803f,0x1ffec003,0xf885ff98,0x3e2000ff,0x07ff73ff, 0xfd00fff9,0xffd30bff,0xa7ffc007,0x5001fff9,0x3fea1fff,0x4c0ff81f, 0xffd82fff,0xfff300df,0x9fffb7ff,0x1bfe2000,0xfd00ffe8,0xdfff703f, 0xfff90003,0x3fea001f,0x05ffe803,0x9817ffc0,0x5fff05ff,0x8fffd400, 0xffa86ff9,0xfffd103f,0x6fffa89f,0x9a7ffc00,0xf5001fff,0x3ffe21ff, 0x7d40ff83,0xfff881ff,0xff9302ff,0x00dfffff,0xb017fe40,0x1ffe03ff, 0x03ffffe8,0x5ffffd10,0x02ffc400,0x2003ffdc,0xff302fff,0x00bffa0b, 0x7f46ffb8,0xcfffd81f,0xfffff510,0xfffd75ff,0xfff8001d,0x003fff34, 0xfe83ffea,0x6c0ff86f,0x3fe607ff,0x440acfff,0x1ffffffb,0x0dff1000, 0xf983ffc8,0x3ffa206f,0x5441adff,0x04fffffb,0x9807fe80,0x3e000fff, 0xbff301ff,0x800fffa0,0x7fe44ffd,0xffffe884,0xff8effff,0x4fffffff, 0x29fff000,0x5001fff9,0x7fdc1fff,0xf307fc3f,0xfe880bff,0xfeffffff, 0xffffffff,0xffc8001e,0x0fffc402,0xb005ffb1,0xdfffffff,0xffffffff, 0x3fee0005,0x02fff802,0x4c07ffe0,0x7ffd05ff,0x217ffc00,0xf880fff9, 0x25ffffff,0xfffffffd,0x3ffe0003,0x003fff34,0xf983ffea,0x43fe3fff, 0x000ffffa,0xfffffff9,0xfdffffff,0x2001bfff,0xf9006ff8,0xdfff9bff, 0x7fffdc00,0xffffffff,0x260000ef,0xffc804ff,0x07ffe005,0xfd82ffcc, 0xfff5003f,0x4417ff60,0xc81cefda,0x880acefe,0x3fe00aaa,0x03fff34f, 0x503ffea0,0xff7dffff,0x07ffffd9,0xfffeb880,0x30beffff,0x007ffffd, 0x22005ff9,0xeffffffd,0xffea8000,0x1cffffff,0x0dff0000,0x001fff30, 0x7cc07ffe,0x07ffb05f,0x4413ff60,0x00004fff,0x0dffd100,0xff34fff8, 0x3fea003f,0xffff980f,0xffffffff,0x54c40002,0x3ea009aa,0x7fc403ff, 0xffda8006,0x9880003d,0x00019aaa,0xb002aa80,0xff1007ff,0x17fe603f, 0x4401ffec,0x3ee00fff,0x000003ff,0x00ffff44,0x7fcd3ffe,0xfff7001f, 0x3fff2601,0x00dfffff,0x5c000000,0x0000000f,0x00000000,0x98000000, 0xff8806ff,0x0bff300f,0x2e013ff6,0xffc804ff,0x800000df,0x802fffea, 0xfff34fff,0x1ffee003,0x0dffdcc0,0x00000000,0x00000002,0x00000000, 0xd8000000,0x7fcc01ff,0x417fe607,0xfe806ffc,0xfffb000f,0x2200007f, 0x002ffffd,0x3fe69fff,0xffe8801f,0x007fc006,0x00000000,0x00000000, 0x00000000,0x3e600000,0x2ffec05f,0x2a0bff30,0x3ea01fff,0x7fdc004f, 0x000adfff,0x3ffff6e2,0xffff300d,0x3fe69fff,0xd33fffff,0x007ffffb, 0x00000ff8,0x00000000,0x00000000,0x00000000,0x42ffc800,0x03fffedc, 0xff817fe6,0x7f41deff,0xfe98000e,0xceefffff,0xfeeccbbc,0x401effff, 0xfffffff9,0xffffff34,0x3fffee7f,0x7fc000ff,0x00000000,0x00000000, 0x00000000,0x00000000,0xffff8dfd,0x2ffcc06f,0x7fffff70,0x0000ffdc, 0x3fffff6a,0xffffffff,0x003fffff,0xfffffff3,0x3ffffe69,0xffffb3ff, 0x0330001d,0x00000000,0x00000000,0x00000000,0x4c000000,0x3fffe2ff, 0x2ffcc00d,0x4ffffea0,0x00004ff8,0x3ffb72a2,0xefffffff,0x000000ac, 0x02aa6200,0x00000000,0x00000000,0x00000000,0x00000000,0x54553000, 0x551000aa,0x35531005,0x00002aa2,0x2aaa6200,0x0000009a,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x40000131,0xa8000099,0x02aaa02a,0x00026200,0x04cc4000,0x2a620000, 0x33000000,0x53000003,0x00660005,0x00fbba20,0x2007ddb0,0x20000998, 0x32606eec,0x2e3efffe,0x4bdd32ee,0xbfffffdb,0x6ff88000,0x8801ffe0, 0x0cfffffd,0x3ae20000,0xceffffff,0xfeb8000a,0xd70cefff,0x3f6a009d, 0x2dffffff,0x07fe8000,0xfffecb98,0xe802bdef,0x3e6007ff,0x3b2601ff, 0x0003ffff,0xfd10fffb,0xbfffffff,0x7fd4fff2,0xffffff96,0x98003fff, 0xdff104ff,0x3fffea00,0x001fffff,0x7fffecc0,0xffffffff,0xffd1002f, 0x1dffffff,0xeb80bff9,0xffffffff,0x0002efff,0x6440bff1,0xffffffff, 0x201effff,0x9002fffb,0x7fc40dff,0x002fffff,0xe88fffb0,0xecbdefff, 0x53ffdeff,0xbfffbdff,0x3ffffd97,0x81ffdc00,0xf9804ffa,0xfffdefff, 0xf50000ff,0xffffffff,0xbfffffff,0x7fff4401,0xffffdcef,0xfb105ffd, 0xffffffff,0x07ffffff,0x205ff500,0xffffffe8,0xffffffff,0x9fff102f, 0x80fffe00,0xfffffffe,0xfffb0000,0x905fffd8,0x2a7fffff,0x80dfffff, 0x2006fffc,0xff701ffc,0xfffe8807,0x17fff221,0x3ffff200,0x7510abcf, 0x01dffffb,0x2037fff6,0x85fffffc,0xaeffffe8,0x7fffdcc1,0x7fec002f, 0xbffffb00,0x3f2a6135,0xfb01ffff,0xfff500ff,0x3bffe601,0xfd80000a, 0x13ffea7f,0x27ffff70,0x405ffffa,0xd003fffb,0x3ff601ff,0x1fffcc01, 0x4007fff8,0x00effffb,0x09ffff50,0xa809fff5,0xfe85ffff,0xf9001eff, 0x7c005fff,0xdfff106f,0xfffb1001,0x0bffea0b,0x540bffb0,0x00003fff, 0xffc9fff6,0xfffe800f,0x01ffff53,0x100dffd0,0x3ffc0dff,0x807ffdc0, 0x1000fffc,0x0007ffff,0xd81fffd1,0xfd800fff,0x7ffdc5ff,0x7fe4000e, 0x9ff3006f,0x007ffee0,0x207ffe88,0x3e205fff,0x3fee02ff,0x3600001f, 0x13ffa7ff,0xa9fffdc0,0xf7004fff,0x9ff300ff,0x201bfe20,0xf900fffb, 0x7ff400ff,0x3e60004f,0x1fffc4ff,0x25fff980,0x000ffff9,0x003fffd0, 0x3f603ff7,0xffa8005f,0x1fff902f,0x803ffee0,0x00007ffb,0xfff3ffec, 0x3ffe2005,0x003fff53,0x7007ffe2,0x3fea07ff,0x3fffa804,0x2009ffd0, 0x0006fffa,0xf10fffe8,0x7fc003ff,0x0ffff25f,0x5fffa800,0x3e07fe80, 0xff0005ff,0x3ffe609f,0x809ffd03,0x00007ffb,0xff9bffec,0x3ffe001f, 0x001fff53,0xeeb97ffc,0xeefffeee,0xeffeeeee,0xfff105ee,0x1fffa83f, 0x05fff900,0x17bf5000,0x8003ffea,0x3ffe5ffe,0x6740000f,0x2ffc401b, 0x001fffd0,0x74055570,0xfff986ff,0xffeeeb81,0x000eeeef,0x7d5fff60, 0x3fa000ff,0x00fff53f,0xff94fff8,0xffffffff,0xffffffff,0x7fe40dff, 0xdfff70ef,0x03fffc00,0x3fee0000,0xaffec007,0x0005fffa,0x1ffd4000, 0x007fff90,0x7ffdc000,0xc837fe40,0xffffffff,0x360000ff,0x1fff77ff, 0xa9ffec00,0x7f4006ff,0xfffff95f,0xffffffff,0xdfffffff,0xdefffe80, 0x2a005fff,0x00006fff,0x003ffe40,0x7fe57ff2,0x0000004f,0xf3007fe4, 0x00019fff,0x87fff100,0xdd704ffe,0xddddfffd,0x7fec0001,0x001fff57, 0xffa9ffec,0x27ffc007,0x2209ff30,0x7cc006ff,0x03ffffff,0x027ffdc0, 0x3fee0000,0x3ff6000f,0x005fffb5,0x6ff80000,0xfffffd80,0x200001be, 0x3fe66ffd,0x7ffb800f,0x7fec0000,0x003fff37,0xffa9fff4,0x17ffc007, 0x2a07ff70,0xfd8004ff,0x8001ffff,0x0003fffc,0x0fffd400,0x36bffd00, 0x00001fff,0x013fe600,0x7fffffe4,0x0001bdff,0x7e47ffea,0xfff7006f, 0xffd80000,0x005fff17,0xffa9fffc,0xfff1000f,0x80ffec01,0x2a002ffc, 0x1ffffffe,0x1fffd800,0x7cc00000,0x3fe002ff,0x01fffd5f,0x7dc00000, 0x3fee002f,0xffffffff,0xff8001cf,0x007ffd3f,0x0001ffee,0x7fcfffb0, 0xfff3005f,0x00bffea7,0x3a03ffdc,0x03ff607f,0x7ffffe40,0x4000ffff, 0x3000fffe,0xddd99999,0x3fe29ddd,0xfff5005f,0x001fffeb,0x1ffb0000, 0xffeb8800,0xffffffff,0x3ff2001d,0x000fff8e,0x0000fff7,0x3f27ffd8, 0xffd801ff,0x0dfff53f,0x8817ffe0,0x1ffe06ff,0x57fffec0,0xa86fffe8, 0x0fffd80a,0xfffff500,0x4dffffff,0xe801fffc,0xfffd5fff,0xf8000000, 0x5440005f,0xfffffffd,0xff1002ff,0x400bff9f,0x00007ffb,0xff13ffec, 0xfff980bf,0x7ffff53f,0x02fffb80,0x7c413fe6,0xfffd805f,0x3fffe60e, 0x917ffe24,0x2a003fff,0xffffffff,0x3fe26fff,0x3ff200ef,0x1fffb5ff, 0x2a000000,0x400003ff,0xfffffdb8,0xfffd001f,0x7dc005ff,0x6c00007f, 0x7ffdc7ff,0xffffa80e,0xfffff53f,0x1bfff209,0x2a07ff70,0x7fcc04ff, 0xfffa80ef,0x89fff52f,0x3002fffc,0x99999999,0xffb8dfff,0xfd510bff, 0x3f6bffff,0x000000ff,0x0003ff90,0xffffc800,0xffff7005,0x7ffb800f, 0x7fec0000,0xdffffd87,0xfffffecb,0xfffff53f,0xffdb79df,0xeeeb81ff, 0xeeeeefff,0xeeeeffee,0x0bfff65e,0xd9ffffc8,0x7fdc1fff,0x3e00004f, 0xfffc86ff,0xdfffffff,0xfff95fff,0x20000005,0x000007fe,0x01fffd30, 0x09ffff10,0x007ffb80,0x83ffec00,0xfffffffc,0x53fff9ef,0xfffd5fff, 0x01dfffff,0xfffffff9,0xffffffff,0x7cdfffff,0xffd807ff,0x886fffef, 0x00006fff,0x7d41bffe,0x3fffffff,0x3fe69ffd,0xeb80004f,0x27fc40ac, 0x000dd540,0x005fff70,0x0007fff6,0xa880fff7,0x7ffe802b,0x3ffffaa0, 0x27fff0df,0xff90fffa,0x64059fff,0xffffffff,0xffffffff,0xff16ffff, 0xffd1009f,0x3607ffff,0x00001fff,0x5440dfff,0x3e1bdfec,0x1bffe4ff, 0x3fffa000,0x2017fdc1,0x0005fff8,0x4013ffe2,0xb8006ffc,0x7fec07ff, 0x06fff805,0xfff03530,0x303ffea7,0x26620035,0x9999cffb,0x999dffa9, 0x9fff1099,0x3fffe200,0x3ffea06f,0xfff00005,0xfff0000d,0x017ffe47, 0x0dfff300,0xfd001ffb,0x7c0001ff,0xfff004ff,0xfff70005,0x806ffc80, 0x80006fff,0xfff53fff,0x7dc00001,0x09ff502f,0x400dfff0,0x204ffffa, 0x003ffff8,0x066fff80,0x8bffe200,0x0007fff9,0x3e0bfff6,0xfffb006f, 0x3fea0005,0x7ffa801f,0x0fff7000,0x200fffb8,0x0004fff9,0xff53fff8, 0x6c00001f,0x5ff901ff,0x05fffd00,0x3fffff60,0x3fffe603,0xff910003, 0x01f7f4df,0x640fffc8,0xc8005fff,0xff987fff,0xffff3004,0xfffb0005, 0x013ffa00,0x203ffdc0,0x3a04fffa,0x80002fff,0xfff53fff,0x7fc00001, 0x003ffa07,0x803bffea,0xffffffe8,0x3fff203f,0x3ee000df,0x3f66ffff, 0x7fcc00ff,0xffff886f,0xfff9000e,0x03ff705f,0x1fffff40,0x4fffd880, 0x3fff6608,0xfff70000,0x19fffd00,0x3ffff6a2,0xfff80000,0x001fff53, 0x81bfe200,0x3f6007ff,0x75441fff,0xfffeffff,0x3fff603f,0x511bdfff, 0xfffffdb7,0x6fffdc1b,0x5fffd301,0x3ffffea0,0xfffa881c,0x0ffd03ff, 0xfffff880,0x2ea61ace,0xe81fffff,0x03ffffff,0x01ffee00,0x3fffffea, 0x03ffffff,0x27fff000,0x0000fffa,0x2609ff50,0x3a2005ff,0xfedfffff, 0xe88effff,0x2e04ffff,0xffffffff,0xffffffff,0xfffb02ef,0xffb979ff, 0xff980bff,0xfeefffff,0x04ffffff,0x3000bff1,0xffffffff,0xffffffff, 0x3fff603f,0x5c0005ff,0xff9007ff,0xffffffff,0x7fc00009,0x01fff53f, 0x0bfee000,0x20027fd4,0xffffffd8,0xfd84ffff,0x7f4c02ff,0xffffffff, 0x403fffff,0xffffffe8,0x004fffff,0xffffffd3,0x5dffffff,0x001ffd40, 0xfffffd88,0xffffffff,0x3fff201e,0xfb80005f,0x3fa6007f,0x01ceffff, 0x9fffc000,0x0000fffa,0x3203ffb0,0xd70002ff,0x5bffffff,0x1001fec0, 0xffffffd7,0x400179df,0xffffffea,0xc98001df,0xffffffff,0x0ffc803e, 0x7f64c000,0xceffffff,0x00353002,0x03ffdc00,0x00554c40,0x00000000, 0x202aa800,0x80000aa9,0x0a000aa9,0xaaa98800,0x53100001,0x00001355, 0x006aaa66,0x00005550,0x01aaa988,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00998800, 0x77777540,0xeeeeeeee,0x0eeeeeee,0x8801ddd5,0x00aceedc,0x3bba0000, 0x6f6e5402,0x774c009b,0x5400000e,0xaaaaaaaa,0x000aaaaa,0x19bddb73, 0xddb93000,0x0000059b,0x37bb6ea0,0x2f76400b,0x13bb6000,0xfffffd98, 0xffb802ef,0xffffffff,0xffffffff,0x1fff50ff,0x3ffff220,0x0004ffff, 0x207fff00,0xffffffe9,0x3fea03ff,0x2200000f,0xffffffff,0x03ffffff, 0x7fffff44,0x8800cfff,0xfffffffd,0x16a000df,0x7ffff440,0x3a04ffff, 0x7c0007ff,0xffc886ff,0xffffffff,0x3ffee01e,0xffffffff,0xffffffff, 0x01fff50f,0x3ffffff6,0x0005ffff,0xa83fff80,0xffffffff,0xff504fff, 0x4c00001f,0xffffffff,0x03ffffff,0x3fffffea,0x406fffff,0xfffffff8, 0x402fffff,0xfa806fd8,0xffffffff,0xffe80eff,0x7ffc0007,0xeffffd86, 0xfffffecd,0x99999501,0x99999999,0x1ffffd99,0x3603ffea,0xa88adfff, 0x0005fffd,0x261fffc0,0x311bffff,0xf50bfffb,0x400001ff,0xfffffffb, 0x3fffffff,0x59ffff50,0x13fffaa2,0x21dfffe8,0x00ffffc9,0xf301bff6, 0x2615bfff,0x740efffc,0x7c0007ff,0x7ffe46ff,0xfffd882e,0x4c00000e, 0x3ea2ffff,0x7ffcc0ff,0x0bfff605,0x3fff8000,0x900ffff4,0xffa83fff, 0x3200000f,0xd00006ff,0x3a203fff,0xffb81fff,0x3ffea04f,0x01bff605, 0x5409fffd,0x7ff44fff,0x7ffc0007,0x03fffe66,0x009fff90,0x7fffc400, 0x207ffd44,0xfd807ffd,0x3e00005f,0x3ffe63ff,0x44ffe803,0x0000fffa, 0x0013ffa0,0x00fffea0,0xfd07fff5,0xfffb00df,0x7037fec0,0xf700bfff, 0x3fff43ff,0x9bffe000,0xd002fffb,0x20000fff,0xa85fffe8,0x3fe60fff, 0xfffa804f,0xfff00001,0x803ffe47,0x7fd46ffc,0x3e00000f,0xe80002ff, 0xffd005ff,0x009fff0d,0x3603fff5,0x3ff606ff,0x9ffd000f,0x0003fff4, 0xffe9bffe,0x3ffee007,0xffe80000,0xfffa80ef,0x007ffee0,0x4013ffe2, 0x7fff0198,0xb802fedc,0x3fea0fff,0x4001980f,0x0001fff9,0x8007ffd4, 0x7fc41aa9,0xfff9803f,0x40dffb02,0x32005fff,0x1fffa6ff,0x2dfff000, 0x2004fff8,0x0002fffa,0x80ffffe4,0x3f60fffa,0x3ff6006f,0x7fff5c06, 0x0fffe3ef,0x6ffd8004,0xeb87ffd4,0x803effff,0x80007ffa,0x00005ffd, 0x2a013ffa,0x3ba60fff,0x1eeeffff,0x4007fff1,0xffd0fffb,0xfff8000f, 0x8006a626,0x0000fffb,0x80bfffea,0x3fa0fffa,0x3fee005f,0xffffd107, 0xff1bffff,0xff80007f,0x4fffd44f,0xfffffffc,0x3ff200ef,0xffe80006, 0x3f200003,0x6ffc806f,0x7fffffcc,0xfff32fff,0x7ffd4005,0x000fffd2, 0x0006fff8,0x0006ffd8,0x00ffffe6,0x3e21fff5,0x3ee004ff,0x7ff441ff, 0xfffdceff,0x0003fffe,0xf507fff6,0x9dfffdff,0x03fffffb,0x76d53ff6, 0x7c01ceff,0x665441ff,0xfff5001a,0x27ffd409,0x3ffffba6,0xfff31eee, 0x7ffd4005,0x000fffd2,0x0006fff8,0x0027ffcc,0x05fffe88,0xf10fffa8, 0x7d4009ff,0x7ffec2ff,0xffffc80d,0x75cc003f,0xffa83fff,0xfd80dfff, 0xbfff06ff,0xfffffffd,0x8fffc09f,0xffffffe9,0xfffb801e,0xfff9309d, 0x37fec01b,0x4009fff0,0xffd3fffc,0xfff8000f,0x3fe60006,0xfb0000ff, 0xf5001dff,0x3ffe21ff,0x3ffea003,0x013ffea2,0x007ffff7,0x3ffffff6, 0xbffff501,0x42fffc80,0xfffffff8,0xefffffff,0x4c7ffc41,0xffffffff, 0xfe9803ff,0xffffffff,0x06ffd803,0xe801bffa,0xfffd3fff,0x6fff8000, 0xffff3000,0x3ff20005,0xff5000ff,0x0bffe61f,0x22fff980,0xe800fffd, 0xf8803fff,0x00cfffff,0x001ffff5,0xff98dfff,0x988acfff,0x4c6ffffc, 0xdfffafff,0xffffecbc,0xffffa802,0xb004ffff,0x7fec0dff,0xfffa802f, 0x00fffd4f,0x006fff80,0x03ffff98,0x5ffff500,0x87ffd400,0x2002fff9, 0x3fa3fff9,0xfff7004f,0xffff3007,0xf509ffff,0x3ee009ff,0x3ffee0ff, 0x3ffa600e,0x3fffea3f,0xfff701ef,0x3ffea01f,0xffffffff,0x37fec03f, 0x03ffff10,0xa7ffff4c,0x40007ffe,0x54006fff,0x0003ffff,0x007ffff3, 0xf30fffa8,0x7cc005ff,0x0bffe3ff,0x01fffc40,0xfff730c4,0x1fffa8bf, 0x45fff300,0x9800dcb9,0xff70ffff,0xfb801fff,0xfffb84ff,0x3fea21bf, 0x3ff604ff,0x7fffdc06,0x3bfee21c,0xfffd3fff,0x6fff8000,0x3fffe200, 0xffd10002,0xff5000bf,0x0bffe21f,0x32fff980,0x7c003fff,0x220003ff, 0x3ea3fffe,0xff1000ff,0xf900007f,0x3ffea3ff,0xfffd002f,0x00efff98, 0x40bfff62,0xfe806ffd,0xffffffff,0xd3fff8ef,0xf8000fff,0x3f6006ff, 0x360002ff,0x50006fff,0x7ffc1fff,0x3ffea003,0x001fff52,0x0001fff4, 0xfa9fffe2,0x7ffc007f,0xff980004,0x0ffff33f,0xb0fffd40,0xf1003fff, 0x3ff60dff,0xffff9006,0x3e1dffff,0x0fffb2ff,0x06fff800,0x009fff10, 0x07fffe40,0x0fffa800,0xa8013ffe,0xfff91fff,0x03ffd800,0x1fffc800, 0xe800dff5,0x880005ff,0xfff14fff,0x7ffcc00b,0x00bfff12,0x6c0fffdc, 0x366006ff,0x222ceffe,0xfffb2fff,0x7ffc4000,0x1fff5005,0x3ffea000, 0x3ea0001f,0x13ffa0ff,0x70fffb80,0x74001fff,0xa80003ff,0xfff52fff, 0x04fff800,0x4bfff000,0x22004fff,0xfff33fff,0x7ffcc007,0x006ffd83, 0x3fe60110,0x01fff91f,0x17ffe600,0x0037fdc0,0x03ffff98,0x07ffd400, 0x6400bffb,0x3ffe67ff,0x0fffe001,0x3ffe6000,0x400fff53,0x0003fff8, 0x3e4fff88,0x3e2005ff,0x5fff52ff,0x84fff800,0x00006ffd,0x3f27ffb8, 0xf50001ff,0x3f2009ff,0xfe88006f,0xa80005ff,0x3ff20fff,0x17ffa007, 0x7c005fff,0x5fdb13ff,0x97ffd400,0x3000fffa,0x37223fff,0x3fe6002e, 0x01fffa2f,0xf30fff98,0x7c4007ff,0x6ffd83ff,0xffe80000,0x00fffea5, 0x017ffdc0,0x8004eec8,0x0006fffd,0x4c1fff50,0xf9802fff,0x27ff43ff, 0x23fff980,0x2e005fff,0xfff50fff,0x3ffee007,0x8017ffe0,0x3ee1fffb, 0xff7001ff,0x005fff8d,0x3607ffe6,0x3bae06ff,0x7fff3005,0x0037ffc4, 0x000ffff8,0xfffc8000,0xf500000e,0x5ffe81ff,0x40fffc80,0xd800fffc, 0x3ff63fff,0xfff8800f,0x017ffea7,0xfb1bffe2,0xff1001ff,0x4fff88df, 0xe89ffd00,0xf9000fff,0xdff901ff,0x803ffdc0,0x7f40fffc,0x7dc004ff, 0x000006ff,0x01ffffa8,0x3ffea000,0x00fffd40,0xf50bfff3,0xffa80bff, 0x3ffee3ff,0x3fffd805,0x00ffffea,0xfb83fff9,0xffc805ff,0x3fffb82f, 0x217ffdc0,0xa805fffb,0xff905fff,0x1fffc40f,0x20fffea0,0x003ffffb, 0x005ffff5,0xfff88000,0xaaaaaadf,0xaaaaaaaa,0xfff51aaa,0x05fffd01, 0x203ffff3,0xa80dfffd,0x6c3fffff,0xd880cfff,0x7fd45fff,0xffb03fff, 0x3fffa0bf,0xfffd880d,0x5ffff105,0x413fff20,0x700dfffd,0x3201ffff, 0x4088bfff,0xb80bfffd,0xfd00ffff,0x2159dfff,0xffffea98,0x7fffc006, 0xffff8800,0xffffffff,0xffffffff,0x1fff54ff,0x9dffff50,0x07ffffb7, 0x6fffff44,0xfeeffecb,0x7fffc43f,0xfffdbbcf,0x7ffd40ff,0xfdbdfffe, 0xf100efff,0xb779ffff,0x401bffff,0xbdfffffa,0x205fffec,0xcefffff8, 0x2ffffecb,0x3ffffea0,0x7fffc43f,0xffffdbdf,0x3ffa201f,0xffffffff, 0x00efffff,0x007fffc0,0x7fffffc4,0xffffffff,0xffffffff,0x201fff54, 0xfffffff9,0xe8804fff,0xffffffff,0x983ffd8e,0xfffffffe,0xfa80dfff, 0xffffd8ef,0x400dffff,0xffffffe9,0x1004ffff,0xfffffffd,0xfb100dff, 0xffffffff,0xffd003df,0xff309fff,0xffffffff,0xffb1003d,0xffffffff, 0x2000bfff,0x8800ffff,0xffffffff,0xffffffff,0x54ffffff,0x6c401fff, 0x1dffffff,0x7fff5c00,0x7ffb0dff,0x7ffffd40,0x3ea02eff,0x3ffff66f, 0x7dc003ef,0x2dffffff,0xfffec800,0x54003dff,0xfffffffe,0x3ff62003, 0xff9106ff,0x007fffff,0xfffff930,0x0039ffff,0x007fffc0,0x00000000, 0x026aa200,0x03553000,0x35731000,0x2aa20000,0x54c40000,0x3100000a, 0x26000035,0x400009aa,0x55300098,0x26000035,0x0019aaa9,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x775c0000,0x440000de,0x3a21eeee,0x20001eee, 0x3aa2eeeb,0x74c002ee,0x4c002eee,0xddd72eee,0x3aa00005,0x3bbba1ee, 0xeeeeeeee,0xeeeeeeee,0x1ddd34ee,0x77764000,0xeeeeeeee,0x00acceee, 0x000eee98,0x3bbbbb60,0xceeeeeee,0x774c00bc,0x27ddd30e,0xff8deeea, 0x6c0004ff,0xffc84fff,0xfa8000ef,0x7ffc46ff,0x7ffe4005,0x7fe4005f, 0x0bfff31f,0x1fffa000,0xffffffff,0xffffffff,0x2bffffff,0x0000fffa, 0x3ffffffa,0xffffffff,0x200cffff,0x0001fffa,0x3ffffffa,0xffffffff, 0xff502dff,0x53ffe63f,0xff56fffb,0x2a0003ff,0x3fa06fff,0x7c4004ff, 0xffe80fff,0x7fff4007,0x7ff4007f,0x007fff47,0x13ffe600,0xffffffff, 0xffffffff,0x2bffffff,0x0000fffa,0x3ffffffa,0xffffffff,0x00efffff, 0x0003fff5,0x7ffffff4,0xffffffff,0xfa83ffff,0x9fff31ff,0xfc9bffee, 0xf88006ff,0x3e201fff,0x3a002fff,0xff902fff,0x3fe2001f,0x1002ffff, 0xffb89fff,0x7e40003f,0x666641ff,0xffeccccc,0xccccccdf,0x1fff53cc, 0x7fff4000,0xaaaaaaaa,0xffffcbaa,0x3fff506f,0x7fff4000,0xcccccccc, 0xfffffecc,0x98fffd42,0xfff74fff,0x27fffc4d,0x13fff600,0x03fffee0, 0x813fff20,0x5002fffa,0x09ffbbff,0x10bffea0,0x8000dfff,0x90006fff, 0x54003fff,0x20000fff,0x88007ffe,0xa81ffffb,0x20001fff,0x4c007ffe, 0x220ffffe,0x3ffe6199,0xa8dfff74,0x5001ffff,0x6c00dfff,0x7d405fff, 0x7fc406ff,0x7ffb004f,0x3200dff7,0xffd80fff,0xff50001f,0x3f20007f, 0x3ea001ff,0x3a0000ff,0x320007ff,0xffa83fff,0x3fa0001f,0xfe88007f, 0xff9803ff,0x0dfff74f,0x100dfff9,0x4003ffff,0x103ffff8,0xd001ffff, 0x3fe00dff,0x00fff99f,0xf506ffe8,0x360009ff,0x90000fff,0x54003fff, 0x20000fff,0x40007ffe,0xffa85fff,0x3fa0001f,0xff70007f,0xfff3009f, 0x21bffee9,0x403ffff8,0x8003fffd,0xe81ffff9,0xf9002fff,0xff9801ff, 0x100fffe7,0x7fc09fff,0xff88006f,0x3f20005f,0x3ea001ff,0x00a880ff, 0x0003fff4,0xf503fffa,0x740003ff,0xf10007ff,0xff300dff,0x17ffee9f, 0x80ffffd4,0x0005fffa,0xf91bfff2,0x7cc009ff,0x7fdc02ff,0x3017ff65, 0x7e403fff,0x7d4001ff,0x320001ff,0x2a001fff,0xffb30fff,0xfd059dff, 0xfe8000ff,0x7ffd40ff,0x1f776c01,0x4000fffd,0x3ba67ffe,0x29fff30e, 0x3605fffa,0xff886fff,0x740000ff,0xfff34fff,0x7fff000d,0x2a3ffe80, 0x7fdc07ff,0x27ffcc07,0x01bffa00,0x03fff900,0x5c7ffd40,0xffffffff, 0x03fff42f,0x0ffff100,0x6c03fff5,0x7ff45fff,0x3ffe0007,0x4c7ffea7, 0xfff54fff,0x7fffc409,0x01fffe42,0x7fffcc00,0x000fffe9,0x2205ffd8, 0x3fe20fff,0x17ff601f,0x801fffa0,0x0003fff8,0x000fffe4,0xfffdfff5, 0xfffffdbf,0x003fff45,0x50bfff70,0x3f603fff,0x7ffe85ff,0xbfff1000, 0xf98fffd4,0x9fff34ff,0x0ffffa80,0x000bfff3,0x7ffffdc0,0xf70002ff, 0x37fd40ff,0xff01fff4,0xfff7007f,0x3ffee005,0x7fe40000,0x3fea001f, 0xfc81dfff,0x1fffa7ff,0x7fffe400,0x81fffa82,0xfd04fffd,0x3f2000ff, 0x3ffea4ff,0x269fff31,0xfd803fff,0x1fffd4ff,0xffd80000,0x20004fff, 0xf901fff9,0x0dff909f,0x2007ffe6,0xd005fff8,0x90000bff,0x54003fff, 0x6c06ffff,0xfffd2fff,0x33333333,0xfffd9533,0x3ffea0bf,0x027ffec1, 0x7000fffd,0x7d41ffff,0x9fff31ff,0x200fffe2,0xffcffff8,0x8800002f, 0x0006ffff,0xfd03fff8,0x1fff505f,0x400dff70,0x4c00fffc,0x80002fff, 0x2001fffc,0x400efffa,0xffd3fff9,0xffffffff,0xffffffff,0x3fea01bf, 0x13fff61f,0x333fffd0,0x75333333,0xa87ffffd,0xfff31fff,0x8017ffc9, 0x4ffffffa,0xff100000,0x80003fff,0xff985ffd,0x05fff00f,0x4c009ffb, 0x7e402fff,0xf900007f,0x7d4003ff,0xfff004ff,0x3fffffa9,0xffffffff, 0x402fffff,0xff91fffa,0xfffd009f,0xffffffff,0xdfffffff,0x263fff50, 0x3ffe4fff,0x3fff6002,0x000000ef,0x0dfffffb,0x87ffb800,0x3f605ffb, 0x02fff85f,0x202fff40,0x00004fff,0x4003fff9,0xd003fffa,0x3fffa9ff, 0xffffffff,0x001bdfff,0xff93fff5,0x3ffa009f,0xffffffff,0x3fffffff, 0x263fff50,0x3ffe4fff,0x3ffe2001,0x7000001f,0x9fffffff,0x7ffcc000, 0x701ffec0,0xfff98dff,0x7ffdc000,0x01fff500,0x3fff2000,0x3ffea001, 0x29ffd002,0x9999fffe,0xefffda99,0x3ffea001,0x004ffffd,0xfffffffd, 0xddffffff,0x7ffd4019,0x749fff31,0x7ec001ff,0x3000007f,0xfff3dfff, 0x7fc0005f,0x00fffc2f,0x7dc1fff3,0xff88006f,0x0bffb03f,0x7ffe4000, 0x3ffea001,0x29ffd001,0xfa807ffe,0xf5003fff,0xffffffff,0x3fffd003, 0x13333333,0x1fffa800,0x7ec9fff3,0x7fec000f,0xe8800007,0xfff71fff, 0x3f20001f,0x01ffe64f,0xffd8bffe,0xdffb0003,0x005fff10,0x0fffe400, 0x01fff500,0x7f53ffa0,0xfff5007f,0xfff5005f,0x0dfff9ff,0x000fffd0, 0x23fff500,0x3f64fff9,0x7fec000f,0xfd800007,0x7ffec4ff,0xdff50005, 0x6c02ffe4,0x07ffe3ff,0x0fffd400,0x0001ffee,0x003fff90,0x8007ffd4, 0xfffd4ffe,0x7fffdc00,0x7fffd401,0x809fff73,0x00007ffe,0xf31fffa8, 0x03fe49ff,0x003ffec0,0x1bffee00,0x00ffffe2,0x743ffe20,0xffa802ff, 0x000fff35,0x7f43fff8,0x6400004f,0x2a001fff,0xfd000fff,0x01fffa9f, 0x01dfffb0,0x3a1fffd4,0x3fa01fff,0xa800007f,0xfff31fff,0x4003fe49, 0x00007ffd,0x407fffe6,0x001ffffa,0xff89ffe8,0x7ff8800f,0x8000bff5, 0x3fe66ffc,0x6400001f,0x2a001fff,0xfd000fff,0x01fffa9f,0x0bffff10, 0x260fffd4,0x3fa06fff,0xa800007f,0xfff31fff,0x4002f549,0x00007ffd, 0x807fffd1,0x8006fffd,0x6ffabffc,0x323ffa00,0x4c0003ff,0xdff91fff, 0xff900000,0x7fd4003f,0x9ffd000f,0x2001fffa,0x502ffffa,0xff903fff, 0x1fffa09f,0x3fea0000,0x09fff31f,0x1fff6000,0x7ffec000,0xfffe8805, 0x6ffd4004,0x32004ffc,0x00ffeaff,0xd4ffe800,0x000007ff,0x4003fff9, 0xd000fffa,0x1fffa9ff,0x7fffec00,0x01fffa80,0xfd03fffd,0x500000ff, 0x3fe63fff,0xfb00004f,0xf70000ff,0x26001fff,0x2002ffff,0x1ffeeff8, 0x3f7fea00,0xf700006f,0x01fff3df,0xfff90000,0x7ffd4003,0x29ffd000, 0x10007ffe,0xf50bffff,0x3fe603ff,0x3fff40ef,0x7fd40000,0x09fff31f, 0x1fff6000,0xffff3000,0xfffc8003,0x3ffa000f,0xff8007ff,0x00004fff, 0x9ffbfff1,0x3f200000,0x3ea001ff,0xffd000ff,0x001fffa9,0x42ffffb8, 0x3201fffa,0x7ff44fff,0xfa800007,0x9fff31ff,0x0017ffea,0x8000fffb, 0x0004fffe,0x400bfffd,0x005ffffc,0x02ffffd8,0x3fff2000,0x000001ff, 0x4003fff9,0xd000fffa,0x1fffa9ff,0xdfffd000,0x201fffa8,0x3a1ffff8, 0x800007ff,0xff31fffa,0x17ffea9f,0x00fffb00,0x037ffe40,0x7ffff300, 0x3fffe600,0xfffb8003,0x2600000f,0x0006ffff,0x07fff200,0x00fffa80, 0x3fa9ffd0,0x7cc0007f,0x3fea4fff,0x7ffd401f,0x00fffd0e,0x3fff5000, 0x7d53ffe6,0x7ec005ff,0xff50007f,0xb80001ff,0xf001ffff,0x30001fff, 0x0000dfff,0x007fffd0,0x7ffe4000,0x3ffea001,0x29ffd000,0x80007ffe, 0xf51ffffb,0xffb003ff,0x01fffa9f,0x3ffea000,0x2a9fff31,0x00005fff, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x3bbb6000,0x3bb60001,0x17bbbba4,0x3bbb2000,0x013bba2e, 0x013bba00,0x277774c0,0x8000ddd9,0x20004eed,0xdd903eeb,0xdddddddd, 0xdddddddd,0x3bbbbb29,0xeeeeeeee,0x26eeeeee,0xeeeeeeed,0x1bceeeee, 0x3bbbba00,0xdeeeeeee,0x640000ac,0x6ffff87f,0x97ffa000,0x00ffffff, 0x3fffe200,0x017ffe3f,0x017ffe00,0x3bfffe60,0x001fff60,0x000dfff0, 0x6c13ffe6,0xffffffff,0xffffffff,0xffffd5ff,0xffffffff,0xffffffff, 0x7ffffff4,0xffffffff,0xfff801df,0xffffffff,0x004fffff,0xff0fff70, 0x20007fff,0x3ffe5ffe,0x20003fff,0x23fffffa,0x80005fff,0x4c005fff, 0xfd85ffff,0x7fc0007f,0xfe88006f,0xfffb04ff,0xffffffff,0xbfffffff, 0x3ffffffa,0xffffffff,0x3a7fffff,0xffffffff,0xffffffff,0x3ffe01ef, 0xffffffff,0x05ffffff,0x43fffcc0,0x01ffffff,0x3e5ffe80,0x006fffff, 0x3fffff60,0x0017ffe3,0x8017ffe0,0xb05ffff9,0xf8000fff,0xfc8006ff, 0xffb04fff,0x9999999f,0x99999999,0x333fffa7,0xcccccccc,0x24cccccc, 0xccccfffe,0xffedcccc,0xff01ffff,0x999999df,0xffffdb99,0xfff1001b, 0xfffff0ff,0xffd000df,0x7fffffcb,0xff88000f,0x3fe3ffff,0xff80005f, 0xfff3005f,0x3ffec0bf,0x1bffe000,0xfffff500,0x03fff609,0x1fffa000, 0xfffd0000,0x7ffdc400,0x5fff80ff,0x3fffea00,0x7fffd402,0xfffff87f, 0x7f4003ff,0x3f7ffe5f,0xfb8003ff,0x3e3fffdf,0xf80005ff,0xff9805ff, 0x7fec05ff,0x7ffc0007,0x3ffe2006,0xffb04fff,0xfd00001f,0xe80000ff, 0xf88007ff,0xfff85fff,0x7ffcc005,0xffffb105,0xdfff0fff,0x4003ffff, 0x3ffe5ffe,0x8006ffcc,0x3fffaffd,0x00017ffe,0xf3017ffe,0xfb00bfff, 0xff8000ff,0x3ff6006f,0xfb04fffc,0xd00001ff,0x80000fff,0x30007ffe, 0xff83ffff,0xffe8005f,0xfffffb87,0xfff87ffe,0x006fffbd,0xfff97ffa, 0x000fff9c,0x3fe3bfe2,0x017ffe3f,0x817ffe00,0x004ffff9,0x8000fffb, 0xf7006fff,0x413ffedf,0x0000fffd,0x0007ffe8,0x003fff40,0xf8bfff70, 0xfc8005ff,0x3fff21ff,0x87ffb8ef,0xfffd5fff,0x97ffa007,0x7fff4fff, 0x467fdc00,0x3ffe3fff,0xfff80005,0x9ffff305,0x03ffec00,0x01bffe00, 0x7fc7ffe6,0x1fffb04f,0xfffd0000,0xffe80000,0x3fe20007,0x02fffc7f, 0x323ffe40,0x3fee4fff,0xf35fff87,0xfd003fff,0xca7ffcbf,0x3fa006ff, 0x23fff89f,0x80005fff,0xff985fff,0x7ec004ff,0x7fc0007f,0x3ffe806f, 0x7ec13ffe,0xe80000ff,0x400007ff,0x40007ffe,0x3fe1fffd,0xffe8005f, 0x2e067e45,0x5fff87ff,0x201bffee,0x3ffe5ffe,0x001fff34,0x3fe2dff1, 0x017ffe3f,0x317ffe00,0x0009ffff,0x8000fffb,0x7e406fff,0x827ffc5f, 0x0000fffd,0x0007ffe8,0x003fff40,0xf93ffea0,0x7cc005ff,0xb80543ff, 0x5fff87ff,0x2027fff4,0x3ffe5ffe,0x200fffe4,0xfff13ffb,0x002fffc7, 0xf32fffc0,0x20007fff,0x40007ffd,0x3e606fff,0x27ffc0ff,0x000fffd8, 0x007ffe80,0x03fff400,0x97ffe600,0x32005fff,0x5c005fff,0x5fff87ff, 0x00ffffcc,0x7ffcbffd,0x201bff24,0xfff10ffe,0x002fffc7,0xf9afffc0, 0x0004ffff,0xfffffffb,0xffffffff,0x0dffffff,0x3e0bffa2,0xfffb04ff, 0x99999999,0xe8599999,0xcccccfff,0xcccccccc,0x3fff44cc,0x3ffe2000, 0x3bbfffe5,0xfeeeeeee,0xb8004fff,0x5fff87ff,0x206fffb8,0x3ffe5ffe, 0x803ffe64,0x3fe26ff8,0x017ffe3f,0x277ffe00,0x2fffffff,0xffffd800, 0xffffffff,0xffffffff,0x0bffb06f,0x7ec13ffe,0xffffffff,0x4fffffff, 0x7ffffff4,0xffffffff,0x7f47ffff,0xff80007f,0x3ffffe6f,0xffffffff, 0x70004fff,0xbfff0fff,0x413fffa0,0x3ffe5ffe,0x701fffc4,0x7ffc47ff, 0x0017ffe3,0x3fffffe0,0x0ffffdff,0x7fffec00,0xffffffff,0xffffffff, 0x0fffa86f,0x3609fff0,0xffffffff,0xffffffff,0x7fffff44,0xffffffff, 0x747fffff,0xf80007ff,0x3fffe6ff,0xffffffff,0x02efffff,0x7c3ffdc0, 0xfff305ff,0x4bffd03f,0x7fe44fff,0x883ffa06,0x3ffe3fff,0xfff80005, 0xffb2ffff,0xffd800df,0xaaaaaaaf,0xaaaaaaaa,0x7fc46fff,0x13ffe02f, 0x7fffffec,0xffffffff,0x7fff44ff,0xeeeeeeee,0x5eeeeeee,0x0003fff4, 0xff9bffe2,0xccccccef,0xffffffed,0x3fee003f,0x205fff87,0xfe86fffb, 0x313ffe5f,0xff301fff,0x23fff88b,0x80005fff,0x22ffffff,0x004ffff8, 0x0001fff6,0xffd8dfff,0x827ffc04,0x0000fffd,0x0007ffe8,0x003fff40, 0xf97ffe60,0x366005ff,0x7002ffff,0xbfff0fff,0x44fffe80,0x3ffe5ffe, 0xb83fff84,0x7ffc43ff,0x0017ffe3,0x0bffffe0,0x007fffea,0x0003ffec, 0xffb9bffe,0x04fff806,0x0001fffb,0x000fffd0,0x007ffe80,0xf1fffd40, 0xf7000bff,0x3ee00dff,0x05fff87f,0xd0ffffcc,0x27ffcbff,0x7f437fe4, 0x1fffc40f,0x0000bfff,0x6405ffff,0xd800ffff,0x7c0007ff,0x7fff36ff, 0x33333333,0x13339fff,0x0003fff6,0x001fffa0,0x00fffd00,0x22fffb80, 0xd0005fff,0xf7005fff,0x0bfff0ff,0x74dfff70,0x13ffe5ff,0xf983ffe6, 0x3fff885f,0x00017ffe,0x3a017ffe,0xfd805fff,0x7fc0007f,0xfffff76f, 0xffffffff,0x27ffffff,0x0000fffd,0x0007ffe8,0x003fff40,0xf87fff60, 0xf90005ff,0xff7007ff,0x00bfff0f,0x7f53fffa,0x413ffe5f,0x3ff23ffe, 0x23fff882,0x80005fff,0xf9805fff,0x7ec03fff,0x7fc0007f,0xfffff76f, 0xffffffff,0x27ffffff,0x0000fffd,0x0007ffe8,0x003fff40,0x41ffff10, 0x30005fff,0xf7009fff,0x0bfff0ff,0x27fffe60,0x3ffe5ffe,0x7cdff904, 0xfff880ff,0x0017ffe3,0x4017ffe0,0x201ffffb,0x40007ffd,0xfff76fff, 0xffffffff,0xffffffff,0x003fff67,0x01fffa00,0x0fffd000,0x27ffe400, 0x40017ffe,0xb803fffa,0x5fff87ff,0x3bffee00,0x3ffe5ffe,0x31fff304, 0x3fe20bff,0x017ffe3f,0x017ffe00,0x00efffe8,0x8000fffb,0x20006fff, 0xffb04fff,0xfd00001f,0xe80000ff,0xf30007ff,0xfff81fff,0xfff90005, 0x0fff7003,0xe800bfff,0x25ffffff,0x3fa04fff,0x102ffcbf,0x7ffc7fff, 0xfff80005,0x3ffe2005,0x0fffb05f,0x06fff800,0x413ffe00,0x0000fffd, 0x0007ffe8,0x003fff40,0x427fff44,0x98005fff,0xb800ffff,0x5fff87ff, 0x7fffcc00,0x13ffe5ff,0x7ffeffc8,0xf8fffe20,0xf80005ff,0x7d4005ff, 0xffd82fff,0x7ffc0007,0x3ffe0006,0x01fffb04,0x0fffd000,0x7ffe8000, 0x7fffdc00,0x05fff80f,0x2ffffcc0,0xf87ffb80,0xfb8005ff,0x3fe5ffff, 0x3ffe604f,0x3fe204ff,0x2bbffe3f,0xaaaaaaaa,0x3fe2aaaa,0xffd8005f, 0x3ffec0ff,0x1bffe000,0x04fff800,0x0001fffb,0x555fffd0,0x55555555, 0x23555555,0xaaaafffe,0xffedcaaa,0xff01ffff,0x555555df,0xfffd9755, 0x3ee001df,0x05fff87f,0xbffffd00,0x3a027ffc,0x2202ffff,0x3ffe3fff, 0xffffffff,0x27ffffff,0x88005fff,0x7ec6ffff,0x7fc0007f,0x3fe0006f, 0x1fffb04f,0xfffd0000,0xffffffff,0xffffffff,0x3ffffabf,0xffffffff, 0x01ffffff,0x3ffffffe,0xffffffff,0x2001ffff,0xfff87ffb,0xfff30005, 0x027ffcbf,0x101ffff2,0x7ffc7fff,0xffffffff,0x27ffffff,0x30005fff, 0x7ec9ffff,0x7fc0007f,0x3fe0006f,0x1fffb04f,0xfffd0000,0xffffffff, 0xffffffff,0x3ffffabf,0xffffffff,0x400bffff,0xffffffff,0xffffffff, 0x7dc001cf,0x05fff87f,0x97fff200,0x7cc04fff,0x7fc404ff,0x3ffffe3f, 0xffffffff,0x3fe7ffff,0x3f20005f,0xfffb2fff,0x6fff8000,0x13ffe000, 0x0007ffec,0x7fffff40,0xffffffff,0x5fffffff,0xfffffffd,0x599ddfff, 0x7ffffc00,0xefffffff,0x70000bcd,0x00000fff,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0xaaaa8000, 0xaaaaaaaa,0x01aaaaaa,0x1eeee880,0x372a0000,0x200bcdfe,0x2003eeea, 0x22000199,0x100001a9,0x40000133,0x200001a9,0x880000a9,0x01510001, 0x000eeea8,0x3ba65ddd,0x3ba2002e,0xffff882e,0xffffffff,0x04ffffff, 0x4ffffb80,0xffe98000,0x3fffffff,0x409fff50,0xfffffdb8,0xffb8801d, 0x01deffff,0x3ffff620,0x54002dff,0xffffffed,0x3b22001d,0x02dfffff, 0x7ec53ba6,0x9dd32dff,0x7ffff6d4,0x0fffa81d,0x7c7fff00,0x3ee005ff, 0xfff880ff,0xffffffff,0x4fffffff,0xffffe800,0x3ee0000f,0xffffffff, 0xffa86fff,0xffff904f,0x09ffffff,0x7fffffcc,0x403fffff,0xffffffc8, 0x400cffff,0xffffffd8,0x00cfffff,0x7fffffd4,0xf504ffff,0xfffff1bf, 0x5dbfeabf,0xffffffff,0x07ffd43f,0x323fff80,0xfd000fff,0x3ffe20bf, 0xffffffff,0x2fffffff,0x777fcc00,0xf30003ff,0x26139fff,0x544ffffb, 0xffd84fff,0xfffcdeff,0xffe884ff,0xfffdccef,0x3ff604ff,0xffecdeff, 0xff300eff,0xfd99bdff,0x6409ffff,0xecdeffff,0x540effff,0xffffddff, 0x7dff52ff,0xffddffff,0x7fd47fff,0x7fff000f,0x401fffcc,0x0002fff9, 0x027ffd40,0x7e67fe40,0xfe88006f,0x3fa201ff,0x266622ff,0x0f7ffdc0, 0x217fff54,0xf502fffc,0xff701fff,0xffb103df,0x3fffa0bf,0x3fffee02, 0x1efffa80,0xa89fffb0,0xbbefffff,0x3fffea6d,0x7fec40df,0x03ffea6f, 0x3a1fffc0,0xffc806ff,0x7c400007,0xff0005ff,0x03fff35f,0x03fffa80, 0x005fff88,0x401dfff1,0x7f46fff9,0x7ffdc04f,0x077ffc42,0x30bfff20, 0xf7005fff,0xdffd05ff,0x1fffb801,0x017fffea,0x809ffff5,0xff52fffd, 0x3ffe001f,0x007ffdc3,0x00013ffa,0x001dffd0,0x3e1fff50,0x7e4005ff, 0x3ff6006f,0x5fff7007,0x21fffb00,0xe802fff8,0x7ffec2ce,0xffff8801, 0x401bff20,0x7dc3fff8,0xffd001ff,0x07fffd4d,0x03fffea0,0x2a7fff30, 0xff000fff,0x3fff887f,0x007ffe60,0x2fffc800,0x4bffb000,0x2000fffc, 0x2e005ffe,0xfe800fff,0x59b1006f,0x002fffc1,0x8017ffe0,0x2622fffb, 0x3ffe002a,0x002fff43,0x3ea1fff5,0xffa804ff,0xfff8804f,0x001fff54, 0x3f60fffe,0x1bff206f,0xfff98000,0xfff10005,0x01fffcc7,0x40079950, 0x4400fffb,0x80004fff,0x00befffc,0x017ffc40,0x007fff10,0x44fff880, 0x26004fff,0xfff51fff,0x7fff5007,0x553ffe00,0xff000fff,0x3fff507f, 0x000fffe0,0x00fffe80,0x81fff700,0x00006ffe,0x807ffd80,0x0003fff9, 0xffffff98,0xffa801ce,0x7ffc001f,0x32ea2004,0x224ffffe,0xaaaacfff, 0xfaaaaaaa,0x5fff52ff,0x05fff500,0x7d53ffa0,0xfff000ff,0x213ffe07, 0x0000fffa,0x007fff70,0x5c2fff40,0x00001fff,0x017ffe20,0x000bffea, 0x7ffffcc0,0x702dffff,0xe8001fff,0xd97105ff,0xffffffff,0x7ffd49ff, 0xffffffff,0x4fffffff,0x5003fff5,0x3a003fff,0x1fff54ff,0x40fffe00, 0xffd87ffc,0xff100005,0x7cc000df,0xfff882ff,0x32000005,0xfa803fff, 0x200001ff,0xffffffd8,0x7e40efff,0xffd8007f,0xfffffc86,0xffdfffff, 0x3fffee4f,0xffffffff,0x55ffffff,0xf5001fff,0x3fa001ff,0x01fff54f, 0x4c0fffe0,0x3fe21fff,0xf700002f,0x6c0007ff,0x3ff607ff,0x9800000f, 0xf3006fff,0x000005ff,0xfffff951,0x7fdc5fff,0x7ff4000f,0x7ffffec6, 0x3fe1bcef,0x2fffea4f,0xaaaaaaaa,0x51aaaaaa,0xf5001fff,0x3fa001ff, 0x01fff54f,0x407fff30,0x3fee4ffe,0x3fa00007,0xf10000ff,0x7fd409ff, 0x4c00003f,0x1000ffff,0x00005fff,0xfffb7300,0x0fffd4ff,0xc97ffe00, 0x201bffff,0x3e64fff8,0xa80002ff,0xfa800fff,0xffd000ff,0x003ffea9, 0xb80fffea,0x13ffa7ff,0x7ffcc000,0x3fee0005,0x37ffc01f,0xfff10000, 0xfff8007f,0x02aee003,0x7fffc400,0x005fff31,0xff27ffc4,0xff3001df, 0x1fffc49f,0x7ffd4000,0x0fffa800,0x2a9ffd00,0xfb801fff,0x3fe203ff, 0x01fff8af,0x3fff9000,0x37ff4000,0x017ffe40,0x7fffcc00,0x5ffe8004, 0x4cfffe00,0xff7004ca,0x13ffe27f,0x32fffa80,0x2a007fff,0x7ffc4fff, 0x2b326005,0x001fff51,0x2001fff5,0xfff34ffe,0x7fffb005,0xfbcffd80, 0x3e00006f,0x260006ff,0xf9803fff,0x540005ff,0x0004ffff,0x5003fff9, 0x3fee3fff,0xfff9800f,0x003fffa2,0xfb87fff4,0xffb002ff,0x2fffd89f, 0x23fffd00,0xa800fffa,0xfd000fff,0x3fffe29f,0x3ffff200,0x77ffd403, 0x500003ff,0x40007fff,0xeeeefffc,0xffeeeeee,0xf70000ff,0xfa809fff, 0x3ffe24ff,0x26ffe805,0xd804fff8,0x3fe60fff,0xfffb805f,0x017ffea5, 0x113ffff2,0xb801dfff,0x3fea6fff,0xfffa800f,0x49ffd000,0x440dfffd, 0x03fffffc,0x0ffffff8,0xfffb0000,0xffff8000,0xffffffff,0x04ffffff, 0x3ffffc80,0x44fffa80,0x880efffb,0x7f42fffd,0x3fea03ff,0xefffc85f, 0x1ffff900,0x00ffffc4,0x0bfffff9,0x103dfff7,0x545ffff5,0xfa800fff, 0xffd000ff,0x7ffffd49,0xddfffece,0xffc803ff,0x100005ff,0x40009fff, 0xfffffffa,0xffffffff,0x6c007fff,0x5002ffff,0xffd09fff,0xffb77bff, 0xfff109ff,0xfd9779ff,0xfd103fff,0xfb79bfff,0xf903ffff,0xd759dfff, 0xdffddfff,0x3bffffa0,0xfffffdbc,0x007ffd43,0x8007ffd4,0x7fdc4ffe, 0x4fffffff,0xf3007ff9,0x00005fff,0x0007fff2,0x999fffd8,0x99999999, 0x802fffd9,0x01ffffd8,0x413ffea0,0xfffffffc,0x3e604fff,0xffffffff, 0x32200eff,0xffffffff,0x3fa01eff,0xffffffff,0x01fff53f,0x3ffffff2, 0xa83fffff,0xfa800fff,0xffd000ff,0xffffb309,0x1ffe47df,0x007ffe80, 0x01bffa00,0x05fff880,0x05fffa80,0x077fff44,0x203fb800,0xffffffe9, 0xffb8801e,0x04efffff,0x3ffffaa0,0xf7002cef,0x1bffffff,0x301fffc4, 0xfffffffb,0x3ffea019,0x0fffa800,0x809ffd00,0x000001a9,0x7fc40000, 0x3ee0005f,0xfd0002ff,0x7fec01ff,0x360000ef,0x3553001f,0x2a660001, 0xa980001a,0x2a60000a,0x400000aa,0x0001aaa8,0x00000000,0x00000000, 0x3fff9800,0x1fffa000,0x4fffc800,0x00bfff70,0x0001ff00,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x2fffb800,0x9fff3000, 0x7ffc4000,0x0efff887,0x97f62000,0xbbbbbbba,0xbbbbbbbb,0x3bbbbbbb, 0x00000000,0x00000000,0x00000000,0x00000000,0x20000000,0x0000fffd, 0x0003fff9,0x6c2fffd8,0xaaaacfff,0xaaaaaaaa,0xfc8bf50a,0xffffffff, 0xffffffff,0x006fffff,0x00000000,0x00000000,0x00000000,0x00000000, 0x3fa00000,0x3fe0007f,0xfa80006f,0x3ffe65ff,0xffffffff,0x1fffffff, 0x3ffff20a,0xffffffff,0xffffffff,0x000006ff,0x00000000,0x00000000, 0x00000000,0x00000000,0x01bffa00,0x01fffd40,0x1ffff800,0xfffffff7, 0xffffffff,0x00003fff,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x13ffe000,0x07ffec00,0xfffc8000,0xffffffb4,0xffffffff, 0x0003ffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x01980000,0xe9806a20,0x3bbb23ee,0x5eee9803, 0x26017bb2,0xec802eee,0x3bbbaa3e,0xeeeeeeee,0x0b23eeee,0x00000000, 0x76c00726,0xaa80002e,0x99998802,0x99999999,0x40199999,0xd10002a9, 0x3bba29dd,0x40bbbae5,0x3f6a4ee9,0xc883dfff,0x40dffffe,0x3e24fffa, 0x7f401fff,0x3ffee1ff,0x2fffe400,0xa8bffe20,0xffffffff,0xffffffff, 0x0033ff64,0xb5000000,0x3fa003ff,0x7d40003f,0x7fec01ff,0xffffffff, 0xffffffff,0x803ff201,0xff34fffa,0x9bffe2bf,0xf502fffc,0x3fffeedf, 0x3a24ffff,0xffffffff,0x713ffea2,0x7e40dfff,0x7ffc43ff,0x3ffff402, 0xf51ffea0,0xffffffff,0x7ffffdff,0x16ffffec,0x71000000,0x003fffff, 0x0000fffa,0xd809fffb,0xffffffff,0xffffffff,0x1ff201ff,0x269fff50, 0xfff15fff,0x817ffe4d,0xfffceffa,0xaffffeef,0xffeffff9,0x3fea6fff, 0x3fffd84f,0xd05fffa8,0x7fc40bff,0x3f201fff,0x7dc0005f,0x7ffe45ff, 0x000befff,0xfffb3000,0x2001dfff,0x20003ffe,0x00fffff9,0x3ffffff6, 0xffffffff,0x7021ffff,0x7fd410df,0x2bfff34f,0x3f26fff8,0xfff502ff, 0xffa839ff,0x4c1effff,0x3313fffe,0xffff1013,0x07fffc41,0x2a07ffc8, 0x203fffff,0x20002fff,0x7106fffa,0x9ffffffd,0x3aa00003,0x1dffffff, 0x01fff400,0xfffff900,0x80000007,0x2df53ef8,0x3fea4fc8,0x2bfff34f, 0x3f26fff8,0xfff502ff,0x7ffdc0bf,0x3ffe606f,0x7ffd4004,0x80bfff65, 0xfb01fff9,0x260bffbf,0x30000fff,0x5001ffff,0xbffffffb,0xff910005, 0x017dffff,0x00fffa00,0x7d7ffc40,0x0000007f,0x7effffd4,0xb87fffde, 0x4bfff13f,0x3fee5fff,0xffff501f,0x7fffc401,0x02fff401,0x5d7ffe40, 0xff804fff,0xf3fff03f,0x17fee0ff,0x7fffc400,0x7fdc4001,0x00bfffff, 0x7ffffecc,0xe80002df,0xf70003ff,0x00bffabf,0xfda80000,0xffffffff, 0xf0fec0ce,0x27ff47ff,0x2a01fff5,0xff804fff,0x6ffd806f,0xffffd000, 0x3f200dff,0xf5ff985f,0x7ffd03ff,0xfffd1000,0xfda80005,0x21cfffff, 0xfffffeb8,0x200000cf,0xf0003ffe,0x1bfea3ff,0x4c000000,0x009dfffb, 0x2ffe83fe,0xff88fff6,0x0bffea07,0x2017ffe0,0x30007ffc,0x01ffffff, 0x703ffea0,0x0fff67ff,0x0001fff1,0x0007fffb,0x7fffe4c0,0xffffb1ff, 0x320005df,0xfeeeeeee,0xeeeeeeff,0x6ffb81ee,0x0000fffc,0xfffd8000, 0x8bfb102f,0x3fee1ffc,0xf502ffc1,0xfff003ff,0x0fff9009,0x7fffdc00, 0x17ffc002,0x7fdc7ff6,0x0037fd45,0x0027ffe4,0xffff5000,0x077fff63, 0xffffb000,0xffffffff,0x03ffffff,0xffc87ffd,0xcccccb85,0xcccccccc, 0xd80ccccc,0x81ffe9ff,0x47fb85fa,0x27f40ffa,0x003fff50,0xf9009fff, 0x7d4000ff,0x6c003fff,0x33ffc4ff,0x3ffd8fff,0x2fffdc00,0xeb880000, 0xffb1ffff,0x40003bff,0xfffffffd,0xffffffff,0x7fcc1fff,0x07ffcc0f, 0x3ffffff6,0xffffffff,0x7dc1ffff,0x01fff34f,0x510aa205,0x54035305, 0xff800fff,0x7ffc804f,0xffff1000,0x7dc001ff,0xf17fea6f,0x0fffc3ff, 0x1dfff500,0xfc980000,0x70dfffff,0x7dffffff,0xaaa98001,0xcfffaaaa, 0x0aaaaaaa,0xfd82ffec,0x7fffec4f,0xffffffff,0x41ffffff,0x3fee0ffd, 0x00000002,0x800fffa8,0xfc804fff,0xffb0007f,0x400dffff,0xff90fff8, 0xf54ffd87,0x7fcc00df,0x200000ff,0xffffffea,0xfffd500c,0x00039fff, 0x800fffa0,0xf501fff8,0x777641ff,0xeeeeeeee,0x1eeeeeee,0x000d82b8, 0xf5000000,0xfff001ff,0x0fff9009,0x79fff500,0x74009fff,0x83ffd3ff, 0x9ff96ffb,0x3fffe600,0xfc880001,0x03efffff,0x3ffff260,0x40002dff, 0x32003ffe,0x7ffc06ff,0x00000003,0x00000000,0x007ffd40,0x64027ffc, 0x7c4007ff,0x3fff66ff,0x1bff7001,0xfff10fff,0x1003fff1,0x0005fffd, 0xfffffda8,0x220001df,0xfffffffb,0xffe8000b,0x7fff1003,0x406ffb80, 0x20800099,0x9885fffd,0x99999999,0x2a000001,0xff800fff,0x7ffc804f, 0x0fffec00,0x200dfff1,0x5ffafff9,0xfff9ffd0,0x0ffffa00,0x7ff5c400, 0x000cffff,0x7fff5400,0x2001dfff,0xf7003ffe,0xff8801ff,0x7fff4c2f, 0x5a802dff,0xb03fffa2,0xffffffff,0x3ffe61ff,0x7fd40004,0x4fff800f, 0x007ffc80,0x2e13ffee,0xfd004fff,0x3207ffdf,0x804fffff,0x0004fffd, 0x3bfffff6,0x98000003,0x1ffffffc,0x007ffd00,0x5400aaaa,0x3fff21aa, 0xcfffffff,0x2637e4c1,0x7fec4fff,0xffffffff,0x009fff30,0x00fffa80, 0xc804fff8,0x9fff57ff,0x206fff98,0xc802fffe,0x500fffff,0x805fffff, 0x0005fffc,0x00efffec,0x5c400000,0xd001ffff,0x000007ff,0xfffff980, 0xffffffff,0x86ffffee,0x3f60fffa,0xffffffff,0x09fff30f,0x0fffa800, 0x804fff80,0xfff57ffc,0x01fffe89,0x003fffe2,0x40dffff5,0x407ffff8, 0xffeffff9,0xffffffff,0x19fb1fff,0x00000000,0x74007f6a,0x000003ff, 0x5ef7fcc0,0xffffffeb,0x05ffffff,0x554c9ff7,0x2aaaaaaa,0x0013ffe6, 0x001fff50,0xf9009fff,0x93ffeaff,0xb804fffc,0xff805fff,0x7ff404ff, 0x7ffcc05f,0xffffffff,0x1fffffff,0x00000003,0xa8004c00,0x000000aa, 0xa8827cc0,0xfffffffd,0x0eee00cf,0x00000000,0xf001fff5,0xff9009ff, 0x4d3ffeaf,0x3a006fff,0x7ec03fff,0x7fe402ff,0x7ffcc02f,0xffffffff, 0x1fffffff,0x00000000,0x00000000,0x00e60000,0x677f75c4,0x00000001, 0x3fea0000,0x4fff800f,0x007ffc80,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, }; static signed short stb__arial_45_usascii_x[95]={ 0,3,1,0,1,2,1,1,2,2,1,2,3,1, 3,0,1,4,1,1,0,1,1,1,1,1,3,3,2,2,2,1,2,-1,2,2,3,3,3,2,3,3,1,2, 2,2,3,1,3,1,3,1,0,3,0,0,0,0,0,2,0,0,1,-1,1,1,2,1,1,1,0,1,2,2, -2,2,2,2,2,1,2,1,2,1,0,2,0,0,0,0,0,1,3,0,1, }; static signed short stb__arial_45_usascii_y[95]={ 36,7,7,6,4,6,6,7,6,6,6,12,31,23, 31,6,7,7,7,7,7,7,7,7,7,7,15,15,12,15,12,6,6,7,7,6,7,7,7,6,7,7,7,7, 7,7,7,6,7,6,7,6,7,7,7,7,7,7,7,7,6,7,6,41,7,14,7,14,7,14,6,14,7,7, 7,7,7,14,14,14,14,14,14,14,7,15,15,15,15,15,15,6,6,6,18, }; static unsigned short stb__arial_45_usascii_w[95]={ 0,5,12,22,20,32,25,5,10,10,14,20,5,12, 5,12,20,12,20,20,21,20,20,20,20,20,5,5,20,20,20,20,38,28,23,26,24,22,20,27,23,5,17,25, 19,29,23,29,23,29,26,24,24,23,27,38,27,27,24,9,12,9,17,24,9,20,19,19,19,20,13,19,18,5, 9,18,5,29,18,20,19,19,12,18,11,18,20,29,20,20,20,12,4,13,21, }; static unsigned short stb__arial_45_usascii_h[95]={ 0,29,11,31,37,32,31,11,39,39,13,20,11,5, 5,31,30,29,29,30,29,30,30,29,30,30,21,27,20,13,20,30,39,29,29,31,29,29,29,31,29,29,30,29, 29,29,29,31,29,33,29,31,29,30,29,29,29,29,29,38,31,38,17,4,6,23,30,23,30,23,30,31,29,29, 38,29,29,22,22,23,31,31,22,23,30,22,21,21,21,30,21,39,39,39,8, }; static unsigned short stb__arial_45_usascii_s[95]={ 251,250,238,41,124,175,64,232,1,44,211, 151,226,222,235,165,1,240,51,42,125,83,104,1,125,158,31,72,130,190,109, 203,55,22,216,138,191,168,147,90,101,244,238,75,55,25,1,208,214,145,168, 178,124,179,96,57,29,1,224,104,238,94,172,78,212,138,63,78,22,159,224, 118,149,238,114,195,249,1,193,117,21,1,180,98,146,212,231,58,37,203,88, 31,26,12,190, }; static unsigned short stb__arial_45_usascii_t[95]={ 1,104,194,41,1,1,41,194,1,1,194, 194,194,208,208,41,73,134,164,73,134,73,73,164,73,73,194,164,194,194,194, 72,1,164,134,41,134,134,134,41,134,104,41,134,134,134,134,1,104,1,104, 41,104,73,104,104,104,104,72,1,1,1,194,188,208,164,73,164,73,164,41, 41,104,104,1,104,72,194,164,164,41,41,164,164,73,164,164,194,194,41,194, 1,1,1,208, }; static unsigned short stb__arial_45_usascii_a[95]={ 179,179,229,358,358,573,430,123, 215,215,251,376,179,215,179,179,358,358,358,358,358,358,358,358, 358,358,179,179,376,376,376,358,654,430,430,465,465,430,394,501, 465,179,322,430,358,537,465,501,430,501,465,430,394,465,430,608, 430,430,394,179,179,179,302,358,215,358,358,322,358,358,179,358, 358,143,143,322,143,537,358,358,358,358,215,322,179,358,322,465, 322,322,322,215,167,215,376, }; // Call this function with // font: NULL or array length // data: NULL or specified size // height: STB_FONT_arial_45_usascii_BITMAP_HEIGHT or STB_FONT_arial_45_usascii_BITMAP_HEIGHT_POW2 // return value: spacing between lines static void stb_font_arial_45_usascii(stb_fontchar font[STB_FONT_arial_45_usascii_NUM_CHARS], unsigned char data[STB_FONT_arial_45_usascii_BITMAP_HEIGHT][STB_FONT_arial_45_usascii_BITMAP_WIDTH], int height) { int i,j; if (data != 0) { unsigned int *bits = stb__arial_45_usascii_pixels; unsigned int bitpack = *bits++, numbits = 32; for (i=0; i < STB_FONT_arial_45_usascii_BITMAP_WIDTH*height; ++i) data[0][i] = 0; // zero entire bitmap for (j=1; j < STB_FONT_arial_45_usascii_BITMAP_HEIGHT-1; ++j) { for (i=1; i < STB_FONT_arial_45_usascii_BITMAP_WIDTH-1; ++i) { unsigned int value; if (numbits==0) bitpack = *bits++, numbits=32; value = bitpack & 1; bitpack >>= 1, --numbits; if (value) { if (numbits < 3) bitpack = *bits++, numbits = 32; data[j][i] = (bitpack & 7) * 0x20 + 0x1f; bitpack >>= 3, numbits -= 3; } else { data[j][i] = 0; } } } } // build font description if (font != 0) { float recip_width = 1.0f / STB_FONT_arial_45_usascii_BITMAP_WIDTH; float recip_height = 1.0f / height; for (i=0; i < STB_FONT_arial_45_usascii_NUM_CHARS; ++i) { // pad characters so they bilerp from empty space around each character font[i].s0 = (stb__arial_45_usascii_s[i]) * recip_width; font[i].t0 = (stb__arial_45_usascii_t[i]) * recip_height; font[i].s1 = (stb__arial_45_usascii_s[i] + stb__arial_45_usascii_w[i]) * recip_width; font[i].t1 = (stb__arial_45_usascii_t[i] + stb__arial_45_usascii_h[i]) * recip_height; font[i].x0 = stb__arial_45_usascii_x[i]; font[i].y0 = stb__arial_45_usascii_y[i]; font[i].x1 = stb__arial_45_usascii_x[i] + stb__arial_45_usascii_w[i]; font[i].y1 = stb__arial_45_usascii_y[i] + stb__arial_45_usascii_h[i]; font[i].advance_int = (stb__arial_45_usascii_a[i]+8)>>4; font[i].s0f = (stb__arial_45_usascii_s[i] - 0.5f) * recip_width; font[i].t0f = (stb__arial_45_usascii_t[i] - 0.5f) * recip_height; font[i].s1f = (stb__arial_45_usascii_s[i] + stb__arial_45_usascii_w[i] + 0.5f) * recip_width; font[i].t1f = (stb__arial_45_usascii_t[i] + stb__arial_45_usascii_h[i] + 0.5f) * recip_height; font[i].x0f = stb__arial_45_usascii_x[i] - 0.5f; font[i].y0f = stb__arial_45_usascii_y[i] - 0.5f; font[i].x1f = stb__arial_45_usascii_x[i] + stb__arial_45_usascii_w[i] + 0.5f; font[i].y1f = stb__arial_45_usascii_y[i] + stb__arial_45_usascii_h[i] + 0.5f; font[i].advance = stb__arial_45_usascii_a[i]/16.0f; } } } #ifndef STB_SOMEFONT_CREATE #define STB_SOMEFONT_CREATE stb_font_arial_45_usascii #define STB_SOMEFONT_BITMAP_WIDTH STB_FONT_arial_45_usascii_BITMAP_WIDTH #define STB_SOMEFONT_BITMAP_HEIGHT STB_FONT_arial_45_usascii_BITMAP_HEIGHT #define STB_SOMEFONT_BITMAP_HEIGHT_POW2 STB_FONT_arial_45_usascii_BITMAP_HEIGHT_POW2 #define STB_SOMEFONT_FIRST_CHAR STB_FONT_arial_45_usascii_FIRST_CHAR #define STB_SOMEFONT_NUM_CHARS STB_FONT_arial_45_usascii_NUM_CHARS #define STB_SOMEFONT_LINE_SPACING STB_FONT_arial_45_usascii_LINE_SPACING #endif
InTheBlack-cn/MorePlanets
src/main/java/stevekung/mods/moreplanets/recipe/DarkEnergyRecipeData.java
package stevekung.mods.moreplanets.recipe; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import net.minecraft.item.ItemStack; public class DarkEnergyRecipeData { private final HashMap<Integer, ItemStack> input; private final ItemStack output; private final int timeMultiplier; private static final List<DarkEnergyRecipeData> RECIPES = new ArrayList<>(); private DarkEnergyRecipeData(HashMap<Integer, ItemStack> input, ItemStack output, int timeMultiplier) { this.input = input; this.output = output; this.timeMultiplier = timeMultiplier; } public HashMap<Integer, ItemStack> getInput() { return this.input; } public ItemStack getOutput() { return this.output; } public int getTimeMultiplier() { return this.timeMultiplier; } public static void registerRecipe(HashMap<Integer, ItemStack> input, ItemStack output, int timeMultiplier) { DarkEnergyRecipeData.RECIPES.add(new DarkEnergyRecipeData(input, output, timeMultiplier)); } public static List<DarkEnergyRecipeData> getRecipeList() { return DarkEnergyRecipeData.RECIPES; } }
kiwi515/ogws
include/egg/gfx/eggScreen.h
#ifndef EGG_GFX_SCREEN_H #define EGG_GFX_SCREEN_H #include "types_egg.h" namespace EGG { struct eggScreen // : public eggFrustum { char UNK_0x0[0x18]; f32 mNearZ; // at 0x18 f32 mFarZ; // at 0x1C }; } #endif
igormskru/code
one-time-examples/ige-example/ige-processApplication/src/main/java/org/camunda/bpm/cockpit/ige/adapter/RepairableFailingDelegate.java
<reponame>igormskru/code package org.camunda.bpm.cockpit.ige.adapter; import java.util.logging.Logger; import org.camunda.bpm.engine.ProcessEngineException; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; /** * This is an simple service implementation throwing a ProcessEngineException * unless a processVariable 'REPAIRED' equals 'true' */ public class RepairableFailingDelegate implements JavaDelegate { public static final String REPAIRED = "REPAIRED"; private final Logger LOGGER = Logger.getLogger(RepairableFailingDelegate.class.getName()); public void execute(DelegateExecution execution) throws Exception { LOGGER.info("\n\n ... " + RepairableFailingDelegate.class.getSimpleName() + " with " + REPAIRED + " = " + execution.getVariable(REPAIRED) + " invoked by " + "processDefinitionId=" + execution.getProcessDefinitionId() + ", activtyId=" + execution.getCurrentActivityId() + ", activtyName='" + execution.getCurrentActivityName() + "'" + ", processInstanceId=" + execution.getProcessInstanceId() + ", businessKey=" + execution.getProcessBusinessKey() + ", executionId=" + execution.getId()); if ("true".equals(execution.getVariable(REPAIRED))) { return; } else { throw new ProcessEngineException("create an incident!"); } } }
OliverSchmitz/lue
source/framework/benchmark/include/lue/framework/benchmark/task.hpp
<reponame>OliverSchmitz/lue #pragma once #include <cstdint> #include <vector> namespace lue { namespace benchmark { class Task { public: using Shape = std::vector<std::uint64_t>; Task (std::uint64_t nr_time_steps, Shape const& array_shape, Shape const& partition_shape); Task (Task const&)=default; Task (Task&&)=default; ~Task ()=default; Task& operator= (Task const&)=default; Task& operator= (Task&&)=default; std::uint64_t nr_time_steps () const; std::size_t rank () const; std::uint64_t nr_elements () const; Shape const& array_shape () const; Shape const& partition_shape () const; private: std::uint64_t const _nr_time_steps; Shape const _array_shape; Shape const _partition_shape; }; } // namespace benchmark } // namespace lue
blockfuse/payment-gateway
client-applications/client/src/models/order-response.js
<filename>client-applications/client/src/models/order-response.js export class OrderResponse { order_id = ''; client_order_id = ''; symbol = ''; price = ''; avg_execution_price = ''; side = ''; type = ''; timestamp = ''; timestampms = ''; is_live = ''; is_cancelled = ''; options = []; executed_amount = ''; remaining_amount = ''; original_amount = ''; type = ''; constructor(data) { Object.assign(this, data); } }
resource-watch/manager
components/dashboards/table/td/PreviewTD.js
<filename>components/dashboards/table/td/PreviewTD.js import React from 'react'; import PropTypes from 'prop-types'; function PreviewTD(props) { const { value, index } = props; return ( <td key={index}> <a target="_blank" href={`/dashboards/${value}`}> {`${window.location.origin}/dashboards/${value}`} </a> </td> ); } PreviewTD.propTypes = { value: PropTypes.string, index: PropTypes.string }; export default PreviewTD;
tusharchoudhary0003/Custom-Football-Game
sources/p005cm/aptoide/p006pt/C0045e.java
<reponame>tusharchoudhary0003/Custom-Football-Game<gh_stars>1-10 package p005cm.aptoide.p006pt; import p026rx.p027b.C0129b; /* renamed from: cm.aptoide.pt.e */ /* compiled from: lambda */ public final /* synthetic */ class C0045e implements C0129b { /* renamed from: a */ public static final /* synthetic */ C0045e f60a = new C0045e(); private /* synthetic */ C0045e() { } public final void call(Object obj) { AptoideApplication.m93a((Long) obj); } }
yangjintao1/myfirstpro
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/nodes/physical/batch/BatchExecHashAggregateBase.scala
<filename>flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/nodes/physical/batch/BatchExecHashAggregateBase.scala<gh_stars>0 /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.flink.table.plan.nodes.physical.batch import org.apache.flink.table.api.BatchTableEnvironment import org.apache.flink.table.api.functions.UserDefinedFunction import org.apache.flink.table.api.types.{DataType, RowType} import org.apache.flink.table.calcite.FlinkTypeFactory import org.apache.flink.table.codegen._ import org.apache.flink.table.codegen.agg.BatchExecHashAggregateCodeGen import org.apache.flink.table.dataformat.{BaseRow, BinaryRow, GenericRow, JoinedRow} import org.apache.flink.table.plan.cost.FlinkBatchCost._ import org.apache.flink.table.plan.cost.FlinkCostFactory import org.apache.flink.table.runtime.AbstractStreamOperatorWithMetrics import org.apache.flink.table.runtime.util.{BytesHashMap, BytesHashMapSpillMemorySegmentPool} import org.apache.calcite.plan.{RelOptCluster, RelOptCost, RelOptPlanner, RelTraitSet} import org.apache.calcite.rel.RelNode import org.apache.calcite.rel.`type`.RelDataType import org.apache.calcite.rel.core.AggregateCall import org.apache.calcite.rel.metadata.RelMetadataQuery import org.apache.calcite.tools.RelBuilder import org.apache.calcite.util.Util abstract class BatchExecHashAggregateBase( cluster: RelOptCluster, relBuilder: RelBuilder, traitSet: RelTraitSet, inputNode: RelNode, aggCallToAggFunction: Seq[(AggregateCall, UserDefinedFunction)], rowRelDataType: RelDataType, inputRelDataType: RelDataType, grouping: Array[Int], auxGrouping: Array[Int], isMerge: Boolean, isFinal: Boolean) extends BatchExecGroupAggregateBase( cluster, relBuilder, traitSet, inputNode, aggCallToAggFunction, rowRelDataType, inputRelDataType, grouping, auxGrouping, isMerge, isFinal) with BatchExecHashAggregateCodeGen { lazy val aggBufferRowType: RowType = new RowType( aggBufferTypes.flatten.toArray[DataType], aggBufferNames.flatten) override def computeSelfCost(planner: RelOptPlanner, mq: RelMetadataQuery): RelOptCost = { val numOfGroupKey = grouping.length val inputRowCnt = mq.getRowCount(getInput()) if (inputRowCnt == null) { return null } val hashCpuCost = HASH_CPU_COST * inputRowCnt * numOfGroupKey val aggFunctionCpuCost = FUNC_CPU_COST * inputRowCnt * aggCallToAggFunction.size val averageRowSize: Double = mq.getAverageRowSize(this) val memCost = if (numOfGroupKey == 0) { averageRowSize } else { // assume memory is enough to hold hashTable to simplify the estimation because spill will not // happen under the assumption val ndvOfGroupKey = Util.first(mq.getRowCount(this), 1d) // We aim for a 200% utilization of the bucket table. val bucketSize = ndvOfGroupKey * BytesHashMap.BUCKET_SIZE / BatchPhysicalRel.HASH_COLLISION_WEIGHT val recordSize = ndvOfGroupKey * (BatchPhysicalRel.binaryRowAverageSize(this) + BytesHashMap.RECORD_EXTRA_LENGTH) bucketSize + recordSize } val cpuCost = hashCpuCost + aggFunctionCpuCost val costFactory = planner.getCostFactory.asInstanceOf[FlinkCostFactory] costFactory.makeCost(mq.getRowCount(this), cpuCost, 0, 0, memCost) } def getOutputRowClass: Class[_ <: BaseRow] = if (grouping.isEmpty) classOf[GenericRow] else classOf[JoinedRow] def codegenWithKeys( ctx: CodeGeneratorContext, tableEnv: BatchTableEnvironment, inputType: RowType, outputType: RowType, reservedManagedMemory: Long, maxManagedMemory: Long): GeneratedOperator = { val config = tableEnv.config val inputTerm = CodeGeneratorContext.DEFAULT_INPUT1_TERM val className = if (isFinal) "HashAggregateWithKeys" else "LocalHashAggregateWithKeys" // add logger val logTerm = CodeGenUtils.newName("LOG") ctx.addReusableLogger(logTerm, className) // gen code to do group key projection from input val currentKeyTerm = CodeGenUtils.newName("currentKey") val currentKeyWriterTerm = CodeGenUtils.newName("currentKeyWriter") val keyProjectionCode = genGroupKeyProjectionCode("HashAgg", ctx, groupKeyRowType, getGrouping, inputType, inputTerm, currentKeyTerm, currentKeyWriterTerm) // --------------------------------------------------------------------------------------------- // gen code to create groupKey, aggBuffer Type array // it will be used in BytesHashMap and BufferedKVExternalSorter if enable fallback val groupKeyTypesTerm = CodeGenUtils.newName("groupKeyTypes") val aggBufferTypesTerm = CodeGenUtils.newName("aggBufferTypes") prepareHashAggKVTypes( ctx, groupKeyTypesTerm, aggBufferTypesTerm, groupKeyRowType, aggBufferRowType) // gen code to aggregate and output using hash map val aggregateMapTerm = CodeGenUtils.newName("aggregateMap") val lookupInfo = ctx.newReusableField( "lookupInfo", classOf[BytesHashMap.LookupInfo].getCanonicalName) prepareHashAggMap( ctx, config, reservedManagedMemory, maxManagedMemory, groupKeyTypesTerm, aggBufferTypesTerm, aggregateMapTerm) val outputTerm = CodeGenUtils.newName("hashAggOutput") val (reuseAggMapEntryTerm, reuseGroupKeyTerm, reuseAggBufferTerm) = prepareTermForAggMapIteration(ctx, outputTerm, outputType, groupKeyRowType, aggBufferRowType) val currentAggBufferTerm = ctx.newReusableField("currentAggBuffer", classOf[BinaryRow].getName) val (initedAggBuffer, aggregate, outputExpr) = genHashAggCodes(isMerge, isFinal, ctx, config, builder, (getGrouping, getAuxGrouping), inputRelDataType, inputTerm, inputType, aggregateCalls, aggCallToAggFunction, aggregates, currentAggBufferTerm, aggBufferRowType, aggBufferNames, aggBufferTypes, outputTerm, outputType, reuseGroupKeyTerm, reuseAggBufferTerm) val outputResultFromMap = genAggMapIterationAndOutput( ctx, config, isFinal, aggregateMapTerm, reuseAggMapEntryTerm, reuseAggBufferTerm, outputExpr) // --------------------------------------------------------------------------------------------- // gen code to deal with hash map oom, if enable fallback we will use sort agg strategy val sorterTerm = CodeGenUtils.newName("sorter") val retryAppend = genRetryAppendToMap( aggregateMapTerm, currentKeyTerm, initedAggBuffer, lookupInfo, currentAggBufferTerm) val (dealWithAggHashMapOOM, fallbackToSortAggCode) = genAggMapOOMHandling( isFinal, ctx, config, builder, (getGrouping, getAuxGrouping), inputRelDataType, aggCallToAggFunction, aggregates, udaggs, logTerm, aggregateMapTerm, (groupKeyTypesTerm, aggBufferTypesTerm), (groupKeyRowType, aggBufferRowType), aggBufferNames, aggBufferTypes, outputTerm, outputType, outputResultFromMap, sorterTerm, retryAppend) prepareMetrics(ctx, aggregateMapTerm, if (isFinal) sorterTerm else null) // -------------------------------------------------------------------------------------------- val lazyInitAggBufferCode = if (auxGrouping.nonEmpty) { s""" |// lazy init agg buffer (with auxGrouping) |${initedAggBuffer.code} """.stripMargin } else { "" } val processCode = s""" | // input field access for group key projection and aggregate buffer update |${ctx.reuseInputUnboxingCode(Set(inputTerm))} | // project key from input |$keyProjectionCode | // look up output buffer using current group key |$lookupInfo = $aggregateMapTerm.lookup($currentKeyTerm); |$currentAggBufferTerm = $lookupInfo.getValue(); | |if (!$lookupInfo.isFound()) { | $lazyInitAggBufferCode | // append empty agg buffer into aggregate map for current group key | try { | $currentAggBufferTerm = | $aggregateMapTerm.append($lookupInfo, ${initedAggBuffer.resultTerm}); | } catch (java.io.EOFException exp) { | $dealWithAggHashMapOOM | } |} | // aggregate buffer fields access |${ctx.reuseInputUnboxingCode(Set(currentAggBufferTerm))} | // do aggregate and update agg buffer |${aggregate.code} |""".stripMargin.trim val endInputCode = if (isFinal) { val memPoolTypeTerm = classOf[BytesHashMapSpillMemorySegmentPool].getName s""" |if ($sorterTerm == null) { | // no spilling, output by iterating aggregate map. | $outputResultFromMap |} else { | // spill last part of input' aggregation output buffer | $sorterTerm.sortAndSpill( | $aggregateMapTerm.getRecordAreaMemorySegments(), | $aggregateMapTerm.getNumElements(), | new $memPoolTypeTerm($aggregateMapTerm.getBucketAreaMemorySegments())); | // only release floating memory in advance. | $aggregateMapTerm.free(true); | // fall back to sort based aggregation | $fallbackToSortAggCode |} """.stripMargin } else { s"$outputResultFromMap" } val baseClass = classOf[AbstractStreamOperatorWithMetrics[_]].getName generateOperator(ctx, className, baseClass, processCode, endInputCode, inputRelDataType, config) } }
mathco-wf/river
river/optim/momentum.py
<reponame>mathco-wf/river<gh_stars>1-10 import collections from . import base __all__ = ["Momentum"] class Momentum(base.Optimizer): """Momentum optimizer. Parameters ---------- lr rho Examples -------- >>> from river import datasets >>> from river import evaluate >>> from river import linear_model >>> from river import metrics >>> from river import optim >>> from river import preprocessing >>> dataset = datasets.Phishing() >>> optimizer = optim.Momentum() >>> model = ( ... preprocessing.StandardScaler() | ... linear_model.LogisticRegression(optimizer) ... ) >>> metric = metrics.F1() >>> evaluate.progressive_val_score(dataset, model, metric) F1: 0.841645 """ def __init__(self, lr=0.1, rho=0.9): super().__init__(lr) self.rho = rho self.s = collections.defaultdict(float) def _step(self, w, g): for i, gi in g.items(): self.s[i] = self.rho * self.s[i] + self.learning_rate * gi w[i] -= self.s[i] return w
mhqz/ouinet
src/util/temp_file.h
<reponame>mhqz/ouinet<filename>src/util/temp_file.h #pragma once #include <boost/asio/posix/stream_descriptor.hpp> #include <boost/filesystem.hpp> #include <boost/optional.hpp> #include <boost/system/error_code.hpp> #include "../namespaces.h" namespace ouinet { namespace util { static const fs::path default_temp_model{"tmp.%%%%-%%%%-%%%%-%%%%"}; class temp_file { public: // Create a temporary file named after the given `temp_model` under `dir` // and open it for reading and writing. // Use its `lowest_layer()` to perform I/O. // If `keep_on_close(false)`, remove the file on close. static boost::optional<temp_file> make( const asio::executor& , const fs::path& dir , const fs::path& model , sys::error_code&); static boost::optional<temp_file> make( const asio::executor& ex , const fs::path& dir , sys::error_code& ec) { return make(ex, dir, default_temp_model, ec); } static boost::optional<temp_file> make( const asio::executor& ex , sys::error_code& ec) { return make(ex, ".", default_temp_model, ec); } public: using lowest_layer_type = asio::posix::stream_descriptor; temp_file(const temp_file&) = delete; temp_file& operator=(const temp_file&) = delete; temp_file(temp_file&&) = default; temp_file& operator=(temp_file&&) = default; ~temp_file() { close(); } const fs::path& path() const { return _path; } bool keep_on_close() const { return _keep_on_close; } void keep_on_close(bool k) { _keep_on_close = k; } lowest_layer_type& lowest_layer() { return _file; } const lowest_layer_type& lowest_layer() const { return _file; } auto native_handle() { return _file.native_handle(); } // <AsyncReadStream+AsyncWriteStream> auto get_executor() { return _file.get_executor(); } template<class MutableBufferSequence, class Token> auto async_read_some(const MutableBufferSequence& mb, Token&& t) { return _file.async_read_some(mb, std::move(t)); } template<class ConstBufferSequence, class Token> auto async_write_some(const ConstBufferSequence& cb, Token&& t) { return _file.async_write_some(cb, std::move(t)); } // </AsyncReadStream+AsyncWriteStream> void close(); private: temp_file( lowest_layer_type&& file , fs::path path) : _file(std::move(file)) , _path(std::move(path)) {} lowest_layer_type _file; fs::path _path; bool _keep_on_close = true; }; }} // namespaces
onosfw/apis
onos/apis/classorg_1_1onosproject_1_1event_1_1TestEvent.js
<reponame>onosfw/apis var classorg_1_1onosproject_1_1event_1_1TestEvent = [ [ "Type", "enumorg_1_1onosproject_1_1event_1_1TestEvent_1_1Type.html", "enumorg_1_1onosproject_1_1event_1_1TestEvent_1_1Type" ], [ "TestEvent", "classorg_1_1onosproject_1_1event_1_1TestEvent.html#a070b5ac2ac6c4ea09274181c565b4084", null ], [ "TestEvent", "classorg_1_1onosproject_1_1event_1_1TestEvent.html#a3886e08ebeab1802a735e904357a8ed2", null ] ];
rocketbase-io/commons-asset
commons-asset-imgproxy/src/main/java/io/rocketbase/commons/service/ImgproxyS3AssetPreviewService.java
package io.rocketbase.commons.service; import io.rocketbase.asset.imgproxy.Signature; import io.rocketbase.asset.imgproxy.SignatureConfiguration; import io.rocketbase.asset.imgproxy.options.ResizeType; import io.rocketbase.commons.config.AssetApiProperties; import io.rocketbase.commons.config.AssetImgproxyProperties; import io.rocketbase.commons.config.AssetS3Properties; import io.rocketbase.commons.converter.AbstractAssetPreviewService; import io.rocketbase.commons.dto.asset.AssetReference; import io.rocketbase.commons.dto.asset.AssetType; import io.rocketbase.commons.dto.asset.PreviewSize; public class ImgproxyS3AssetPreviewService extends AbstractAssetPreviewService { final AssetImgproxyProperties imgproxyProperties; final AssetS3Properties s3Properties; final BucketResolver bucketResolver; public ImgproxyS3AssetPreviewService(AssetApiProperties assetApiProperties, AssetImgproxyProperties imgproxyProperties, AssetS3Properties s3Properties, BucketResolver bucketResolver, FileStorageService fileStorageService) { super(assetApiProperties, fileStorageService, true); this.imgproxyProperties = imgproxyProperties; this.s3Properties = s3Properties; this.bucketResolver = bucketResolver; } @Override protected String getBaseUrl() { return null; } @Override public boolean isPreviewSupported(AssetType assetType) { return assetType.isImage(); } @Override public String getPreviewUrl(AssetReference AssetReference, PreviewSize previewSize) { Signature signature = Signature.of(new SignatureConfiguration(imgproxyProperties.getBaseUrl(), imgproxyProperties.getKey(), imgproxyProperties.getSalt())) .resize(ResizeType.fit, previewSize.getMaxWidth(), previewSize.getMaxHeight(), imgproxyProperties.isEnlarge()); return signature.url("s3://" + getBucket(AssetReference) + "/" + AssetReference.getUrlPath()); } protected String getBucket(AssetReference AssetReference) { return bucketResolver != null ? bucketResolver.resolveBucketName(AssetReference) : s3Properties.getBucket(); } }
bg1bgst333/Sample
cpp/set/set/src/set/set.cpp
// ヘッダのインクルード #include <iostream> // C++標準入出力 #include <set> // 集合 #include <iterator> // イテレータ // main関数の定義 int main(){ // オブジェクトの定義 std::set<int> set; // std::setオブジェクトset(int型要素) std::set<int>::iterator itor; // std::set<int>のイテレータitor. // 要素の追加 set.insert(30); // set.insertで30を追加. set.insert(10); // set.insertで10を追加. set.insert(40); // set.insertで40を追加. set.insert(20); // set.insertで20を追加. set.insert(50); // set.insertで50を追加. // イテレータですべての要素を取得し, 出力. for (itor = set.begin(); itor != set.end(); itor++){ // set.begin()からset.end()まで繰り返す. // イテレータの指す位置の値を出力. std::cout << "*itor = " << *itor << std::endl; // *itorでitorの指す位置の値が取得できるので, それを出力. } // プログラムの終了 return 0; }
TUD-UCB-Boda/tud_boda
src/cnn_codegen.cc
<reponame>TUD-UCB-Boda/tud_boda // Copyright (c) 2015, <NAME> <<EMAIL>>; part of Boda framework; see LICENSE #include"boda_tu_base.H" #include"rtc_func_gen.H" #include"geom_prim.H" namespace boda { struct cnn_custom_codegen_t : public custom_codegen_t { virtual void gen_op( rtc_call_gen_t * rcg, string const & op_name ) { // *** custom codegen hooks *** if( op_name == "conv" ) { gen_op_conv(rcg); } else if( op_name == "conv_simd" ) { gen_op_conv_simd(rcg); } else if( op_name == "ipconv" ) { gen_op_ipconv(rcg); } else if( op_name == "k1conv" ) { gen_op_k1conv(rcg); } else if( op_name == "k1conv_simd" ) { gen_op_k1conv_simd(rcg); } else if( op_name == "tconv" ) { gen_op_tconv(rcg); } else if( op_name == "sgemm" ) { gen_op_sgemm(rcg); } else if( op_name == "sgemm_no_local" ) { gen_op_sgemm_no_local(rcg); } else if( op_name == "sgemm_simd" ) { gen_op_sgemm_simd(rcg); } else if( op_name == "sgemm_simd_local" ) { gen_op_sgemm_simd_local(rcg); } else if( op_name == "bconv" ) { gen_op_bconv(rcg); } else if( op_name == "bconv_fb" ) { gen_op_bconv_fb(rcg); } else if( op_name == "reduce" ) { gen_op_reduce(rcg); } } void gen_op_reduce( rtc_call_gen_t * rcg ) { // FIXME: iterator over non-flat args and/or select ins arg directly, then do inner iter? for( vect_arg_decl_t::multi_iter i = rcg->rtc_func_template->arg_decls.multi_begin( &rcg->op ); !i.at_end(); ++i ) { if( i.ad().vn != "ins" ) { continue; } rcg->line( "ins_ops", "v += "+i.vn()+"[GLOB_ID_1D];" ); } } string maybe_add_relu( rtc_call_gen_t * rcg, string const & ve ) { return rcg->op.get_u32("conv_has_relu") ? ( "max(0.0f,"+ve+")" ) : ve; } string add_bias_then_maybe_relu( rtc_call_gen_t * rcg, dims_t const & work, uint32_t const & tx, uint32_t const ty ) { string const ve = strprintf( "(out_tile[%s] + filts_strip[%s])", str((ty*work.dsz("out_chan")+tx)).c_str(), str(tx).c_str() ); return maybe_add_relu( rcg, ve ); } void gen_op_bconv( rtc_call_gen_t * rcg ) { dims_t const & work = rcg->get_arg_dims_by_name( "work" ); uint32_t const in_smem_sz = work.dsz("pels_tile")*work.dsz("pels"); rcg->set( "in_smem_sz", str(in_smem_sz) ); uint32_t const in_smem_load_iter = u32_ceil_div( in_smem_sz, rcg->rtc_call_geom.tpb ); rcg->set( "in_smem_load_iter", str(in_smem_load_iter) ); uint32_t const filts_smem_sz = work.dsz("out_ix_tile")*work.dsz("out_ix"); rcg->set( "filts_smem_sz", str(filts_smem_sz) ); uint32_t const filts_smem_load_iter = u32_ceil_div( filts_smem_sz, rcg->rtc_call_geom.tpb ); rcg->set( "filts_smem_load_iter", str(filts_smem_load_iter) ); for( uint32_t tx = 0; tx != work.dsz( "out_ix" ); ++tx ) { rcg->line( "loads", strprintf( "filts_strip[%s] = filts_smem[%%(LOC_ID_1D_out_ix_tile)*%%(work_out_ix_dim)+%s];", str(tx).c_str(), str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { // note: could merge with above loop, but we want to use ty for consistency rcg->line( "loads", strprintf( "in_strip[%s] = in_smem[%%(LOC_ID_1D_pels_tile)*%%(work_pels_dim)+%s];", str(ty).c_str(), str(ty).c_str() ) ); } rcg->line( "outs_to_filts_strip", "switch(work_pel) { " ); for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { rcg->line( "outs_to_filts_strip", "case "+str(ty)+":" ); for( uint32_t tx = 0; tx != work.dsz( "out_ix" ); ++tx ) { uint32_t const rix = ty*work.dsz("out_ix")+tx; rcg->line( "fmas", strprintf( "out_tile[%s] += filts_strip[%s]*in_strip[%s];", str(rix).c_str(), str(tx).c_str(), str(ty).c_str() ) ); rcg->line( "outs_to_filts_strip", strprintf( "filts_strip[%s] = out_tile[%s];", str(tx).c_str(), str(rix).c_str() ) ); } rcg->line( "outs_to_filts_strip", "break;" ); } rcg->line( "outs_to_filts_strip", "} " ); string store_expr = R"foo( igl_y = (%(pel_ix_y)-%(bck_in_pad_y_dim))*%(stride_y_dim)+%(out_ix_sy)-%(in_pad_y_dim)+%(bck_pad_in_off_y_dim); igl_x = (%(pel_ix_x)-%(bck_in_pad_x_dim))*%(stride_x_dim)+%(out_ix_sx)-%(in_pad_x_dim)+%(bck_pad_in_off_x_dim); if( igl_x >= 0 && igl_y >= 0 && igl_y < %(in_grad_loss_y_dim) && igl_x < %(in_grad_loss_x_dim) && %(out_ix_in_chan) < %(in_grad_loss_chan_dim) && %(pel_ix_img) < %(in_grad_loss_img_dim) ) { in_grad_loss[ %(pel_ix_img)*%(in_grad_loss_img_stride) + %(out_ix_in_chan)*%(in_grad_loss_chan_stride) + igl_y*%(in_grad_loss_y_stride) + igl_x*%(in_grad_loss_x_stride)] = filts_strip[)foo"; for( uint32_t tx = 0; tx != work.dsz( "out_ix" ); ++tx ) { rcg->line( "stores", store_expr + strprintf( "%s];\n};", str(tx).c_str() ) ); rcg->line( "stores", "++out_ix;" ); } } void gen_op_bconv_fb( rtc_call_gen_t * rcg ) { dims_t const & work = rcg->get_arg_dims_by_name( "work_fb" ); uint32_t const in_smem_sz = work.dsz("pels_tile")*work.dsz("pels"); rcg->set( "in_smem_sz", str(in_smem_sz) ); uint32_t const in_smem_load_iter = u32_ceil_div( in_smem_sz, rcg->rtc_call_geom.tpb ); rcg->set( "in_smem_load_iter", str(in_smem_load_iter) ); uint32_t const filts_smem_sz = work.dsz("out_ix_tile")*work.dsz("out_ix"); rcg->set( "filts_smem_sz", str(filts_smem_sz) ); uint32_t const filts_smem_load_iter = u32_ceil_div( filts_smem_sz, rcg->rtc_call_geom.tpb ); rcg->set( "filts_smem_load_iter", str(filts_smem_load_iter) ); for( uint32_t tx = 0; tx != work.dsz( "out_ix" ); ++tx ) { rcg->line( "loads", strprintf( "filts_strip[%s] = filts_smem[%%(LOC_ID_1D_out_ix_tile)*%%(work_fb_out_ix_dim)+%s];", str(tx).c_str(), str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { // note: could merge with above loop, but we want to use ty for consistency rcg->line( "loads", strprintf( "in_strip[%s] = in_smem[%%(LOC_ID_1D_pels_tile)*%%(work_fb_pels_dim)+%s];", str(ty).c_str(), str(ty).c_str() ) ); } rcg->line( "outs_to_filts_strip", "switch(work_pel) { " ); for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { rcg->line( "outs_to_filts_strip", "case "+str(ty)+":" ); for( uint32_t tx = 0; tx != work.dsz( "out_ix" ); ++tx ) { uint32_t const rix = ty*work.dsz("out_ix")+tx; rcg->line( "fmas", strprintf( "out_tile[%s] += filts_strip[%s]*in_strip[%s];", str(rix).c_str(), str(tx).c_str(), str(ty).c_str() ) ); rcg->line( "outs_to_filts_strip", strprintf( "filts_strip[%s] = out_tile[%s];", str(tx).c_str(), str(rix).c_str() ) ); } rcg->line( "outs_to_filts_strip", "break;" ); } rcg->line( "outs_to_filts_strip", "} " ); string store_expr = R"foo( if( %(pel_ix_in_chan) < %(filts_grad_loss_in_chan_dim) && %(out_ix_out_chan) < %(filts_grad_loss_out_chan_dim) ) { filts_grad_loss[ %(out_ix_out_chan)*%(filts_grad_loss_out_chan_stride) + %(pel_ix_in_chan)*%(filts_grad_loss_in_chan_stride) + %(pel_ix_y)*%(filts_grad_loss_y_stride) + %(pel_ix_x)*%(filts_grad_loss_x_stride)] = filts_strip[)foo"; for( uint32_t tx = 0; tx != work.dsz( "out_ix" ); ++tx ) { rcg->line( "stores", store_expr + strprintf( "%s];\n};", str(tx).c_str() ) ); rcg->line( "stores", "++out_ix;" ); } } void gen_filts_smem_loads( rtc_call_gen_t * rcg, uint32_t const filts_smem_sz ) { // note: filts_smem_sz must == tvv %(filts_smem_sz) uint32_t const out_chan_smem_load_iter = u32_ceil_div( filts_smem_sz, rcg->rtc_call_geom.tpb ); for( uint32_t i = 0; i != out_chan_smem_load_iter; ++i ) { string const ixe = "(LOC_ID_1D + %(tpb) * "+str(i)+")"; string eif; if( (i+1)*rcg->rtc_call_geom.tpb > filts_smem_sz ) { rcg->line( "filts_smem_loads", "if( "+ixe+" < %(filts_smem_sz) ) {" );eif = "}";} // note: load is (always) contiguous rcg->line( "filts_smem_loads", strprintf("filts_smem[%s] = filts[filts_off+(%%(tpb)*%s)];%s",ixe.c_str(),str(i).c_str(),eif.c_str()) ); } // number of out chans per block; note: == work_out_chan_tile_dim*work_out_chan_dim uint32_t const filts_x_stride = rcg->get_arg_dims_by_name("filts").dstride("x"); uint32_t const out_chan_bias_smem_load_iter = u32_ceil_div( filts_x_stride, rcg->rtc_call_geom.tpb ); rcg->set( "out_chan_bias_smem_load_iter", str(out_chan_bias_smem_load_iter) ); rcg->line( "biases_smem_loads","int32_t ocix; int32_t const ocix_base = %(GRP_ID_1D_out_chan_blk)*%(filts_x_stride);" ); for( uint32_t i = 0; i != out_chan_bias_smem_load_iter; ++i ) { string const ixe = "(LOC_ID_1D + %(tpb) * "+str(i)+")"; string eif; rcg->line( "biases_smem_loads", strprintf( "ocix = ocix_base + (%s %%%% %%(work_out_chan_tile_dim))*%%(work_out_chan_dim) + ( %s / %%(work_out_chan_tile_dim) );", ixe.c_str(), ixe.c_str() ) ); if( (i+1)*rcg->rtc_call_geom.tpb > filts_x_stride ) { rcg->line( "biases_smem_loads", "if( "+ixe+" < %(filts_x_stride) ) {" );eif = "}";} // note: load is (always) contiguous rcg->line( "biases_smem_loads", strprintf("if( ocix < %%(biases_out_chan_dim) ) {filts_smem[%s] = biases[ocix];}%s",ixe.c_str(),eif.c_str()) ); } } void gen_op_conv( rtc_call_gen_t * rcg ) { dims_t const & work = rcg->get_arg_dims_by_name( "work" ); dims_t const & filts = rcg->get_arg_dims_by_name( "filts" ); uint32_t const filts_smem_sz = filts.dstride("x"); rcg->set( "filts_smem_sz", str(filts_smem_sz) ); gen_filts_smem_loads( rcg, filts_smem_sz ); uint32_t const pel_smem_load_iter = u32_ceil_div( (work.dsz( "pels" ) * work.dsz( "pels_tile" )), rcg->rtc_call_geom.tpb ); rcg->set( "pel_smem_load_iter", str(pel_smem_load_iter) ); rcg->set( "out_chan_tile", "(%(LOC_ID_1D_out_chan_tile)+%(GRP_ID_1D_out_chan_blk)*%(work_out_chan_tile_dim))"); rcg->set( "pel_tile", "(%(LOC_ID_1D_pels_tile)+%(GRP_ID_1D_pels_blk)*%(work_pels_tile_dim))"); rcg->set( "out_chan_ix","(%(out_chan_tile)*%(work_out_chan_dim))" ); for( uint32_t i = 0; i != work.dsz( "pels" ); ++i ) { insert_nda_ix_exprs( rcg->tsvs, "pel_ix_" + str(i), must_find(rcg->all_ix_dims,"out_pel_ix"), strprintf( "(%%(pel_tile)*%%(work_pels_dim)+%s)", str(i).c_str() ) ); } for( uint32_t tx = 0; tx != work.dsz( "out_chan" ); ++tx ) { rcg->line( "loads", strprintf( "filts_strip[%s] = filts_smem[%%(LOC_ID_1D_out_chan_tile)+%s*%%(work_out_chan_tile_dim)];", str(tx).c_str(), str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { // note: could merge with above loop, but we want to use ty for consistency rcg->line( "loads", strprintf( "in_strip[%s] = in_smem[%%(LOC_ID_1D_pels_tile)*%%(work_pels_dim)+%s];", str(ty).c_str(), str(ty).c_str() ) ); } rcg->line( "stores", "int32_t tpix[%(work_pels_dim)];"); rcg->line( "stores", "int32_t tcix[%(work_out_chan_dim)];"); // FIXME: should somehow assert that both out_ix and pel_ix_N have the same dims here for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { rcg->line( "stores", strprintf( "tpix[%s] = %%(pel_ix_%s_img)*%%(out_img_stride) + " "( %%(pel_ix_%s_x_nomod) %%%% (%%(out_y_dim)*%%(out_x_dim)) ); // cache out pel ixs ", // note: y:x adj-dim opt. str(ty).c_str(), str(ty).c_str(), str(ty).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz( "out_chan" ); ++ty ) { rcg->line( "stores", strprintf( " tcix[%s] = (%%(out_chan_ix)+%s)*%%(out_chan_stride); // cache out chan ixs", str(ty).c_str(), str(ty).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { rcg->line( "stores", "if( %(pel_ix_"+str(ty)+"_x_nomod) >= %(pel_ix_0_dims_prod) ) { return; } " "// this pel and the following are off-the-end pels, so don't store them." ); for( uint32_t tx = 0; tx != work.dsz( "out_chan" ); ++tx ) { rcg->line( "fmas", strprintf( "out_tile[%s] += filts_strip[%s]*in_strip[%s];", str((ty*work.dsz( "out_chan" )+tx)).c_str(), str(tx).c_str(), str(ty).c_str() ) ); rcg->line( "stores", strprintf( "if( tcix[%s] < (%%(out_chan_dim)*%%(out_chan_stride)) ) { out[ tpix[%s] + tcix[%s] ] = %s; }", str(tx).c_str(), str(ty).c_str(), str(tx).c_str(), add_bias_then_maybe_relu(rcg,work,tx,ty).c_str() ) ); } } } void gen_op_ipconv( rtc_call_gen_t * rcg ) { dims_t const & work = rcg->get_arg_dims_by_name( "work" ); //dims_t const & filts = get_arg_dims_by_name( "filts" ); uint32_t const filts_smem_sz = work.dsz("out_chan_tile")*work.dsz("out_chan")*work.dsz("fioc_tile"); rcg->set( "filts_smem_sz", str(filts_smem_sz) ); uint32_t const out_chan_smem_load_iter = u32_ceil_div( filts_smem_sz, rcg->rtc_call_geom.tpb ); for( uint32_t i = 0; i != out_chan_smem_load_iter; ++i ) { string const ixe = "(LOC_ID_1D + %(tpb) * "+str(i)+")"; string const filt_ix = "( LOC_ID_1D/%(work_fioc_tile_dim) + %(tpb)/%(work_fioc_tile_dim)* "+str(i)+")"; string eif; // FIXME: can load garbage when ((out_chan_dim % filts_per_blk) != 0). pad output? add conditionals here? ignore? if( (i+1)*rcg->rtc_call_geom.tpb > filts_smem_sz ) { rcg->line( "filts_smem_loads", "if( "+ixe+" < %(filts_smem_sz) ) {" );eif = "}";} rcg->line( "filts_smem_loads", strprintf("filts_smem[%s] = filts[filts_off+(%s*%%(filts_out_chan_stride))];%s",ixe.c_str(),filt_ix.c_str(),eif.c_str()) ); } uint32_t const in_smem_sz = work.dsz("pels_tile")*work.dsz("pels")*work.dsz("fioc_tile"); rcg->set( "in_smem_sz", str(in_smem_sz) ); uint32_t const in_smem_load_iter = u32_ceil_div( in_smem_sz, rcg->rtc_call_geom.tpb ); // currently, ipconv can only handle one output point per image, and assume the filt and in data-layouts are the // same (hence the name ipconv, for inner-product-conv). for( uint32_t i = 0; i != in_smem_load_iter; ++i ) { string const ixe = "(LOC_ID_1D + %(tpb) * "+str(i)+")"; string const img_ix = "( LOC_ID_1D/%(work_fioc_tile_dim) + %(tpb)/%(work_fioc_tile_dim)* "+str(i)+")"; string eif; // FIXME: can load garbage when ((in_img_dim % imgs_per_blk) != 0). pad input? add conditionals here? ignore? if( (i+1)*rcg->rtc_call_geom.tpb > in_smem_sz ) { rcg->line( "in_smem_loads", "if( "+ixe+" < %(in_smem_sz) ) {" );eif = "}";} rcg->line( "in_smem_loads", strprintf("in_smem[%s] = in[in_off+(%s*%%(in_img_stride))];%s",ixe.c_str(),img_ix.c_str(),eif.c_str()) ); } for( uint32_t tx = 0; tx != work.dsz( "out_chan" ); ++tx ) { rcg->line( "loads", strprintf( "filts_strip[%s] = filts_smem_off[%s*%%(work_fioc_tile_dim)];", str(tx).c_str(), str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { // note: could merge with above loop, but we want to use ty for consistency rcg->line( "loads", strprintf( "in_strip[%s] = in_smem_off[%s*%%(work_fioc_tile_dim)];", str(ty).c_str(), str(ty).c_str() ) ); } rcg->line( "outs_to_filts_strip", "if( (in_pel+work_pel) >= %(in_img_dim) ) { return; } " "// this pel and the following are off-the-end pels, so don't store them." ); rcg->line( "outs_to_filts_strip", "switch(work_pel) { " ); for( uint32_t ty = 0; ty != work.dsz( "pels" ); ++ty ) { rcg->line( "outs_to_filts_strip", "case "+str(ty)+":" ); for( uint32_t tx = 0; tx != work.dsz( "out_chan" ); ++tx ) { rcg->line( "fmas", strprintf( "out_tile[%s] += filts_strip[%s]*in_strip[%s];", str((ty*work.dsz( "out_chan" )+tx)).c_str(), str(tx).c_str(), str(ty).c_str() ) ); rcg->line( "outs_to_filts_strip", strprintf( "filts_strip[%s] = out_tile[%s];", str(tx).c_str(), str((ty*work.dsz("out_chan")+tx)).c_str() ) ); } rcg->line( "outs_to_filts_strip", "break;" ); } rcg->line( "outs_to_filts_strip", "} " ); for( uint32_t tx = 0; tx != work.dsz( "out_chan" ); ++tx ) { string ve = strprintf( "(filts_strip[%s] + biases[ocix+%s])", str(tx).c_str(), str(tx).c_str() ); ve = rcg->op.get_u32("conv_has_relu") ? ( "max(0.0f,"+ve+")" ) : ve; for( uint32_t wb = work.dsz("fioc_tile") / 2; wb; wb /= 2 ) { rcg->line( "stores", strprintf( "filts_strip[%s] += __shfl_down( filts_strip[%s], %s, %s );", str(tx).c_str(), str(tx).c_str(), str(wb).c_str(), str( work.dsz("fioc_tile") ).c_str() ) ); } rcg->line( "stores", strprintf( "if( (%%(LOC_ID_1D_fioc_tile) == 0 ) && ((ocix + %s) < %%(out_chan_dim)) ) " "{ out[out_off + %s*%%(out_chan_stride)] = %s; }", str(tx).c_str(), str(tx).c_str(), str(ve).c_str() ) ); } } string gva( uint32_t const & vw, uint32_t const & ix ) { assert_st( vw <= 16 ); string const pss("0123456789abcdef"); string const pss_alt("xyzw"); string const maybe_s( (vw<=4) ? "" : "s" ); return strprintf( "[%s].%s%s", str(ix/vw).c_str(), maybe_s.c_str(), string((vw<=4)?pss_alt:pss,ix%vw,1).c_str() ); } void gen_op_sgemm_simd_local( rtc_call_gen_t * rcg ) { uint32_t const vw = rcg->op.get_u32( "vw" ); dims_t const & work = rcg->get_arg_dims_by_name( "work" ); assert( (work.dsz("Mt") % vw) == 0 ); assert( (work.dsz("Nt") % vw) == 0 ); dims_t const & a_dims = rcg->get_arg_dims_by_name("a"); dims_t const & b_dims = rcg->get_arg_dims_by_name("b"); uint64_t const blk_M = work.dsz("Mb")*work.dsz("Mt")/vw; uint32_t const a_sm_sz = blk_M*work.dsz("Kb"); gen_sgemm_sm_load( rcg, "sm_loads", "a", a_sm_sz, blk_M, a_dims, vw ); uint64_t const blk_N = work.dsz("Nb")*work.dsz("Nt")/vw; uint32_t const b_sm_sz = blk_N*work.dsz("Kb"); gen_sgemm_sm_load( rcg, "sm_loads", "b", b_sm_sz, blk_N, b_dims, vw ); for( uint32_t Kb = 0; Kb != work.dsz("Kb"); ++Kb ) { for( uint32_t Mt = 0; Mt != work.dsz("Mt")/vw; ++Mt ) { rcg->line( "inner_loop_body", strprintf( "a_r[%s] = a_sm_off[%s];", str(Mt).c_str(), str(Mt+Kb*blk_M).c_str() ) ); } for( uint32_t Nt = 0; Nt != work.dsz("Nt")/vw; ++Nt ) { rcg->line( "inner_loop_body", strprintf( "b_r[%s] = b_sm_off[%s];", str(Nt).c_str(), str(Nt+Kb*blk_N).c_str() ) ); } for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "inner_loop_body", strprintf( "c_r[%s] += a_r%s*b_r%s;",str(rix).c_str(), gva(vw,Mt).c_str(), gva(vw,Nt).c_str())); } } } rcg->line( "outs_to_b_r", "switch(Mt) { " ); for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { rcg->line( "outs_to_b_r", "case "+str(Mt)+":" ); for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "outs_to_b_r", strprintf( "b_r%s = c_r[%s];", gva(vw,Nt).c_str(), str(rix).c_str() ) ); } rcg->line( "outs_to_b_r", "break;" ); } rcg->line( "outs_to_b_r", "} " ); // note: for this section, there will be a local 'Mt' in scope, used to adjust c_off each iteration for( uint32_t Nt = 0; Nt != work.dsz("Nt")/vw; ++Nt ) { rcg->line( "stores", strprintf( "((GASQ float%s *)c)[c_off+%s] = b_r[%s];", str(vw).c_str(), str(Nt).c_str(), str(Nt).c_str() ) ); } } void gen_op_sgemm_simd( rtc_call_gen_t * rcg ) { uint32_t const vw = rcg->op.get_u32( "vw" ); dims_t const & work = rcg->get_arg_dims_by_name( "work" ); assert( (work.dsz("Mt") % vw) == 0 ); assert( (work.dsz("Nt") % vw) == 0 ); uint64_t a_K_stride = rcg->get_arg_dims_by_name("a").dstride("K"); uint64_t b_K_stride = rcg->get_arg_dims_by_name("b").dstride("K"); assert_st( ( a_K_stride % vw ) == 0 ); a_K_stride /= vw; assert_st( ( b_K_stride % vw ) == 0 ); b_K_stride /= vw; for( uint32_t Kb = 0; Kb != work.dsz("Kb"); ++Kb ) { for( uint32_t Mt = 0; Mt != work.dsz("Mt")/vw; ++Mt ) { rcg->line( "inner_loop_body", strprintf( "a_r[%s] = ((GASQ float%s const *)a)[a_off+%s];", str(Mt).c_str(), str(vw).c_str(), str(Mt+Kb*a_K_stride).c_str() ) ); } for( uint32_t Nt = 0; Nt != work.dsz("Nt")/vw; ++Nt ) { rcg->line( "inner_loop_body", strprintf( "b_r[%s] = ((GASQ float%s const *)b)[b_off+%s];", str(Nt).c_str(), str(vw).c_str(), str(Nt+Kb*b_K_stride).c_str() ) ); } for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "inner_loop_body", strprintf( "c_r[%s] += a_r%s*b_r%s;",str(rix).c_str(), gva(vw,Mt).c_str(), gva(vw,Nt).c_str())); } } } rcg->line( "outs_to_b_r", "switch(Mt) { " ); for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { rcg->line( "outs_to_b_r", "case "+str(Mt)+":" ); for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "outs_to_b_r", strprintf( "b_r%s = c_r[%s];", gva(vw,Nt).c_str(), str(rix).c_str() ) ); } rcg->line( "outs_to_b_r", "break;" ); } rcg->line( "outs_to_b_r", "} " ); // note: for this section, there will be a local 'Mt' in scope, used to adjust c_off each iteration for( uint32_t Nt = 0; Nt != work.dsz("Nt")/vw; ++Nt ) { rcg->line( "stores", strprintf( "((GASQ float%s *)c)[c_off+%s] = b_r[%s];", str(vw).c_str(), str(Nt).c_str(), str(Nt).c_str() ) ); } } void gen_op_sgemm_no_local( rtc_call_gen_t * rcg ) { dims_t const & work = rcg->get_arg_dims_by_name( "work" ); uint64_t const a_K_stride = rcg->get_arg_dims_by_name("a").dstride("K"); uint64_t const b_K_stride = rcg->get_arg_dims_by_name("b").dstride("K"); for( uint32_t Kb = 0; Kb != work.dsz("Kb"); ++Kb ) { for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { rcg->line( "inner_loop_body", strprintf( "a_r[%s] = a[a_off+%s];", str(Mt).c_str(), str(Mt+Kb*a_K_stride).c_str() ) ); } for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { rcg->line( "inner_loop_body", strprintf( "b_r[%s] = b[b_off+%s];", str(Nt).c_str(), str(Nt+Kb*b_K_stride).c_str() ) ); } for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "inner_loop_body", strprintf( "c_r[%s] += a_r[%s]*b_r[%s];",str(rix).c_str(), str(Mt).c_str(), str(Nt).c_str())); } } } gen_sgemm_write_out( rcg, 0 ); } void gen_sgemm_sm_load( rtc_call_gen_t * rcg, string const & code_sec, string const & vn, uint64_t const & sm_sz, uint64_t const row_len, dims_t const & vdims, uint32_t const & vw ) { uint64_t stride = vdims.dstride("K"); assert_st( ( stride % vw ) == 0 ); stride /= vw; uint64_t const rows = sm_sz / row_len; assert_st( row_len * rows == sm_sz ); // must be loading exactly an integer number of rows (not sensible otherwise?) assert_st( rows ); // no null load allowed (could just return no-op i suppose, if that ever made sense) assert_st( stride >= row_len ); // could relax in rows == 1 case (i.e. if there is no stride) uint64_t const row_pad = stride - row_len; string const smvn = vn + "_sm"; // note: could be customizable. rcg->set( smvn + "_sz", str(sm_sz) ); uint32_t const sm_load_iter = u32_ceil_div( sm_sz, rcg->rtc_call_geom.tpb ); for( uint32_t i = 0; i != sm_load_iter; ++i ) { uint64_t const iter_sm_off = rcg->rtc_call_geom.tpb*i; uint64_t const iter_row = iter_sm_off / row_len; uint64_t const iter_row_off = iter_sm_off % row_len; uint64_t const iter_off = iter_sm_off + iter_row*row_pad; string extra_off_str; if( row_pad && (iter_row_off + rcg->rtc_call_geom.tpb > row_len) ) { // more than one row-per-block, need to add dynamic offset term extra_off_str = strprintf("+(LOC_ID_1D+%s)/%s*%s", str(iter_row_off).c_str(), str(row_len).c_str(), str(row_pad).c_str() ); } string eif; if( (iter_sm_off + rcg->rtc_call_geom.tpb) > sm_sz ) { // block extends past end of sm, need to add guard rcg->line( code_sec, strprintf("if( (LOC_ID_1D+%s) < %s ) {", str(iter_sm_off).c_str(), str(sm_sz).c_str() ) ); eif="}";} string vn_vw = vn; assert_st( vw ); if( vw > 1 ) { vn_vw = strprintf("((GASQ %%(a_tn)%s const *)(%s))", str(vw).c_str(), vn.c_str() ); } assert_st( vdims.tinfo().is_float == 1 ); bool const half_to_float = (vdims.tsz() == 2); if( half_to_float ) { rcg->line( code_sec, strprintf("%s[LOC_ID_1D+%s] = vload_half( %s_off+%s%s, %s );%s", smvn.c_str(), str(iter_sm_off).c_str(), vn.c_str(), str(iter_off).c_str(), extra_off_str.c_str(), vn_vw.c_str(), eif.c_str()) ); } else { assert_st( vdims.tsz() == 4 ); // i.e. float rcg->line( code_sec, strprintf("%s[LOC_ID_1D+%s] = %s[%s_off+%s%s];%s", smvn.c_str(), str(iter_sm_off).c_str(), vn_vw.c_str(), vn.c_str(), str(iter_off).c_str(), extra_off_str.c_str(), eif.c_str()) ); } } } void gen_op_sgemm( rtc_call_gen_t * rcg ) { dims_t const & work = rcg->get_arg_dims_by_name( "work" ); uint64_t const blk_M = work.dsz("Mb")*work.dsz("Mt"); uint32_t const a_sm_sz = blk_M*work.dsz("Kb"); gen_sgemm_sm_load( rcg, "sm_loads", "a", a_sm_sz, blk_M, rcg->get_arg_dims_by_name("a"), 1 ); uint64_t const blk_N = work.dsz("Nb")*work.dsz("Nt"); uint32_t const b_sm_sz = blk_N*work.dsz("Kb"); gen_sgemm_sm_load( rcg, "sm_loads", "b", b_sm_sz, blk_N, rcg->get_arg_dims_by_name("b"), 1 ); for( uint32_t Kb = 0; Kb != work.dsz("Kb"); ++Kb ) { for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { rcg->line( "inner_loop_body", strprintf( "a_r[%s] = a_sm_off[%s];", str(Mt).c_str(), str(Mt+Kb*blk_M).c_str())); } for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { rcg->line( "inner_loop_body", strprintf( "b_r[%s] = b_sm_off[%s];", str(Nt).c_str(), str(Nt+Kb*blk_N).c_str())); //rcg->line( "inner_loop_body", strprintf( "b_r[%s] = b[k*%%(b_K_stride)+thr_N+%s];", str(Nt).c_str(), str(Nt).c_str() ) ); } for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "inner_loop_body", strprintf( "c_r[%s] += a_r[%s]*b_r[%s];",str(rix).c_str(), str(Mt).c_str(), str(Nt).c_str())); } } } dims_t const & c_dims = rcg->get_arg_dims_by_name("c"); assert( c_dims.tinfo().is_float ); bool const half_to_float = (c_dims.tsz() == 2); assert( half_to_float || (c_dims.tsz() == 4) ); gen_sgemm_write_out( rcg, half_to_float ); } void gen_sgemm_write_out( rtc_call_gen_t * rcg, bool const & half_to_float ) { dims_t const & work = rcg->get_arg_dims_by_name( "work" ); rcg->line( "outs_to_b_r", "switch(Mt) { " ); for( uint32_t Mt = 0; Mt != work.dsz("Mt"); ++Mt ) { rcg->line( "outs_to_b_r", "case "+str(Mt)+":" ); for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { uint32_t const rix = (Mt*work.dsz("Nt")+Nt); rcg->line( "outs_to_b_r", strprintf( "b_r[%s] = c_r[%s];", str(Nt).c_str(), str(rix).c_str() ) ); } rcg->line( "outs_to_b_r", "break;" ); } rcg->line( "outs_to_b_r", "} " ); // note: for this section, there will be a local 'Mt' in scope, used to adjust c_off each iteration for( uint32_t Nt = 0; Nt != work.dsz("Nt"); ++Nt ) { if( half_to_float ) { rcg->line( "stores", strprintf( "vstore_half( b_r[%s], c_off+%s, c );", str(Nt).c_str(), str(Nt).c_str() ) ); } else { rcg->line( "stores", strprintf( "c[c_off+%s] = b_r[%s];", str(Nt).c_str(), str(Nt).c_str() ) ); } } } void gen_op_k1conv_simd( rtc_call_gen_t * rcg ) { uint32_t const vw = rcg->op.get_u32( "vw" ); dims_t const & work = rcg->get_arg_dims_by_name( "work" ); assert( (work.dsz("pels") % vw) == 0 ); assert( (work.dsz("out_chan") % vw) == 0 ); uint64_t in_chan_stride = rcg->get_arg_dims_by_name("in").dstride("chan"); uint64_t filts_in_chan_stride = rcg->get_arg_dims_by_name("filts").dstride("in_chan"); assert_st( ( in_chan_stride % vw ) == 0 ); in_chan_stride /= vw; assert_st( ( filts_in_chan_stride % vw ) == 0 ); filts_in_chan_stride /= vw; uint32_t const Kb_dim = rcg->op.get_u32( "Kb" ); for( uint32_t Kb = 0; Kb != Kb_dim; ++Kb ) { for( uint32_t tx = 0; tx != work.dsz("pels")/vw; ++tx ) { rcg->line( "inner_loop_body", strprintf( "in_strip[%s] = ((GASQ float%s const *)in)[in_off+%s];", str(tx).c_str(), str(vw).c_str(), str(tx+Kb*in_chan_stride).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("out_chan")/vw; ++ty ) { rcg->line( "inner_loop_body", strprintf( "filts_strip[%s] = ((GASQ float%s const *)filts)[filts_off+%s];", str(ty).c_str(), str(vw).c_str(), str(ty+Kb*filts_in_chan_stride).c_str() ) ); } for( uint32_t tx = 0; tx != work.dsz("pels"); ++tx ) { for( uint32_t ty = 0; ty != work.dsz("out_chan"); ++ty ) { uint32_t const rix = (tx*work.dsz("out_chan")+ty); rcg->line( "inner_loop_body", strprintf( "out_tile[%s] += in_strip%s*filts_strip%s;",str(rix).c_str(), gva(vw,tx).c_str(), gva(vw,ty).c_str())); } } } rcg->line( "outs_to_in_strip", "switch(ty) { " ); for( uint32_t ty = 0; ty != work.dsz("out_chan"); ++ty ) { rcg->line( "outs_to_in_strip", "case "+str(ty)+":" ); for( uint32_t tx = 0; tx != work.dsz("pels"); ++tx ) { uint32_t const rix = (tx*work.dsz("out_chan")+ty); string const ve = strprintf( "(out_tile[%s]+filts_strip%s)", str(rix).c_str(), gva(vw,ty).c_str() ); rcg->line( "outs_to_in_strip", strprintf( "in_strip%s = %s;", gva(vw,tx).c_str(), maybe_add_relu(rcg,ve).c_str() ) ); } rcg->line( "outs_to_in_strip", "break;" ); } rcg->line( "outs_to_in_strip", "} " ); // note: for this section, there will be a local 'tx' in scope for( uint32_t tx = 0; tx != work.dsz("pels")/vw; ++tx ) { rcg->line( "stores", strprintf( "((GASQ float%s *)out)[out_off+%s] = in_strip[%s];", str(vw).c_str(), str(tx).c_str(), str(tx).c_str() ) ); } } void gen_op_conv_simd( rtc_call_gen_t * rcg ) { uint32_t const vw = rcg->op.get_u32( "vw" ); dims_t const & work = rcg->get_arg_dims_by_name( "work" ); dims_t const & in_pels = rcg->get_arg_dims_by_name( "in_pels" ); assert( (work.dsz("pels") % vw) == 0 ); assert( (work.dsz("out_chan") % vw) == 0 ); //uint64_t in_chan_stride = rcg->get_arg_dims_by_name("in").dstride("chan"); //printf( "in_chan_stride=%s\n", str(in_chan_stride).c_str() ); uint64_t filts_in_chan_stride = rcg->get_arg_dims_by_name("filts").dstride("in_chan"); //assert_st( ( in_chan_stride % vw ) == 0 ); in_chan_stride /= vw; assert_st( ( filts_in_chan_stride % vw ) == 0 ); filts_in_chan_stride /= vw; dims_t const & stride = rcg->get_arg_dims_by_name( "stride" ); uint32_t const row_extra_off = (stride.dsz("y")-1)*in_pels.dstride("y"); assert_st( stride.dsz("y") == stride.dsz("x") ); // FIXME/NOTE: see uniform stride FIXMEs in kernel and cnn_op.cc uint32_t const Kb_dim = rcg->op.get_u32( "Kb" ); for( uint32_t Kb = 0; Kb != Kb_dim; ++Kb ) { for( uint32_t tx = 0; tx != work.dsz("pels"); ++tx ) { assert_st( Kb == 0 ); // see FIXME in cnn_op.cc; stride in in is wrong here (needs to be per X/Y/chan, // prob. need other approach like fixed unroll over x dim or the like to be eff.) string reo; if( row_extra_off ) { reo = strprintf( "+((out_x + %s)/%%(out_pels_x_dim)*%s)", str(tx).c_str(),str(row_extra_off).c_str() ); } rcg->line( "inner_loop_body", strprintf( "in_strip%s = in[in_off+%s %s];", // FIXME: use Kb gva(vw,tx).c_str(), str(tx*stride.dsz("x")).c_str(), reo.c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("out_chan")/vw; ++ty ) { rcg->line( "inner_loop_body", strprintf( "filts_strip[%s] = ((GASQ float%s const *)filts)[filts_off+%s];", str(ty).c_str(), str(vw).c_str(), str(ty+Kb*filts_in_chan_stride).c_str() ) ); } for( uint32_t tx = 0; tx != work.dsz("pels"); ++tx ) { for( uint32_t ty = 0; ty != work.dsz("out_chan"); ++ty ) { uint32_t const rix = (tx*work.dsz("out_chan")+ty); rcg->line( "inner_loop_body", strprintf( "out_tile[%s] += in_strip%s*filts_strip%s;",str(rix).c_str(), gva(vw,tx).c_str(), gva(vw,ty).c_str())); } } } rcg->line( "outs_to_in_strip", "switch(ty) { " ); for( uint32_t ty = 0; ty != work.dsz("out_chan"); ++ty ) { rcg->line( "outs_to_in_strip", "case "+str(ty)+":" ); for( uint32_t tx = 0; tx != work.dsz("pels"); ++tx ) { uint32_t const rix = (tx*work.dsz("out_chan")+ty); string const ve = strprintf( "(out_tile[%s]+filts_strip%s)", str(rix).c_str(), gva(vw,ty).c_str() ); rcg->line( "outs_to_in_strip", strprintf( "in_strip%s = %s;", gva(vw,tx).c_str(), maybe_add_relu(rcg,ve).c_str() ) ); } rcg->line( "outs_to_in_strip", "break;" ); } rcg->line( "outs_to_in_strip", "} " ); // note: for this section, there will be a local 'tx' in scope for( uint32_t tx = 0; tx != work.dsz("pels")/vw; ++tx ) { rcg->line( "stores", strprintf( "((GASQ float%s *)out)[out_off+%s] = in_strip[%s];", str(vw).c_str(), str(tx).c_str(), str(tx).c_str() ) ); } } void gen_op_k1conv( rtc_call_gen_t * rcg ) { assert_st( get_xy_dims( rcg->get_arg_dims_by_name( "in_pad" ) ).is_zeros() ); assert_st( (get_xy_dims( rcg->get_arg_dims_by_name( "stride" ) ) == u32_pt_t{1,1}) ); dims_t const & work = rcg->get_arg_dims_by_name( "work" ); dims_t const & filts = rcg->get_arg_dims_by_name( "filts" ); assert_st( filts.dsz("x") == 1 ); assert_st( filts.dsz("y") == 1 ); dims_t const & in = rcg->get_arg_dims_by_name( "in" ); dims_t const & out = rcg->get_arg_dims_by_name( "out" ); // calculate needed smem sizes (and total kernel needed smem size) // note: filts and in smem are used concurrently, then just all of all_smem as an output buffer uint32_t const filts_smem_sz = filts.dstride("in_chan")*in.dsz("blk_iter_chan"); rcg->set( "filts_smem_sz", str(filts_smem_sz) ); uint32_t const out_smem_sz = work.dsz("pels_tile")*work.dsz("out_chan_tile")*work.dsz("pels"); // note: == oi->tpb*work.dsz("pels") rcg->set( "out_smem_sz", str(out_smem_sz) ); // note: unused, but assumed that all_smem_sz >= out_smem_sz uint32_t const all_smem_sz = std::max( out_smem_sz, filts_smem_sz+in.dstride("blk_iter") ); // note: %(in_blk_iter_sz) == in_smem_sz rcg->set( "all_smem_sz", str(all_smem_sz) ); // generate smem loads gen_filts_smem_loads( rcg, filts_smem_sz ); uint32_t const in_smem_load_iter = u32_ceil_div( in.dstride("blk_iter"), rcg->rtc_call_geom.tpb ); for( uint32_t i = 0; i != in_smem_load_iter; ++i ) { string const ixe = "(LOC_ID_1D + %(tpb) * "+str(i)+")"; string eif; if( (i+1)*rcg->rtc_call_geom.tpb > in.dstride("blk_iter") ) { rcg->line( "smem_loads", "if( "+ixe+" < %(in_blk_iter_stride)) { ");eif = "}";} rcg->line( "smem_loads", strprintf(" in_smem[%s] = in[ blk_in_ix_base + (%%(tpb)*%s) ];%s\n", ixe.c_str(),str(i).c_str(),eif.c_str()) ); } rcg->set( "out_chan_tile", "(%(GRP_ID_1D_out_chan_blk)*%(work_out_chan_tile_dim)+%(LOC_ID_1D_out_chan_tile))"); rcg->set( "out_chan_ix","(%(out_chan_tile)*%(work_out_chan_dim))" ); // rcg->line( "stores", " if( %(out_line_img) >= %(out_ix_img_dim) ) { return; } "; // not possible due to no-partial-imgs-per-block // FIXME: should somehow assert that both out_ix and pel_ix_N have the same dims here // FIXME: out_pel must be per-tpix (again) if( out.get_dim_by_name("blk") ) { // aka if(write_xposed) -- if this dim names exists in the output, we know to write in xposed format // padded # of in chans of next layer == out.dsz("blk_iter")*out.dsz("blk_iter_chan") // padded # of out chans of this layer == work.dsz("out_chan_blk")*work.dsz("out_chan_tile")*work.dsz("out_chan") // if these are ==, we don't have to worry about bounds-checking our writes to out in the chan dim assert_st( work.dsz("out_chan_blk")*work.dsz("out_chan_tile")*work.dsz("out_chan") == out.dsz("blk_iter")*out.dsz("blk_iter_chan") ); // padded # of in pels of next layer: == out.dsz("blk")*out.dsz("blk_pel") // padded # of out pels of this layer: == work.dsz("pels_blk")*work.dsz("pels_tile")*work.dsz("pels") // if these are ==, we don't have to worry about bounds-checking our writes to out in the pel dim assert_st( work.dsz("pels_blk")*work.dsz("pels_tile")*work.dsz("pels") == out.dsz("blk")*out.dsz("blk_pel") ); // we assume out_blk_pel_dim (== noi->thr_per_blk.d[0]*t_tile_sz) is divisible by t_tile_sz. but let's check it explicitly: // FIXME_WXP: i don't see where we assume this, and hence i dunno what t_tile_sz refers to below. poop. assert is removed for now: // assert_st( (out.dsz("blk_pel") % t_tile_sz) == 0 ); // we assume the out chans are a single (span of) dims in out. FIXME: check this?. FIXME_WXP: what does this even mean? //rcg->line( "stores", " int32_t xpbuf[%(work_out_chan_dim)];\n"; // FIXME: assumes (for GRP_ID_1D_pels_blk*... term) that input and output block have same # of pels ... too strong? assert_st( out.dsz("blk_pel") == in.dsz("blk_pel") ); rcg->line( "stores", "int32_t const out_ix = (%(GRP_ID_1D_out_chan_blk)*%(work_out_chan_tile_dim)*%(work_out_chan_dim))*%(out_blk_iter_chan_stride) + %(GRP_ID_1D_pels_blk)*%(out_blk_stride);" ); rcg->line( "stores", "int32_t xpbuf_rd_pel;" ); rcg->line( "stores", "int32_t xpbuf_rd_chan;" ); for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { // transpose each thread's tx'th out_chan (= work_out_chan_dim out chans across all threads) into xpbuf (again across all threads) // such that we can do (mostly) sequential writes to global memory for this set of work_out_chan_dim out chans rcg->line( "stores", " BARRIER_SYNC;" ); for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { // out_tile[] (registers) -> all_smem[] rcg->line( "stores", strprintf( "out_smem_off[%%(tpb)*%s] = %s;", str(ty).c_str(), add_bias_then_maybe_relu(rcg,work,tx,ty).c_str() ) ); } rcg->line( "stores", " BARRIER_SYNC;" ); for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { // all_smem[] -> [xpbuf[] (registers)] -> out[] (global) // here, we reshape the threads so that the total threads across iterations (%(tbp)*work.dsz("pels")) covers // the space of the data in out_smem as a (simple) 2D array ordered as chan:pel. thus, for each thread, we // have a single chan and pel index that we must read from smem and write to global memory. this mapping is // such that the writes to global memory are somewhat sequential (with jumps at chan boundaries). however, // for the reads from smem we just calculate the correct index and hope for the best. note that the actual // output chan indexes read/written to here are strided by %(work_out_chan_dim) and offset by tx. string const obe = "(LOC_ID_1D + %(tpb)*"+str(ty)+")"; rcg->line( "stores", " xpbuf_rd_pel = "+obe+" %% %(out_blk_pel_dim) ;" ); rcg->line( "stores", " xpbuf_rd_chan = "+obe+" / %(out_blk_pel_dim) ;" ); rcg->line( "stores", strprintf( "out[out_ix + xpbuf_rd_pel + (xpbuf_rd_chan*%%(work_out_chan_dim)+%s)*%%(out_blk_iter_chan_stride)] = " "all_smem[xpbuf_rd_chan+(xpbuf_rd_pel %%%% %%(work_pels_dim))*%%(tpb)" "+ (xpbuf_rd_pel / %%(work_pels_dim))*%%(work_out_chan_tile_dim) ];", str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { // xpbuf[] registers -> out[] (global) // TODO/UNUSED? } } } else { rcg->line( "stores", " int32_t tpix[%(work_pels_dim)];" ); rcg->line( "stores", " int32_t tcix[%(work_out_chan_dim)];" ); for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { insert_nda_ix_exprs( rcg->tsvs, "out_pel_" + str(ty), must_find(rcg->all_ix_dims,"out_ref_pel"), "( (%(GRP_ID_1D_pels_blk)*%(work_pels_tile_dim) + %(LOC_ID_1D_pels_tile))*%(work_pels_dim) + "+str(ty)+" )" ); rcg->line( "stores", strprintf( " tpix[%s] = %%(out_pel_%s_img)*%%(out_img_stride) + " " %%(out_pel_%s_x)*%%(out_x_stride) + %%(out_pel_%s_y)*%%(out_y_stride) " // FIXME_WXP:restore: y:x adj-dim opt? " ; // cache out pel ixs", str(ty).c_str(), str(ty).c_str(), str(ty).c_str(), str(ty).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("out_chan"); ++ty ) { rcg->line( "stores", strprintf( " tcix[%s] = (%%(out_chan_ix)+%s)*%%(out_chan_stride); // cache out chan ixs", str(ty).c_str(), str(ty).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { rcg->line( "stores", " if( %(out_pel_"+str(ty)+"_img) >= %(out_img_dim) ) { return; } " "// this pel and the following are off-the-end pels, so don't store them." ); for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "stores", strprintf( "if( tcix[%s] < (%%(out_chan_dim)*%%(out_chan_stride)) ) { out[ tpix[%s] + tcix[%s] ] = %s; }", str(tx).c_str(), str(ty).c_str(), str(tx).c_str(), add_bias_then_maybe_relu(rcg,work,tx,ty).c_str() ) ); } } } for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "dummy_stores", strprintf( "out_off[%s] = %s;", str((ty*work.dsz("out_chan")+tx)*rcg->rtc_call_geom.tpb).c_str(), add_bias_then_maybe_relu(rcg,work,tx,ty).c_str() ) ); } } for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "bias_loads", strprintf( "filts_strip[%s] = filts_smem_off[%s*%%(work_out_chan_tile_dim)];", str(tx).c_str(), str(tx).c_str() ) ); } assert_st( in.dsz("blk_pel") == work.dsz("pels_tile")*work.dsz("pels") ); // by input xform design for( uint32_t ict = 0; ict != in.dsz("blk_iter_chan"); ++ict ) { for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "inner_loop_body", strprintf( "filts_strip[%s] = filts_smem_off[(%s*%%(filts_in_chan_stride))+%s*%%(work_out_chan_tile_dim)];", str(tx).c_str(), str(ict).c_str(), str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { rcg->line( "inner_loop_body", strprintf( "in_strip[%s] = in_smem_off[(%s*%%(in_blk_pel_dim)+%s)];", str(ty).c_str(), str(ict).c_str(), str(ty).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "inner_loop_body", strprintf( "out_tile[%s] += filts_strip[%s]*in_strip[%s];", str((ty*work.dsz("out_chan")+tx)).c_str(), str(tx).c_str(), str(ty).c_str() ) ); } } } } void gen_op_tconv( rtc_call_gen_t * rcg ) { dims_t const & stride = rcg->get_arg_dims_by_name( "stride" ); dims_t const & work = rcg->get_arg_dims_by_name( "work" ); dims_t const & filts = rcg->get_arg_dims_by_name( "filts" ); dims_t const & in = rcg->get_arg_dims_by_name( "in" ); uint32_t const filts_smem_sz = filts.dstride("y"); rcg->set( "filts_smem_sz", str(filts_smem_sz) ); gen_filts_smem_loads( rcg, filts_smem_sz ); rcg->line( "filts_smem_loads", "filts_off += %(filts_smem_sz);" ); uint32_t const in_smem_load_iter = u32_ceil_div( in.dstride("blk_in_chan"), rcg->rtc_call_geom.tpb ); // in smem loads for( uint32_t i = 0; i != in_smem_load_iter; ++i ) { string const ixe = "(LOC_ID_1D + %(tpb) * "+str(i)+")"; string eif; if( (i+1)*rcg->rtc_call_geom.tpb > in.dstride("blk_in_chan") ) { rcg->line( "in_smem_loads", "if( "+ixe+" < %(in_blk_in_chan_stride)) { " );eif = "}";} rcg->line( "in_smem_loads", strprintf("in_smem[%s] = in[ blk_in_ix_base + (%%(tpb)*%s) ];%s", ixe.c_str(),str(i).c_str(),eif.c_str())); } rcg->line( "in_smem_loads", "blk_in_ix_base += %(in_blk_in_chan_stride);" ); for( uint32_t i = 0; i != in.dsz("blk_x"); ++i ) { rcg->line( "inner_loop_body", strprintf( "in_strip[%s] = in_smem_off[%s];", str(i).c_str(), str(i).c_str() ) ); } assert_st( work.dsz("out_chan_tile") == filts.dsz("out_chan_tile") ); // also == %(filts_out_chan_reg_stride) for( uint32_t kx = 0; kx != filts.dsz("x"); ++kx ) { for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "inner_loop_body", strprintf( "filts_strip[%s] = filts_smem_off[%s*%%(filts_x_stride)+%s*%%(filts_out_chan_reg_stride)];", str(tx).c_str(), str(kx).c_str(), str(tx).c_str() ) ); } for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "inner_loop_body", strprintf( "out_tile[%s] += filts_strip[%s]*in_strip[%s];", str((ty*work.dsz("out_chan")+tx)).c_str(), str(tx).c_str(), str(ty*stride.dsz("x")+kx).c_str())); } } } for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { rcg->line( "bias_loads", strprintf( "filts_strip[%s] = filts_smem_off[%s*%%(filts_out_chan_reg_stride)];", str(tx).c_str(), str(tx).c_str() ) ); } //rcg->line( "stores", " if( %(out_line_y) >= %(out_ix_y_stride) ) { return; }" ); // not possible rcg->line( "stores", "if( %(out_line_img) >= %(out_img_dim) ) { return; }" ); rcg->line( "stores", "int32_t out_x = %(GRP_ID_1D_blk_bx)*%(work_pels_dim);" ); rcg->line( "stores", "int32_t out_chan = (%(GRP_ID_1D_out_chan_blk)*%(work_out_chan_tile_dim) + %(LOC_ID_1D_out_chan_tile))*%(work_out_chan_dim);" ); rcg->line( "stores", "GASQ float * out_off = out + %(out_line_img)*%(out_img_stride) + out_chan*%(out_chan_stride) + " "%(out_line_y)*%(out_y_stride) + out_x*%(out_x_stride) ;" ); for( uint32_t ty = 0; ty != work.dsz("pels"); ++ty ) { rcg->line( "stores", "if( (out_x + "+str(ty)+") >= %(out_x_dim) ) { return; } " "// this x value and the following are off-the-end pels, so don't store them." ); for( uint32_t tx = 0; tx != work.dsz("out_chan"); ++tx ) { #if 1 string const ve = add_bias_then_maybe_relu(rcg,work,tx,ty); #else string const ve = strprintf( "(filts_strip[%s])", str(tx).c_str() ); #endif rcg->line( "stores", strprintf( "if( (out_chan + %s) < %%(out_chan_dim) ) { " "out_off[ %s*%%(out_chan_stride) + %s*%%(out_x_stride) ] = %s; }", str(tx).c_str(), str(tx).c_str(), str(ty).c_str(), ve.c_str() ) ); } } } }; p_custom_codegen_t make_cnn_custom_codegen_t( void ) { return p_custom_codegen_t( new cnn_custom_codegen_t ); } }
ryanhammonds/bycycle
bycycle/tests/features/test_shapes.py
"""Tests for features.shape.""" import pytest import numpy as np from bycycle.features.shape import * ################################################################################################### ################################################################################################### @pytest.mark.parametrize("find_extrema_kwargs", [ None, pytest.param({'first_extrema': 'peak'}, marks=pytest.mark.xfail) ] ) @pytest.mark.parametrize("center_extrema", [ 'peak', 'trough', pytest.param(None, marks=pytest.mark.xfail) ] ) def test_compute_shape_features(sim_args, find_extrema_kwargs, center_extrema): sig = sim_args['sig'] fs = sim_args['fs'] f_range = sim_args['f_range'] df_shapes = compute_shape_features(sig, fs, f_range, center_extrema=center_extrema, find_extrema_kwargs=find_extrema_kwargs) # Ensure sample columns are returned sample_cols = [col for col in list(df_shapes.columns) if "sample_" in col] assert len(sample_cols) == 6 # Assert that np.nan isn't in dataframe(s), with the exception of the first and last row for idx, row in df_shapes.iterrows(): assert not np.isnan(row[1:-1]).any() # Check inverted signal gives appropriately opposite data extrema_opp = 'trough' if center_extrema == 'peak' else 'peak' df_opp = compute_shape_features(-sig, fs, f_range, center_extrema=extrema_opp, find_extrema_kwargs=find_extrema_kwargs) cols_peak = ['time_peak', 'time_rise', 'volt_rise', 'volt_amp', 'period', 'time_rdsym', 'time_ptsym'] cols_trough = ['time_trough', 'time_decay', 'volt_decay', 'volt_amp', 'period', 'time_rdsym', 'time_ptsym'] df_opp['time_rdsym'] = 1 - df_opp['time_rdsym'] df_opp['time_ptsym'] = 1 - df_opp['time_ptsym'] for idx, col in enumerate(cols_peak): if center_extrema == 'peak': np.testing.assert_allclose(df_shapes.loc[:, col], df_opp.loc[:, cols_trough[idx]]) else: np.testing.assert_allclose(df_opp.loc[:, col], df_shapes.loc[:, cols_trough[idx]]) def test_compute_durations(sim_args): df_shapes = sim_args['df_shapes'] period, time_peak, time_trough = compute_durations(df_shapes) assert ((time_trough + time_peak) == period).all() def test_compute_extrema_voltage(sim_args): df_shapes = sim_args['df_shapes'] sig = sim_args['sig'] volt_peaks, volt_troughs = compute_extrema_voltage(df_shapes, sig) for idx, volt_peak in enumerate(volt_peaks): assert volt_peak > volt_troughs[idx] @pytest.mark.parametrize("recompute", [True, False]) def test_compute_symmetry(sim_args, recompute): df_shapes = sim_args['df_shapes'] sig = sim_args['sig'] if recompute: sym_features = compute_symmetry(df_shapes, sig) else: period, time_peak, time_trough = compute_durations(df_shapes) sym_features = compute_symmetry(df_shapes, sig, period=period, time_peak=time_peak, time_trough=time_trough) # This is the case for only simulated sine waves assert (sym_features['time_decay'] == sym_features['time_rise']).all() assert (sym_features['volt_decay'] == sym_features['volt_rise']).all() assert (sym_features['volt_amp'] == \ (sym_features['volt_rise'] + sym_features['volt_decay'])/2).all() np.testing.assert_almost_equal(sym_features['time_rdsym'].values, sym_features['time_ptsym'].values, decimal=1) def test_compute_band_amp(sim_args): df_shapes = sim_args['df_shapes'] sig = sim_args['sig'] fs = sim_args['fs'] f_range = sim_args['f_range'] band_amp = compute_band_amp(df_shapes, sig, fs, f_range) for amp in band_amp[:-1]: np.testing.assert_allclose(amp, band_amp[0], rtol=1e-1)
kmecpp/Engine
src/test/scala/com/builtbroken/test/transform/region/TriangleTest.java
package com.builtbroken.test.transform.region; import com.builtbroken.mc.imp.transform.vector.Point; import junit.framework.TestCase; import com.builtbroken.mc.imp.transform.region.Triangle; /** Tests the triangle class for math based errors * * Created by robert on 12/17/2014. */ public class TriangleTest extends TestCase { //TODO include a performance test to see how fast these method calls run on average public void testTriangleAreas() { //Dummy checks for the hell of it Triangle t = new Triangle(new Point(), new Point(), new Point()); assertEquals("Expected zero due to all 3 points being zero zero", 0.0, t.getArea()); t = new Triangle(new Point(0, 1), new Point(0, 2), new Point(0, 3)); assertEquals("Expected zero due to all 3 points being in a line", 0.0, t.getArea()); //http://www.mathopenref.com/coordtrianglearea.html t = new Triangle(new Point(0, 0), new Point(-1, 2), new Point(13, 5)); assertEquals("Expected an exact match for area check one", 15.5, t.getArea()); t = new Triangle(new Point(0, 0), new Point(-12, 27), new Point(37, 25)); assertEquals("Expected an exact match for area check two", 649.5, t.getArea()); t = new Triangle(new Point(0, 0), new Point(-12, 27), new Point(14, -10)); assertEquals("Expected an exact match for area check three", 129.0, t.getArea()); t = new Triangle(new Point(15, 15), new Point(23, 30), new Point(25, 8)); assertEquals("Expected an exact match for area check four", 103.0, t.getArea()); t = new Triangle(new Point(10, -6), new Point(42, -6), new Point(25, -12)); assertEquals("Expected an exact match for area check five", 96.0, t.getArea()); } /** * Tests area method using 4 triangles in each section * of pos & neg relations. It also tests the order of the points * when constructing the triangle to ensure there are no ordering * issues with how the math is handled */ public void testRightTriangleAreas() { final double expectedArea = 2; //Using zero zero Point zeroZero = new Point(); Point p1 = null; Point p2 = null; Triangle a, b, c; for (int i = 0; i < 4; i++) { switch (i) { case 0: //positive positive p1 = new Point(0, 2); p2 = new Point(2, 0); break; case 2: //neg positive p1 = new Point(0, 2); p2 = new Point(-2, 0); break; case 3: //positive neg p1 = new Point(0, -2); p2 = new Point(2, 0); break; case 4: //neg neg p1 = new Point(0, -2); p2 = new Point(-2, 0); break; } a = new Triangle(zeroZero, p1, p2); b = new Triangle(p1, p2, zeroZero); c = new Triangle(p2, zeroZero, p1); assertEquals("Failed area check for A" + i, expectedArea, a.getArea()); assertEquals("Failed area check for B" + i, expectedArea, b.getArea()); assertEquals("Failed area check for C" + i, expectedArea, c.getArea()); } } /** * Tests area method using 4 triangles in each section * of pos & neg relations. It also tests the order of the points * when constructing the triangle to ensure there are no ordering * issues with how the math is handled */ public void testObtuseTriangleAreas() { final double expectedArea = 4; //Using zero zero Point zeroZero = new Point(); Point p1 = null; Point p2 = null; Triangle a, b, c; for (int i = 0; i < 4; i++) { switch (i) { case 0: //UP p1 = new Point(2, 2); p2 = new Point(-2, 2); break; case 2: //DOWN p1 = new Point(2, -2); p2 = new Point(-2, -2); break; case 3: //RIGHT p1 = new Point(2, 2); p2 = new Point(2, -2); break; case 4: //LEFT p1 = new Point(-2, 2); p2 = new Point(-2, -2); break; } a = new Triangle(zeroZero, p1, p2); b = new Triangle(p1, p2, zeroZero); c = new Triangle(p2, zeroZero, p1); assertEquals("Failed area check for A" + i, expectedArea, a.getArea()); assertEquals("Failed area check for B" + i, expectedArea, b.getArea()); assertEquals("Failed area check for C" + i, expectedArea, c.getArea()); } } /** * Tests area method using 4 triangles in each section * of pos & neg relations. It also tests the order of the points * when constructing the triangle to ensure there are no ordering * issues with how the math is handled */ public void testAcuteTriangleAreas() { final double expectedArea = 2; //Using zero zero Point zeroZero = new Point(); Point p1 = null; Point p2 = null; Triangle a, b, c; for (int i = 0; i < 4; i++) { switch (i) { case 0: //UP p1 = new Point(1, 2); p2 = new Point(-1, 2); break; case 2: //DOWN p1 = new Point(1, -2); p2 = new Point(-1, -2); break; case 3: //RIGHT p1 = new Point(2, 1); p2 = new Point(2, -1); break; case 4: //LEFT p1 = new Point(-2, 1); p2 = new Point(-2, -1); break; } a = new Triangle(zeroZero, p1, p2); b = new Triangle(p1, p2, zeroZero); c = new Triangle(p2, zeroZero, p1); assertEquals("Failed area check for A" + i, expectedArea, a.getArea()); assertEquals("Failed area check for B" + i, expectedArea, b.getArea()); assertEquals("Failed area check for C" + i, expectedArea, c.getArea()); } } }
ccetc/mahaplatform.com
src/apps/maha/admin/api/assets/url/show.js
<filename>src/apps/maha/admin/api/assets/url/show.js<gh_stars>0 import { validateUrl } from './utils' import axios from 'axios' import path from 'path' import Url from 'url' const urlRoute = async (req, res) => { if(!validateUrl(req.query.url)) return res.status(404).respond({ code: 404, message: 'Not Found' }) try { const response = await axios({ url: req.query.url, method: 'get', headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36' }, responseType: 'stream' }) if(response.status >= 300) return res.status(response.status).respond({ code: response.status, message: response.statusText }) const parsed = Url.parse(req.query.url) await res.status(200).respond({ ...response.headers, file_name: path.basename(parsed.pathname) }) } catch(e) { console.log(e) res.status(404).respond({ message: 'Unable to load url' }) } } export default urlRoute
shiwenqiang/dmm
src/framework/mem/dmm_share.h
<reponame>shiwenqiang/dmm /* * * Copyright (c) 2018 Huawei Technologies Co.,Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _DMM_SHARE_H_ #define _DMM_SHARE_H_ #define DMM_SHARE_PATH_MAX 100 enum dmm_share_type { DMM_SHARE_HEAP, DMM_SHARE_FSHM, DMM_SHARE_HUGE, DMM_SHARE_ANY = -1 }; struct dmm_share { int type; /* share type enum dmm_share_type */ pid_t pid; /* owner/creator pid */ void *base; /* base logical address */ size_t size; /* memory size */ char path[DMM_SHARE_PATH_MAX]; /* share path */ }; int dmm_heap_create (struct dmm_share *share); int dmm_heap_delete (struct dmm_share *share); int dmm_heap_attach (struct dmm_share *share); int dmm_heap_detach (struct dmm_share *share); int dmm_fshm_create (struct dmm_share *share); int dmm_fshm_delete (struct dmm_share *share); int dmm_fshm_attach (struct dmm_share *share); int dmm_fshm_detach (struct dmm_share *share); int dmm_huge_create (struct dmm_share *share); int dmm_huge_delete (struct dmm_share *share); int dmm_huge_attach (struct dmm_share *share); int dmm_huge_detach (struct dmm_share *share); #define DMM_SHARE_DISPATCH(share, action) \ ({ \ int _r; \ switch (share->type) \ { \ case DMM_SHARE_HEAP: \ _r = dmm_heap_##action(share); \ break; \ case DMM_SHARE_FSHM: \ _r = dmm_fshm_##action(share); \ break; \ case DMM_SHARE_HUGE: \ _r = dmm_huge_##action(share); \ break; \ default: \ _r = -1; \ } \ _r; \ }) /* create share memory input: share->type, share->size, share->pid output: share->base, share->path */ inline static int dmm_share_create (struct dmm_share *share) { return DMM_SHARE_DISPATCH (share, create); } /* delete share memory input: share->type, share->base, share->size, share->path */ inline static int dmm_share_delete (struct dmm_share *share) { return DMM_SHARE_DISPATCH (share, delete); } /* attach share memory input: share->type share->path [share->size] [share->base] output: share->base, share->size */ inline static int dmm_share_attach (struct dmm_share *share) { return DMM_SHARE_DISPATCH (share, attach); } /* attach share memory input: share->type share->size share->base */ inline static int dmm_share_detach (struct dmm_share *share) { return DMM_SHARE_DISPATCH (share, detach); } #undef DMM_SHARE_DISPATCH #endif /* #ifndef _DMM_SHARE_H_ */
wesleywisch/Devfit
src/components/CustomTabBar/index.js
<reponame>wesleywisch/Devfit import React from 'react'; import { TabBarArea, TabBarItem, TabRegular, TabImage, Text, TabBall, TabBallImage, } from './styles'; export function CustomTabBar(props) { return ( <TabBarArea> {props.itens.map(item => ( <TabBarItem key={item.route}> {item.type === 'regular' && ( <TabRegular underlayColor="transparent" onPress={() => props.navigation.navigate(item.route)}> <> <TabImage source={item.icon} /> <Text>{item.text}</Text> </> </TabRegular> )} {item.type === 'big' && ( <TabBall underlayColor="#00ff00" onPress={() => props.navigation.navigate(item.route)}> <TabBallImage source={item.icon} /> </TabBall> )} </TabBarItem> ))} </TabBarArea> ); }
dmitryvinn-fb/flow
tests/config_module_file_exts_precedence/test.js
<filename>tests/config_module_file_exts_precedence/test.js // @flow // .zzz comes before .aaa import {aaa_vs_zzz__aaa} from './aaa_vs_zzz'; // error import {aaa_vs_zzz__zzz} from './aaa_vs_zzz'; // .aaa comes before .bbb import {aaa_vs_bbb__aaa} from './aaa_vs_bbb'; import {aaa_vs_bbb__bbb} from './aaa_vs_bbb'; // error // .aaa comes before .aaa.js even though .js comes before .aaa, because exact match wins import {aaa_vs_aaa_js__aaa} from './aaa_vs_aaa_js.aaa'; import {aaa_vs_aaa_js__aaa__js} from './aaa_vs_aaa_js.aaa'; // error // .zzz comes before .zzz.js import {zzz_vs_zzz_js__zzz} from './zzz_vs_zzz_js.zzz'; import {zzz_vs_zzz_js__zzz__js} from './zzz_vs_zzz_js.zzz'; // error // .js comes before .zzz.js even though .zzz comes before .js (resolved right to left) import {js_vs_zzz_js__js} from './js_vs_zzz_js'; import {js_vs_zzz_js__zzz__js} from './js_vs_zzz_js'; // error import {js_vs_zzz_js__js as js2} from './js_vs_zzz_js.zzz'; // error import {js_vs_zzz_js__zzz__js as zzz_js2} from './js_vs_zzz_js.zzz'; // only one extension is stripped import {multiple_exts as multiple_exts1} from './multiple_exts'; // error import {multiple_exts as multiple_exts2} from './multiple_exts.zzz';
akashgangurde/anotherJavaRepository
IOFileReader/src/FileReaderExample.java
import java.io.FileReader; public class FileReaderExample { public static void main(String[] args) throws Exception { FileReader fr = new FileReader("E:\\testout.txt"); int i ; while((i=fr.read())!=-1) System.out.print((char)i); fr.close(); } }
Reno-Greenleaf/bsd-games
battlestar/command4.c
<filename>battlestar/command4.c /* $NetBSD: command4.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95"; #else __RCSID("$NetBSD: command4.c,v 1.2 2003/08/07 09:37:00 agc Exp $"); #endif #endif /* not lint */ #include "extern.h" int take(from) unsigned int from[]; { int firstnumber, heavy, bulky, value; firstnumber = wordnumber; if (wordnumber < wordcount && wordvalue[wordnumber + 1] == OFF) { wordnumber++; wordvalue[wordnumber] = TAKEOFF; wordtype[wordnumber] = VERB; return (cypher()); } else { wordnumber++; while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) { value = wordvalue[wordnumber]; printf("%s:\n", objsht[value]); heavy = (carrying + objwt[value]) <= WEIGHT; bulky = (encumber + objcumber[value]) <= CUMBER; if ((testbit(from, value) || wiz || tempwiz) && heavy && bulky && !testbit(inven, value)) { setbit(inven, value); carrying += objwt[value]; encumber += objcumber[value]; ourtime++; if (testbit(from, value)) printf("Taken.\n"); else printf("Zap! Taken from thin air.\n"); clearbit(from, value); if (value == MEDALION) win--; } else if (testbit(inven, value)) printf("You're already holding %s%s.\n", A_OR_AN_OR_BLANK(value), objsht[value]); else if (!testbit(from, value)) printf("I don't see any %s around here.\n", objsht[value]); else if (!heavy) printf("The %s %stoo heavy.\n", objsht[value], IS_OR_ARE(value)); else printf("The %s %stoo cumbersome to hold.\n", objsht[value], IS_OR_ARE(value)); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } } /* special cases with their own return()'s */ if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) switch (wordvalue[wordnumber]) { case SWORD: if (testbit(from, SWORD)) { wordtype[wordnumber--] = OBJECT; return (take(from)); } if (testbit(from, TWO_HANDED)) { wordvalue[wordnumber] = TWO_HANDED; wordtype[wordnumber--] = OBJECT; return (take(from)); } wordvalue[wordnumber] = BROAD; wordtype[wordnumber--] = OBJECT; return (take(from)); case BODY: if (testbit(from, MAID)) { wordvalue[wordnumber] = MAID; wordtype[wordnumber--] = OBJECT; return (take(from)); } else if (testbit(from, DEADWOOD)) { wordvalue[wordnumber] = DEADWOOD; wordtype[wordnumber--] = OBJECT; return (take(from)); } else if (testbit(from, DEADNATIVE)) { wordvalue[wordnumber] = DEADNATIVE; wordtype[wordnumber--] = OBJECT; return (take(from)); } else { if (testbit(from, DEADGOD)) { wordvalue[wordnumber] = DEADGOD; wordtype[wordnumber--] = OBJECT; return (take(from)); } else { wordvalue[wordnumber] = DEADTIME; wordtype[wordnumber--] = OBJECT; return (take(from)); } } break; case AMULET: if (testbit(location[position].objects, AMULET)) { puts("The amulet is warm to the touch, and its beauty catches your breath."); puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer"); puts("and sharper but far away as if in a dream. The sound of purling water"); puts("reaches you from afar. The mist falls again, and your heart leaps in horror."); puts("The gold freezes your hands and fathomless darkness engulfs your soul."); } wordtype[wordnumber--] = OBJECT; return (take(from)); case MEDALION: if (testbit(location[position].objects, MEDALION)) { puts("The medallion is warm, and it rekindles your spirit with the warmth of life."); puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate."); } wordtype[wordnumber--] = OBJECT; return (take(from)); case TALISMAN: if (testbit(location[position].objects, TALISMAN)) { puts("The talisman is cold to the touch, and it sends a chill down your spine."); } wordtype[wordnumber--] = OBJECT; return (take(from)); case NORMGOD: if (testbit(location[position].objects, BATHGOD) && (testbit(wear, AMULET) || testbit(inven, AMULET))) { puts("She offers a delicate hand, and you help her out of the sparkling springs."); puts("Water droplets like liquid silver bedew her golden skin, but when they part"); puts("from her, they fall as teardrops. She wraps a single cloth around her and"); puts("ties it at the waist. Around her neck hangs a golden amulet."); puts("She bids you to follow her, and walks away."); pleasure++; followgod = ourtime; clearbit(location[position].objects, BATHGOD); } else if (!testbit(location[position].objects, BATHGOD)) puts("You're in no position to take her."); else puts("She moves away from you."); break; default: puts("It doesn't seem to work."); } else puts("You've got to be kidding."); return (firstnumber); } int throw(name) const char *name; { unsigned int n; int deposit = 0; int first, value; first = wordnumber; if (drop(name) != -1) { switch (wordvalue[wordnumber]) { case AHEAD: deposit = ahead; break; case BACK: deposit = back; break; case LEFT: deposit = left; break; case RIGHT: deposit = right; break; case UP: deposit = location[position].up * (location[position].access || position == FINAL); break; case DOWN: deposit = location[position].down; break; } wordnumber = first + 1; while (wordnumber <= wordcount) { value = wordvalue[wordnumber]; if (deposit && testbit(location[position].objects, value)) { clearbit(location[position].objects, value); if (value != GRENADE) setbit(location[deposit].objects, value); else { puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel."); for (n = 0; n < NUMOFWORDS; n++) location[deposit].objects[n] = 0; setbit(location[deposit].objects, CHAR); } if (value == ROPE && position == FINAL) location[position].access = 1; switch (deposit) { case 189: case 231: puts("The stone door is unhinged."); location[189].north = 231; location[231].south = 189; break; case 30: puts("The wooden door is blown open."); location[30].west = 25; break; case 31: puts("The door is not damaged."); } } else if (value == GRENADE && testbit(location[position].objects, value)) { puts("You are blown into shreds when your grenade explodes."); die(); } if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (first); } return (first); } return (first); } int drop(name) const char *name; { int firstnumber, value; firstnumber = wordnumber; wordnumber++; while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) { value = wordvalue[wordnumber]; if (value == BODY) { /* special case */ wordtype[wordnumber] = OBJECT; if (testbit(inven, MAID) || testbit(location[position].objects, MAID)) value = MAID; else if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD)) value = DEADWOOD; else if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD)) value = DEADGOD; else if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME)) value = DEADTIME; else if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE)) value = DEADNATIVE; } if (wordtype[wordnumber] == NOUNS && value == DOOR) { if (*name == 'K') puts("You hurt your foot."); else puts("You're not holding a door."); } else if (objsht[value] == NULL) { if (*name == 'K') puts("That's not for kicking!"); else puts("You don't have that."); } else { printf("%s:\n", objsht[value]); if (testbit(inven, value)) { clearbit(inven, value); carrying -= objwt[value]; encumber -= objcumber[value]; if (value == BOMB) { puts("The bomb explodes. A blinding white light and immense concussion obliterate us."); die(); } if (value != AMULET && value != MEDALION && value != TALISMAN) setbit(location[position].objects, value); else tempwiz = 0; ourtime++; if (*name == 'K') puts("Drop kicked."); else printf("%s.\n", name); } else { if (*name != 'K') { printf("You aren't holding the %s.\n", objsht[value]); if (testbit(location[position].objects, value)) { if (*name == 'T') puts("Kicked instead."); else if (*name == 'G') puts("Given anyway."); } } else if (testbit(location[position].objects, value)) puts("Kicked."); else if (testbit(wear, value)) puts("Not while it's being worn."); else puts("Not found."); } } if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } puts("Do what?"); return (-1); } int takeoff() { wordnumber = take(wear); return (drop("Dropped")); } int puton() { wordnumber = take(location[position].objects); return (wearit()); } int eat() { int firstnumber, value; firstnumber = wordnumber; wordnumber++; while (wordnumber <= wordcount) { value = wordvalue[wordnumber]; if (wordtype[wordnumber] != OBJECT || objsht[value] == NULL) value = -2; switch (value) { case -2: puts("You can't eat that!"); return (firstnumber); case -1: puts("Eat what?"); return (firstnumber); default: printf("You can't eat %s%s!\n", A_OR_AN_OR_BLANK(value), objsht[value]); return (firstnumber); case PAPAYAS: case PINEAPPLE: case KIWI: case COCONUTS: /* eatable things */ case MANGO: printf("%s:\n", objsht[value]); if (testbit(inven, value) && ourtime > ate - CYCLE && testbit(inven, KNIFE)) { clearbit(inven, value); carrying -= objwt[value]; encumber -= objcumber[value]; ate = max(ourtime, ate) + CYCLE / 3; snooze += CYCLE / 10; ourtime++; puts("Eaten. You can explore a little longer now."); } else if (!testbit(inven, value)) printf("You aren't holding the %s.\n", objsht[value]); else if (!testbit(inven, KNIFE)) puts("You need a knife."); else puts("You're stuffed."); if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND) wordnumber++; else return (firstnumber); } /* end switch */ } /* end while */ return (firstnumber); }
allardhoeve/pcgen-multiline-objects
pcgen/code/src/java/plugin/charactersheet/gui/WeaponPane.java
<reponame>allardhoeve/pcgen-multiline-objects /* * WeaponPane.java * * Created on February 4, 2004, 10:34 AM */ package plugin.charactersheet.gui; import pcgen.core.Equipment; import pcgen.core.PlayerCharacter; /** * <code>WeaponoToken</code>. * * @author ddjone3 * @version $Revision$ */ public class WeaponPane extends javax.swing.JPanel { private PlayerCharacter pc; private Equipment eq; private MeleeWeaponPane meleeWeaponPane; private NaturalWeaponPane naturalWeaponPane; private RangedWeaponPane rangedWeaponPane; private WeaponSpecialPane weaponSpecialPane; private WeaponTitlePane weaponTitlePane; /** * Constructor */ public WeaponPane() { initComponents(); setLocalColor(); } private void initComponents() { setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS)); weaponTitlePane = new WeaponTitlePane(); meleeWeaponPane = new MeleeWeaponPane(); naturalWeaponPane = new NaturalWeaponPane(); rangedWeaponPane = new RangedWeaponPane(); weaponSpecialPane = new WeaponSpecialPane(); add(weaponTitlePane); add(meleeWeaponPane); add(naturalWeaponPane); add(rangedWeaponPane); add(weaponSpecialPane); setVisible(false); } /** * Set the colour of the pane and sub panes. */ public void setColor() { setLocalColor(); meleeWeaponPane.setColor(); naturalWeaponPane.setColor(); rangedWeaponPane.setColor(); weaponSpecialPane.setColor(); weaponTitlePane.setColor(); } /** * Set the colour of the pane. */ public void setLocalColor() { setBackground(CharacterPanel.white); } /** * Set the Weapon. * * @param pc Player Character associated with the pane. * @param eq Equipment associated with the pane. */ public void setWeapon(PlayerCharacter pc, Equipment eq) { this.pc = pc; this.eq = eq; } /** * Refresh the pane. Creates sub panes and sets the weapon for each * sub pane if they don't exist. */ public void refresh() { setVisible(true); if (weaponTitlePane == null) { weaponTitlePane = new WeaponTitlePane(); add(weaponTitlePane); } weaponTitlePane.setWeapon(pc, eq); if (meleeWeaponPane == null) { meleeWeaponPane = new MeleeWeaponPane(); add(meleeWeaponPane); } meleeWeaponPane.setWeapon(pc, eq); if (naturalWeaponPane == null) { naturalWeaponPane = new NaturalWeaponPane(); add(naturalWeaponPane); } naturalWeaponPane.setWeapon(pc, eq); if (rangedWeaponPane == null) { rangedWeaponPane = new RangedWeaponPane(); add(rangedWeaponPane); } rangedWeaponPane.setWeapon(pc, eq); if (weaponSpecialPane == null) { weaponSpecialPane = new WeaponSpecialPane(); add(weaponSpecialPane); } weaponSpecialPane.setWeapon(pc, eq); } /** * Clear the pane. */ public void clear() { meleeWeaponPane = null; naturalWeaponPane = null; rangedWeaponPane = null; weaponSpecialPane = null; weaponTitlePane = null; } }
RyanAFinney/sakai
citations/citations-osid/web2bridge/src/java/edu/indiana/lib/osid/base/repository/Asset.java
package edu.indiana.lib.osid.base.repository; /********************************************************************************** * $URL$ * $Id$ ********************************************************************************** * * Copyright (c) 2003, 2004, 2005, 2007, 2008 The Sakai Foundation * * Licensed under the Educational Community License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.opensource.org/licenses/ECL-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * **********************************************************************************/ public abstract class Asset implements org.osid.repository.Asset { public String getDisplayName() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void updateDisplayName(String displayName) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public String getDescription() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void updateDescription(String description) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.shared.Id getId() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.shared.Id getRepository() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public java.io.Serializable getContent() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void updateContent(java.io.Serializable content) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void addAsset(org.osid.shared.Id assetId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void removeAsset(org.osid.shared.Id assetId , boolean includeChildren) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.AssetIterator getAssets() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.AssetIterator getAssetsByType(org.osid.shared.Type assetType) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.Record createRecord(org.osid.shared.Id recordStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void inheritRecordStructure(org.osid.shared.Id assetId , org.osid.shared.Id recordStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void copyRecordStructure(org.osid.shared.Id assetId , org.osid.shared.Id recordStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void deleteRecord(org.osid.shared.Id recordId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.RecordIterator getRecords() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.RecordIterator getRecordsByRecordStructure(org.osid.shared.Id recordStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.RecordStructureIterator getRecordStructures() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.RecordStructure getContentRecordStructure() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.Record getRecord(org.osid.shared.Id recordId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.Part getPart(org.osid.shared.Id partId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public java.io.Serializable getPartValue(org.osid.shared.Id partId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.PartIterator getPartByPart(org.osid.shared.Id partStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.shared.ObjectIterator getPartValueByPart(org.osid.shared.Id partStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public long getEffectiveDate() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void updateEffectiveDate(long effectiveDate) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public long getExpirationDate() throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public void updateExpirationDate(long expirationDate) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.shared.ObjectIterator getPartValuesByPartStructure(org.osid.shared.Id partStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } public org.osid.repository.PartIterator getPartsByPartStructure(org.osid.shared.Id partStructureId) throws org.osid.repository.RepositoryException { throw new org.osid.repository.RepositoryException(org.osid.OsidException.UNIMPLEMENTED); } }
justin-espedal/polydes
Common/src/com/polydes/common/comp/utils/DocumentAdapter.java
package com.polydes.common.comp.utils; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; public abstract class DocumentAdapter implements DocumentListener { private boolean noBlank; public DocumentAdapter(boolean noBlank) { this.noBlank = noBlank; } protected abstract void update(); private void innerUpdate(DocumentEvent e) { try { if(noBlank && e.getDocument().getText(0, e.getDocument().getLength()).equals("")) return; } catch (BadLocationException e1) { e1.printStackTrace(); } update(); } @Override public void changedUpdate(DocumentEvent e){innerUpdate(e);} @Override public void insertUpdate(DocumentEvent e){innerUpdate(e);} @Override public void removeUpdate(DocumentEvent e){innerUpdate(e);} }
harsh789rai/components
src/data/rooms.js
export default { room1: { ID: 'room1', title: 'Developer Standup', roomType: 'group', }, 'room1-activities': [ 'activity1', 'activity2', 'activity3', 'activity4', 'activity5', ], 'room1-previous-activities': ['default', 'no-header', 'long', 'multi-line'], room2: { ID: 'room2', title: 'UI/UX Design', roomType: 'group', }, 'room2-activities': [ 'activity6', {date: '2019-08-15T21:00:07.047'}, 'activity7', {date: '2019-08-20T21:00:07.047'}, 'activity8', ], room3: { ID: 'room3', title: 'Marketing Campaign', roomType: 'space', }, 'room3-activities': [], room4: { ID: 'room4', title: '<NAME>', roomType: 'direct', }, 'room4-activities': [], 'test-widgets': { ID: '1', title: 'test-widgets', type: 'group', }, widgets: { ID: '2', title: 'widgets', type: 'group', }, };
patrickneubauer/XMLIntellEdit
xmlintelledit/intelledit/src/main/java/at/ac/tuwien/big/xmlintelledit/intelledit/oclvisit/TracingEvaluationVisitor.java
/** * <copyright> * * Copyright (c) 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM - Initial API and implementation * * </copyright> * * $Id: TracingEvaluationVisitor.java,v 1.2 2009/09/01 20:11:22 ewillink Exp $ */ package at.ac.tuwien.big.xmlintelledit.intelledit.oclvisit; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Objects; import java.util.Stack; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.ocl.Environment; import org.eclipse.ocl.EnvironmentFactory; import org.eclipse.ocl.EvaluationEnvironment; import org.eclipse.ocl.EvaluationVisitor; import org.eclipse.ocl.EvaluationVisitorDecorator; import org.eclipse.ocl.expressions.AssociationClassCallExp; import org.eclipse.ocl.expressions.BooleanLiteralExp; import org.eclipse.ocl.expressions.CollectionItem; import org.eclipse.ocl.expressions.CollectionKind; import org.eclipse.ocl.expressions.CollectionLiteralExp; import org.eclipse.ocl.expressions.CollectionRange; import org.eclipse.ocl.expressions.EnumLiteralExp; import org.eclipse.ocl.expressions.IfExp; import org.eclipse.ocl.expressions.IntegerLiteralExp; import org.eclipse.ocl.expressions.InvalidLiteralExp; import org.eclipse.ocl.expressions.IterateExp; import org.eclipse.ocl.expressions.IteratorExp; import org.eclipse.ocl.expressions.LetExp; import org.eclipse.ocl.expressions.MessageExp; import org.eclipse.ocl.expressions.NullLiteralExp; import org.eclipse.ocl.expressions.OCLExpression; import org.eclipse.ocl.expressions.OperationCallExp; import org.eclipse.ocl.expressions.PropertyCallExp; import org.eclipse.ocl.expressions.RealLiteralExp; import org.eclipse.ocl.expressions.StateExp; import org.eclipse.ocl.expressions.StringLiteralExp; import org.eclipse.ocl.expressions.TupleLiteralExp; import org.eclipse.ocl.expressions.TupleLiteralPart; import org.eclipse.ocl.expressions.TypeExp; import org.eclipse.ocl.expressions.UnlimitedNaturalLiteralExp; import org.eclipse.ocl.expressions.UnspecifiedValueExp; import org.eclipse.ocl.expressions.Variable; import org.eclipse.ocl.expressions.VariableExp; import org.eclipse.ocl.types.CollectionType; import org.eclipse.ocl.util.CollectionUtil; import org.eclipse.ocl.utilities.ExpressionInOCL; import org.eclipse.ocl.utilities.Visitor; import at.ac.tuwien.big.xmlintelledit.intelledit.ecore.util.MyResource; import at.ac.tuwien.big.xmlintelledit.util.VisitorDecorable; /** * A decorator for evaluation visitors that is installed when evaluation tracing * is enabled, to trace interim evaluation results to the console. * * @author <NAME> (cdamus) */ public class TracingEvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> extends EvaluationVisitorDecorator<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> implements VisitorDecorable<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> { private VisitorDecorable visitor = this; private List<Object> evaluatedObjects = new ArrayList<>(); private int evaluationIndex = 0; private Stack<EvalResult> evalResults = new Stack<>(); private EvalResult last; private Object lastPretrace; public boolean isTitleAt = false; /** * Initializes me with the visitor whose evaluation I trace to the console. * * @param decorated a real evaluation visitor */ public TracingEvaluationVisitor( EvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> decorated) { super(decorated); if (decorated instanceof VisitorDecorable) { ((VisitorDecorable)decorated).setVisitor(this); } } public Object getCurResult() { return this.evaluatedObjects.get(this.evaluationIndex); } public Stack<EvalResult> getEvalResults() { return this.evalResults; } private Object getInvalid() { return getEnvironment().getOCLStandardLibrary().getInvalid(); } @Override public EvaluationVisitor getOtherDelegate() { return super.getDelegate(); } public EvalResult getTopResult() { return this.last; } @Override public VisitorDecorable getVisitor() { return this.visitor; } public boolean hasCurResult() { return this.evaluationIndex < this.evaluatedObjects.size(); } private boolean isInvalid(Object value) { return value == getEnvironment().getOCLStandardLibrary().getInvalid(); } private boolean isUndefined(Object value) { return (value == null) || (value == getEnvironment().getOCLStandardLibrary().getInvalid()); } private void mergeWith(TracingEvaluationVisitor sub) { } private void preTrace(Object expression) { EvalResult result; //Sometimes expressions are double?! EvalResult parent = (this.evalResults.isEmpty())?null:this.evalResults.peek(); if (parent != null && expression == parent.getExpression()) { result = parent; } else { if (expression instanceof OCLExpression) { OCLExpression<?> expr = (OCLExpression<?>)expression; result = new ExpressionResult(expr); } else { result = new SimpleResult(expression); } if (parent != null) { if (parent instanceof ExpressionResult) { ExpressionResult er = (ExpressionResult)parent; er.addSubResult(result); } else { //Should not happen new Exception().printStackTrace(); result.setParent(parent); } } } this.evalResults.push(result); } private Object privNavigate(P property, OCLExpression<C> derivation, Object target) { Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> myEnv = getEnvironment(); EnvironmentFactory<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> factory = myEnv.getFactory(); // create a nested evaluation environment for this property call EvaluationEnvironment<C, O, P, CLS, E> nested = factory.createEvaluationEnvironment(getEvaluationEnvironment()); // bind "self" nested.add(Environment.SELF_VARIABLE_NAME, target); EvaluationVisitor nestedV = factory.createEvaluationVisitor( myEnv, nested, getExtentMap()); EvaluationVisitor sub = getVisitor().spawnNewGlobal(getDelegate(),nestedV); //Here I need to rebuild the hierarchy EvaluationVisitor test = sub; TracingEvaluationVisitor tev = null; while (test instanceof EvaluationVisitorDecorator) { if (test instanceof TracingEvaluationVisitor) { tev = (TracingEvaluationVisitor)test; tev.evalResults = this.evalResults; tev.evaluatedObjects = this.evaluatedObjects; tev.evaluationIndex = this.evaluationIndex; break; } try { Method m = EvaluationVisitorDecorator.class.getDeclaredMethod("getDelegate"); m.setAccessible(true); test = (EvaluationVisitor)m.invoke(test); } catch (Exception e) { e.printStackTrace(); break; } } Object ret = sub.visitExpression(derivation); if (tev == null) { System.err.println("Could not find tev!"); } else { this.evaluationIndex = tev.evaluationIndex; } return ret; } private Object privVisitPropertyCallExp(PropertyCallExp<C, P> pc) { P property = pc.getReferredProperty(); OCLExpression<C> source = pc.getSource(); // evaluate source Object context = source.accept(getVisitor()); // if source is undefined, result is OclInvalid if (isUndefined(context)) { return getInvalid(); } EClass cl = null; if (property instanceof EStructuralFeature) { cl = ((EStructuralFeature) property).getEContainingClass(); if (context instanceof EObject) { cl = ((EObject)context).eClass(); } OCLExpression<C> derivation = MyResource.getDerivation(cl,(EStructuralFeature)property); if (derivation != null) { // this is an additional property //Wie geht das? return privNavigate(property, derivation, context); } } List<Object> qualifiers; if (pc.getQualifier().isEmpty()) { qualifiers = Collections.emptyList(); } else { // handle qualified association navigation qualifiers = new java.util.ArrayList<>(); for (OCLExpression<C> q : pc.getQualifier()) { //TODO: this VS getVisitor?! qualifiers.add(q.accept(getVisitor())); } } Object result = getEvaluationEnvironment().navigateProperty(property, qualifiers, context); if ((pc.getType() instanceof CollectionType<?, ?>) && !(result instanceof Collection<?>)) { // this was an XSD "unspecified multiplicity". Now that we know what // the multiplicity is, we can coerce it to a collection value @SuppressWarnings("unchecked") CollectionKind kind = ((CollectionType<C, O>) pc.getType()).getKind(); Collection<Object> collection = CollectionUtil.createNewCollection(kind); collection.add(result); result = collection; } return result; } public void reset() { this.evaluationIndex = 0; } @Override public void setVisitor(VisitorDecorable visitor) { this.visitor = visitor; if (getDelegate() instanceof VisitorDecorable ) { ((VisitorDecorable)getDelegate()).setVisitor(visitor); } } @Override public VisitorDecorable spawnNew(EvaluationVisitor sub) { return new TracingEvaluationVisitor(sub); } private Object trace(Object expression, Object value) { try { if (value instanceof HashMap) { System.err.println("Hashmap-value?!"); if (!this.isTitleAt) { value = null; } else { System.err.println("HashMap in title?!"); } } if (this.evaluationIndex == this.evaluatedObjects.size()) { this.evaluatedObjects.add(value); } else { assert Objects.equals(this.evaluatedObjects.get(this.evaluationIndex),value); } EvalResult cur = this.last = this.evalResults.pop(); if (expression instanceof OCLExpression) { while (!(cur instanceof ExpressionResult) || ((ExpressionResult)cur).getExpression() != expression) { //Maybe needed for exceptions, but don't know //System.err.println("Stepping up"); EvalResult oldCur = cur; cur = this.evalResults.pop(); if (cur == null) { System.err.println("ERROR: Stepped up till nothing existing ..."); new Exception().printStackTrace(); cur = oldCur; break; } } } cur.setResult(value); ++this.evaluationIndex; } catch (Exception e) { // tracing must not interfere with evaluation } return value; } @Override public Object visitAssociationClassCallExp( AssociationClassCallExp<C, P> callExp) { preTrace(callExp); return trace(callExp, getDelegate().visitAssociationClassCallExp(callExp)); } @Override public Object visitBooleanLiteralExp(BooleanLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitBooleanLiteralExp(literalExp)); } @Override public Object visitCollectionItem(CollectionItem<C> item) { preTrace(item); return trace(item, getDelegate().visitCollectionItem(item)); } @Override public Object visitCollectionLiteralExp(CollectionLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitCollectionLiteralExp(literalExp)); } @Override public Object visitCollectionRange(CollectionRange<C> range) { preTrace(range); return trace(range, getDelegate().visitCollectionRange(range)); } @Override public Object visitConstraint(CT constraint) { preTrace(constraint); return trace(constraint, getDelegate().visitConstraint(constraint)); } @Override public Object visitEnumLiteralExp(EnumLiteralExp<C, EL> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitEnumLiteralExp(literalExp)); } @Override public Object visitExpression(OCLExpression<C> expression) { preTrace(expression); return trace(expression, getDelegate().visitExpression(expression)); } @Override public Object visitExpressionInOCL(ExpressionInOCL<C, PM> expression) { preTrace(expression); return trace(expression, getDelegate().visitExpressionInOCL(expression)); } @Override public Object visitIfExp(IfExp<C> ifExp) { preTrace(ifExp); return trace(ifExp, getDelegate().visitIfExp(ifExp)); } @Override public Object visitIntegerLiteralExp(IntegerLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitIntegerLiteralExp(literalExp)); } @Override public Object visitInvalidLiteralExp(InvalidLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitInvalidLiteralExp(literalExp)); } @Override public Object visitIterateExp(IterateExp<C, PM> callExp) { preTrace(callExp); return trace(callExp, getDelegate().visitIterateExp(callExp)); } @Override public Object visitIteratorExp(IteratorExp<C, PM> callExp) { preTrace(callExp); return trace(callExp, getDelegate().visitIteratorExp(callExp)); } @Override public Object visitLetExp(LetExp<C, PM> letExp) { preTrace(letExp); return trace(letExp, getDelegate().visitLetExp(letExp)); } @Override public Object visitMessageExp(MessageExp<C, COA, SSA> messageExp) { preTrace(messageExp); return trace(messageExp, getDelegate().visitMessageExp(messageExp)); } @Override public Object visitNullLiteralExp(NullLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitNullLiteralExp(literalExp)); } @Override public Object visitOperationCallExp(OperationCallExp<C, O> callExp) { preTrace(callExp); return trace(callExp, getDelegate().visitOperationCallExp(callExp)); } @Override public Object visitPropertyCallExp(PropertyCallExp<C, P> callExp) { preTrace(callExp); Object result = privVisitPropertyCallExp(callExp); return trace(callExp, result); } @Override public Object visitRealLiteralExp(RealLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitRealLiteralExp(literalExp)); } @Override public Object visitStateExp(StateExp<C, S> stateExp) { preTrace(stateExp); return trace(stateExp, getDelegate().visitStateExp(stateExp)); } @Override public Object visitStringLiteralExp(StringLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitStringLiteralExp(literalExp)); } @Override public Object visitTupleLiteralExp(TupleLiteralExp<C, P> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitTupleLiteralExp(literalExp)); } @Override public Object visitTupleLiteralPart(TupleLiteralPart<C, P> part) { preTrace(part); return trace(part, getDelegate().visitTupleLiteralPart(part)); } @Override public Object visitTypeExp(TypeExp<C> typeExp) { preTrace(typeExp); return trace(typeExp, getDelegate().visitTypeExp(typeExp)); } @Override public Object visitUnlimitedNaturalLiteralExp( UnlimitedNaturalLiteralExp<C> literalExp) { preTrace(literalExp); return trace(literalExp, getDelegate().visitUnlimitedNaturalLiteralExp(literalExp)); } @Override public Object visitUnspecifiedValueExp(UnspecifiedValueExp<C> unspecExp) { preTrace(unspecExp); return trace(unspecExp, getDelegate().visitUnspecifiedValueExp(unspecExp)); } @Override public Object visitVariable(Variable<C, PM> variable) { preTrace(variable); return trace(variable, getDelegate().visitVariable(variable)); } @Override public Object visitVariableExp(VariableExp<C, PM> variableExp) { preTrace(variableExp); return trace(variableExp, getDelegate().visitVariableExp(variableExp)); } }
nuest/ami3
src/main/java/org/contentmine/image/diagram/ExampleImageConvert.java
<reponame>nuest/ami3<filename>src/main/java/org/contentmine/image/diagram/ExampleImageConvert.java package org.contentmine.image.diagram; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.List; import javax.imageio.ImageIO; import org.apache.commons.io.FilenameUtils; import org.contentmine.cproject.files.CTree; import org.contentmine.cproject.util.CMineGlobber; import org.contentmine.image.ImageUtil; import boofcv.alg.filter.binary.ThresholdImageOps; import boofcv.alg.filter.derivative.DerivativeType; import boofcv.alg.filter.derivative.GImageDerivativeOps; import boofcv.alg.misc.GPixelMath; import boofcv.alg.misc.ImageStatistics; import boofcv.core.image.ConvertImage; import boofcv.core.image.GeneralizedImageOps; import boofcv.core.image.border.BorderType; import boofcv.io.image.ConvertBufferedImage; import boofcv.struct.image.GrayF32; import boofcv.struct.image.GrayS16; import boofcv.struct.image.GrayU8; /** * Demonstrates how to convert between different BoofCV image types. * * @author <NAME> */ public class ExampleImageConvert { // image loaded from a file BufferedImage image; // gray scale image with element values from 0 to 255 GrayU8 gray; // Derivative of gray image. Elements are 16-bit signed integers GrayS16 derivX,derivY; // private ListDisplayPanel panel; private File root; public ExampleImageConvert() { // TODO Auto-generated constructor stub } void createPanel() { // panel = new ListDisplayPanel(); // root = new File("/Users/pm286/workspace/uclforest/forestplots/campbell/pdfimages"); } void convert(String imageName) { // Converting between BoofCV image types is easy with ConvertImage. ConvertImage copies // the value of a pixel in one image into another image. When doing so you need to take // in account the storage capabilities of these different class types. // Going from an unsigned 8-bit image to unsigned 16-bit image is no problem // GrayU16 imageU16 = new GrayU16(gray.width,gray.height); // ConvertImage.convert(gray,imageU16); // You can convert back into the 8-bit image from the 16-bit image with no problem // in this situation because imageU16 does not use the full range of 16-bit values // ConvertImage.convert(imageU16,gray); // // Here is an example where you over flow the image after converting // // There won't be an exception or any error messages but the output image will be corrupted // GrayU8 imageBad = new GrayU8(derivX.width,derivX.height); // ConvertImage.convert(derivX,imageBad); // One way to get around this problem rescale and adjust the pixel values so that they // will be within a valid range. int width = derivX.width; int height = derivX.height; GrayS16 scaledAbs = new GrayS16(width,height); GPixelMath.abs(derivX,scaledAbs); GPixelMath.multiply(scaledAbs, 255.0 / ImageStatistics.max(scaledAbs), scaledAbs); GrayU8 binary = new GrayU8(gray.getWidth(), gray.getHeight()); // ConvertImage.convert(gray,binary); GrayF32 imageF32 = new GrayF32(gray.width,gray.height); ConvertImage.convert(gray,imageF32); float threshold = 100.f; ThresholdImageOps.threshold(imageF32, binary, threshold, false); // If you just want to see the values of a 16-bit image there are built in utility functions // for visualizing their values too BufferedImage imageOut = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); ConvertBufferedImage.convertTo(binary, imageOut); // BufferedImage colorX = VisualizeImageData.colorizeSign(derivX, null, -1); // Let's see what all the bad image looks like // ConvertBufferedImage is similar to ImageConvert in that it does a direct coversion with out // adjusting the pixel's value // BufferedImage outBad = new BufferedImage(imageBad.width,imageBad.height,BufferedImage.TYPE_INT_RGB); // BufferedImage outScaled = new BufferedImage(imageBad.width,imageBad.height,BufferedImage.TYPE_INT_RGB); // panel.addImage(ConvertBufferedImage.convertTo(scaledAbs,outScaled),"Scaled"); // panel.addImage(gray,"gray"+imageName); // panel.addImage(imageOut,"bin"+imageName); // panel.addImage(colorX,"Col"+imageName); // panel.addImage(ConvertBufferedImage.convertTo(imageBad,outBad),"Bad"); } /** * Load and generate images */ public void createImages(String imageName) { // image = UtilImageIO.loadImage(UtilIO.pathExample("standard/barbara.jpg")); try { image = ImageUtil.readImage(new File(root, imageName)); } catch (RuntimeException e) { return; } gray = ConvertBufferedImage.convertFromSingle(image, null, GrayU8.class); derivX = GeneralizedImageOps.createSingleBand(GrayS16.class, gray.getWidth(), gray.getHeight()); derivY = GeneralizedImageOps.createSingleBand(GrayS16.class, gray.getWidth(), gray.getHeight()); GImageDerivativeOps.gradient(DerivativeType.SOBEL, gray, derivX, derivY, BorderType.EXTENDED); } public static void main( String args[] ) { ExampleImageConvert app = new ExampleImageConvert(); app.runApp(); } private void runApp() { this.createPanel(); List<File> imageFiles = CMineGlobber.listSortedChildFiles(root, CTree.PNG); for (File imageFile : imageFiles) { String imageName = FilenameUtils.getName(imageFile.toString()); this.createImages(imageName); this.convert(imageName); } // ShowImages.showWindow(panel,"Image Convert",true); } }
ricortiz/OpenTissue
OpenTissue/core/containers/mesh/trimesh/trimesh_vertex.h
<filename>OpenTissue/core/containers/mesh/trimesh/trimesh_vertex.h #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_TRIMESH_TRIMESH_VERTEX_H #define OPENTISSUE_CORE_CONTAINERS_MESH_TRIMESH_TRIMESH_VERTEX_H // // OpenTissue Template Library // - A generic toolbox for physics-based modeling and simulation. // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. // // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php // #include <OpenTissue/configuration.h> namespace OpenTissue { namespace trimesh { template< typename trimesh_type_ > class TriMeshVertex : public trimesh_type_::vertex_traits { public: typedef trimesh_type_ mesh_type; typedef typename mesh_type::vertex_handle vertex_handle; private: vertex_handle m_self; mesh_type * m_owner; unsigned int m_face_count; public: TriMeshVertex() : m_self() , m_owner(0) , m_face_count(0) {}; public: vertex_handle get_handle() const { return m_self; }; mesh_type * get_owner() const { return m_owner; }; unsigned int get_face_count() const { return m_face_count; }; private: friend class trimesh_core_access; void set_handle(vertex_handle v) { m_self = v; }; void set_owner(mesh_type * owner) { m_owner = owner; }; }; } // namespace trimesh } // namespace OpenTissue //OPENTISSUE_CORE_CONTAINERS_MESH_TRIMESH_TRIMESH_VERTEX_H #endif
shengnian/shengnian-ui-react
docs/app/Examples/elements/Segment/Variations/SegmentExampleClearing.js
<reponame>shengnian/shengnian-ui-react<filename>docs/app/Examples/elements/Segment/Variations/SegmentExampleClearing.js import React from 'react' import { Button, Segment } from 'shengnian-ui-react' const SegmentExampleClearing = () => ( <Segment clearing> <Button floated='right'> floated </Button> </Segment> ) export default SegmentExampleClearing
Hex27/TerraformGenerator
common/src/main/java/org/terraform/utils/WoodUtils.java
<reponame>Hex27/TerraformGenerator package org.terraform.utils; import org.bukkit.Material; import org.terraform.biome.BiomeBank; public class WoodUtils { public static enum WoodSpecies{ OAK, SPRUCE, BIRCH, JUNGLE, ACACIA, DARK_OAK; } public static enum WoodType{ PLANKS("%WOOD%_PLANKS"), SAPLING("%WOOD%_SAPLING"), POTTED_SAPLING("POTTED_%WOOD%_SAPLING"), LOG("%WOOD%_LOG"), STRIPPED_LOG("STRIPPED_%WOOD%_LOG"), WOOD("%WOOD%_WOOD"), STRIPPED_WOOD("STRIPPED_%WOOD%_WOOD"), LEAVES("%WOOD%_LEAVES"), SLAB("%WOOD%_SLAB"), PRESSURE_PLATE("%WOOD%_PRESSURE_PLATE"), FENCE("%WOOD%_FENCE"), TRAPDOOR("%WOOD%_TRAPDOOR"), FENCE_GATE("%WOOD%_FENCE_GATE"), STAIRS("%WOOD%_STAIRS"), BUTTON("%WOOD%_BUTTON"), DOOR("%WOOD%_DOOR"), SIGN("%WOOD%_SIGN"), WALL_SIGN("%WOOD%_WALL_SIGN"), BOAT("%WOOD%_BOAT"), ; String template; WoodType(String template){ this.template = template; } /** * Converts an oak material to a WoodType template. * Do not use for any other wood. * <br><br> * The dark oak check is there because schematics only check for the * keyword "oak" * @param oak material to convert to an WoodType enum * @return */ public static WoodType parse(Material oak) { return WoodType.valueOf(oak.toString() .replace("DARK_OAK","OAK") .replace("OAK_","")); } //I am the pinnacle of optimisation //Fear my absolutely unbeatable timings public Material getWood(WoodSpecies species) { return Material.getMaterial(template.replace("%WOOD%", species.toString())); } } public static Material getWoodForBiome(BiomeBank biome, WoodType wood) { switch (biome) { case BADLANDS: case BADLANDS_RIVER: case SAVANNA: case DESERT_MOUNTAINS: case DESERT: case DESERT_RIVER: case BADLANDS_BEACH: case BADLANDS_CANYON: return wood.getWood(WoodSpecies.ACACIA); case BIRCH_MOUNTAINS: return wood.getWood(WoodSpecies.BIRCH); case COLD_OCEAN: case WARM_OCEAN: case SWAMP: case PLAINS: case OCEAN: case MUDFLATS: case CORAL_REEF_OCEAN: case DEEP_LUKEWARM_OCEAN: case DEEP_OCEAN: case DEEP_WARM_OCEAN: case DEEP_DRY_OCEAN: case DEEP_HUMID_OCEAN: case DRY_OCEAN: case HUMID_OCEAN: case RIVER: case ERODED_PLAINS: case FOREST: return wood.getWood(WoodSpecies.OAK); case FROZEN_OCEAN: case TAIGA: case SNOWY_WASTELAND: case SNOWY_TAIGA: case SNOWY_MOUNTAINS: case ROCKY_MOUNTAINS: case ROCKY_BEACH: case FROZEN_RIVER: case DEEP_COLD_OCEAN: case DEEP_FROZEN_OCEAN: case ICY_BEACH: case ICE_SPIKES: return wood.getWood(WoodSpecies.SPRUCE); case SANDY_BEACH: case JUNGLE: case JUNGLE_RIVER: case BAMBOO_FOREST: return wood.getWood(WoodSpecies.JUNGLE); case BLACK_OCEAN: case DEEP_BLACK_OCEAN: case DARK_FOREST: case DARK_FOREST_RIVER: case DARK_FOREST_BEACH: return wood.getWood(WoodSpecies.DARK_OAK); default: break; } return wood.getWood(WoodSpecies.OAK); } }
qiufeng9862/mfish-cloud
mf-oauth/src/main/java/cn/com/mfish/oauth/controller/AccessTokenController.java
<reponame>qiufeng9862/mfish-cloud package cn.com.mfish.oauth.controller; import cn.com.mfish.oauth.annotation.LogAnnotation; import cn.com.mfish.oauth.cache.redis.UserTokenCache; import cn.com.mfish.oauth.common.CheckWithResult; import cn.com.mfish.oauth.common.SerConstant; import cn.com.mfish.common.core.exception.OAuthValidateException; import cn.com.mfish.oauth.model.AccessToken; import cn.com.mfish.oauth.model.AuthorizationCode; import cn.com.mfish.oauth.model.OAuthClient; import cn.com.mfish.oauth.model.RedisAccessToken; import cn.com.mfish.oauth.service.LoginService; import cn.com.mfish.oauth.service.OAuth2Service; import cn.com.mfish.oauth.validator.Code2TokenValidator; import cn.com.mfish.oauth.validator.Refresh2TokenValidator; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.oltu.oauth2.as.request.OAuthTokenRequest; import org.apache.oltu.oauth2.common.OAuth; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.exception.OAuthSystemException; import org.apache.oltu.oauth2.common.message.types.GrantType; import org.apache.shiro.SecurityUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.lang.reflect.InvocationTargetException; /** * @author qiufeng * @date 2020/2/17 14:17 */ @Api(tags = "token获取") @RestController @RequestMapping public class AccessTokenController { @Resource Code2TokenValidator code2TokenValidator; @Resource Refresh2TokenValidator refresh2TokenValidator; @Resource OAuth2Service oAuth2Service; @Resource LoginService loginService; @Resource UserTokenCache userTokenCache; @ApiOperation("token获取") @PostMapping(value = "/accessToken") @ApiImplicitParams({ @ApiImplicitParam(name = OAuth.HeaderType.CONTENT_TYPE, value = "请求类型,必须使用application/x-www-form-urlencoded类型", required = true, paramType = "header", defaultValue = "application/x-www-form-urlencoded"), @ApiImplicitParam(name = OAuth.OAUTH_GRANT_TYPE, value = "token获取类型", required = true, paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_CLIENT_ID, value = "客户端ID", required = true, paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_CLIENT_SECRET, value = "客户端密钥", required = true, paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_REDIRECT_URI, value = "回调地址", required = true, paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_STATE, value = "状态", paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_CODE, value = "认证code grant_type=authorization_code时必须", paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_USERNAME, value = "账号,手机,email grant_type=password时必须", paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_PASSWORD, value = "密码 grant_type=password时必须", paramType = "query"), @ApiImplicitParam(name = OAuth.OAUTH_REFRESH_TOKEN, value = "密码 grant_type=refresh_token时必须", paramType = "query") }) @LogAnnotation("getToken") public AccessToken token(HttpServletRequest request) throws OAuthSystemException, OAuthProblemException, InvocationTargetException, IllegalAccessException { OAuthTokenRequest tokenRequest = new OAuthTokenRequest(request); CheckWithResult<OAuthClient> result = code2TokenValidator.validateClient(request, null); if (!result.isSuccess()) { throw new OAuthValidateException(result.getMsg()); } GrantType grantType = GrantType.valueOf(request.getParameter(OAuth.OAUTH_GRANT_TYPE).toUpperCase()); RedisAccessToken token; switch (grantType) { case AUTHORIZATION_CODE: token = code2Token(request, tokenRequest); break; case REFRESH_TOKEN: token = refresh2Token(request); break; case PASSWORD: token = pwd2Token(request, tokenRequest); break; default: throw new OAuthValidateException(result.getMsg()); } //增加用户登录互斥缓存 userTokenCache.addUserTokenCache(SerConstant.DeviceType.Web , SecurityUtils.getSubject().getSession().getId().toString() , token.getUserId(), token.getAccessToken()); return new AccessToken().setAccess_token(token.getAccessToken()).setExpires_in(token.getExpire()).setRefresh_token(token.getRefreshToken()); } /** * 通过code换取token * * @param request * @param tokenRequest * @return * @throws OAuthSystemException * @throws IllegalAccessException * @throws InvocationTargetException */ private RedisAccessToken code2Token(HttpServletRequest request, OAuthTokenRequest tokenRequest) throws OAuthSystemException, IllegalAccessException, InvocationTargetException { CheckWithResult<AuthorizationCode> result = code2TokenValidator.validateCode(request, null); if (!result.isSuccess()) { throw new OAuthValidateException(result.getMsg()); } return oAuth2Service.code2Token(tokenRequest, result.getResult()); } /** * 通过refreshtoken获取token * * @param request * @return * @throws OAuthSystemException */ private RedisAccessToken refresh2Token(HttpServletRequest request) throws OAuthSystemException { CheckWithResult<RedisAccessToken> result = refresh2TokenValidator.validateToken(request, null); if (!result.isSuccess()) { throw new OAuthValidateException(result.getMsg()); } return oAuth2Service.refresh2Token(result.getResult()); } /** * 用户名密码直接登录获取token * * @param request * @param tokenRequest * @return * @throws OAuthSystemException * @throws IllegalAccessException * @throws InvocationTargetException */ private RedisAccessToken pwd2Token(HttpServletRequest request, OAuthTokenRequest tokenRequest) throws OAuthSystemException, IllegalAccessException, InvocationTargetException { CheckWithResult<String> result = loginService.login(request); if (!result.isSuccess()) { throw new OAuthValidateException(result.getMsg()); } return oAuth2Service.buildToken(tokenRequest); } }
jacogreyling/pexeso
client/helpers/json-fetch.js
/* global window, document */ 'use strict'; const Cookie = require('cookie'); const Qs = require('qs'); const Xhr = require('xhr'); const jsonFetch = function (options, callback) { const cookies = Cookie.parse(document.cookie); const config = { url: options.url, method: options.method, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }; if (cookies.crumb) { config.headers['X-CSRF-Token'] = cookies.crumb; } if (options.query) { config.url += '?' + Qs.stringify(options.query); } if (options.data) { config.body = JSON.stringify(options.data); } Xhr(config, (err, response, body) => { if (err) { return callback(err); } if (response.statusCode >= 200 && response.statusCode < 300) { if (response.headers.hasOwnProperty('x-auth-required')) { if (window.location.pathname === '/login') { return callback(Error('Auth required.')); } let returnUrl = window.location.pathname; if (window.location.search.length > 0) { returnUrl += window.location.search; } returnUrl = encodeURIComponent(returnUrl); window.location.href = `/login?returnUrl=${returnUrl}`; } else { callback(null, JSON.parse(body)); } } else { const httpErr = new Error(response.rawRequest.statusText); callback(httpErr, JSON.parse(body)); } }); }; if (global.window) { window.jsonFetch = jsonFetch; } module.exports = jsonFetch;
vnctbb/final-project-back
src/friend/validator/friend_update_params.js
<gh_stars>0 'use strict' exports.updateValidator = (params) => { const validParams = {}; if(params._id || params.__v || params.senderId || params.receiverId || params.creationDatetime){ return undefined; } if (params.status){ if(params.status === "CANCEL"){ validParams.status = params.status; if(params.modificationDatetime){ validParams.modificationDatetime = params.modificationDatetime; } return validParams } } return undefined; }
faserg1/adb
libadb/include/libadb/api/interactions/data/message-interaction.hpp
#pragma once #include <optional> #include <string> #include <nlohmann/json_fwd.hpp> #include <libadb/libadb.hpp> #include <libadb/types/snowflake.hpp> #include <libadb/api/interactions/data/interaction-type.hpp> #include <libadb/api/user/data/user.hpp> #include <libadb/api/guild/data/guild-member.hpp> namespace adb::api { /** * @brief Message interaction * @details https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object */ struct MessageInteraction { /// id of the interaction adb::types::SFID id; /// the type of interaction InteractionType type; /// the name of the application command std::string name; /// the user who invoked the interaction User user; /// the member who invoked the interaction in the guild std::optional<GuildMember> guildMember; }; LIBADB_API void to_json(nlohmann::json& j, const MessageInteraction& msgInteraction); LIBADB_API void from_json(const nlohmann::json& j, MessageInteraction& msgInteraction); }
sodero/clib2-1
library/wchar/wcsrtombs.c
/* * $Id: wchar_wcsrtombs.c,v 1.3 2006-01-08 12:04:27 clib2devs Exp $ */ #ifndef _WCHAR_HEADERS_H #include "wchar_headers.h" #endif /* _WCHAR_HEADERS_H */ size_t wcsrtombs(char *s, const wchar_t **ws, size_t n, mbstate_t *st) { return wcsnrtombs(s, ws, (size_t) -1, n, st); }
hitsmaxft/SimpleLight
emusrc/goombacolor/src/equates.h
<gh_stars>1-10 #pragma once #include "config.h" //Must update cleanup_ewram if EWRAM equates are changed! VERSION_IN_ROM = 1 #ifndef _GBAMP_VERSION #define _GBAMP_VERSION 0 #endif GBAMPVERSION = _GBAMP_VERSION #include "macro.h" @GBLL DEBUG @GBLL SAFETY @GBLL PROFILE @GBLL SPEEDHACKS_OLD @GBLL MOVIEPLAYER @GBLL RESIZABLE @GBLL RUMBLE @GBLL SAVESTATES @GBLL SRAM_32 @GBLL VISOLY @GBLL LITTLESOUNDDJ SRAM_32 = 0 DEBUG = 0 PROFILE = 0 @ SPEEDHACKS_OLD = 0 // LITTLESOUNDDJ = 0 // .if GBAMPVERSION // MOVIEPLAYER = 1 // RESIZABLE = 1 // RUMBLE = 0 // VISOLY = 0 // .else // MOVIEPLAYER = 0 // RESIZABLE = 0 // RUMBLE = 1 // VISOLY = 1 // .endif SAVESTATES = 0 @BUILD SETS "DEBUG"/"GBA" (defined at cmdline) @---------------------------------------------------------------------------- MAX_RECENT_TILES = 96 @if you change this, change RECENT_TILES as well! RECENT_TILENUM_SIZE = 128 @ BG_CACHE_SIZE = 512 @statck starts at 0x03007700 BORDER_PALETTE = 0x0600EF80 @formerly 0x06006F80 @VRAM areas: @0x600 bytes at 06006200 @0x80 bytes at 06006f00 @0x400 bytes at 0600cc00 @0x4000 at 06014000 @0x300 at 06007D00-06008000 @SGB border areas coincide with the GBA areas reserved for them SNES_VRAM = 0x0600C220 @one tile ahead, too bad if games don't write low tiles then high tiles, also overlaps with recent_tiles... SNES_MAP = 0x0600E780 @overlaps with recent_tiles, map must be updated in reverse order RECENT_TILES = 0x0600E200 @DIRTY_TILES-(MAX_RECENT_TILES*16) AGB_SGB_MAP = 0x0600E800 AGB_SGB_VRAM = 0x0600C200 @GBLA Next MEM_END = 0x02040000 Next = MEM_END .if MOVIEPLAYER FAT_MEM_END = MEM_END FAT_MEM_START = FAT_MEM_END-4096 fatBuffer = FAT_MEM_END-512 fatWriteBuffer = fatBuffer globalBuffer = fatBuffer-512 lfnName = globalBuffer-256 SramName = lfnName-256 openFiles = SramName-1200 stateexist = openFiles-36 System = stateexist-4 PALMode = System-4 rom_file = PALMode-4 nocash = rom_file-4 rom_filesize = nocash-4 Next = FAT_MEM_START .endif .if RESIZABLE .else XGB_SRAM = Next-0x8000 XGB_VRAM = XGB_SRAM-0x4000 GBC_EXRAM = XGB_VRAM-0x6000 Next = GBC_EXRAM .endif @ INSTANT_PAGES = 0x06004c00 @SGB_PACKET-1024 ;formerly 0x0600CC00 SGB_PALETTE = Next-16*4 Next = SGB_PALETTE @ DIRTY_ROWS = Next-48 @ DIRTY_TILES = DIRTY_ROWS-768-4 @ RECENT_TILENUM = DIRTY_TILES-(MAX_RECENT_TILES+2)*2 @ BG_CACHE = RECENT_TILENUM-BG_CACHE_SIZE @ Next = RECENT_TILENUM .if RESIZABLE .else SGB_PALS = Next-4096 SGB_ATFS = SGB_PALS-4096 SGB_PACKET = SGB_ATFS-112 SGB_ATTRIBUTES = SGB_PACKET-360 Next = SGB_ATTRIBUTES .endif GBOAMBUFF1 = Next-160 GBOAMBUFF2 = GBOAMBUFF1-160 GBOAMBUFF3 = GBOAMBUFF2-160 BG0CNT_SCROLL_BUFF = GBOAMBUFF3-144*24 WINDOWBUFF = BG0CNT_SCROLL_BUFF-144*2 DISPCNTBUFF = WINDOWBUFF-144*2 BG0CNT_SCROLL_BUFF2 = DISPCNTBUFF-144*24 WINDOWBUFF2 = BG0CNT_SCROLL_BUFF2-144*2 DISPCNTBUFF2 = WINDOWBUFF2-144*2 Next = DISPCNTBUFF2 @WXBUFF1 EQU DISPCNTBUFF-144 @YSCROLLBUFF1 EQU WXBUFF1-144 @XSCROLLBUFF1 EQU YSCROLLBUFF1-144 @LCDCBUFF1 EQU XSCROLLBUFF1-144 @WXBUFF2 EQU LCDCBUFF1-144 @YSCROLLBUFF2 EQU WXBUFF2-144 @XSCROLLBUFF2 EQU YSCROLLBUFF2-144 @LCDCBUFF2 EQU XSCROLLBUFF2-144 TEXTMEM = Next - 632 Next = TEXTMEM ewram_canary_2 = Next - 4 Next = ewram_canary_2 DIRTY_TILE_BITS = Next - 48 dirty_map_words = DIRTY_TILE_BITS - 64 Next = dirty_map_words RECENT_TILENUM = Next - RECENT_TILENUM_SIZE @32 words Next = RECENT_TILENUM @24 packets at 8 bytes per packet, 20 packets might be okay too... (modify dma.c as well) vram_packets_incoming = Next - 192 vram_packets_registered_bank0 = vram_packets_incoming - 192 vram_packets_registered_bank1 = vram_packets_registered_bank0 - 192 vram_packets_dirty = vram_packets_registered_bank1 - 196 Next = vram_packets_dirty INSTANT_PAGES = Next-1024 Next = INSTANT_PAGES ewram_canary_1 = Next - 4 Next = ewram_canary_1 .if SPEEDHACKS_OLD SPEEDHACK_FIND_JR_Z_BUF = Next - 64 SPEEDHACK_FIND_JR_NZ_BUF = SPEEDHACK_FIND_JR_Z_BUF-64 SPEEDHACK_FIND_JR_C_BUF = SPEEDHACK_FIND_JR_NZ_BUF-64 SPEEDHACK_FIND_JR_NC_BUF = SPEEDHACK_FIND_JR_C_BUF-64 Next = SPEEDHACK_FIND_JR_NC_BUF .endif @ _FF41_PC_4 = Next - 168 @ Next = _FF41_PC_4 MULTIBOOT_LIMIT = Next @How much data is left for Multiboot to work. END_OF_EXRAM = MULTIBOOT_LIMIT AGB_IRQVECT = 0x3007FFC AGB_PALETTE = 0x5000000 AGB_VRAM = 0x6000000 AGB_OAM = 0x7000000 AGB_SRAM = 0xE000000 REG_BASE = 0x4000000 REG_DISPCNT = 0x00 REG_DISPSTAT = 0x04 REG_VCOUNT = 0x06 REG_BG0CNT = 0x08 REG_BG1CNT = 0x0A REG_BG2CNT = 0x0C REG_BG3CNT = 0x0E REG_BG0HOFS = 0x10 REG_BG0VOFS = 0x12 REG_BG1HOFS = 0x14 REG_BG1VOFS = 0x16 REG_BG2HOFS = 0x18 REG_BG2VOFS = 0x1A REG_BG3HOFS = 0x1C REG_BG3VOFS = 0x1E REG_WIN0H = 0x40 REG_WIN1H = 0x42 REG_WIN0V = 0x44 REG_WIN1V = 0x46 REG_WININ = 0x48 REG_WINOUT = 0x4A REG_BLDMOD = 0x50 REG_BLDALPHA = 0x52 REG_BLDY = 0x54 REG_SG1CNT_L = 0x60 REG_SG1CNT_H = 0x62 REG_SG1CNT_X = 0x64 REG_SG2CNT_L = 0x68 REG_SG2CNT_H = 0x6C REG_SG3CNT_L = 0x70 REG_SG3CNT_H = 0x72 REG_SG3CNT_X = 0x74 REG_SG4CNT_L = 0x78 REG_SG4CNT_H = 0x7c REG_SGCNT_L = 0x80 REG_SGCNT_H = 0x82 REG_SGCNT_X = 0x84 REG_SGBIAS = 0x88 REG_SGWR0_L = 0x90 REG_FIFO_A_L = 0xA0 REG_FIFO_A_H = 0xA2 REG_FIFO_B_L = 0xA4 REG_FIFO_B_H = 0xA6 REG_DM0SAD = 0xB0 REG_DM0DAD = 0xB4 REG_DM0CNT_L = 0xB8 REG_DM0CNT_H = 0xBA REG_DM1SAD = 0xBC REG_DM1DAD = 0xC0 REG_DM1CNT_L = 0xC4 REG_DM1CNT_H = 0xC6 REG_DM2SAD = 0xC8 REG_DM2DAD = 0xCC REG_DM2CNT_L = 0xD0 REG_DM2CNT_H = 0xD2 REG_DM3SAD = 0xD4 REG_DM3DAD = 0xD8 REG_DM3CNT_L = 0xDC REG_DM3CNT_H = 0xDE REG_TM0D = 0x100 REG_TM0CNT = 0x102 REG_IE = 0x200 REG_IME = 0x208 REG_IF = 0x4000202 REG_P1 = 0x4000130 REG_P1CNT = 0x132 REG_WAITCNT = 0x4000204 REG_SIOMULTI0 = 0x20 @+100 REG_SIOMULTI1 = 0x22 @+100 REG_SIOMULTI2 = 0x24 @+100 REG_SIOMULTI3 = 0x26 @+100 REG_SIOCNT = 0x28 @+100 REG_SIOMLT_SEND = 0x2a @+100 REG_RCNT = 0x34 @+100 @r0,r1,r2=temp regs gb_flg .req r3 @bit 31=N, Z=1 if bits 0-7=0 gb_a .req r4 @bits 0-15=0 gb_bc .req r5 @bits 0-15=0 gb_de .req r6 @bits 0-15=0 gb_hl .req r7 @bits 0-15=0 cycles .req r8 gb_pc .req r9 globalptr .req r10 @=wram_globals* ptr gb_optbl .req r10 gb_sp .req r11 addy .req r12 @keep this at r12 (scratch for APCS) @r13=SP @r14=LR @r15=PC @---------------------------------------------------------------------------- @everything in wram_globals* areas: start_map -19*4,globalptr @gbz80.s _m_ speedhack_ram_address,4 _m_ quickhackused,1 _m_ quickhackcounter,1 _m_ joy_read_count,1 _m_ speedhack_mode,1 _m_ speedhack_pc,4 @readmem_tbl _m_ readmem_tbl_begin,0 _m_ readmem_tbl_end,16*4 _m_ ,-4 _m_ readmem_tbl_,0 _m_ ,4 _m_ opz,256*4 _m_ writemem_tbl,16*4 _m_ memmap_tbl,16*4 _m_ cpuregs,8*4 _m_ ,1 @gb_ime,1 @not used _m_ gb_ie,1 _m_ gb_if,1 _m_ ,1 @gb_interrupt_lines, not used _m_ rambank,1 _m_ gbcmode,1 _m_ sgbmode,1 _m_ ,1 _m_ dividereg,4 _m_ timercounter,4 _m_ timermodulo,1 _m_ timerctrl,1 _m_ stctrl,1 _m_ ,1 _m_ frame,4 _m_ nexttimeout,4 _m_ nexttimeout_alt,4 _m_ scanlinehook,4 _m_ lastbank,4 _m_ cyclesperscanline,4 _m_ timercyclesperscanline,4 _m_ scanline_oam_position,4 @ .if PROFILE @ _m_ profiler,4 @ .endif _m_ doubletimer_,1 _m_ gbamode,1 _m_ request_gb_type_,1 _m_ novblankwait_,1 .if RESIZABLE _m_ xgb_sram,4 _m_ xgb_sramsize,4 _m_ xgb_vram,4 _m_ xgb_vramsize,4 _m_ gbc_exram,4 _m_ gbc_exramsize,4 _m_ end_of_exram,4 _m_ xgb_vram_1800,4 _m_ xgb_vram_1C00,4 _m_ sgb_pals,4 _m_ sgb_atfs,4 _m_ sgb_packet,4 _m_ sgb_attributes,4 _m_ ,12 @padding .endif @#6 word (of 8) @lcd.s (wram_globals1) _m_ fpsvalue,4 _m_ AGBjoypad,4 _m_ XGBjoypad,4 _m_ lcdctrl,1 _m_ lcdstat_save,1 _m_ scrollX,1 _m_ scrollY,1 _m_ scanline,1 _m_ lcdyc,1 _m_ ,1 _m_ bgpalette,1 _m_ ob0palette,1 _m_ ob1palette,1 _m_ windowX,1 _m_ windowY,1 _m_ BCPS_index,1 _m_ doublespeed,1 _m_ OCPS_index,1 _m_ vrambank,1 _m_ dma_src,2 _m_ dma_dest,2 _m_ dirty_tile_bits,4 _m_ gb_oam_buffer_alt,4 @ _m_ dirty_tiles,4 @ _m_ dirty_rows,4 _m_ bigbuffer,4 _m_ bg01cnt,4 _m_ bg23cnt,4 _m_ xyscroll,4 _m_ xyscroll2,4 _m_ dispcntdata,4 _m_ windata,4 _m_ dispcntaddr,4 _m_ windowyscroll,4 _m_ buffer_lastscanline,4 _m_ lcdctrl0midframe,1 _m_ lcdctrl0frame,1 _m_ rendermode,1 _m_ _ui_border_visible,1 _m_ _sgb_palette_number,1 _m_ _gammavalue,1 _m_ _darkness,1 _m_ ,1 _m_ ui_border_cnt_bic,4 _m_ ui_border_cnt_orr,4 _m_ ui_border_scroll2,4 _m_ ui_border_scroll3,4 _m_ _ui_x,4 _m_ _ui_y,4 _m_ _ui_border_request,4 _m_ _ui_border_screen,4 _m_ _ui_border_buffer,4 _m_ dispcntbase,4 _m_ dispcntbase2,4 _m_ bigbufferbase,4 _m_ bigbufferbase2,4 _m_ gboamdirty,1 _m_ consume_dirty,1 _m_ consume_buffer,1 _m_ vblank_happened,1 _m_ gb_oam_buffer_screen,4 _m_ gb_oam_buffer_writing,4 _m_ _palettebank,4 @ _m_ bg_cache_cursor,4 @ _m_ bg_cache_base,4 @ _m_ bg_cache_limit,4 @ _m_ bg_cache_full,1 @ _m_ bg_cache_updateok,1 @ _m_ lcdhack,1 @ _m_ dmamode,1 _m_ sound_shadow,12 _m_ ,1 _m_ bg_cache_updateok,1 _m_ lcdhack,1 _m_ dmamode,1 @VRAM_name0_ptr # 4 @cart.s (wram_globals2) _m_ bank0,4 _m_ bank1,4 _m_ srambank,4 _m_ mapperdata,32 _m_ sramwptr,4 _m_ biosbase,4 _m_ rombase,4 _m_ romnumber,4 _m_ emuflags,4 @NOT ACTUALLY USED! _m_ rommask,4 _m_ rammask,4 _m_ cartflags,1 _m_ sramsize,1 _m_ ,2 @io.s (wram_globals3) _m_ joy0state,1 _m_ joy1state,1 _m_ joy2state,1 _m_ joy3state,1 _m_ joy0serial,1 _m_ ,1 _m_ ,2 @sgb.s (wram_globals4) _m_ packetcursor,4 _m_ packetbitcursor,4 _m_ packetstate,1 _m_ player_turn,1 _m_ player_mask,1 _m_ sgb_mask,1 _m_ update_border_palette,1 _m_ autoborder,1 _m_ autoborderstate,1 _m_ borderpartsadded,1 _m_ sgb_hack_frame,4 _m_ auto_border_reboot_frame,4 _m_ lineslow,1 _m_ ,1 _m_ ,1 _m_ ,1 @gbz80.s (wram_globals5) _m_ fiveminutes_,4 _m_ sleeptime_,4 _m_ dontstop_,1 _m_ hackflags,1 _m_ hackflags2,1 _m_ ,1 @lcd.s (wram_globals6) _m_ FF41_R_function,4 _m_ FF41_R_vblank_function,4 _m_ vram_packet_dest,4 _m_ vram_packet_source,4 _m_ FF41_PC,4 _m_ FF41_handler,4 _m_ FF41_PC_2,4 _m_ FF41_handler_2,4 _m_ FF41_PC_3,4 _m_ FF41_handler_3,4 _m_ FF41_PC_4,4 _m_ FF41_handler_4,4 _m_ FF44_PC,4 _m_ FF44_handler,4 _m_ FF44_PC_2,4 _m_ FF44_handler_2,4 @gbz80.s (wram_globals7) _m_ xgb_ram,0x2000 _m_ xgb_hram,0x80 @---------------------------------------------------------------------------- @IRQ_VECTOR EQU 0xfffe ; IRQ/BRK interrupt vector address @RES_VECTOR EQU 0xfffc ; RESET interrupt vector address @NMI_VECTOR EQU 0xfffa ; NMI interrupt vector address @-----------------------------------------------------------cartflags MBC_RAM = 0x01 @ram in cart MBC_SAV = 0x02 @battery in cart MBC_TIM = 0x04 @timer in cart MBC_RUM = 0x08 @rumble in cart MBC_TIL = 0x10 @tilt in cart @-----------------------------------------------------------hackflags USEPPUHACK = 1 @use $2002 hack CPUHACK = 2 @don't use JMP hack @? EQU 16 @FOLLOWMEM EQU 32 ;0=follow sprite, 1=follow mem @bits 8-5=scale type @bits 16-31=sprite follow val @---------------------------------------------------------------------------- CYC_SHIFT = 4 CYCLE = 1<<CYC_SHIFT @one cycle (455*CYCLE cycles per scanline) @cycle flags- (stored in cycles reg for speed) CYC_IE = 0x01 @interrupts are enabled CYC_LCD_ENABLED = 0x02 @LCD controller is enabled @ CYC_LYC = 0x04 @LY matches LYC @ BRANCH = 0x02 @branch instruction encountered @ EQU 0x04 @ EQU 0x08 CYC_MASK = CYCLE-1 @Mask SINGLE_SPEED = 456*CYCLE DOUBLE_SPEED = 912*CYCLE SINGLE_SPEED_SCANLINE_OAM_POSITION = 204*CYCLE @should be 204 DOUBLE_SPEED_SCANLINE_OAM_POSITION = 204*2*CYCLE @SINGLE_SPEED_HBLANK EQU 204*CYCLE ;should be 204 @DOUBLE_SPEED_HBLANK EQU 408*CYCLE WINDOW_TOP = 8 WINDOW_LEFT = 40 @---------------------------------------------------------------------------- @.end
potrepka/DSP
src/Nodes/Trigger/TriggerHold.h
#pragma once #include "../Core/Transformer.h" namespace dsp { class TriggerHold : public Transformer { public: TriggerHold(); std::shared_ptr<Input> getHoldTime() const; std::shared_ptr<Output> getCurrentTime() const; protected: void setNumOutputChannelsNoLock(size_t numChannels) override; void processNoLock() override; private: const std::shared_ptr<Input> holdTime; const std::shared_ptr<Output> currentTime; Array index; }; } // namespace dsp
yingzhuo/myscala
src/main/java/myscala/RichStringNullable.scala
<reponame>yingzhuo/myscala /* _ _ __ ___ _ _ ___ ___ __ _| | __ _ | '_ ` _ \| | | / __|/ __/ _` | |/ _` | | | | | | | |_| \__ \ (_| (_| | | (_| | |_| |_| |_|\__, |___/\___\__,_|_|\__,_| |___/ https://github.com/yingzhuo/myscala */ package myscala private[myscala] final class RichStringNullable(val s: String) { // empty / blank / null def isNullOrEmpty: Boolean = s == null || s.isEmpty def isNotNullOrEmpty: Boolean = !s.isNullOrEmpty def isNullOrBlank: Boolean = s == null || s.isBlank def isNotNullOrBlank: Boolean = !s.isNullOrBlank def isBlank: Boolean = s == null || s.forall(_.isWhitespace) def isNotBlank: Boolean = !s.isBlank }
wenweicui/react-native-knowme
app/project/assets/str.js
export const str = { APP_NAME: "Know Me", SPLASH_CON: "发现自我" }
neurorestore/neuraldynamicplatform
code/WebotsControl.py
import subprocess import socket from tools import structures_tools as tls class WebotsControl(): """ Run a webots simulation. Run the musculoskeletal model with defined muscle control values. """ def __init__(self,experiment): # Define experiment type (bed vs treadmill vs bodyweight) self._experiment = experiment self._init_muscle_controls() def _init_muscle_controls(self,activation=0): """ Initialize webots muscles names. """ self._nnData = "" self._nnData +=" ".join(["RIGHT_SOL",str(activation)]) + "\n" self._nnData +=" ".join(["RIGHT_TA",str(activation)]) + "\n" self._nnData +=" ".join(["RIGHT_VAS",str(activation)]) + "\n" self._nnData +=" ".join(["RIGHT_HAM",str(activation)]) + "\n" self._nnData +=" ".join(["RIGHT_GLU",str(activation)]) + "\n" self._nnData +=" ".join(["RIGHT_HF",str(activation)]) + "\n" self._nnData +=" ".join(["LEFT_SOL",str(activation)]) + "\n" self._nnData +=" ".join(["LEFT_TA",str(activation)]) + "\n" self._nnData +=" ".join(["LEFT_VAS",str(activation)]) + "\n" self._nnData +=" ".join(["LEFT_HAM",str(activation)]) + "\n" self._nnData +=" ".join(["LEFT_GLU",str(activation)]) + "\n" self._nnData +=" ".join(["LEFT_HF",str(activation)]) + "\n" def _run_webots(self): """ Run webots as a subprocess """ if self._experiment == "bed": program = ["webots","--stdout","../../sml/controller_current/webots/worlds/743_formento_bed.wbt"] elif self._experiment == "treadmill": program = ["webots","--stdout","../../sml/controller_current/webots/worlds/743_formento_tbws.wbt"] elif self._experiment == "bodyweight": program = ["webots","--stdout","../../sml/controller_current/webots/worlds/743_formento_bw.wbt"] elif self._experiment == "testMuscLength": program = ["webots","--stdout","../../sml/controller_current/webots/worlds/743_formento_testMuscRestingLength.wbt"] else: raise(Exception("Unknown experiment!")) self._webots = subprocess.Popen(program, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # Initialize TCP communication (server side) TCP_IP = '127.0.0.1' TCP_PORT = 5005 BUFFER_SIZE = 512 self._s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._s.bind((TCP_IP, TCP_PORT)) self._s.listen(1) self._conn, addr = self._s.accept() def run(self): """ Run the closed loop simualtion. """ self._run_webots() # We first wait for webots inputs webotsTurn = True neuralNetworkTurn = False while True: if webotsTurn: print "reading data from webots:" wbtData = self._wbt_read_data() webotsTurn = False neuralNetworkTurn = True elif neuralNetworkTurn: print "sending data to webots..." self._send_data_to_wbt(self._nnData) neuralNetworkTurn = False webotsTurn = True def _wbt_read_data(self): """ Read the data coming from the webots controller. """ reaData = True wbtIncomingData = False wbtData = "" while reaData: wbtIncomingMsg = self._webots.stdout.readline().rstrip("\n").split() if "COMM_OUT" in wbtIncomingMsg: wbtIncomingData = True elif "END" in wbtIncomingMsg: reaData = False elif wbtIncomingData: wbtData += " ".join(wbtIncomingMsg[1:])+"\n" print "\t\t\t\tWebots: :"+" ".join(wbtIncomingMsg[1:]) return wbtData def _send_data_to_wbt(self,nnData): """ Send the neural network's data to the webots controller. """ nnData += "END\n" self._conn.send(nnData)
ChillyWe/JavaOOP_AdvancedNov2017
src/interfaces_and_abstraction/Problem09/AddCollection.java
<reponame>ChillyWe/JavaOOP_AdvancedNov2017 package interfaces_and_abstraction.Problem09; /** * Created by Chilly on 19.11.2017 г.. */ public interface AddCollection<T> { int add(T element); }
svic/jenkins-configuration
e2e/pages/email_ext_subpage.py
from . import JENKINS_HOST from bok_choy.page_object import PageObject from configuration_page import ConfigurationSubPageMixIn class EmailExtConfigurationSubPage(ConfigurationSubPageMixIn, PageObject): def __init__(self, *args, **kwargs): super(EmailExtConfigurationSubPage, self).__init__(*args, **kwargs) self.name = "hudson-plugins-emailext-ExtendedEmailPublisher" def get_default_email_body(self): return self.value_of_first_element_named('ext_mailer_default_body') def get_advanced_email_properties(self): return self.value_of_first_element_named('ext_mailer_adv_properties')
frankgh/cassandra
test/unit/org/apache/cassandra/db/virtual/SSTableTasksTableTest.java
<filename>test/unit/org/apache/cassandra/db/virtual/SSTableTasksTableTest.java /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.cassandra.db.virtual; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.IntStream; import com.google.common.collect.ImmutableList; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.apache.cassandra.cql3.CQLTester; import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.compaction.CompactionInfo; import org.apache.cassandra.db.compaction.CompactionManager; import org.apache.cassandra.db.compaction.OperationType; import org.apache.cassandra.io.sstable.format.SSTableReader; import org.apache.cassandra.schema.MockSchema; import org.apache.cassandra.utils.TimeUUID; import static org.apache.cassandra.utils.TimeUUID.Generator.nextTimeUUID; public class SSTableTasksTableTest extends CQLTester { private static final String KS_NAME = "vts"; @SuppressWarnings("FieldCanBeLocal") private SSTableTasksTable table; @BeforeClass public static void setUpClass() { CQLTester.setUpClass(); CompactionManager.instance.disableAutoCompaction(); } @Before public void config() { table = new SSTableTasksTable(KS_NAME); VirtualKeyspaceRegistry.instance.register(new VirtualKeyspace(KS_NAME, ImmutableList.of(table))); disablePreparedReuseForTest(); } @Test public void testSelectAll() throws Throwable { createTable("CREATE TABLE %s (pk int, ck int, PRIMARY KEY (pk, ck))"); ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); long bytesCompacted = 123; long bytesTotal = 123456; TimeUUID compactionId = nextTimeUUID(); List<SSTableReader> sstables = IntStream.range(0, 10) .mapToObj(i -> MockSchema.sstable(i, i * 10L, i * 10L + 9, cfs)) .collect(Collectors.toList()); CompactionInfo.Holder compactionHolder = new CompactionInfo.Holder() { public CompactionInfo getCompactionInfo() { return new CompactionInfo(cfs.metadata(), OperationType.COMPACTION, bytesCompacted, bytesTotal, compactionId, sstables); } public boolean isGlobal() { return false; } }; CompactionManager.instance.active.beginCompaction(compactionHolder); UntypedResultSet result = execute("SELECT * FROM vts.sstable_tasks"); assertRows(result, row(CQLTester.KEYSPACE, currentTable(), compactionId, 1.0 * bytesCompacted / bytesTotal, OperationType.COMPACTION.toString().toLowerCase(), bytesCompacted, sstables.size(), bytesTotal, CompactionInfo.Unit.BYTES.toString())); CompactionManager.instance.active.finishCompaction(compactionHolder); result = execute("SELECT * FROM vts.sstable_tasks"); assertEmpty(result); } }
vidkidz/crossbridge
llvm-2.9/tools/clang/test/Sema/carbon.c
<filename>llvm-2.9/tools/clang/test/Sema/carbon.c // RUN: %clang_cc1 -target-cpu pentium4 %s -print-stats #ifdef __APPLE__ #include <Carbon/Carbon.h> #endif
6thquake/taro-material
packages/taro-material/src/TagBar/index.js
import Taro, { Component } from '@tarojs/taro'; import { View, ScrollView } from '@tarojs/components'; import PropTypes from 'prop-types'; import RMTag from '../Tag'; import RMTypography from '../Typography'; import theme from '../styles/theme'; import './index.scss'; class RMTagBar extends Component { state = { scrollTop: 0, scrollbar: { opacity: 1, visibility: 'visible', _height: 'auto' }, valueBar: { opacity: 0, visibility: 'hidden', _height: 'auto' }, }; scrollbarRef = node => (this.scrollbarRefEle = node); valueBarRef = node => (this.valueBarRefEle = node); componentDidMount() { const { onAddPageScroll } = this.props; if (onAddPageScroll) { onAddPageScroll(this.handlePageScroll.bind(this)); } // setTimeout(() => { this.scrollbarRefEle .boundingClientRect(rect => { if (!rect) return; this.setState({ top: rect.top, scrollbar: { ...rect, opacity: 1, visibility: 'visible', height: rect.height, _height: 'auto', }, }); }) .exec(); this.valueBarRefEle .boundingClientRect(rect => { if (!rect) return; this.setState({ valueBar: { ...rect, opacity: 0, visibility: 'hidden', height: rect.height, _height: 'auto', }, }); }) .exec(); // }, 1000); } componentWillUnmount() {} componentDidShow() {} componentDidHide() {} handlePageScroll(params) { const { scrollTop } = params; const { scrollbar, valueBar, top } = this.state; const { offsetTop } = this.props; let comps = {}; if (scrollTop - offsetTop < scrollbar.height - valueBar.height) { comps = { scrollbar: { ...scrollbar, opacity: 1, visibility: 'visible', _height: scrollbar.height, }, valueBar: { ...valueBar, opacity: 0, visibility: 'hidden', _height: 0, }, }; } else if (scrollTop - offsetTop < scrollbar.height) { const h = scrollTop - offsetTop - scrollbar.height + valueBar.height; const opacity = h / valueBar.height; comps = { scrollbar: { ...scrollbar, opacity: 1 - opacity, visibility: 'visible', _height: scrollbar.height - h, }, valueBar: { ...valueBar, opacity, visibility: 'visible', _height: h, }, }; } else if (scrollTop - offsetTop >= scrollbar.height) { comps = { scrollbar: { ...scrollbar, opacity: 0, visibility: 'hidden', _height: scrollbar.height - valueBar.height, }, valueBar: { ...valueBar, opacity: 1, visibility: 'visible', _height: valueBar.height, }, }; } let other = {}; if (scrollTop >= 0) { other = { scrollTop, }; } this.setState({ ...comps, ...other, }); } handleClick(name, option, e) { const { values, onChange } = this.props; const { value, disabled } = option; if (disabled) { return; } onChange && onChange( { ...values, [name]: value, }, e, ); } handleReset(name, e) { const { values, onChange } = this.props; const rs = { ...values, }; delete rs[name]; onChange && onChange(rs, e); } getValuesText() { const { values, data } = this.props; const text = []; Object.keys(values).forEach(key => { const d = data.find(item => item.name === key); if (d) { const op = d.options.find(option => option.value === values[key]); if (op) { text.push(op.label); } } }); return text.join(' · ') || '暂无过滤条件'; } render() { const { data, values, offsetTop, color, selectedColor, customStyle } = this.props; const { scrollbar, valueBar } = this.state; const valuesText = this.getValuesText(); let _color = theme.palette[selectedColor]; const valColor = _color ? _color.main : theme.palette.text.primary; _color = theme.palette[color]; const labelColor = _color ? _color.contrastText : color; return ( <View className="tagbar"> <View ref={this.scrollbarRef} style={{ ...customStyle, opacity: scrollbar.opacity, // height: `${scrollbar._height}px`, visibility: scrollbar.visibility, }} > {data.map((item, index) => ( <ScrollView key={index} scrollX scrollWithAnimation style={{ width: 'auto' }}> <View className="scrollbar"> <View onClick={this.handleReset.bind(this, item.name)} className="tag"> {!values[item.name] ? ( <RMTag circle color={selectedColor} size="small" active block> {item.label} </RMTag> ) : ( <RMTypography color={labelColor} className="body1" block> {item.label} </RMTypography> )} </View> {item.options.map((option, key) => { const active = !option.disabled && values[item.name] === option.value; return ( <View onClick={this.handleClick.bind(this, item.name, option)} className="tag" key={key} > {active ? ( <RMTag circle color={selectedColor} size="small" active block> {option.label} </RMTag> ) : ( <RMTypography color={labelColor} className="body1" block> {option.label} </RMTypography> )} </View> ); })} </View> </ScrollView> ))} </View> <View className="vals" ref={this.valueBarRef} style={{ ...customStyle, opacity: valueBar.opacity, height: `${valueBar._height}px`, visibility: valueBar.visibility, top: `${offsetTop}px`, }} > <RMTypography color={valColor} className="body2" block> {valuesText} </RMTypography> </View> </View> ); } } RMTagBar.propTypes = { onChange: PropTypes.func, onAddPageScroll: PropTypes.func, data: PropTypes.array, values: PropTypes.object, offsetTop: PropTypes.number, customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), selectedColor: PropTypes.oneOf([ 'default', 'primary', 'secondary', 'error', 'success', 'warning', 'progress', ]), color: PropTypes.oneOf([ 'default', 'inherit', 'primary', 'secondary', 'error', 'success', 'warning', 'progress', ]), }; RMTagBar.defaultProps = { onChange: () => {}, data: [], values: {}, onAddPageScroll: () => {}, offsetTop: 0, color: 'default', selectedColor: 'primary', customStyle: {}, }; export default RMTagBar;
build2-packaging/boost
libboost-bind/include/boost/mem_fn.hpp
#ifndef BOOST_MEM_FN_HPP_INCLUDED #define BOOST_MEM_FN_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // // mem_fn.hpp - a generalization of std::mem_fun[_ref] // // Copyright (c) 2009 <NAME> // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://www.boost.org/libs/bind/mem_fn.html for documentation. // #include <boost/bind/mem_fn.hpp> #endif // #ifndef BOOST_MEM_FN_HPP_INCLUDED
suxinde2009/XDUIKitFramwork
XDUIKitFramework/UIColor+XDCategory.h
<filename>XDUIKitFramework/UIColor+XDCategory.h // // UIColor+XDCategory.h // XDUIKitFramework // // Created by admin on 12-8-18. // Copyright (c) 2012年 __MyCompany__. All rights reserved. // #import <UIKit/UIKit.h> #define UIColorMakeRGBA(nRed, nGreen, nBlue, nAlpha) [UIColor colorWithRed:(nRed)/255.0f \ green:(nGreen)/255.0f \ blue:(nBlue)/255.0f \ alpha:nAlpha] #define UIColorMakeRGB(nRed, nGreen, nBlue) UIColorMakeRGBA(nRed, nGreen, nBlue, 1.0f) @interface UIColor (XDCategory) + (id)colorWithHex:(NSUInteger)hexValue; + (id)colorWithHex:(NSUInteger)hexValue alpha:(CGFloat)alpha; @end
Delphboy/Bug-Buster
src/BugBuster/Screens/MapSelectionScreen.java
<filename>src/BugBuster/Screens/MapSelectionScreen.java package BugBuster.Screens; import BugBuster.BugBuster; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.Button; import javafx.scene.image.Image; import javafx.scene.layout.Pane; import javafx.scene.text.Font; /** * A class to represent the MapSelectionScreen * This screen displays the three maps that the use can select. A game screen object is created * based off the user's seleciton of map. * @author <NAME> * @version 1.0.0 */ public class MapSelectionScreen extends Pane implements ScreenIF { Canvas canvas; GraphicsContext graphicsContext; /** * Create a new MapSelectionScreen */ public MapSelectionScreen() { canvas = new Canvas(BugBuster.STAGE_WIDTH, BugBuster.STAGE_HEIGHT); graphicsContext = canvas.getGraphicsContext2D(); Image backGroundImage = new Image("resources/map-selection-screen.png"); graphicsContext.drawImage(backGroundImage, 0, 0); // Create button to return to main menu Button buttonReturnToMenu = new Button("Return to Menu"); buttonReturnToMenu.setFont(new Font("Cooper Black", 16)); buttonReturnToMenu.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { BugBuster.updateScene(new MainMenuScreen()); } }); buttonReturnToMenu.setMinSize(160,40); buttonReturnToMenu.setMaxSize(160, 40); buttonReturnToMenu.setLayoutX(10); buttonReturnToMenu.setLayoutY(10); // Create a button to select the 1st map Button buttonLeftMap = new Button("Left Map"); buttonLeftMap.setFont(new Font("Cooper Black", 24)); buttonLeftMap.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Left Map Selected"); BugBuster.updateScene(new GameScreen(1)); } }); buttonLeftMap.setMinSize(200, 45); buttonLeftMap.setMaxSize(200, 45); buttonLeftMap.setLayoutX(115); buttonLeftMap.setLayoutY(420); // Create a button to select the 2nd map Button buttonMiddleMap = new Button("Middle Map"); buttonMiddleMap.setFont(new Font("Cooper Black", 24)); buttonMiddleMap.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Middle Map Selected"); BugBuster.updateScene(new GameScreen(2)); } }); buttonMiddleMap.setMinSize(200, 45); buttonMiddleMap.setMaxSize(200, 45); buttonMiddleMap.setLayoutX(424); buttonMiddleMap.setLayoutY(420); // Create a button to select the 3rd Map Button buttonRightMap = new Button("Right Map"); buttonRightMap.setFont(new Font("Cooper Black", 24)); buttonRightMap.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Right Map Selected"); BugBuster.updateScene(new GameScreen(3)); } }); buttonRightMap.setMinSize(200, 45); buttonRightMap.setMaxSize(200, 45); buttonRightMap.setLayoutX(733); buttonRightMap.setLayoutY(420); getChildren().addAll(canvas, buttonReturnToMenu, buttonLeftMap, buttonMiddleMap, buttonRightMap); } /** * Set the canvas and graphicsContext to null; */ @Override public void killScreen() { canvas = null; graphicsContext = null; } }
adamclerk/generator-yeogurt
app/templates/client/scripts/react/components/js/account/settings.js
'use strict'; var React = require('react'); var DefaultLayout = require('../layouts/default'); var userStore = require('../../stores/user'); var userActions = require('../../actions/user'); // Alias for making element creation less verbose var DOM = React.createElement; var getState = function() { return { user: userStore.get() }; }; var SettingsComponent = React.createClass({ mixins: [userStore.mixin], getInitialState: function() { return getState(); }, render: function() { var user = this.state.user; return ( DOM(DefaultLayout, null, DOM('h3', null, 'Profile Information'), DOM('form', { id: 'profile-form', action: '/user?_method=PUT', method: 'post', onSubmit: this.handleSettings }, DOM('p', null, DOM('label', { htmlFor: 'email' }, 'Email:'), DOM('input', { type: 'text', name: 'email', id: 'email', defaultValue: user.email }) ), DOM('p', null, DOM('label', { htmlFor: 'firstName' }, 'First Name:'), DOM('input', { type: 'text', name: 'firstName', id: 'firstName', defaultValue: user.firstName }) ), DOM('p', null, DOM('label', { htmlFor: 'lastName' }, 'Last Name:'), DOM('input', { type: 'text', name: 'lastName', id: 'lastName', defaultValue: user.lastName }) ), DOM('button', null, 'Update Profile') ), DOM('h3', null, 'Change Password'), DOM('form', { id: 'password-form', action: '/user/password?_method=PUT', method: 'post', onSubmit: this.handlePassword }, DOM('p', null, DOM('label', { htmlFor: 'password' }, 'New Password:'), DOM('input', { type: 'password', name: 'password', id: 'password', defaultValue: '' }) ), DOM('p', null, DOM('label', { htmlFor: 'confirmPassword' }, 'Confirm Password:'), DOM('input', { type: 'password', name: 'confirmPassword', id: 'confirmPassword', defaultValue: '' }) ), DOM('button', null, 'Change Password') ), DOM('h3', null, 'Delete Account'), DOM('p', null, 'You can delete your account, but keep in mind this action is irreversible.'), DOM('form', { id: 'delete-form', action: '/user?_method=DELETE', method: 'post', onSubmit: this.handleDestroy }, DOM('button', null, 'Delete my account') ) ) ); }, handleSettings: function(e) { e.preventDefault(); var form = e.currentTarget; userActions.updateSettings(form); }, handlePassword: function(e) { e.preventDefault(); var form = e.currentTarget; userActions.updatePassword(form); }, handleDestroy: function(e) { e.preventDefault(); var form = e.currentTarget; userActions.destroy(form); }, /** * Event handler for 'change' events coming from store mixins. */ _onChange: function() { this.setState(getState()); } }); module.exports = SettingsComponent;
titan-data/kubernetes-java-client
kubernetes/src/test/java/io/kubernetes/client/openapi/models/V1beta1APIServiceSpecTest.java
<filename>kubernetes/src/test/java/io/kubernetes/client/openapi/models/V1beta1APIServiceSpecTest.java /* * Kubernetes * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v1.15.6 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ package io.kubernetes.client.openapi.models; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import io.kubernetes.client.openapi.models.ApiregistrationV1beta1ServiceReference; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; /** * Model tests for V1beta1APIServiceSpec */ public class V1beta1APIServiceSpecTest { private final V1beta1APIServiceSpec model = new V1beta1APIServiceSpec(); /** * Model tests for V1beta1APIServiceSpec */ @Test public void testV1beta1APIServiceSpec() { // TODO: test V1beta1APIServiceSpec } /** * Test the property 'caBundle' */ @Test public void caBundleTest() { // TODO: test caBundle } /** * Test the property 'group' */ @Test public void groupTest() { // TODO: test group } /** * Test the property 'groupPriorityMinimum' */ @Test public void groupPriorityMinimumTest() { // TODO: test groupPriorityMinimum } /** * Test the property 'insecureSkipTLSVerify' */ @Test public void insecureSkipTLSVerifyTest() { // TODO: test insecureSkipTLSVerify } /** * Test the property 'service' */ @Test public void serviceTest() { // TODO: test service } /** * Test the property 'version' */ @Test public void versionTest() { // TODO: test version } /** * Test the property 'versionPriority' */ @Test public void versionPriorityTest() { // TODO: test versionPriority } }
guhilot/DashboardProject
custom-info-dash/src/components/Navbar.js
<filename>custom-info-dash/src/components/Navbar.js<gh_stars>0 /** * <NAME> */ import React from "react" import {Link} from "react-router-dom" function Navbar(){ return( <div className="flex-container"> <ul className="nav"> <Link to="/"><li><i className="fa fa-2x fa-home"></i></li></Link> <Link to="/currency"><li className="money"><h3><b>$</b></h3></li></Link> <Link to="/crypto"><li><i className="fa fa-2x fa-bitcoin"></i></li></Link> <Link to="/metal"><li><h3><b>GolDD</b></h3></li></Link> <Link to="/country"><li><i className="fa fa-2x fa-globe"></i></li></Link> </ul> </div> ) } export default Navbar
hroken/MNN
tools/quantization/quantizeWeight.hpp
<reponame>hroken/MNN // // quantizeWeight.hpp // MNN // // Created by MNN on 2019/04/21. // Copyright © 2018, Alibaba Group Holding Limited // #ifndef QUANTIZEWEIGHT_HPP #define QUANTIZEWEIGHT_HPP #include <stdint.h> #include <vector> #include <string> // default: quantize weight every channel int SymmetricQuantizeWeight(const float* weight, const int size, int8_t* quantizedWeight, float* scale, const int channels, float weightClampValue); // quantize convolution weight per channle // firstly, multiply float weight by input_scale, then quantize the result to get input_sacle*weight_scale // secondly, divide input_sacle*weight_scale by output_scale int QuantizeConvPerChannel(const float* weight, const int size, const float* bias, int8_t* quantizedWeight, int32_t* quantizedBias, float* scale, const std::vector<float>& inputScale, const std::vector<float>& outputScale, std::string method, float weightClampValue, bool mergeChannel = true); int QuantizeDepthwiseConv(const float* weight, const int size, const float* bias, int8_t* quantizedWeight, int32_t* quantizedBias, float* scale, const std::vector<float>& inputScale, const std::vector<float>& outputScale, std::string method, float weightClampValue); #endif // QUANTIZEWEIGHT_HPP
Lzw2016/clever-security
clever-security-server/src/main/java/org/clever/security/service/local/ServiceSysServiceProxy.java
package org.clever.security.service.local; import lombok.extern.slf4j.Slf4j; import org.clever.common.utils.mapper.BeanMapper; import org.clever.security.client.ServiceSysClient; import org.clever.security.dto.request.ServiceSysAddReq; import org.clever.security.entity.ServiceSys; import org.clever.security.service.ServiceSysService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; /** * 参考 ServiceSysController * <p> * 作者: lzw<br/> * 创建时间:2018-11-11 19:28 <br/> */ @Component @Slf4j public class ServiceSysServiceProxy implements ServiceSysClient { @Autowired private ServiceSysService serviceSysService; @Override public List<ServiceSys> allSysName() { return serviceSysService.selectAll(); } @Override public ServiceSys registerSys(ServiceSysAddReq serviceSysAddReq) { ServiceSys serviceSys = BeanMapper.mapper(serviceSysAddReq, ServiceSys.class); return serviceSysService.registerSys(serviceSys); } @Override public ServiceSys delServiceSys(String sysName) { return serviceSysService.delServiceSys(sysName); } }
duonglvtnaist/Multi-ROMix-Scrypt-Accelerator
Software/CPU/myscrypt/build/cmake-3.12.3/Tests/CSharpLinkToCxx/cpp_native.hpp
<filename>Software/CPU/myscrypt/build/cmake-3.12.3/Tests/CSharpLinkToCxx/cpp_native.hpp #pragma once namespace CppApp { class MyCpp { public: void testMyCpp(); }; }
Ckath/k88
mods/quotes/quotes.c
#include <stdlib.h> #include <string.h> #include <time.h> #include <stdio.h> #include <unistd.h> #include "../../utils/format.h" /* required */ #include "../modtape.h" #include "../../core/modules.h" #include "../../core/log.h" #include "../../core/irc.h" #include "../../utils/strutils.h" static void handle_cmdmsg(msg_info *mi, char *msg) { if (strstr(msg, ".") || strstr(msg, "/")) { return; /* no escaping */ } /* open file if its there */ char quote_path[BUFSIZE]; strcpy(quote_path, "mods/quotes/quotes/"); strcat(quote_path, msg); char *space = strchr(quote_path, ' '); if (space) { space[0] = '\0'; } if (access(quote_path, F_OK)) { return; /* no quote file found */ } if (quote_path[strlen(quote_path)-1] == '/') { return; /* empty or dir path */ } /* load in file */ FILE *f = fopen(quote_path, "r"); fseek(f, 0, SEEK_END); long size = ftell(f); fseek(f, 0, SEEK_SET); char data[size+1]; fread(data, 1, size, f); data[size] = '\0'; /* count lines */ char *r = data; char *line_end; long lines = 0; while ((line_end = strchr(r, '\n'))) { lines++; r = line_end+1; } /* pick random line and get it */ srand(time(NULL)); long pick = (rand()%lines)+1; r = data; lines = 0; fseek(f, 0, SEEK_SET); while ((line_end = strchr(r, '\n'))) { if (++lines == pick) { char quote[BUFSIZE]; strncpy(quote, r, BUFSIZE-1); strchr(quote, '\n')[0] = '\0'; char *arg = strchr(msg, ' '); mi_format(quote, mi, arg ? arg+1: arg); send_privmsg("%s", quote); fclose(f); return; } r = line_end+1; } } void quotes_init() { mods_new("quotes", true); mods_cmdmsg_handler(handle_cmdmsg); }
CreativePenguin/stuy-cs
ap-comp-sci2/src/main/java/hw/exam/VoterBallots.java
package hw.exam; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.HashSet; public class VoterBallots { private Map<String, Integer> voteCount; private int maxVotes; public VoterBallots(List<Set<String>> ballotList) { voteCount = new HashMap<>(); maxVotes = 0; for(Set<String> i : ballotList) { for(String j : i) { if(voteCount.get(j) == null) { voteCount.put(j, 1); if(maxVotes == 0) maxVotes = 1; } voteCount.put(j, voteCount.get(j) + 1); if(voteCount.get(j) > maxVotes) maxVotes = voteCount.get(j); } } } private Integer maxVotes() { return maxVotes; } public Set<String> candidatesWithMost() { Set<String> ans = new HashSet<>(); for(String i : voteCount.keySet()) { if(voteCount.get(i) == maxVotes()) ans.add(i); } return ans; } }
luciensn/Noteberry-Pi-App
Notes/Notes/_NSManagedObjects/Note.h
<reponame>luciensn/Noteberry-Pi-App // // Note.h // // Created by <NAME> on 2/15/14. // Copyright (c) 2014 <NAME>. All rights reserved. // @import Foundation; @import CoreData; @class Group, Photo; @interface Note : NSManagedObject @property (nonatomic, retain) NSDate * date; @property (nonatomic, retain) NSString * text; @property (nonatomic, retain) NSNumber * row; @property (nonatomic, retain) NSString * tags; @property (nonatomic, retain) NSString * displayName; @property (nonatomic, retain) Group *group; @property (nonatomic, retain) NSSet *photos; @end @interface Note (CoreDataGeneratedAccessors) - (void)addPhotosObject:(Photo *)value; - (void)removePhotosObject:(Photo *)value; - (void)addPhotos:(NSSet *)values; - (void)removePhotos:(NSSet *)values; @end
larkov/MailTrackerBlocker
MailHeaders/Catalina/MailCore/MCURLMatch.h
// // Generated by class-dump 3.5b1 (64 bit) (Debug version compiled Dec 3 2019 19:59:57). // // Copyright (C) 1997-2019 <NAME>. // #import <objc/NSObject.h> @class NSString; @interface MCURLMatch : NSObject { NSString *_urlString; // 8 = 0x8 struct _NSRange _range; // 16 = 0x10 } @property(readonly, nonatomic) struct _NSRange range; // @synthesize range=_range; @property(readonly, copy, nonatomic) NSString *urlString; // @synthesize urlString=_urlString; // - (void).cxx_destruct; // IMP=0x000000000009e0cb - (id)description; // IMP=0x000000000009dff2 - (id)debugDescription; // IMP=0x000000000009df13 - (id)init; // IMP=0x000000000009de44 - (id)initWithRange:(struct _NSRange)arg1 urlString:(id)arg2; // IMP=0x000000000009ddbb @end
ljdawn/asa_code
override_code.py
<gh_stars>1-10 registry = {} class MultiMethod(object): def __init__(self, name): self.name = name self.typemap = {} def __call__(self, *args): types = tuple(arg.__class__ for arg in args) # a generator expression! function = self.typemap.get(types) if function is None: raise TypeError("no match") return function(*args) def register(self, types, function): if types in self.typemap: raise TypeError("duplicate registration") self.typemap[types] = function def multimethod(*types): def register(function): name = function.__name__ mm = registry.get(name) if mm is None: mm = registry[name] = MultiMethod(name) mm.register(types, function) return mm return register # 'overload' makes more sense in this case overload = multimethod class Sprite(object): pass class Point(object): pass class Curve(object): pass @overload(Sprite, Point, Direction, int) def add_bullet(sprite, start, direction, speed): # ... @overload(Sprite, Point, Point, int, int) def add_bullet(sprite, start, headto, speed, acceleration): # ... @overload(Sprite, str) def add_bullet(sprite, script): # ... @overload(Sprite, Curve, speed) def add_bullet(sprite, curve, speed): # ...
waynelewis/pmac
pmacApp/pmacAsynVMEPortSrc/pmacError.h
/* * Implementation of the pmacError call * * Author: <NAME> * Date: 2 August 2006 * */ #ifndef __INCpmacErrorH #define __INCpmacErrorH const char * pmacError( const char * errStr ); #endif
kimjand/cxf
services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsNotificationBroker.java
<filename>services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsNotificationBroker.java /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.wsn.jms; import java.net.URI; import java.net.URISyntaxException; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import org.apache.cxf.wsn.AbstractNotificationBroker; import org.apache.cxf.wsn.AbstractPublisher; import org.apache.cxf.wsn.AbstractSubscription; import org.oasis_open.docs.wsrf.rp_2.GetResourcePropertyResponse; import org.oasis_open.docs.wsrf.rpw_2.InvalidResourcePropertyQNameFault; import org.oasis_open.docs.wsrf.rw_2.ResourceUnavailableFault; import org.oasis_open.docs.wsrf.rw_2.ResourceUnknownFault; public abstract class JmsNotificationBroker extends AbstractNotificationBroker { private ConnectionFactory connectionFactory; private Connection connection; public JmsNotificationBroker(String name) { super(name); } public JmsNotificationBroker(String name, ConnectionFactory connectionFactory) { super(name); this.connectionFactory = connectionFactory; } public void init() throws Exception { if (connection == null) { connection = connectionFactory.createConnection(); connection.start(); } super.init(); } public void destroy() throws Exception { if (connection != null) { connection.close(); } super.destroy(); } @Override protected AbstractPublisher createPublisher(String name) { JmsPublisher publisher = createJmsPublisher(name); publisher.setAddress(URI.create(getAddress()).resolve("registrations/" + name).toString()); publisher.setManager(getManager()); publisher.setConnection(connection); return publisher; } @Override protected AbstractSubscription createSubscription(String name) { JmsSubscription subscription = createJmsSubscription(name); subscription.setAddress(URI.create(getAddress()).resolve("subscriptions/" + name).toString()); subscription.setManager(getManager()); subscription.setConnection(connection); return subscription; } protected abstract JmsSubscription createJmsSubscription(String name); protected abstract JmsPublisher createJmsPublisher(String name); public ConnectionFactory getConnectionFactory() { return connectionFactory; } public void setConnectionFactory(ConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; } protected GetResourcePropertyResponse handleGetResourceProperty(QName property) throws ResourceUnavailableFault, ResourceUnknownFault, InvalidResourcePropertyQNameFault { if (TOPIC_EXPRESSION_QNAME.equals(property)) { // TODO } else if (FIXED_TOPIC_SET_QNAME.equals(property)) { // TODO } else if (TOPIC_EXPRESSION_DIALECT_QNAME.equals(property)) { GetResourcePropertyResponse r = new GetResourcePropertyResponse(); try { r.getAny().add(new JAXBElement<URI>(TOPIC_EXPRESSION_DIALECT_QNAME, URI.class, new URI(JmsTopicExpressionConverter.SIMPLE_DIALECT))); } catch (URISyntaxException e) { r.getAny().add(new JAXBElement<String>(TOPIC_EXPRESSION_DIALECT_QNAME, String.class, JmsTopicExpressionConverter.SIMPLE_DIALECT)); } return r; } else if (TOPIC_SET_QNAME.equals(property)) { // TODO } return super.handleGetResourceProperty(property); } }
ghsecuritylab/tomato_egg
release/src-rt/linux/linux-2.6/include/asm-v850/ma1.h
/* * include/asm-v850/ma1.h -- V850E/MA1 cpu chip * * Copyright (C) 2001,02,03 NEC Electronics Corporation * Copyright (C) 2001,02,03 <NAME> <<EMAIL>> * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this * archive for more details. * * Written by <NAME> <<EMAIL>> */ #ifndef __V850_MA1_H__ #define __V850_MA1_H__ /* Inherit more generic details from MA series. */ #include <asm/ma.h> #define CPU_MODEL "v850e/ma1" #define CPU_MODEL_LONG "NEC V850E/MA1" /* Hardware-specific interrupt numbers (in the kernel IRQ namespace). */ #define IRQ_INTOV(n) (n) /* 0-3 */ #define IRQ_INTOV_NUM 4 #define IRQ_INTP(n) (0x4 + (n)) /* Pnnn (pin) interrupts */ #define IRQ_INTP_NUM 24 #define IRQ_INTCMD(n) (0x1c + (n)) /* interval timer interrupts 0-3 */ #define IRQ_INTCMD_NUM 4 #define IRQ_INTDMA(n) (0x20 + (n)) /* DMA interrupts 0-3 */ #define IRQ_INTDMA_NUM 4 #define IRQ_INTCSI(n) (0x24 + (n)*4)/* CSI 0-2 transmit/receive completion */ #define IRQ_INTCSI_NUM 3 #define IRQ_INTSER(n) (0x25 + (n)*4) /* UART 0-2 reception error */ #define IRQ_INTSER_NUM 3 #define IRQ_INTSR(n) (0x26 + (n)*4) /* UART 0-2 reception completion */ #define IRQ_INTSR_NUM 3 #define IRQ_INTST(n) (0x27 + (n)*4) /* UART 0-2 transmission completion */ #define IRQ_INTST_NUM 3 #define NUM_CPU_IRQS 0x30 /* The MA1 has a UART with 3 channels. */ #define V850E_UART_NUM_CHANNELS 3 #endif /* __V850_MA1_H__ */
blAs1N/C-programming
SDL/Game1/Ball.cpp
#include "Ball.h" #include "Constant.h" #include <cmath> #include <random> Ball::Ball() : pos({ SCREEN_W * 0.5f, SCREEN_H * 0.5f }), vel({ 0.0f, 0.0f }) { std::random_device rd; std::mt19937_64 rnd(rd()); std::uniform_real_distribution<float> range(180, 230); std::uniform_int_distribution<int> signRange(0, 1); vel.x = range(rnd) * (signRange(rnd) * 2 - 1); vel.y = range(rnd) * (signRange(rnd) * 2 - 1); } void Ball::Update(float deltaTime, Vector2 p1Pos, Vector2 p2Pos) { pos.x += vel.x * deltaTime; pos.y += vel.y * deltaTime; const auto isNearP1X = pos.x <= p1Pos.x && pos.x >= p1Pos.x - 5.0f; const auto isNearP2X = pos.x >= p2Pos.x && pos.x <= p2Pos.x + 5.0f; const auto isNearP1Y = fabsf(p1Pos.y - pos.y) <= PADDLE_H * 0.5f; const auto isNearP2Y = fabsf(p2Pos.y - pos.y) <= PADDLE_H * 0.5f; if ((isNearP1X && vel.x < 0.0f && isNearP1Y) || (isNearP2X && vel.x > 0.0f && isNearP2Y)) vel.x *= -1; if ((pos.y <= THICKNESS && vel.y < 0.0f) || (pos.y >= (SCREEN_H - THICKNESS) && vel.y > 0.0f)) vel.y *= -1; } Vector2 Ball::GetPos() const { return pos; }
gradleupdate/coderadar
coderadar-server/coderadar-core/src/test/java/org/wickedsource/coderadar/factories/resources/FilePatternResourceFactory.java
package org.wickedsource.coderadar.factories.resources; import java.util.ArrayList; import java.util.List; import org.wickedsource.coderadar.filepattern.domain.FileSetType; import org.wickedsource.coderadar.filepattern.rest.FilePatternDTO; import org.wickedsource.coderadar.filepattern.rest.FilePatternResource; import org.wickedsource.coderadar.project.domain.InclusionType; public class FilePatternResourceFactory { public FilePatternResource filePatterns() { FilePatternResource filePatterns = new FilePatternResource(); List<FilePatternDTO> patterns = new ArrayList<>(); FilePatternDTO pattern = new FilePatternDTO(); pattern.setFileSetType(FileSetType.SOURCE); pattern.setInclusionType(InclusionType.INCLUDE); pattern.setPattern("src/main/java/**/*.java"); patterns.add(pattern); FilePatternDTO pattern2 = new FilePatternDTO(); pattern2.setFileSetType(FileSetType.SOURCE); pattern2.setInclusionType(InclusionType.EXCLUDE); pattern2.setPattern("src/main/java/**/generated/**/*.java"); patterns.add(pattern2); filePatterns.setFilePatterns(patterns); return filePatterns; } }
zhengxiaobin/shifu
src/main/java/ml/shifu/shifu/core/Scorer.java
<reponame>zhengxiaobin/shifu<filename>src/main/java/ml/shifu/shifu/core/Scorer.java /** * Copyright [2012-2014] eBay Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ml.shifu.shifu.core; import ml.shifu.shifu.container.ScoreObject; import ml.shifu.shifu.container.obj.ColumnConfig; import ml.shifu.shifu.util.CommonUtils; import org.encog.ml.BasicML; import org.encog.ml.data.MLData; import org.encog.ml.data.MLDataPair; import org.encog.ml.svm.SVM; import org.encog.neural.networks.BasicNetwork; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Scorer, calculate the score for a specify input */ public class Scorer { private static Logger log = LoggerFactory.getLogger(Scorer.class); @SuppressWarnings("unused") private String alg; private List<BasicML> models; private List<ColumnConfig> columnConfigList; private double cutoff = 4.0d; // private boolean verbose = false; public Scorer(List<BasicML> models, List<ColumnConfig> columnConfigList, String algorithm) { this(models, columnConfigList, algorithm, 4.0d); } public Scorer(List<BasicML> models, List<ColumnConfig> columnConfigList, String algorithm, Double cutoff) { this.models = models; this.columnConfigList = columnConfigList; this.cutoff = cutoff; this.alg = algorithm; } public ScoreObject score(Map<String, String> rawDataMap) { MLDataPair pair = CommonUtils.assembleDataPair(columnConfigList, rawDataMap, cutoff); return score(pair, rawDataMap); } public ScoreObject score(MLDataPair pair, Map<String, String> rawDataMap) { if (pair == null) { return null; } List<Integer> scores = new ArrayList<Integer>(); for (BasicML model : models) { if (model instanceof BasicNetwork) { BasicNetwork network = (BasicNetwork) model; if (network.getInputCount() != pair.getInput().size()) { log.error("Network and input size mismatch: Network Size = " + network.getInputCount() + "; Input Size = " + pair.getInput().size()); continue; } MLData score = network.compute(pair.getInput()); scores.add(toScore(score.getData(0))); } else if (model instanceof SVM) { SVM svm = (SVM) model; if (svm.getInputCount() != pair.getInput().size()) { log.error("SVM and input size mismatch: SVM Size = " + svm.getInputCount() + "; Input Size = " + pair.getInput().size()); continue; } MLData score = svm.compute(pair.getInput()); scores.add(toScore(score.getData(0))); } else { throw new RuntimeException("unspport models"); } } Integer tag = (int) pair.getIdeal().getData(0); if (scores.size() == 0) { log.error("No Scores Calculated..."); return null; } return new ScoreObject(scores, tag); } private Integer toScore(Double d) { return (int) Math.round(d * 1000); } }
cmbrandt/nola-simd
examples/stat-simd-impl/stat_impl_serial.hxx
// Copyright (c) 2020-2021 <NAME> // All rights reserved #ifndef NOLA_STAT_IMPL_SERIAL_HXX #define NOLA_STAT_IMPL_SERIAL_HXX #include <cmath> #include <nola/internal/concepts.hxx> namespace nola { //----------------------------------------------------------------------------// // Declarations template <Integer I, Real R> inline R arithmetic_mean_serial(I n, R const x[]); template <Integer I, Real R> inline R variance_serial(I n, R const x[]); template <Integer I, Real R> inline R standard_deviation_serial(I n, R const x[]); template <Integer I, Real R> inline R covariance_serial(I n, R const x[], R const y[]); template <Integer I, Real R> inline R correlation_serial(I n, R const x[], R const y[]); //----------------------------------------------------------------------------// // Definitions // Arithmetic Mean template <Integer I, Real R> inline R arithmetic_mean_serial(I n, R const x[]) { R sum{0.0}; for (I i{0}; i < n; ++i) sum += x[i]; return sum / n; } // Variance template <Integer I, Real R> inline R variance_serial(I n, R const x[]) { // Compute the mean of the sequence R sum{0.0}; for (I i{0}; i < n; ++i) sum += x[i]; R mean = sum / n; // Compute and return the variance of the sequence sum = 0.0; for (I i{0}; i < n; ++i) { R center = x[i] - mean; sum += center * center; } return sum / (n - 1); } // Standard Deviation template <Integer I, Real R> inline R standard_deviation_serial(I n, R const x[]) { // Compute the mean of the sequence R sum{0.0}; for (I i{0}; i < n; ++i) sum += x[i]; R mean = sum / n; // Compute the variance of the sequence sum = 0.0; for (I i{0}; i < n; ++i) { R center = x[i] - mean; sum += center * center; } R var = sum / (n - 1); // Compute and return the standard deviation of the sequence return std::sqrt(var); } // Covariance template <Integer I, Real R> inline R covariance_serial(I n, R const x[], R const y[]) { // Compute the mean of the first sequence R sum{0.0}; for (I i{0}; i < n; ++i) sum += x[i]; R x_mean = sum / n; // Compute the mean of the second sequence sum = 0.0; for (I i{0}; i < n; ++i) sum += y[i]; R y_mean = sum / n; // Compute and return the covariance of the two sequences sum = 0.0; for (I i{0}; i < n; ++i) { R x_center = x[i] - x_mean; R y_center = y[i] - y_mean; sum += x_center * y_center; } return sum / (n - 1); } // Correlation template <Integer I, Real R> inline R correlation_serial(I n, R const x[], R const y[]) { // Compute the mean of the first sequence R sum{0.0}; for (I i{0}; i < n; ++i) sum += x[i]; R x_mean = sum / n; // Compute the variance of the first sequence sum = 0.0; for (I i{0}; i < n; ++i) { R x_center = x[i] - x_mean; sum += x_center * x_center; } R x_var = sum / (n - 1); // Compute the mean of the second sequence sum = 0.0; for (I i{0}; i < n; ++i) sum += y[i]; R y_mean = sum / n; // Compute the variance of the second sequence sum = 0.0; for (I i{0}; i < n; ++i) { R y_center = y[i] - y_mean; sum += y_center * y_center; } R y_var = sum / (n - 1); // Compute the standard deviation of the two sequences R x_std = std::sqrt(x_var); R y_std = std::sqrt(y_var); // Compute and return the correlation of the two sequences sum = 0.0; for (I i{0}; i < n; ++i) { R x_center = x[i] - x_mean; R y_center = y[i] - y_mean; sum += x_center * y_center; } R cov = sum / (n - 1); return cov / (x_std * y_std); } } // namespace nola #endif
CarlAmbroselli/barcelona
Frameworks/MediaPlayer.framework/Headers/MPAVRouteConnection.h
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by <NAME>. // #import <objc/NSObject.h> @class NSMutableArray; @protocol OS_dispatch_queue; @interface MPAVRouteConnection : NSObject { NSObject *_accessQueue; NSObject *_calloutQueue; _Bool _invalidated; NSMutableArray *_pendingConnectionHandlers; id _receivedCustomDataHandler; id _invalidationHandler; void *_externalDevice; } @property(readonly, nonatomic) void *externalDevice; // @synthesize externalDevice=_externalDevice; @property(copy, nonatomic) id invalidationHandler; // @synthesize invalidationHandler=_invalidationHandler; @property(copy, nonatomic) id receivedCustomDataHandler; // @synthesize receivedCustomDataHandler=_receivedCustomDataHandler; - (void)_connectionStateDidChange:(unsigned int)arg1 error:(id)arg2; - (void)_connectionDidReceiveCustomData:(id)arg1; - (void)resignActiveOriginWithCompletionHandler:(id)arg1; - (void)becomeActiveOriginWithCompletionHandler:(id)arg1; - (void)sendMediaRemoteCommand:(unsigned int)arg1 withOptions:(id)arg2 completionHandler:(id)arg3; - (void)sendCustomData:(id)arg1; - (void)reset; @property(readonly, nonatomic, getter=isInvalidated) _Bool invalidated; - (void)connectWithOptions:(unsigned long long)arg1 completion:(id)arg2; - (void)connectWithCompletion:(id)arg1; @property(readonly, nonatomic, getter=isConnected) _Bool connected; - (void)dealloc; - (id)initWithExternalDevice:(void *)arg1; @end
scalavision/bash4s
workflow/src/workflow/terminal/package.scala
package workflow import zio._ package object terminal { type Terminal = Has[Terminal.Service] object Terminal { trait Service { val getUserInput: UIO[String] def display(frame: String): UIO[Unit] } val ansiClearScreen: String = "\u001b[H\u001b[2J" val live: URLayer[console.Console, Terminal] = ZLayer.fromManaged { ZIO.environment[console.Console].map { console => new Service { override val getUserInput: zio.UIO[String] = console.get.getStrLn.orDie override def display(frame: String): zio.UIO[Unit] = for { _ <- console.get.putStr(ansiClearScreen) _ <- console.get.putStr(frame) } yield () } }.toManaged(_ => console.putStrLn("Exiting, Goodbye .. !")) } /* Could also use fromEffect val live: URLayer[console.Console, Terminal] = ZLayer.fromEffect { ZIO.environment[console.Console].map { console => new Service { override val getUserInput: zio.UIO[String] = console.get.getStrLn.orDie override def display(frame: String): zio.UIO[Unit] = for { _ <- console.get.putStr(ansiClearScreen) _ <- console.get.putStr(frame) } yield () } } } */ } val getUserInput: URIO[Terminal, String] = ZIO.accessM(_.get.getUserInput) def display(frame: String): URIO[Terminal, Unit] = ZIO.accessM(_.get.display(frame)) }
cwiki-us/Java-Tutorial
parent-java/java-numbers/src/test/java/com/ossez/maths/BigDecimalDemoUnitTest.java
<filename>parent-java/java-numbers/src/test/java/com/ossez/maths/BigDecimalDemoUnitTest.java package com.ossez.maths; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import java.math.RoundingMode; import java.util.Random; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * */ public class BigDecimalDemoUnitTest { private static final Logger logger = LoggerFactory.getLogger(BigDecimalDemoUnitTest.class); @Test public void whenBigDecimalCreated_thenValueMatches() { BigDecimal bdFromString = new BigDecimal("0.1"); BigDecimal bdFromCharArray = new BigDecimal( new char[]{'3', '.', '1', '6', '1', '5'}); BigDecimal bdlFromInt = new BigDecimal(42); BigDecimal bdFromLong = new BigDecimal(123412345678901L); BigInteger bigInteger = BigInteger.probablePrime(100, new Random()); BigDecimal bdFromBigInteger = new BigDecimal(bigInteger); assertEquals("0.1", bdFromString.toString()); assertEquals("3.1615", bdFromCharArray.toString()); assertEquals("42", bdlFromInt.toString()); assertEquals("123412345678901", bdFromLong.toString()); assertEquals(bigInteger.toString(), bdFromBigInteger.toString()); } @Test public void whenBigDecimalCreatedFromDouble_thenValueMayNotMatch() { BigDecimal bdFromDouble = new BigDecimal(0.1d); assertNotEquals("0.1", bdFromDouble.toString()); } @Test public void whenBigDecimalCreatedUsingValueOf_thenValueMatches() { BigDecimal bdFromLong1 = BigDecimal.valueOf(123412345678901L); BigDecimal bdFromLong2 = BigDecimal.valueOf(123412345678901L, 2); BigDecimal bdFromDouble = BigDecimal.valueOf(0.1d); assertEquals("123412345678901", bdFromLong1.toString()); assertEquals("1234123456789.01", bdFromLong2.toString()); assertEquals("0.1", bdFromDouble.toString()); } @Test public void whenEqualsCalled_thenSizeAndScaleMatched() { BigDecimal bd1 = new BigDecimal("1.0"); BigDecimal bd2 = new BigDecimal("1.00"); assertFalse(bd1.equals(bd2)); } @Test public void whenComparingBigDecimals_thenExpectedResult() { BigDecimal bd1 = new BigDecimal("1.0"); BigDecimal bd2 = new BigDecimal("1.00"); BigDecimal bd3 = new BigDecimal("2.0"); assertTrue(bd1.compareTo(bd3) < 0); assertTrue(bd3.compareTo(bd1) > 0); assertTrue(bd1.compareTo(bd2) == 0); assertTrue(bd1.compareTo(bd3) <= 0); assertTrue(bd1.compareTo(bd2) >= 0); assertTrue(bd1.compareTo(bd3) != 0); } @Test public void whenPerformingArithmetic_thenExpectedResult() { BigDecimal bd1 = new BigDecimal("4.0"); BigDecimal bd2 = new BigDecimal("2.0"); BigDecimal sum = bd1.add(bd2); BigDecimal difference = bd1.subtract(bd2); BigDecimal quotient = bd1.divide(bd2); BigDecimal product = bd1.multiply(bd2); assertTrue(sum.compareTo(new BigDecimal("6.0")) == 0); assertTrue(difference.compareTo(new BigDecimal("2.0")) == 0); assertTrue(quotient.compareTo(new BigDecimal("2.0")) == 0); assertTrue(product.compareTo(new BigDecimal("8.0")) == 0); } @Test public void whenGettingAttributes_thenExpectedResult() { BigDecimal bd = new BigDecimal("-12345.6789"); assertEquals(9, bd.precision()); assertEquals(4, bd.scale()); assertEquals(-1, bd.signum()); } @Test public void whenRoundingDecimal_thenExpectedResult() { BigDecimal bd = new BigDecimal("2.5"); // Round to 1 digit using HALF_EVEN BigDecimal rounded = bd .round(new MathContext(1, RoundingMode.HALF_EVEN)); assertEquals("2", rounded.toString()); } @Test public void givenPurchaseTxn_whenCalculatingTotalAmount_thenExpectedResult() { BigDecimal quantity = new BigDecimal("4.5"); BigDecimal unitPrice = new BigDecimal("2.69"); BigDecimal discountRate = new BigDecimal("0.10"); BigDecimal taxRate = new BigDecimal("0.0725"); BigDecimal amountToBePaid = BigDecimalDemo .calculateTotalAmount(quantity, unitPrice, discountRate, taxRate); assertEquals("11.68", amountToBePaid.toString()); } /** * To String without ScientificNotation */ @Test public void bigDecimalWithoutScientificNotationTest() { String input = RandomStringUtils.randomNumeric(12) + "12345678901234567" + "8901234567890123" + "4567890123456789" + "0123456789012345" + "6789012345678901" + "2345678901234567" + "8901234567890123" + "4567890123456789" + "0123456789012345" + "6789012345678901" + "2345678901234567" + "8901234567890123" + "4567890123456789" + "0123456789012345" + "6789012345678901" + "2345678901234567" + "8901234567890123" + "4554324324362432" + "7674637264783264" + "7832678463726478" + "3264736274673864" + "7364732463546354" + "6354632564532645" + "6325463546536453" + "6546325463546534" + "6325465345326456" + "4635463263453264"; // Converting to BigDecimal BigDecimal bigNumber = new BigDecimal(input); // Apply toString() method String numberStr = bigNumber.toString(); // Print the result logger.info("{}", numberStr); } /** * To String with ScientificNotation */ @Test public void bigDecimalScientificNotation() { // Create a BigDecimal object BigDecimal bigNumber; // Create a String object String numberStr; // Set precision to 5 MathContext mc = new MathContext(6); bigNumber = new BigDecimal(RandomStringUtils.randomNumeric(10) + "E5", mc); // apply toString() method logger.info("{}", bigNumber.toString()); logger.info("{}", bigNumber.toEngineeringString()); logger.info("{}", bigNumber.toPlainString()); } /** * To StripTrailingZeros */ @Test public void bigDecimalStripTrailingZerosTest() { BigDecimal bigNumber = new BigDecimal("2707000000000"); // apply StripTrailingZeros function logger.info("{}", bigNumber.toString()); logger.info("{}", bigNumber.stripTrailingZeros().toString()); logger.info("{}", bigNumber.stripTrailingZeros().toPlainString()); } }
6486449j/Blocks
game/item/LockedItem.java
<filename>game/item/LockedItem.java<gh_stars>0 package game.item; import util.BmpRes; public class LockedItem extends SingleItem{ SingleItem w; LockedItem(SingleItem w){super();this.w=w;} BmpRes getTipBmp(){ return Disabled.bmp; } SingleItem unlock(){return w;} public int maxAmount(){return 0;} public void insert(SingleItem si){} }
RichardRanft/Torque6
src/math/mathIO.h
//----------------------------------------------------------------------------- // Copyright (c) 2013 GarageGames, LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- #ifndef _MATHIO_H_ #define _MATHIO_H_ //Includes #ifndef _PLATFORM_H_ #include "platform/platform.h" #endif #ifndef _STREAM_H_ #include "io/stream.h" #endif #ifndef _MMATH_H_ #include "math/mMath.h" #endif //------------------------------------------------------------------------------ //-------------------------------------- READING // inline bool mathRead(Stream& stream, Point2I* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); return success; } inline bool mathRead(Stream& stream, Point3I* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); success &= stream.read(&p->z); return success; } inline bool mathRead(Stream& stream, Point2F* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); return success; } inline bool mathRead(Stream& stream, Point3F* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); success &= stream.read(&p->z); return success; } inline bool mathRead(Stream& stream, Point4F* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); success &= stream.read(&p->z); success &= stream.read(&p->w); return success; } inline bool mathRead(Stream& stream, Point3D* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); success &= stream.read(&p->z); return success; } inline bool mathRead(Stream& stream, PlaneF* p) { bool success = stream.read(&p->x); success &= stream.read(&p->y); success &= stream.read(&p->z); success &= stream.read(&p->d); return success; } inline bool mathRead(Stream& stream, Box3F* b) { bool success = mathRead(stream, &b->minExtents); success &= mathRead(stream, &b->maxExtents); return success; } inline bool mathRead(Stream& stream, SphereF* s) { bool success = mathRead(stream, &s->center); success &= stream.read(&s->radius); return success; } inline bool mathRead(Stream& stream, RectI* r) { bool success = mathRead(stream, &r->point); success &= mathRead(stream, &r->extent); return success; } inline bool mathRead(Stream& stream, RectF* r) { bool success = mathRead(stream, &r->point); success &= mathRead(stream, &r->extent); return success; } inline bool mathRead(Stream& stream, MatrixF* m) { bool success = true; F32* pm = *m; for (U32 i = 0; i < 16; i++) success &= stream.read(&pm[i]); return success; } inline bool mathRead(Stream& stream, QuatF* q) { bool success = stream.read(&q->x); success &= stream.read(&q->y); success &= stream.read(&q->z); success &= stream.read(&q->w); return success; } //------------------------------------------------------------------------------ //-------------------------------------- WRITING // inline bool mathWrite(Stream& stream, const Point2I& p) { bool success = stream.write(p.x); success &= stream.write(p.y); return success; } inline bool mathWrite(Stream& stream, const Point3I& p) { bool success = stream.write(p.x); success &= stream.write(p.y); success &= stream.write(p.z); return success; } inline bool mathWrite(Stream& stream, const Point2F& p) { bool success = stream.write(p.x); success &= stream.write(p.y); return success; } inline bool mathWrite(Stream& stream, const Point3F& p) { bool success = stream.write(p.x); success &= stream.write(p.y); success &= stream.write(p.z); return success; } inline bool mathWrite(Stream& stream, const Point4F& p) { bool success = stream.write(p.x); success &= stream.write(p.y); success &= stream.write(p.z); success &= stream.write(p.w); return success; } inline bool mathWrite(Stream& stream, const Point3D& p) { bool success = stream.write(p.x); success &= stream.write(p.y); success &= stream.write(p.z); return success; } inline bool mathWrite(Stream& stream, const PlaneF& p) { bool success = stream.write(p.x); success &= stream.write(p.y); success &= stream.write(p.z); success &= stream.write(p.d); return success; } inline bool mathWrite(Stream& stream, const Box3F& b) { bool success = mathWrite(stream, b.minExtents); success &= mathWrite(stream, b.maxExtents); return success; } inline bool mathWrite(Stream& stream, const SphereF& s) { bool success = mathWrite(stream, s.center); success &= stream.write(s.radius); return success; } inline bool mathWrite(Stream& stream, const RectI& r) { bool success = mathWrite(stream, r.point); success &= mathWrite(stream, r.extent); return success; } inline bool mathWrite(Stream& stream, const RectF& r) { bool success = mathWrite(stream, r.point); success &= mathWrite(stream, r.extent); return success; } inline bool mathWrite(Stream& stream, const MatrixF& m) { bool success = true; const F32* pm = m; for (U32 i = 0; i < 16; i++) success &= stream.write(pm[i]); return success; } inline bool mathWrite(Stream& stream, const QuatF& q) { bool success = stream.write(q.x); success &= stream.write(q.y); success &= stream.write(q.z); success &= stream.write(q.w); return success; } #endif //_MATHIO_H_
flowonyx/functional
strings/conversions_test.go
<gh_stars>0 package strings import "fmt" func ExampleFromBool() { t := FromBool(true) f := FromBool(false) fmt.Printf("%s, %s", t, f) // Output: true, false } func ExampleToBool() { t1, err := ToBool("1") if err != nil { panic(err) } t2, err := ToBool("t") if err != nil { panic(err) } t3, err := ToBool("true") if err != nil { panic(err) } t4, err := ToBool("True") if err != nil { panic(err) } f1, err := ToBool("0") if err != nil { panic(err) } f2, err := ToBool("f") if err != nil { panic(err) } f3, err := ToBool("false") if err != nil { panic(err) } f4, err := ToBool("False") if err != nil { panic(err) } _, err = ToBool("junk") if err == nil { panic("should have errored") } fmt.Printf("%t, %t, %t, %t | %t, %t, %t, %t", t1, t2, t3, t4, f1, f2, f3, f4) // Output: true, true, true, true | false, false, false, false } func ExampleToBoolOpt() { t1 := ToBoolOpt("1") t2 := ToBoolOpt("t") t3 := ToBoolOpt("true") t4 := ToBoolOpt("True") f1 := ToBoolOpt("0") f2 := ToBoolOpt("f") f3 := ToBoolOpt("false") f4 := ToBoolOpt("False") b := ToBoolOpt("junk") fmt.Printf("%s, %s, %s, %s | %s, %s, %s, %s | %s", t1.String(), t2.String(), t3.String(), t4.String(), f1.String(), f2.String(), f3.String(), f4.String(), b.String()) // Output: Some(true), Some(true), Some(true), Some(true) | Some(false), Some(false), Some(false), Some(false) | None } func ExampleFromInt() { s1 := FromInt(-1) s2 := FromInt(1025) fmt.Printf("%s | %s", s1, s2) // Output: -1 | 1025 } func ExampleToInt() { i1, err := ToInt("-1") if err != nil { panic(err) } i2, err := ToInt("1025") if err != nil { panic(err) } i3, err := ToInt8("127") if err != nil { panic(err) } i4, err := ToInt8("128") if err == nil { panic("should have error") } fmt.Printf("%d, %d, %d, %d", i1, i2, i3, i4) // Output: -1, 1025, 127, 127 } func ExampleToIntOpt() { i1 := ToIntOpt("-1") i2 := ToIntOpt("junk") fmt.Printf("%s, %s", i1, i2) // Output: Some(-1), None } func ExampleFromFloat() { s := FromFloat(123.4) fmt.Println(s) // Output: 123.4 } func ExampleToFloat() { f1, err := ToFloat("123.4") if err != nil { panic(err) } f2, err := ToFloat("5") if err != nil { panic(err) } _, err = ToFloat("junk") if err == nil { panic("should have errored") } fmt.Printf("%.2f, %.2f", f1, f2) // Output: 123.40, 5.00 } func ExampleToFloatOpt() { f1 := ToFloatOpt("123.4") f2 := ToFloatOpt("5") b := ToFloatOpt("junk") fmt.Printf("%.2f, %.2f, %s", f1.Value(), f2.Value(), b) // Output: 123.40, 5.00, None } func ExampleToDate() { d, err := ToDate("2022-3-14") if err != nil { panic(err) } fmt.Printf("%v", d.Format(MDYYYYFullName)) // Output: March 14, 2022 } func ExampleCamelCaseToUnderscore() { s := CamelCaseToUnderscore("exampleString") fmt.Print(s) // Output: example_string } func ExampleNormalizeNewLine() { s := NormalizeNewLine("line1\nline2\r\nline3\rline4") fmt.Print(Quote(s)) // Output: "line1\nline2\nline3\nline4" }
Tiiinky/hairball
node_modules/react-images/examples/src/components/Gallery.js
<filename>node_modules/react-images/examples/src/components/Gallery.js import React, { Component, PropTypes } from 'react'; import Lightbox from 'react-images'; class Gallery extends Component { constructor() { super(); this.state = { lightboxIsOpen: false, currentImage: 0, }; this.closeLightbox = this.closeLightbox.bind(this); this.gotoNext = this.gotoNext.bind(this); this.gotoPrevious = this.gotoPrevious.bind(this); this.openLightbox = this.openLightbox.bind(this); } openLightbox (index, event) { event.preventDefault(); this.setState({ currentImage: index, lightboxIsOpen: true, }); } closeLightbox () { this.setState({ currentImage: 0, lightboxIsOpen: false, }); } gotoPrevious () { this.setState({ currentImage: this.state.currentImage - 1, }); } gotoNext () { this.setState({ currentImage: this.state.currentImage + 1, }); } renderGallery () { if (!this.props.images) return; const gallery = this.props.images.map((obj, i) => { return ( <a key={i} href={obj.src} onClick={(event) => this.openLightbox(i, event)} style={styles.thumbnail}> <img src={obj.thumbnail} style={styles.thumbnailImage} width={styles.thumbnail.size} height={styles.thumbnail.size} /> </a> ); }); return ( <div style={styles.gallery}> {gallery} </div> ); } render () { return ( <div className="section"> {this.props.heading && <h2>{this.props.heading}</h2>} {this.props.subheading && <p>{this.props.subheading}</p>} {this.renderGallery()} <Lightbox currentImage={this.state.currentImage} images={this.props.images} isOpen={this.state.lightboxIsOpen} onClickPrev={this.gotoPrevious} onClickNext={this.gotoNext} onClose={this.closeLightbox} theme={this.props.theme} /> </div> ); } }; Gallery.displayName = 'Gallery'; Gallery.propTypes = { images: PropTypes.array, heading: PropTypes.string, subheading: PropTypes.string, sepia: PropTypes.bool, }; const THUMBNAIL_SIZE = 72; const styles = { gallery: { marginLeft: -5, marginRight: -5, overflow: 'hidden', }, thumbnail: { backgroundSize: 'cover', borderRadius: 3, float: 'left', height: THUMBNAIL_SIZE, margin: 5, overflow: 'hidden', width: THUMBNAIL_SIZE, }, thumbnailImage: { display: 'block', height: 'auto', maxWidth: '100%', // height: THUMBNAIL_SIZE, // left: '50%', // position: 'relative', // // WebkitTransform: 'translateX(-50%)', // MozTransform: 'translateX(-50%)', // msTransform: 'translateX(-50%)', // transform: 'translateX(-50%)', }, }; export default Gallery;
aouos/leetcode
code/0297_serialize_seserialize/serialize_seserialize.js
<filename>code/0297_serialize_seserialize/serialize_seserialize.js /** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } */ /** * Encodes a tree to a single string. * * @param {TreeNode} root * @return {string} */ var serialize = function (root) { if (!root) return 'x'; const left = serialize(root.left); const right = serialize(root.right); return root.val + ',' + left + ',' + right; }; /** * Decodes your encoded data to tree. * * @param {string} data * @return {TreeNode} */ var deserialize = function (data) { const arr = data.split(','); function buildTree(list) { const item = list.shift(); if (item === 'x') { return null; } const node = new TreeNode(item); node.left = buildTree(list); node.right = buildTree(list); return node; } return buildTree(arr); }; /** * Your functions will be called as such: * deserialize(serialize(root)); */
adzza24/Defaults
app/directives/components/directive.labelcheck.js
<reponame>adzza24/Defaults /* Copyright (c) 2016 <NAME> * Licensed under The MIT License (MIT) - http://opensource.org/licenses/MIT * checkBox - Directive to make custom check boxes * Version 1.01 - included keydown event handler for spacebar and enter keys */ (function (ng) { angular.module('directives').directive('checkBox', function () { var CheckBox = function ($scope, element, attrs, ctrl) { this.element = element; this.attrs = attrs; this.ctrl = ctrl[0]; this.ngModel = ctrl[1]; this.scope = $scope; this.template = angular.element('<label for="' + this.attrs['id'] + '" class="label_' + this.attrs['type'] + '"><span></span>' + this.attrs['namedValue'] + '</label>'); this.init(); return this; }; CheckBox.prototype = { init: function () { this.element.next("span").remove(); this.element.after(this.template); this.element.remove(); this.template.prepend(this.element); this.StartupFunctions(); var self = this; if (self.ctrl.$name.length > 0) { this.scope.$watch(self.ctrl.$name + '["' + self.attrs['name'] + '"].$valid', function (validity) { if (validity) { self.template.addClass("ng-valid"); self.template.removeClass("ng-invalid"); } else { self.template.addClass("ng-invalid"); self.template.removeClass("ng-valid"); } }); this.scope.$watch(self.ctrl.$name + '["' + self.attrs['name'] + '"].$touched', function (touched) { if (touched) { self.template.addClass("ng-touched"); self.template.removeClass("ng-untouched"); } else { self.template.addClass("ng-untouched"); self.template.removeClass("ng-touched"); } }); } //else { throw new Error("The Form element requires a name value."); } }, StartupFunctions: function () { var self = this; this.template.unbind('click'); this.template.on('click', function (e) { e.preventDefault(); self.labelClick(); }); this.template.on('keydown', function (e) { if (e.which === 13 || e.which === 32) { //if spacebar || enter key pressed e.preventDefault(); self.labelClick(); } }); this.setupLabel(); this.template.addClass(this.attrs['type']); this.element.on('change', function () { self.setupLabel(); }); }, labelClick: function () { var self = this; var checked = this.element.is(':checkbox') ? this.setChecks() : this.setRadios(); this.element.prop('checked', checked); this.ngModel.$setViewValue(checked); this.element.change(); setTimeout(function () { self.scope.$digest(); }, 10); }, setRadios: function () { this.group.prop('checked', false); return true; }, setChecks: function () { if (this.element.prop('checked')) { return false; } return true; }, setupLabel: function () { var checks = []; var group = angular.element('input[name="' + this.attrs['name'] + '"]'); group.length || (group = this.element); angular.forEach(group, function (v, k) { v = angular.element(v); var label = v.closest('label') label.removeClass('c_on'); if (v.is(':checked')) { checks.push(label); } }); this.group = group; checks.length && angular.forEach(checks, function (v, k) { v = angular.element(v).addClass('c_on'); }); } }; return ({ restrict: 'AEC', require: ['^form', 'ngModel'], transclude: true, replace: true, link: function ($scope, element, attrs, ctrl) { return new CheckBox($scope, element, attrs, ctrl); } }); }) }(angular));
sslikewater/likewater-shardingphere
sharding-complex-strategy-example/src/main/java/com/example/sharding/complex/service/convert/OrderConvertor.java
package com.example.sharding.complex.service.convert; import com.example.sharding.complex.infrastructure.dal.mysql.dataobject.OrderDO; import com.example.sharding.complex.service.dto.OrderDTO; import org.springframework.beans.BeanUtils; import java.util.ArrayList; import java.util.List; /** * @Author: likewater * @Description: * @Date: Create in 1:00 下午 2022/3/13 */ public class OrderConvertor { //同名的属性用spring utils,不同名的手工转化 public static OrderDO dto2do(OrderDTO orderDTO) { if (orderDTO == null) return null; OrderDO userDO = new OrderDO(); BeanUtils.copyProperties(orderDTO, userDO); //默认不删除记录 userDO.setDeleted(0); return userDO; } public static OrderDTO do2DTO(OrderDO orderDO) { if (orderDO == null) return null; OrderDTO orderDTO = new OrderDTO(); BeanUtils.copyProperties(orderDO, orderDTO); return orderDTO; } public static List<OrderDTO> doList2DTOList(List<OrderDO> userDOList) { if(userDOList == null) return null; List<OrderDTO> userDTOList = new ArrayList<>(); userDOList.forEach(e -> { userDTOList.add(do2DTO(e)); }); return userDTOList; } }
sleyzerzon/soar
AgentDevelopmentTools/Soar-Editor/Editor/src/com/soartech/soar/ide/core/ast/HasPair.java
package com.soartech.soar.ide.core.ast; public interface HasPair { public Pair getPair(); }
neonkingfr/wildogcad
Source/Workbenches/PartDesign/part_plane.h
/******************************************************************************* * Copyright (c) 2007, 2008, CerroKai Development * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of CerroKai Development nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY CerroKai Development ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CerroKai Development BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************************/ #ifndef __PART_PLANE_H__ #define __PART_PLANE_H__ /*** Included Header Files ***/ #include <Kernel/wftrl.h> #include <PartDesign/part_feature.h> #include <PartDesign/part_plane_actions.h> #include <PartDesign/part_plane_controller.h> /*** Locally Defined Values ***/ #define PARTPLANE_CLASSNAME "Plane" #define PARTPLANE_DEFAULT_VISIBILITY true #define PARTPLANE_SCALE 0.25 #define PARTPLANE_LINE_THICKNESS 1.5 /*** Namespace Declaration ***/ namespace __WILDCAT_NAMESPACE__ { /*** Class Predefines ***/ class WCPart; /***********************************************~***************************************************/ class WCPartPlane : public WCPartFeature, virtual public WCVisualObject { protected: GLuint _buffer; //!< Corners buffer WCVector4 _base, _uAxis, _vAxis; //!< Orienting vectors WCMatrix4 _matrix, _inverseMatrix; //!< Plane matrices private: void GenerateVBO(void); //!< Genreate the display VBO void GenerateMatrices(void); //!< Generate the matrices void Initialize(void); //!< Initialization method //Deny Access WCPartPlane(); //!< Deny access to default constructor WCPartPlane(const WCPartPlane &plane); //!< Deny access to copy constructor WCPartPlane& operator=(const WCPartPlane &plane); //!< Deny access to equals operator public: //Constructors and Destructors WCPartPlane(WCFeature *creator, const std::string &name, const WCVector4 &p0, const WCVector4 &p1,//!< Primary constructor const WCVector4 &p2); WCPartPlane(xercesc::DOMElement *element, WCSerialDictionary *dictionary); //!< Persistance constructor ~WCPartPlane(); //!< Default destructor //Member Access Methods WCMatrix4 TransformMatrix(void) const { return this->_matrix; } //!< Get transform matrix WCMatrix4 InverseTransformMatrix(void) const{ return this->_inverseMatrix; } //!< Get inverse transform matrix inline WCVector4 Base(void) const { return this->_base; } //!< Get base vector inline WCVector4 UAxis(void) const { return this->_uAxis; } //!< Get u-axis vector inline WCVector4 VAxis(void) const { return this->_vAxis; } //!< Get v-axis vector //Inherited Required Methods virtual inline std::string RootName(void) const { return PARTPLANE_CLASSNAME; } //!< Get the class name virtual void ReceiveNotice(WCObjectMsg msg, WCObject *sender); //!< Receive notice from point or curve virtual bool Regenerate(void); //!< Validate and rebuild xercesc::DOMElement* Serialize(xercesc::DOMDocument *document, WCSerialDictionary *dict); //!< Serialize the object virtual void Render(const GLuint &defaultProg, const WCColor &color, const WPFloat &zoom); //!< Render the object virtual void OnSelection(const bool fromManager, std::list<WCVisualObject*> objects); //!< Called on selection virtual void OnDeselection(const bool fromManager); //!< Called on deselection /*** Actions and Drawing Modes ***/ static WCActionPartPlaneCreate* ActionCreate(WCFeature *creator, const std::string &name, //!< Primary create action const WCVector4 &p0, const WCVector4 &p1, const WCVector4 &p2); /*** Friend Functions ***/ friend std::ostream& operator<<(std::ostream& out, const WCPartPlane &plane); //!< Overloaded output operator }; /***********************************************~***************************************************/ } // End Wildcat Namespace #endif //__PART_PLANE_H__
srcarter3/python-awips
dynamicserialize/dstypes/gov/__init__.py
<filename>dynamicserialize/dstypes/gov/__init__.py __all__ = [ 'noaa' ]
Pandinosaurus/chartbrew
client/src/modules/checkForUpdates.js
import { API_HOST } from "../config/settings"; function checkForUpdates() { const url = `${API_HOST}/update`; const method = "GET"; const headers = new Headers({ "Accept": "application/json", }); return fetch(url, { method, headers }) .then((response) => { if (!response.ok) return Promise.reject(response.statusCode); return response.json(); }) .then((data) => { return data; }) .catch((err) => { return Promise.reject(err); }); } export default checkForUpdates;
ThorsteinnAdal/webcrawls_in_singapore_shippinglane
db_format_helpers/drop_ship_by_key.py
<reponame>ThorsteinnAdal/webcrawls_in_singapore_shippinglane<filename>db_format_helpers/drop_ship_by_key.py __author__ = 'thorsteinn' def drop_ships_by_key_value(key_to_check, value_to_check, db): """ Steady method for dropping db entries using a key:value requirement :param key_to_check: :param value_to_check: :param db: :return: alters the db in place """ ships = db.keys() for ship in ships: ship_db = db[ship] if ship_db[key_to_check] is value_to_check: del(db[ship])
only-romano/junkyard
projects/code_combat/1_Kithgard_Dungeon/034-Known_Enemy/knownEnemy.js
// You can use a variable like a nametag. var enemy1 = "Kratt"; var enemy2 = "Gert"; var enemy3 = "Ursa"; hero.attack(enemy1); // repeat if not dead hero.attack(enemy2); // repeat if not dead hero.attack(enemy3); // repeat if not dead
avinashpujala/av_segmentation
test_predictions.py
<reponame>avinashpujala/av_segmentation import os import time import glob import h5py import numpy as np import dask.array as da import preProcess import seeSound import importlib from networks import asfv importlib.reload(asfv) importlib.reload(preProcess) importlib.reload(seeSound) dir_ebs = r'/home/ubuntu/avinash/vol_ebs' dir_hFile = '/home/ubuntu/avinash/vol_ebs/avspeech/storage_20200628' dir_model = dir_hFile sound_dir = os.path.join(dir_ebs, 'avspeech/train') noise_dir = os.path.join(dir_ebs, 'audioset/videos') dir_temp = os.path.join(dir_ebs, 'temp') #%% Path to hdf file path_hFile = glob.glob(dir_hFile + '/stored*.h5') if len(path_hFile) == 0: print('No hdf file found!') else: path_hFile = path_hFile[-1] #%% Reading from hFile and creating Video Normalizer with h5py.File(path_hFile, mode='r') as hFile: print(hFile.keys()) print(hFile['vid_samples_train'].shape) tic = time.time() arr = da.from_array(hFile['vid_samples_train']) img_mean = arr.mean(axis=0).mean(axis=-1).compute() img_std = arr.std(axis=0).mean(axis=-1).compute() vid_norm = preProcess.VideoNormalizer(hFile['vid_samples_train'][:5]) vid_norm._VideoNormalizer__mean_image = img_mean vid_norm._VideoNormalizer__std_image = img_std print(int(time.time() - tic), 's') #%% Save vid_norm path_vid_norm = os.path.join(dir_hFile, 'vid_norm.pkl') vid_norm.save(path_vid_norm) #%% If pre-trained model already exists load from path tic = time.time() path_model = glob.glob(dir_model + '/trained_model.h5') if len(path_model) == 0: print('Model not found') else: path_model = path_model[-1] neural_network = asfv.NeuralNetwork.load(path_model) print(int(time.time() - tic), 's') #%% Load VideoNormalizer path_vid_norm = os.path.join(dir_hFile, 'vid_norm.pkl') vid_norm = seeSound.load_vid_norm(path_vid_norm) #%% Assess predictions offset = 0 nSlices = 5 inds = range(offset, offset+nSlices+1) with h5py.File(path_hFile, mode='r') as hFile: print(hFile.keys()) spec_mixed = np.array(hFile['mixed_spectrograms_train'][inds]) spec_pure = np.array(hFile['sound_spectrograms_train'][inds]) vid_slices = np.array(hFile['vid_samples_train'][inds]) vid_slices = vid_norm.normalize(vid_slices) predicted_spectrogram = neural_network.predict(vid_slices, spec_mixed) predicted_signal = preProcess.reconstruct_speech_signal(out['mixed_signal'], predicted_spectrogram, 25) #%% Save stuff out['mixed_signal'].save_to_wav_file(os.path.join(dir_temp, 'mixed_signal_norm.wav')) out['speech_signal'].save_to_wav_file(os.path.join(dir_temp, 'sound_signal_norm.wav')) predicted_signal.save_to_wav_file(os.path.join(dir_temp, 'predicted_signal_norm.wav')) #%% # neural_network = None # print('Creating model...') # if neural_network is None: # neural_network = \ # asfv.NeuralNetwork.build(vid_samples_train.shape[1:], # mixed_spectrograms_train.shape[1:]) # elif isinstance(neural_network, str): # if not os.path.exists(neural_network): # print('Check path, neural network not found!') # else: # neural_network = asfv.NeuralNetwork.load(neural_network) # else: # neural_network = asfv.NeuralNetwork(neural_network) #%% Train from data stored in h5py HDF file dir_hFile = r'/home/ubuntu/avinash/vol_ebs/avspeech/storage_20200628' path_hFile = os.path.join(dir_hFile, 'stored_data_20200628.h5') path_model = seeSound.train_from_hdf(path_hFile, neural_network=None) #%%
aranajhonny/chromium
net/spdy/hpack_decoder_test.cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/spdy/hpack_decoder.h" #include <map> #include <string> #include "base/basictypes.h" #include "base/logging.h" #include "base/strings/string_piece.h" #include "net/spdy/hpack_encoder.h" #include "net/spdy/hpack_input_stream.h" #include "net/spdy/hpack_output_stream.h" #include "net/spdy/spdy_test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { namespace test { using base::StringPiece; using std::string; class HpackDecoderPeer { public: explicit HpackDecoderPeer(HpackDecoder* decoder) : decoder_(decoder) {} void HandleHeaderRepresentation(StringPiece name, StringPiece value) { decoder_->HandleHeaderRepresentation(name, value); } bool DecodeNextName(HpackInputStream* in, StringPiece* out) { return decoder_->DecodeNextName(in, out); } HpackHeaderTable* header_table() { return &decoder_->header_table_; } void set_cookie_value(string value) { decoder_->cookie_value_ = value; } string cookie_value() { return decoder_->cookie_value_; } const std::map<string, string>& decoded_block() const { return decoder_->decoded_block_; } const string& headers_block_buffer() const { return decoder_->headers_block_buffer_; } private: HpackDecoder* decoder_; }; } // namespace test namespace { using base::StringPiece; using std::string; using test::a2b_hex; using testing::ElementsAre; using testing::Pair; const size_t kLiteralBound = 1024; class HpackDecoderTest : public ::testing::Test { protected: HpackDecoderTest() : decoder_(ObtainHpackHuffmanTable()), decoder_peer_(&decoder_) {} bool DecodeHeaderBlock(StringPiece str) { return decoder_.HandleControlFrameHeadersData(0, str.data(), str.size()) && decoder_.HandleControlFrameHeadersComplete(0); } const std::map<string, string>& decoded_block() const { // TODO(jgraettinger): HpackDecoderTest should implement // SpdyHeadersHandlerInterface, and collect headers for examination. return decoder_peer_.decoded_block(); } const std::map<string, string>& DecodeBlockExpectingSuccess(StringPiece str) { EXPECT_TRUE(DecodeHeaderBlock(str)); return decoded_block(); } void expectEntry(size_t index, size_t size, const string& name, const string& value) { HpackEntry* entry = decoder_peer_.header_table()->GetByIndex(index); EXPECT_EQ(name, entry->name()) << "index " << index; EXPECT_EQ(value, entry->value()); EXPECT_EQ(size, entry->Size()); EXPECT_EQ(index, decoder_peer_.header_table()->IndexOf(entry)); } void expectStaticEntry(size_t index) { HpackEntry* entry = decoder_peer_.header_table()->GetByIndex(index); EXPECT_TRUE(entry->IsStatic()) << "index " << index; } HpackDecoder decoder_; test::HpackDecoderPeer decoder_peer_; }; TEST_F(HpackDecoderTest, HandleControlFrameHeadersData) { // Strings under threshold are concatenated in the buffer. EXPECT_TRUE(decoder_.HandleControlFrameHeadersData( 0, "small string one", 16)); EXPECT_TRUE(decoder_.HandleControlFrameHeadersData( 0, "small string two", 16)); // A string which would push the buffer over the threshold is refused. EXPECT_FALSE(decoder_.HandleControlFrameHeadersData( 0, "fails", kMaxDecodeBufferSize - 32 + 1)); EXPECT_EQ(decoder_peer_.headers_block_buffer(), "small string onesmall string two"); } TEST_F(HpackDecoderTest, HandleControlFrameHeadersComplete) { // Decode a block which toggles two static headers into the reference set. EXPECT_TRUE(DecodeHeaderBlock("\x82\x86")); decoder_peer_.set_cookie_value("foobar=baz"); // Headers in the reference set should be emitted. // Incremental cookie buffer should be emitted and cleared. decoder_.HandleControlFrameHeadersData(0, NULL, 0); decoder_.HandleControlFrameHeadersComplete(0); EXPECT_THAT(decoded_block(), ElementsAre( Pair(":method", "GET"), Pair(":path", "/index.html"), Pair("cookie", "foobar=baz"))); EXPECT_EQ(decoder_peer_.cookie_value(), ""); } TEST_F(HpackDecoderTest, HandleHeaderRepresentation) { // All cookie crumbs are joined. decoder_peer_.HandleHeaderRepresentation("cookie", " part 1"); decoder_peer_.HandleHeaderRepresentation("cookie", "part 2 "); decoder_peer_.HandleHeaderRepresentation("cookie", "part3"); // Already-delimited headers are passed through. decoder_peer_.HandleHeaderRepresentation("passed-through", string("foo\0baz", 7)); // Other headers are joined on \0. Case matters. decoder_peer_.HandleHeaderRepresentation("joined", "not joined"); decoder_peer_.HandleHeaderRepresentation("joineD", "value 1"); decoder_peer_.HandleHeaderRepresentation("joineD", "value 2"); // Empty headers remain empty. decoder_peer_.HandleHeaderRepresentation("empty", ""); // Joined empty headers work as expected. decoder_peer_.HandleHeaderRepresentation("empty-joined", ""); decoder_peer_.HandleHeaderRepresentation("empty-joined", "foo"); decoder_peer_.HandleHeaderRepresentation("empty-joined", ""); decoder_peer_.HandleHeaderRepresentation("empty-joined", ""); // Non-contiguous cookie crumb. decoder_peer_.HandleHeaderRepresentation("cookie", " fin!"); // Finish and emit all headers. decoder_.HandleControlFrameHeadersComplete(0); EXPECT_THAT(decoded_block(), ElementsAre( Pair("cookie", " part 1; part 2 ; part3; fin!"), Pair("empty", ""), Pair("empty-joined", string("\0foo\0\0", 6)), Pair("joineD", string("value 1\0value 2", 15)), Pair("joined", "not joined"), Pair("passed-through", string("foo\0baz", 7)))); } // Decoding an encoded name with a valid string literal should work. TEST_F(HpackDecoderTest, DecodeNextNameLiteral) { HpackInputStream input_stream(kLiteralBound, StringPiece("\x00\x04name", 6)); StringPiece string_piece; EXPECT_TRUE(decoder_peer_.DecodeNextName(&input_stream, &string_piece)); EXPECT_EQ("name", string_piece); EXPECT_FALSE(input_stream.HasMoreData()); } TEST_F(HpackDecoderTest, DecodeNextNameLiteralWithHuffmanEncoding) { string input = a2b_hex("008825a849e95ba97d7f"); HpackInputStream input_stream(kLiteralBound, input); StringPiece string_piece; EXPECT_TRUE(decoder_peer_.DecodeNextName(&input_stream, &string_piece)); EXPECT_EQ("custom-key", string_piece); EXPECT_FALSE(input_stream.HasMoreData()); } // Decoding an encoded name with a valid index should work. TEST_F(HpackDecoderTest, DecodeNextNameIndexed) { HpackInputStream input_stream(kLiteralBound, "\x01"); StringPiece string_piece; EXPECT_TRUE(decoder_peer_.DecodeNextName(&input_stream, &string_piece)); EXPECT_EQ(":authority", string_piece); EXPECT_FALSE(input_stream.HasMoreData()); } // Decoding an encoded name with an invalid index should fail. TEST_F(HpackDecoderTest, DecodeNextNameInvalidIndex) { // One more than the number of static table entries. HpackInputStream input_stream(kLiteralBound, "\x3e"); StringPiece string_piece; EXPECT_FALSE(decoder_peer_.DecodeNextName(&input_stream, &string_piece)); } // Decoding an indexed header should toggle the index's presence in // the reference set, making a copy of static table entries if // necessary. It should also emit the header if toggled on (and only // as many times as it was toggled on). TEST_F(HpackDecoderTest, IndexedHeaderBasic) { // Toggle on static table entry #2 (and make a copy at index #1), // then toggle on static table entry #5 (which is now #6 because of // the copy of #2). std::map<string, string> header_set1 = DecodeBlockExpectingSuccess("\x82\x86"); std::map<string, string> expected_header_set1; expected_header_set1[":method"] = "GET"; expected_header_set1[":path"] = "/index.html"; EXPECT_EQ(expected_header_set1, header_set1); std::map<string, string> expected_header_set2; expected_header_set2[":path"] = "/index.html"; // Toggle off the copy of static table entry #5. std::map<string, string> header_set2 = DecodeBlockExpectingSuccess("\x82"); EXPECT_EQ(expected_header_set2, header_set2); } // Test a too-large indexed header. TEST_F(HpackDecoderTest, InvalidIndexedHeader) { // High-bit set, and a prefix of one more than the number of static entries. EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\xbe", 1))); } TEST_F(HpackDecoderTest, ContextUpdateMaximumSize) { EXPECT_EQ(kDefaultHeaderTableSizeSetting, decoder_peer_.header_table()->max_size()); string input; { // Maximum-size update with size 126. Succeeds. HpackOutputStream output_stream; output_stream.AppendPrefix(kEncodingContextOpcode); output_stream.AppendPrefix(kEncodingContextNewMaximumSize); output_stream.AppendUint32(126); output_stream.TakeString(&input); EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input))); EXPECT_EQ(126u, decoder_peer_.header_table()->max_size()); } { // Maximum-size update with kDefaultHeaderTableSizeSetting. Succeeds. HpackOutputStream output_stream; output_stream.AppendPrefix(kEncodingContextOpcode); output_stream.AppendPrefix(kEncodingContextNewMaximumSize); output_stream.AppendUint32(kDefaultHeaderTableSizeSetting); output_stream.TakeString(&input); EXPECT_TRUE(DecodeHeaderBlock(StringPiece(input))); EXPECT_EQ(kDefaultHeaderTableSizeSetting, decoder_peer_.header_table()->max_size()); } { // Maximum-size update with kDefaultHeaderTableSizeSetting + 1. Fails. HpackOutputStream output_stream; output_stream.AppendPrefix(kEncodingContextOpcode); output_stream.AppendPrefix(kEncodingContextNewMaximumSize); output_stream.AppendUint32(kDefaultHeaderTableSizeSetting + 1); output_stream.TakeString(&input); EXPECT_FALSE(DecodeHeaderBlock(StringPiece(input))); EXPECT_EQ(kDefaultHeaderTableSizeSetting, decoder_peer_.header_table()->max_size()); } } TEST_F(HpackDecoderTest, ContextUpdateClearReferenceSet) { // Toggle on a couple of headers. std::map<string, string> header_set1 = DecodeBlockExpectingSuccess("\x82\x86"); std::map<string, string> expected_header_set1; expected_header_set1[":method"] = "GET"; expected_header_set1[":path"] = "/index.html"; EXPECT_EQ(expected_header_set1, header_set1); // Send a context update to clear the reference set. std::map<string, string> header_set2 = DecodeBlockExpectingSuccess("\x30"); std::map<string, string> expected_header_set2; EXPECT_EQ(expected_header_set2, header_set2); } // Decoding two valid encoded literal headers with no indexing should // work. TEST_F(HpackDecoderTest, LiteralHeaderNoIndexing) { // First header with indexed name, second header with string literal // name. const char input[] = "\x04\x0c/sample/path\x00\x06:path2\x0e/sample/path/2"; std::map<string, string> header_set = DecodeBlockExpectingSuccess(StringPiece(input, arraysize(input) - 1)); std::map<string, string> expected_header_set; expected_header_set[":path"] = "/sample/path"; expected_header_set[":path2"] = "/sample/path/2"; EXPECT_EQ(expected_header_set, header_set); } // Decoding two valid encoded literal headers with incremental // indexing and string literal names should work and add the headers // to the reference set. TEST_F(HpackDecoderTest, LiteralHeaderIncrementalIndexing) { const char input[] = "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2"; std::map<string, string> header_set = DecodeBlockExpectingSuccess(StringPiece(input, arraysize(input) - 1)); std::map<string, string> expected_header_set; expected_header_set[":path"] = "/sample/path"; expected_header_set[":path2"] = "/sample/path/2"; EXPECT_EQ(expected_header_set, header_set); // Decoding an empty string should just return the reference set. std::map<string, string> header_set2 = DecodeBlockExpectingSuccess(""); EXPECT_EQ(expected_header_set, header_set2); } TEST_F(HpackDecoderTest, LiteralHeaderWithIndexingInvalidNameIndex) { decoder_.ApplyHeaderTableSizeSetting(0); // Name is the last static index. Works. EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x7d\x03ooo"))); // Name is one beyond the last static index. Fails. EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x7e\x03ooo"))); } TEST_F(HpackDecoderTest, LiteralHeaderNoIndexingInvalidNameIndex) { // Name is the last static index. Works. EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x0f\x2e\x03ooo"))); // Name is one beyond the last static index. Fails. EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x0f\x2f\x03ooo"))); } TEST_F(HpackDecoderTest, LiteralHeaderNeverIndexedInvalidNameIndex) { // Name is the last static index. Works. EXPECT_TRUE(DecodeHeaderBlock(StringPiece("\x1f\x2e\x03ooo"))); // Name is one beyond the last static index. Fails. EXPECT_FALSE(DecodeHeaderBlock(StringPiece("\x1f\x2f\x03ooo"))); } // Round-tripping the header set from E.2.1 should work. TEST_F(HpackDecoderTest, BasicE21) { HpackEncoder encoder(ObtainHpackHuffmanTable()); std::map<string, string> expected_header_set; expected_header_set[":method"] = "GET"; expected_header_set[":scheme"] = "http"; expected_header_set[":path"] = "/"; expected_header_set[":authority"] = "www.example.com"; string encoded_header_set; EXPECT_TRUE(encoder.EncodeHeaderSet( expected_header_set, &encoded_header_set)); EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set)); EXPECT_EQ(expected_header_set, decoded_block()); } TEST_F(HpackDecoderTest, SectionD3RequestHuffmanExamples) { std::map<string, string> header_set; // 82 | == Indexed - Add == // | idx = 2 // | -> :method: GET // 87 | == Indexed - Add == // | idx = 7 // | -> :scheme: http // 86 | == Indexed - Add == // | idx = 6 // | -> :path: / // 44 | == Literal indexed == // | Indexed name (idx = 4) // | :authority // 8c | Literal value (len = 15) // | Huffman encoded: // f1e3 c2e5 f23a 6ba0 ab90 f4ff | .....:k..... // | Decoded: // | www.example.com // | -> :authority: www.example.com string first = a2b_hex("828786448cf1e3c2e5f23a6ba0ab90f4" "ff"); header_set = DecodeBlockExpectingSuccess(first); EXPECT_THAT(header_set, ElementsAre( Pair(":authority", "www.example.com"), Pair(":method", "GET"), Pair(":path", "/"), Pair(":scheme", "http"))); expectEntry(1, 57, ":authority", "www.example.com"); expectEntry(2, 38, ":path", "/"); expectEntry(3, 43, ":scheme", "http"); expectEntry(4, 42, ":method", "GET"); expectStaticEntry(5); EXPECT_EQ(180u, decoder_peer_.header_table()->size()); // 5c | == Literal indexed == // | Indexed name (idx = 28) // | cache-control // 86 | Literal value (len = 8) // | Huffman encoded: // a8eb 1064 9cbf | ...d.. // | Decoded: // | no-cache // | -> cache-control: no-cache string second = a2b_hex("5c86a8eb10649cbf"); header_set = DecodeBlockExpectingSuccess(second); EXPECT_THAT(header_set, ElementsAre( Pair(":authority", "www.example.com"), Pair(":method", "GET"), Pair(":path", "/"), Pair(":scheme", "http"), Pair("cache-control", "no-cache"))); expectEntry(1, 53, "cache-control", "no-cache"); expectEntry(2, 57, ":authority", "www.example.com"); expectEntry(3, 38, ":path", "/"); expectEntry(4, 43, ":scheme", "http"); expectEntry(5, 42, ":method", "GET"); expectStaticEntry(6); EXPECT_EQ(233u, decoder_peer_.header_table()->size()); // 30 | == Empty reference set == // | idx = 0 // | flag = 1 // 85 | == Indexed - Add == // | idx = 5 // | -> :method: GET // 8c | == Indexed - Add == // | idx = 12 // | -> :scheme: https // 8b | == Indexed - Add == // | idx = 11 // | -> :path: /index.html // 84 | == Indexed - Add == // | idx = 4 // | -> :authority: www.example.com // 40 | == Literal indexed == // 88 | Literal name (len = 10) // | Huffman encoded: // 25a8 49e9 5ba9 7d7f | %.I.[.}. // | Decoded: // | custom-key // 89 | Literal value (len = 12) // | Huffman encoded: // 25a8 49e9 5bb8 e8b4 bf | %.I.[.... // | Decoded: // | custom-value // | -> custom-key: custom-value string third = a2b_hex("30858c8b84408825a849e95ba97d7f89" "25a849e95bb8e8b4bf"); header_set = DecodeBlockExpectingSuccess(third); EXPECT_THAT(header_set, ElementsAre( Pair(":authority", "www.example.com"), Pair(":method", "GET"), Pair(":path", "/index.html"), Pair(":scheme", "https"), Pair("custom-key", "custom-value"))); expectEntry(1, 54, "custom-key", "custom-value"); expectEntry(2, 48, ":path", "/index.html"); expectEntry(3, 44, ":scheme", "https"); expectEntry(4, 53, "cache-control", "no-cache"); expectEntry(5, 57, ":authority", "www.example.com"); expectEntry(6, 38, ":path", "/"); expectEntry(7, 43, ":scheme", "http"); expectEntry(8, 42, ":method", "GET"); expectStaticEntry(9); EXPECT_EQ(379u, decoder_peer_.header_table()->size()); } TEST_F(HpackDecoderTest, SectionD5ResponseHuffmanExamples) { std::map<string, string> header_set; decoder_.ApplyHeaderTableSizeSetting(256); // 48 | == Literal indexed == // | Indexed name (idx = 8) // | :status // 82 | Literal value (len = 3) // | Huffman encoded: // 6402 | d. // | Decoded: // | 302 // | -> :status: 302 // 59 | == Literal indexed == // | Indexed name (idx = 25) // | cache-control // 85 | Literal value (len = 7) // | Huffman encoded: // aec3 771a 4b | ..w.K // | Decoded: // | private // | -> cache-control: private // 63 | == Literal indexed == // | Indexed name (idx = 35) // | date // 96 | Literal value (len = 29) // | Huffman encoded: // d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f // e082 a62d 1bff | ...-.. // | Decoded: // | Mon, 21 Oct 2013 20:13:21 // | GMT // | -> date: Mon, 21 Oct 2013 // | 20:13:21 GMT // 71 | == Literal indexed == // | Indexed name (idx = 49) // | location // 91 | Literal value (len = 23) // | Huffman encoded: // 9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 | .)...c.........C // d3 | . // | Decoded: // | https://www.example.com // | -> location: https://www.e // | xample.com string first = a2b_hex("488264025985aec3771a4b6396d07abe" "941054d444a8200595040b8166e082a6" "2d1bff71919d29ad171863c78f0b97c8" "e9ae82ae43d3"); header_set = DecodeBlockExpectingSuccess(first); EXPECT_THAT(header_set, ElementsAre( Pair(":status", "302"), Pair("cache-control", "private"), Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), Pair("location", "https://www.example.com"))); expectEntry(1, 63, "location", "https://www.example.com"); expectEntry(2, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT"); expectEntry(3, 52, "cache-control", "private"); expectEntry(4, 42, ":status", "302"); expectStaticEntry(5); EXPECT_EQ(222u, decoder_peer_.header_table()->size()); // 8c | == Indexed - Add == // | idx = 12 // | - evict: :status: 302 // | -> :status: 200 string second = a2b_hex("8c"); header_set = DecodeBlockExpectingSuccess(second); EXPECT_THAT(header_set, ElementsAre( Pair(":status", "200"), Pair("cache-control", "private"), Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), Pair("location", "https://www.example.com"))); expectEntry(1, 42, ":status", "200"); expectEntry(2, 63, "location", "https://www.example.com"); expectEntry(3, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT"); expectEntry(4, 52, "cache-control", "private"); expectStaticEntry(5); EXPECT_EQ(222u, decoder_peer_.header_table()->size()); // 84 | == Indexed - Remove == // | idx = 4 // | -> cache-control: private // 84 | == Indexed - Add == // | idx = 4 // | -> cache-control: private // 43 | == Literal indexed == // | Indexed name (idx = 3) // | date // 96 | Literal value (len = 29) // | Huffman encoded: // d07a be94 1054 d444 a820 0595 040b 8166 | .z...T.D. .....f // e084 a62d 1bff | ...-.. // | Decoded: // | Mon, 21 Oct 2013 20:13:22 // | GMT // | - evict: cache-control: pr // | ivate // | -> date: Mon, 21 Oct 2013 // | 20:13:22 GMT // 5e | == Literal indexed == // | Indexed name (idx = 30) // | content-encoding // 83 | Literal value (len = 4) // | Huffman encoded: // 9bd9 ab | ... // | Decoded: // | gzip // | - evict: date: Mon, 21 Oct // | 2013 20:13:21 GMT // | -> content-encoding: gzip // 84 | == Indexed - Remove == // | idx = 4 // | -> location: https://www.e // | xample.com // 84 | == Indexed - Add == // | idx = 4 // | -> location: https://www.e // | xample.com // 83 | == Indexed - Remove == // | idx = 3 // | -> :status: 200 // 83 | == Indexed - Add == // | idx = 3 // | -> :status: 200 // 7b | == Literal indexed == // | Indexed name (idx = 59) // | set-cookie // ad | Literal value (len = 56) // | Huffman encoded: // 94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 | .........5...[9` // d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 | ..'..6r..'..)... // 3160 65c0 03ed 4ee5 b106 3d50 07 | 1`e...N...=P. // | Decoded: // | foo=ASDJKHQKBZXOQWEOPIUAXQ // | WEOIU; max-age=3600; versi // | on=1 // | - evict: location: https:/ // | /www.example.com // | - evict: :status: 200 // | -> set-cookie: foo=ASDJKHQ // | KBZXOQWEOPIUAXQWEOIU; ma // | x-age=3600; version=1 string third = a2b_hex("84844396d07abe941054d444a8200595" "040b8166e084a62d1bff5e839bd9ab84" "8483837bad94e7821dd7f2e6c7b335df" "dfcd5b3960d5af27087f3672c1ab270f" "b5291f9587316065c003ed4ee5b1063d" "5007"); header_set = DecodeBlockExpectingSuccess(third); EXPECT_THAT(header_set, ElementsAre( Pair(":status", "200"), Pair("cache-control", "private"), Pair("content-encoding", "gzip"), Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), Pair("location", "https://www.example.com"), Pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" " max-age=3600; version=1"))); expectEntry(1, 98, "set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" " max-age=3600; version=1"); expectEntry(2, 52, "content-encoding", "gzip"); expectEntry(3, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); expectStaticEntry(4); EXPECT_EQ(215u, decoder_peer_.header_table()->size()); } } // namespace } // namespace net
abdullatif1992/gitlabhq
spec/javascripts/fixtures/merge_requests.rb
require 'spec_helper' describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do include JavaScriptFixturesHelpers let(:admin) { create(:admin) } let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') } let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') } let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) } let(:pipeline) do create( :ci_pipeline, project: merge_request.source_project, ref: merge_request.source_branch, sha: merge_request.diff_head_sha ) end let(:path) { "files/ruby/popen.rb" } let(:position) do Gitlab::Diff::Position.new( old_path: path, new_path: path, old_line: nil, new_line: 14, diff_refs: merge_request.diff_refs ) end render_views before(:all) do clean_frontend_fixtures('merge_requests/') end before do sign_in(admin) end after do remove_repository(project) end it 'merge_requests/merge_request_of_current_user.html.raw' do |example| merge_request.update(author: admin) render_merge_request(example.description, merge_request) end it 'merge_requests/merge_request_with_task_list.html.raw' do |example| create(:ci_build, :pending, pipeline: pipeline) render_merge_request(example.description, merge_request) end it 'merge_requests/merged_merge_request.html.raw' do |example| allow_any_instance_of(MergeRequest).to receive(:source_branch_exists?).and_return(true) allow_any_instance_of(MergeRequest).to receive(:can_remove_source_branch?).and_return(true) render_merge_request(example.description, merged_merge_request) end it 'merge_requests/diff_comment.html.raw' do |example| create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) render_merge_request(example.description, merge_request) end it 'merge_requests/merge_request_with_comment.html.raw' do |example| create(:note_on_merge_request, author: admin, project: project, noteable: merge_request, note: '- [ ] Task List Item') render_merge_request(example.description, merge_request) end it 'merge_requests/discussions.json' do |example| create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) render_discussions_json(merge_request, example.description) end it 'merge_requests/diff_discussion.json' do |example| create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) render_discussions_json(merge_request, example.description) end context 'with image diff' do let(:merge_request2) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, title: "Added images") } let(:image_path) { "files/images/ee_repo_logo.png" } let(:image_position) do Gitlab::Diff::Position.new( old_path: image_path, new_path: image_path, width: 100, height: 100, x: 1, y: 1, position_type: "image", diff_refs: merge_request2.diff_refs ) end it 'merge_requests/image_diff_discussion.json' do |example| create(:diff_note_on_merge_request, project: project, noteable: merge_request2, position: image_position) render_discussions_json(merge_request2, example.description) end end private def render_discussions_json(merge_request, fixture_file_name) get :discussions, namespace_id: project.namespace.to_param, project_id: project, id: merge_request.to_param, format: :json store_frontend_fixture(response, fixture_file_name) end def render_merge_request(fixture_file_name, merge_request) get :show, namespace_id: project.namespace.to_param, project_id: project, id: merge_request.to_param, format: :html expect(response).to be_success store_frontend_fixture(response, fixture_file_name) end end
maroozm/AliPhysics
PWGCF/Correlations/DPhi/AliAnalysisTaskCorPIDTOFdeut.cxx
<gh_stars>100-1000 /************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* AliAnaysisTaskCorPIDTOFdiprot * * empty task which can serve as a starting point for building an analysis * as an example, one histogram is filled */ //#include <iostream> #include <fstream> #include <cmath> #include <bitset> #include <iomanip> #include "TChain.h" #include "TF1.h" #include "TH1F.h" #include "TH2F.h" #include "TH3F.h" #include "TProfile.h" #include "TMath.h" //#include "TGraphErrors.h" #include "TList.h" #include "TCanvas.h" #include "TStyle.h" #include "TFile.h" #include "AliAnalysisTask.h" #include "AliAnalysisManager.h" #include "AliAODEvent.h" #include "AliAODInputHandler.h" #include "AliAnalysisTaskCorPIDTOFdeut.h" //#include "AliPIDResponse.h" //#include "AliAnalysisUtils.h" //#include "AliEmcalTrackSelection.h" //#include "AliEmcalTrackSelectionAOD.h" //#include "TFile.h" //#include "AliMultSelection.h" // particle identifications in ALICE // // enum EParticleType // // kElectron = 0; // kMuon = 1; // kPion = 2; // kKaon = 3; // kProton = 4; // kDeuteron = 5; // kTriton = 6; // kHe3 = 7; // kAlpha = 8; // kPhoton = 9; // kPi0 = 10; // kNeutron = 11; // kKaon0 = 12; // kEleCon = 13; // kUnknown = 14; // event trigger selection // if(datajets) // { // if(!(fInputHandler->IsEventSelected() & fTriggerSelectionBits)) return false; // if(fTriggerSelectionString.Length()) // { // if(!fInputEvent->GetFiredTriggerClasses().Contains(fTriggerSelectionString)) return false; // } // } using namespace std; // std namespace: so you can do things like 'cout' //using namespace BSchaefer_devel; //ofstream file_output("output.txt"); ClassImp(AliAnalysisTaskCorPIDTOFdeut) // classimp: necessary for root AliAnalysisTaskCorPIDTOFdeut::AliAnalysisTaskCorPIDTOFdeut() : AliAnalysisTaskSE(), fAOD(0), fOutputList(0), fPIDResponse(0), fAnalysisUtils(0), fHistPt(0), // 1 cent_ntracks(0), // 2 m2_pt_pos(0), // 3 m2_pt_neg(0), // 4 beta_p_pos(0), // 5 beta_p_neg(0), // 6 deltat_pt_pos(0), // 7 deltat_pt_neg(0), // 8 m2_pt_pos_cut(0), // 9 m2_pt_neg_cut(0), // 10 beta_p_pos_cut(0), // 11 beta_p_neg_cut(0), // 12 deltat_pt_pos_cut(0), // 13 deltat_pt_neg_cut(0), // 14 m2_pt_pos_cut_T(0), // 15 m2_pt_neg_cut_T(0), // 16 m2_pt_pos_cut_G(0), // 17 m2_pt_neg_cut_G(0), // 18 m2_pt_pos_cut_A(0), // 19 m2_pt_neg_cut_A(0), // 20 m2_pt_pos_cut_B(0), // 21 m2_pt_neg_cut_B(0), // 22 deut_phi_pt_pos_T(0), // 23 deut_phi_pt_neg_T(0), // 24 deut_phi_pt_pos_A(0), // 25 deut_phi_pt_neg_A(0), // 26 deut_phi_pt_pos_B(0), // 27 deut_phi_pt_neg_B(0), // 28 deut_per_event(0), // 29 trig_03_per_event(0), // 30 trig_05_per_event(0), // 31 trig_08_per_event(0), // 32 trig_03_phi_pt_pos(0), // 33 trig_03_phi_pt_neg(0), // 34 trig_05_phi_pt_pos(0), // 35 trig_05_phi_pt_neg(0), // 36 trig_08_phi_pt_pos(0), // 37 trig_08_phi_pt_neg(0), // 38 tof_phi_eta_pos(0), // 39 tof_phi_eta_neg(0), // 40 tof_phi_eta_pos_deut(0), // 41 tof_phi_eta_neg_deut(0), // 42 deut_pt_compare_pos(0), // 43 deut_pt_compare_neg(0), // 44 tpc_sector_fraction(0), // 45 primary_vertex_z(0), // 46 primary_vertex_z_cut(0), // 47 deut_dphi_pt_pos_pos_03_T(0), // 48 deut_dphi_pt_pos_neg_03_T(0), // 49 deut_dphi_pt_neg_neg_03_T(0), // 50 deut_dphi_pt_pos_pos_05_T(0), // 51 deut_dphi_pt_pos_neg_05_T(0), // 52 deut_dphi_pt_neg_neg_05_T(0), // 53 deut_dphi_pt_pos_pos_08_T(0), // 54 deut_dphi_pt_pos_neg_08_T(0), // 55 deut_dphi_pt_neg_neg_08_T(0), // 56 deut_dphi_pt_pos_pos_03_A(0), // 57 deut_dphi_pt_pos_neg_03_A(0), // 58 deut_dphi_pt_neg_neg_03_A(0), // 59 deut_dphi_pt_pos_pos_05_A(0), // 60 deut_dphi_pt_pos_neg_05_A(0), // 61 deut_dphi_pt_neg_neg_05_A(0), // 62 deut_dphi_pt_pos_pos_08_A(0), // 63 deut_dphi_pt_pos_neg_08_A(0), // 64 deut_dphi_pt_neg_neg_08_A(0), // 65 deut_dphi_pt_pos_pos_03_B(0), // 66 deut_dphi_pt_pos_neg_03_B(0), // 67 deut_dphi_pt_neg_neg_03_B(0), // 68 deut_dphi_pt_pos_pos_05_B(0), // 69 deut_dphi_pt_pos_neg_05_B(0), // 70 deut_dphi_pt_neg_neg_05_B(0), // 71 deut_dphi_pt_pos_pos_08_B(0), // 72 deut_dphi_pt_pos_neg_08_B(0), // 73 deut_dphi_pt_neg_neg_08_B(0), // 74 DCAxy_pos(0), // 75 DCAxy_neg(0), // 76 DCAz_pos(0), // 77 DCAz_neg(0), // 78 m2_pt_pos_fine(0), // 79 m2_pt_neg_fine(0), // 80 m2_pt_pos_cut_fine(0), // 81 m2_pt_neg_cut_fine(0), // 82 m2_pt_pos_cut_T_fine(0), // 83 m2_pt_neg_cut_T_fine(0) // 84 // deut_eta_vs_phi_pos(0), // 50 // deut_eta_vs_phi_neg(0) // 51 { // default constructor, don't allocate memory here! // this is used by root for IO purposes, it needs to remain empty } //_____________________________________________________________________________ AliAnalysisTaskCorPIDTOFdeut::AliAnalysisTaskCorPIDTOFdeut(const char* name) : AliAnalysisTaskSE(name), fAOD(0), fOutputList(0), fPIDResponse(0), fAnalysisUtils(0), fHistPt(0), // 1 cent_ntracks(0), // 2 m2_pt_pos(0), // 3 m2_pt_neg(0), // 4 beta_p_pos(0), // 5 beta_p_neg(0), // 6 deltat_pt_pos(0), // 7 deltat_pt_neg(0), // 8 m2_pt_pos_cut(0), // 9 m2_pt_neg_cut(0), // 10 beta_p_pos_cut(0), // 11 beta_p_neg_cut(0), // 12 deltat_pt_pos_cut(0), // 13 deltat_pt_neg_cut(0), // 14 m2_pt_pos_cut_T(0), // 15 m2_pt_neg_cut_T(0), // 16 m2_pt_pos_cut_G(0), // 17 m2_pt_neg_cut_G(0), // 18 m2_pt_pos_cut_A(0), // 19 m2_pt_neg_cut_A(0), // 20 m2_pt_pos_cut_B(0), // 21 m2_pt_neg_cut_B(0), // 22 deut_phi_pt_pos_T(0), // 23 deut_phi_pt_neg_T(0), // 24 deut_phi_pt_pos_A(0), // 25 deut_phi_pt_neg_A(0), // 26 deut_phi_pt_pos_B(0), // 27 deut_phi_pt_neg_B(0), // 28 deut_per_event(0), // 29 trig_03_per_event(0), // 30 trig_05_per_event(0), // 31 trig_08_per_event(0), // 32 trig_03_phi_pt_pos(0), // 33 trig_03_phi_pt_neg(0), // 34 trig_05_phi_pt_pos(0), // 35 trig_05_phi_pt_neg(0), // 36 trig_08_phi_pt_pos(0), // 37 trig_08_phi_pt_neg(0), // 38 tof_phi_eta_pos(0), // 39 tof_phi_eta_neg(0), // 40 tof_phi_eta_pos_deut(0), // 41 tof_phi_eta_neg_deut(0), // 42 deut_pt_compare_pos(0), // 43 deut_pt_compare_neg(0), // 44 tpc_sector_fraction(0), // 45 primary_vertex_z(0), // 46 primary_vertex_z_cut(0), // 47 deut_dphi_pt_pos_pos_03_T(0), // 48 deut_dphi_pt_pos_neg_03_T(0), // 49 deut_dphi_pt_neg_neg_03_T(0), // 50 deut_dphi_pt_pos_pos_05_T(0), // 51 deut_dphi_pt_pos_neg_05_T(0), // 52 deut_dphi_pt_neg_neg_05_T(0), // 53 deut_dphi_pt_pos_pos_08_T(0), // 54 deut_dphi_pt_pos_neg_08_T(0), // 55 deut_dphi_pt_neg_neg_08_T(0), // 56 deut_dphi_pt_pos_pos_03_A(0), // 57 deut_dphi_pt_pos_neg_03_A(0), // 58 deut_dphi_pt_neg_neg_03_A(0), // 59 deut_dphi_pt_pos_pos_05_A(0), // 60 deut_dphi_pt_pos_neg_05_A(0), // 61 deut_dphi_pt_neg_neg_05_A(0), // 62 deut_dphi_pt_pos_pos_08_A(0), // 63 deut_dphi_pt_pos_neg_08_A(0), // 64 deut_dphi_pt_neg_neg_08_A(0), // 65 deut_dphi_pt_pos_pos_03_B(0), // 66 deut_dphi_pt_pos_neg_03_B(0), // 67 deut_dphi_pt_neg_neg_03_B(0), // 68 deut_dphi_pt_pos_pos_05_B(0), // 69 deut_dphi_pt_pos_neg_05_B(0), // 70 deut_dphi_pt_neg_neg_05_B(0), // 71 deut_dphi_pt_pos_pos_08_B(0), // 72 deut_dphi_pt_pos_neg_08_B(0), // 73 deut_dphi_pt_neg_neg_08_B(0), // 74 DCAxy_pos(0), // 75 DCAxy_neg(0), // 76 DCAz_pos(0), // 77 DCAz_neg(0), // 78 m2_pt_pos_fine(0), // 79 m2_pt_neg_fine(0), // 80 m2_pt_pos_cut_fine(0), // 81 m2_pt_neg_cut_fine(0), // 82 m2_pt_pos_cut_T_fine(0), // 83 m2_pt_neg_cut_T_fine(0) // 84 // deut_eta_vs_phi_pos(0), // 50 // deut_eta_vs_phi_neg(0) // 51 { // constructor DefineInput(0, TChain::Class()); DefineOutput(1, TList::Class()); } //_____________________________________________________________________________ AliAnalysisTaskCorPIDTOFdeut::~AliAnalysisTaskCorPIDTOFdeut() { // destructor if(fAnalysisUtils) delete fAnalysisUtils; if(fOutputList) { delete fOutputList; // at the end of your task, it is deleted from memory by calling this function } } //_____________________________________________________________________________ void AliAnalysisTaskCorPIDTOFdeut::UserCreateOutputObjects() { // 2.88465 0.0761582 0.709281 0.124386 0.017642 -0.0316078 2.65738 0.115151 0.918566 0.0986592 0.0187545 0.00346519 // pp 2016 untriggered deut_curves[0][0][0] = 2.88465; // pos deut mean curve deut_curves[0][0][1] = 0.0761582; deut_curves[0][0][2] = 0.709281; deut_curves[0][1][0] = 0.124386; // pos deut sigma curve deut_curves[0][1][1] = 0.017642; deut_curves[0][1][2] = -0.0316078; deut_curves[1][0][0] = 2.65738; // neg deut mean curve deut_curves[1][0][1] = 0.115151; deut_curves[1][0][2] = 0.918566; deut_curves[1][1][0] = 0.0986592; // neg deut sigma curve deut_curves[1][1][1] = 0.0187545; deut_curves[1][1][2] = 0.00346519; fAnalysisUtils = new AliAnalysisUtils; fOutputList = new TList(); // this is a list which will contain all of your histograms // at the end of the analysis, the contents of this list are written // to the output file fOutputList->SetOwner(kTRUE); // memory stuff: the list is owner of all objects it contains and will delete them // if requested (dont worry about this now) /* Double_t pt_binning[2001]; Float_t moving_marker = 0.10; for(int i=0; i<1202; i++) { pt_binning[i] = moving_marker; moving_marker = moving_marker + pt_binning[i] * 0.005; } */ float lower = -pio2; float upper = 3.0*pio2; Double_t pt_binning[2001]; Float_t moving_marker = 0.10; for(int i=0; i<1202; i++) { pt_binning[i] = moving_marker; moving_marker = moving_marker + pt_binning[i] * 0.005; } fHistPt = new TH1F("fHistPt", "Pt()", 50, 0.0, 5.0); // 1 cent_ntracks = new TH2F("cent_ntracks", "cent_ntracks", 100, 0, 100, 100, 0, 800); // 2 m2_pt_pos = new TH2F("m2_pt_pos", "m2_pt_pos", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 3 m2_pt_neg = new TH2F("m2_pt_neg", "m2_pt_neg", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 4 beta_p_pos = new TH2F("beta_p_pos", "beta_p_pos", 50, 0.0, 5.0, 3000, 0.1, 1.1); // 5 beta_p_neg = new TH2F("beta_p_neg", "beta_p_neg", 50, 0.0, 5.0, 3000, 0.1, 1.1); // 6 deltat_pt_pos = new TH2F("deltat_pt_pos", "deltat_pt_pos", 50, 0.0, 5.0, 2500, -1.0, 24.0); // 7 deltat_pt_neg = new TH2F("deltat_pt_neg", "deltat_pt_neg", 50, 0.0, 5.0, 2500, -1.0, 24.0); // 8 m2_pt_pos_cut = new TH2F("m2_pt_pos_cut", "m2_pt_pos_cut", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 9 m2_pt_neg_cut = new TH2F("m2_pt_neg_cut", "m2_pt_neg_cut", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 10 beta_p_pos_cut = new TH2F("beta_p_pos_cut", "beta_p_pos_cut", 50, 0.0, 5.0, 3000, 0.1, 1.1); // 11 beta_p_neg_cut = new TH2F("beta_p_neg_cut", "beta_p_neg_cut", 50, 0.0, 5.0, 3000, 0.1, 1.1); // 12 deltat_pt_pos_cut = new TH2F("deltat_pt_pos_cut", "deltat_pt_pos_cut", 50, 0.0, 5.0, 2500, -1.0, 24.0); // 13 deltat_pt_neg_cut = new TH2F("deltat_pt_neg_cut", "deltat_pt_neg_cut", 50, 0.0, 5.0, 2500, -1.0, 24.0); // 14 m2_pt_pos_cut_T = new TH2F("m2_pt_pos_cut_T", "m2_pt_pos_cut_T", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 15 m2_pt_neg_cut_T = new TH2F("m2_pt_neg_cut_T", "m2_pt_neg_cut_T", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 16 m2_pt_pos_cut_G = new TH2F("m2_pt_pos_cut_G", "m2_pt_pos_cut_G", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 17 m2_pt_neg_cut_G = new TH2F("m2_pt_neg_cut_G", "m2_pt_neg_cut_G", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 18 m2_pt_pos_cut_A = new TH2F("m2_pt_pos_cut_A", "m2_pt_pos_cut_A", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 19 m2_pt_neg_cut_A = new TH2F("m2_pt_neg_cut_A", "m2_pt_neg_cut_A", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 20 m2_pt_pos_cut_B = new TH2F("m2_pt_pos_cut_B", "m2_pt_pos_cut_B", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 21 m2_pt_neg_cut_B = new TH2F("m2_pt_neg_cut_B", "m2_pt_neg_cut_B", 50, 0.0, 5.0, 2400, -1.0, 7.0); // 22 deut_phi_pt_pos_T = new TH2F("deut_phi_pt_pos_T", "deut_phi_pt_pos_T", 50, 0.0, 5.0, 288, lower, upper); // 23 deut_phi_pt_neg_T = new TH2F("deut_phi_pt_neg_T", "deut_phi_pt_neg_T", 50, 0.0, 5.0, 288, lower, upper); // 24 deut_phi_pt_pos_A = new TH2F("deut_phi_pt_pos_A", "deut_phi_pt_pos_A", 50, 0.0, 5.0, 288, lower, upper); // 25 deut_phi_pt_neg_A = new TH2F("deut_phi_pt_neg_A", "deut_phi_pt_neg_A", 50, 0.0, 5.0, 288, lower, upper); // 26 deut_phi_pt_pos_B = new TH2F("deut_phi_pt_pos_B", "deut_phi_pt_pos_B", 50, 0.0, 5.0, 288, lower, upper); // 27 deut_phi_pt_neg_B = new TH2F("deut_phi_pt_neg_B", "deut_phi_pt_neg_B", 50, 0.0, 5.0, 288, lower, upper); // 28 deut_per_event = new TH1I("deut_per_event", "deut_per_event", 12, 0, 12); // 29 trig_03_per_event = new TH1I("trig_03_per_event", "trig_03_per_event", 20, 0, 20); // 30 trig_05_per_event = new TH1I("trig_05_per_event", "trig_05_per_event", 20, 0, 20); // 31 trig_08_per_event = new TH1I("trig_08_per_event", "trig_08_per_event", 20, 0, 20); // 32 trig_03_phi_pt_pos = new TH2F("trig_03_phi_pt_pos", "trig_03_phi_pt_pos", 170, 3.0, 20.0, 288, lower, upper); // 33 trig_03_phi_pt_neg = new TH2F("trig_03_phi_pt_neg", "trig_03_phi_pt_neg", 170, 3.0, 20.0, 288, lower, upper); // 34 trig_05_phi_pt_pos = new TH2F("trig_05_phi_pt_pos", "trig_05_phi_pt_pos", 170, 3.0, 20.0, 288, lower, upper); // 35 trig_05_phi_pt_neg = new TH2F("trig_05_phi_pt_neg", "trig_05_phi_pt_neg", 170, 3.0, 20.0, 288, lower, upper); // 36 trig_08_phi_pt_pos = new TH2F("trig_08_phi_pt_pos", "trig_08_phi_pt_pos", 170, 3.0, 20.0, 288, lower, upper); // 37 trig_08_phi_pt_neg = new TH2F("trig_08_phi_pt_neg", "trig_08_phi_pt_neg", 170, 3.0, 20.0, 288, lower, upper); // 38 tof_phi_eta_pos = new TH2F("tof_phi_eta_pos", "tof_phi_eta_pos", 190,lower,upper, 60, -0.92, 0.92); // 39 tof_phi_eta_neg = new TH2F("tof_phi_eta_neg", "tof_phi_eta_neg", 190,lower,upper, 60, -0.92, 0.92); // 40 tof_phi_eta_pos_deut = new TH2F("tof_phi_eta_pos_deut", "tof_phi_eta_pos_deut", 190,lower,upper, 60, -0.92, 0.92); // 41 tof_phi_eta_neg_deut = new TH2F("tof_phi_eta_neg_deut", "tof_phi_eta_neg_deut", 190,lower,upper, 60, -0.92, 0.92); // 42 deut_pt_compare_pos = new TH1F("deut_pt_compare_pos", "deut_pt_compare_pos", 100, -0.2, 0.2); // 43 deut_pt_compare_neg = new TH1F("deut_pt_compare_neg", "deut_pt_compare_neg", 100, -0.2, 0.2); // 44 tpc_sector_fraction = new TH1F("tpc_sector_fraction", "tpc_sector_fraction", 100, 0.0, 1.0); // 45 primary_vertex_z = new TH1F("primary_vertex_z", "primary_vertex_z", 400,-20.0, 20.0); // 46 primary_vertex_z_cut = new TH1F("primary_vertex_z_cut", "primary_vertex_z_cut", 400,-20.0, 20.0); // 47 deut_dphi_pt_pos_pos_03_T = new TH2F("deut_dphi_pt_pos_pos_03_T", "deut_dphi_pt_pos_pos_03_T", 50, 0.0, 5.0, 288, lower, upper); // 48 deut_dphi_pt_pos_neg_03_T = new TH2F("deut_dphi_pt_pos_neg_03_T", "deut_dphi_pt_pos_neg_03_T", 50, 0.0, 5.0, 288, lower, upper); // 49 deut_dphi_pt_neg_neg_03_T = new TH2F("deut_dphi_pt_neg_neg_03_T", "deut_dphi_pt_neg_neg_03_T", 50, 0.0, 5.0, 288, lower, upper); // 50 deut_dphi_pt_pos_pos_05_T = new TH2F("deut_dphi_pt_pos_pos_05_T", "deut_dphi_pt_pos_pos_05_T", 50, 0.0, 5.0, 288, lower, upper); // 51 deut_dphi_pt_pos_neg_05_T = new TH2F("deut_dphi_pt_pos_neg_05_T", "deut_dphi_pt_pos_neg_05_T", 50, 0.0, 5.0, 288, lower, upper); // 52 deut_dphi_pt_neg_neg_05_T = new TH2F("deut_dphi_pt_neg_neg_05_T", "deut_dphi_pt_neg_neg_05_T", 50, 0.0, 5.0, 288, lower, upper); // 53 deut_dphi_pt_pos_pos_08_T = new TH2F("deut_dphi_pt_pos_pos_08_T", "deut_dphi_pt_pos_pos_08_T", 50, 0.0, 5.0, 288, lower, upper); // 54 deut_dphi_pt_pos_neg_08_T = new TH2F("deut_dphi_pt_pos_neg_08_T", "deut_dphi_pt_pos_neg_08_T", 50, 0.0, 5.0, 288, lower, upper); // 55 deut_dphi_pt_neg_neg_08_T = new TH2F("deut_dphi_pt_neg_neg_08_T", "deut_dphi_pt_neg_neg_08_T", 50, 0.0, 5.0, 288, lower, upper); // 56 deut_dphi_pt_pos_pos_03_A = new TH2F("deut_dphi_pt_pos_pos_03_A", "deut_dphi_pt_pos_pos_03_A", 50, 0.0, 5.0, 288, lower, upper); // 57 deut_dphi_pt_pos_neg_03_A = new TH2F("deut_dphi_pt_pos_neg_03_A", "deut_dphi_pt_pos_neg_03_A", 50, 0.0, 5.0, 288, lower, upper); // 58 deut_dphi_pt_neg_neg_03_A = new TH2F("deut_dphi_pt_neg_neg_03_A", "deut_dphi_pt_neg_neg_03_A", 50, 0.0, 5.0, 288, lower, upper); // 59 deut_dphi_pt_pos_pos_05_A = new TH2F("deut_dphi_pt_pos_pos_05_A", "deut_dphi_pt_pos_pos_05_A", 50, 0.0, 5.0, 288, lower, upper); // 60 deut_dphi_pt_pos_neg_05_A = new TH2F("deut_dphi_pt_pos_neg_05_A", "deut_dphi_pt_pos_neg_05_A", 50, 0.0, 5.0, 288, lower, upper); // 61 deut_dphi_pt_neg_neg_05_A = new TH2F("deut_dphi_pt_neg_neg_05_A", "deut_dphi_pt_neg_neg_05_A", 50, 0.0, 5.0, 288, lower, upper); // 62 deut_dphi_pt_pos_pos_08_A = new TH2F("deut_dphi_pt_pos_pos_08_A", "deut_dphi_pt_pos_pos_08_A", 50, 0.0, 5.0, 288, lower, upper); // 63 deut_dphi_pt_pos_neg_08_A = new TH2F("deut_dphi_pt_pos_neg_08_A", "deut_dphi_pt_pos_neg_08_A", 50, 0.0, 5.0, 288, lower, upper); // 64 deut_dphi_pt_neg_neg_08_A = new TH2F("deut_dphi_pt_neg_neg_08_A", "deut_dphi_pt_neg_neg_08_A", 50, 0.0, 5.0, 288, lower, upper); // 65 deut_dphi_pt_pos_pos_03_B = new TH2F("deut_dphi_pt_pos_pos_03_B", "deut_dphi_pt_pos_pos_03_B", 50, 0.0, 5.0, 288, lower, upper); // 66 deut_dphi_pt_pos_neg_03_B = new TH2F("deut_dphi_pt_pos_neg_03_B", "deut_dphi_pt_pos_neg_03_B", 50, 0.0, 5.0, 288, lower, upper); // 67 deut_dphi_pt_neg_neg_03_B = new TH2F("deut_dphi_pt_neg_neg_03_B", "deut_dphi_pt_neg_neg_03_B", 50, 0.0, 5.0, 288, lower, upper); // 68 deut_dphi_pt_pos_pos_05_B = new TH2F("deut_dphi_pt_pos_pos_05_B", "deut_dphi_pt_pos_pos_05_B", 50, 0.0, 5.0, 288, lower, upper); // 69 deut_dphi_pt_pos_neg_05_B = new TH2F("deut_dphi_pt_pos_neg_05_B", "deut_dphi_pt_pos_neg_05_B", 50, 0.0, 5.0, 288, lower, upper); // 70 deut_dphi_pt_neg_neg_05_B = new TH2F("deut_dphi_pt_neg_neg_05_B", "deut_dphi_pt_neg_neg_05_B", 50, 0.0, 5.0, 288, lower, upper); // 71 deut_dphi_pt_pos_pos_08_B = new TH2F("deut_dphi_pt_pos_pos_08_B", "deut_dphi_pt_pos_pos_08_B", 50, 0.0, 5.0, 288, lower, upper); // 72 deut_dphi_pt_pos_neg_08_B = new TH2F("deut_dphi_pt_pos_neg_08_B", "deut_dphi_pt_pos_neg_08_B", 50, 0.0, 5.0, 288, lower, upper); // 73 deut_dphi_pt_neg_neg_08_B = new TH2F("deut_dphi_pt_neg_neg_08_B", "deut_dphi_pt_neg_neg_08_B", 50, 0.0, 5.0, 288, lower, upper); // 74 DCAxy_pos = new TH1F("DCAxy_pos", "DCAxy_pos", 100, -3.0, 3.0); // 75 DCAxy_neg = new TH1F("DCAxy_neg", "DCAxy_neg", 100, -3.0, 3.0); // 76 DCAz_pos = new TH1F("DCAz_pos", "DCAz_pos", 100, -3.0, 3.0); // 77 DCAz_neg = new TH1F("DCAz_neg", "DCAz_neg", 100, -3.0, 3.0); // 78 m2_pt_pos_fine = new TH2F("m2_pt_pos_fine", "m2_pt_pos_fine", 800,pt_binning, 2400, -1.0, 7.0); // 79 m2_pt_neg_fine = new TH2F("m2_pt_neg_fine", "m2_pt_neg_fine", 800,pt_binning, 2400, -1.0, 7.0); // 80 m2_pt_pos_cut_fine = new TH2F("m2_pt_pos_cut_fine", "m2_pt_pos_cut_fine", 800,pt_binning, 2400, -1.0, 7.0); // 79 m2_pt_neg_cut_fine = new TH2F("m2_pt_neg_cut_fine", "m2_pt_neg_cut_fine", 800,pt_binning, 2400, -1.0, 7.0); // 80 m2_pt_pos_cut_T_fine = new TH2F("m2_pt_pos_cut_T_fine", "m2_pt_pos_cut_T_fine", 800,pt_binning, 2400, -1.0, 7.0); // 79 m2_pt_neg_cut_T_fine = new TH2F("m2_pt_neg_cut_T_fine", "m2_pt_neg_cut_T_fine", 800,pt_binning, 2400, -1.0, 7.0); // 80 // deut_eta_vs_phi_pos = new TH2F("deut_eta_vs_phi_pos", "deut_eta_vs_phi_pos", 300, lower, upper, 150, -0.82, 0.82); // 50 // deut_eta_vs_phi_neg = new TH2F("deut_eta_vs_phi_neg", "deut_eta_vs_phi_neg", 300, lower, upper, 150, -0.82, 0.82); // 50 // objects added to output file fOutputList->Add(fHistPt); // 1 fOutputList->Add(cent_ntracks); // 2 fOutputList->Add(m2_pt_pos); // 3 fOutputList->Add(m2_pt_neg); // 4 fOutputList->Add(beta_p_pos); // 5 fOutputList->Add(beta_p_neg); // 6 fOutputList->Add(deltat_pt_pos); // 7 fOutputList->Add(deltat_pt_neg); // 8 fOutputList->Add(m2_pt_pos_cut); // 9 fOutputList->Add(m2_pt_neg_cut); // 10 fOutputList->Add(beta_p_pos_cut); // 11 fOutputList->Add(beta_p_neg_cut); // 12 fOutputList->Add(deltat_pt_pos_cut); // 13 fOutputList->Add(deltat_pt_neg_cut); // 14 fOutputList->Add(m2_pt_pos_cut_T); // 15 fOutputList->Add(m2_pt_neg_cut_T); // 16 fOutputList->Add(m2_pt_pos_cut_G); // 17 fOutputList->Add(m2_pt_neg_cut_G); // 18 fOutputList->Add(m2_pt_pos_cut_A); // 19 fOutputList->Add(m2_pt_neg_cut_A); // 20 fOutputList->Add(m2_pt_pos_cut_B); // 21 fOutputList->Add(m2_pt_neg_cut_B); // 22 fOutputList->Add(deut_phi_pt_pos_T); // 23 fOutputList->Add(deut_phi_pt_neg_T); // 24 fOutputList->Add(deut_phi_pt_pos_A); // 25 fOutputList->Add(deut_phi_pt_neg_A); // 26 fOutputList->Add(deut_phi_pt_pos_B); // 27 fOutputList->Add(deut_phi_pt_neg_B); // 28 fOutputList->Add(deut_per_event); // 29 fOutputList->Add(trig_03_per_event); // 30 fOutputList->Add(trig_05_per_event); // 31 fOutputList->Add(trig_08_per_event); // 32 fOutputList->Add(trig_03_phi_pt_pos); // 33 fOutputList->Add(trig_03_phi_pt_neg); // 34 fOutputList->Add(trig_05_phi_pt_pos); // 35 fOutputList->Add(trig_05_phi_pt_neg); // 36 fOutputList->Add(trig_08_phi_pt_pos); // 37 fOutputList->Add(trig_08_phi_pt_neg); // 38 fOutputList->Add(tof_phi_eta_pos); // 39 fOutputList->Add(tof_phi_eta_neg); // 40 fOutputList->Add(tof_phi_eta_pos_deut); // 41 fOutputList->Add(tof_phi_eta_neg_deut); // 42 fOutputList->Add(deut_pt_compare_pos); // 43 fOutputList->Add(deut_pt_compare_neg); // 44 fOutputList->Add(tpc_sector_fraction); // 45 fOutputList->Add(primary_vertex_z); // 46 fOutputList->Add(primary_vertex_z_cut); // 47 fOutputList->Add(deut_dphi_pt_pos_pos_03_T); // 48 fOutputList->Add(deut_dphi_pt_pos_neg_03_T); // 49 fOutputList->Add(deut_dphi_pt_neg_neg_03_T); // 50 fOutputList->Add(deut_dphi_pt_pos_pos_05_T); // 51 fOutputList->Add(deut_dphi_pt_pos_neg_05_T); // 52 fOutputList->Add(deut_dphi_pt_neg_neg_05_T); // 53 fOutputList->Add(deut_dphi_pt_pos_pos_08_T); // 54 fOutputList->Add(deut_dphi_pt_pos_neg_08_T); // 55 fOutputList->Add(deut_dphi_pt_neg_neg_08_T); // 56 fOutputList->Add(deut_dphi_pt_pos_pos_03_A); // 57 fOutputList->Add(deut_dphi_pt_pos_neg_03_A); // 58 fOutputList->Add(deut_dphi_pt_neg_neg_03_A); // 59 fOutputList->Add(deut_dphi_pt_pos_pos_05_A); // 60 fOutputList->Add(deut_dphi_pt_pos_neg_05_A); // 61 fOutputList->Add(deut_dphi_pt_neg_neg_05_A); // 62 fOutputList->Add(deut_dphi_pt_pos_pos_08_A); // 63 fOutputList->Add(deut_dphi_pt_pos_neg_08_A); // 64 fOutputList->Add(deut_dphi_pt_neg_neg_08_A); // 65 fOutputList->Add(deut_dphi_pt_pos_pos_03_B); // 66 fOutputList->Add(deut_dphi_pt_pos_neg_03_B); // 67 fOutputList->Add(deut_dphi_pt_neg_neg_03_B); // 68 fOutputList->Add(deut_dphi_pt_pos_pos_05_B); // 69 fOutputList->Add(deut_dphi_pt_pos_neg_05_B); // 70 fOutputList->Add(deut_dphi_pt_neg_neg_05_B); // 71 fOutputList->Add(deut_dphi_pt_pos_pos_08_B); // 72 fOutputList->Add(deut_dphi_pt_pos_neg_08_B); // 73 fOutputList->Add(deut_dphi_pt_neg_neg_08_B); // 74 fOutputList->Add(DCAxy_pos); // 75 fOutputList->Add(DCAxy_neg); // 76 fOutputList->Add(DCAz_pos); // 77 fOutputList->Add(DCAz_neg); // 78 fOutputList->Add(m2_pt_pos_fine); // 79 fOutputList->Add(m2_pt_neg_fine); // 80 fOutputList->Add(m2_pt_pos_cut_fine); // 81 fOutputList->Add(m2_pt_neg_cut_fine); // 82 fOutputList->Add(m2_pt_pos_cut_T_fine); // 83 fOutputList->Add(m2_pt_neg_cut_T_fine); // 84 // fOutputList->Add(trigger_selection); // 40 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager(); //// added by Brennan AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); //// added by Brennan fPIDResponse = inputHandler->GetPIDResponse(); //// added by Brennan // fPIDResponse->SetRecoPass(1); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// PostData(1, fOutputList); } //_____________________________________________________________________________ void AliAnalysisTaskCorPIDTOFdeut::UserExec(Option_t *) { fAOD = dynamic_cast<AliAODEvent*>(InputEvent()); if(!fAOD) return; // int x=5; // std::cout<<std::bitset<32>(x)<<std::endl; // // ULong64_t mask = AliVEvent::kEMCEJE; // ULong64_t anded = trigger & mask; // // else cout<<"false "; // cout<<endl; // cout<<"Trigger mask is: "<<trigger<<" "<<mask<<" "<<anded<<endl; // cout<<std::bitset<64>(trigger)<<" & "<<std::bitset<64>(mask)<<" = "<<std::bitset<64>(anded)<<endl; // task->SetTriggerMask(AliVEvent::kEMCEGA); // cout<<"Trigger is: "<<fAOD->GetFiredTriggerClasses()<<endl<<endl; // cout<<"Trigger is: "<<fAOD->GetEventType()<<endl<<endl; // if(TString(fAOD->GetFiredTriggerClasses()).Contains("CINT7"))// return; // { // ULong64_t trigger = fAOD->GetTriggerMask(); // ULong64_t mask = AliVEvent::kMB; // ULong64_t anded = trigger & mask; // cout<<std::bitset<64>(trigger)<<" & "<<std::bitset<64>(mask)<<" = "<<std::bitset<64>(anded)<<endl; // if(trigger & mask ? 1:0) ; // else return; // cout<<std::bitset<64>(trigger)<<endl; // ULong64_t iTrig = 1; // for(int i=0; i<64; i++) // { // int i = iTrig; // long j = iTrig; // cout<<iTrig<<" "; // if(i==15 || i==31){ } // else { // if(trigger & iTrig ? 1:0) trigger_selection->Fill(i);// } // ULong64_t anded = trigger & iTrig; // cout<<std::bitset<64>(trigger)<<" & "<<std::bitset<64>(iTrig)<<" = "<<std::bitset<64>(anded)<<endl; // iTrig = iTrig * 2; // } // cout<<endl; // cout<<endl<<endl<<endl; // } if(fInputHandler->IsEventSelected() & AliVEvent::kINT7) ; else return; // count 7208 const AliAODVertex *primVertex = fAOD->GetPrimaryVertex(); Double_t pv = primVertex->GetZ(); primary_vertex_z->Fill(pv); if(!fAnalysisUtils->IsVertexSelected2013pA(fAOD)) return; // if(TMath::Abs(pv) > 10.) return; // handled in IsVertexSelected2013pA primary_vertex_z_cut->Fill(pv); // count 6983 if(fAnalysisUtils->IsPileUpSPD(fAOD)) return; // count !-187 Int_t iTracks(fAOD->GetNumberOfTracks()); cent_ntracks->Fill(50.0, iTracks); /* if(!TString(fAOD->GetFiredTriggerClasses()).Contains("DG1") && !TString(fAOD->GetFiredTriggerClasses()).Contains("DJ1") && !TString(fAOD->GetFiredTriggerClasses()).Contains("EG1") && !TString(fAOD->GetFiredTriggerClasses()).Contains("EJ1") && !TString(fAOD->GetFiredTriggerClasses()).Contains("DG2") && !TString(fAOD->GetFiredTriggerClasses()).Contains("DJ2") && !TString(fAOD->GetFiredTriggerClasses()).Contains("EG2") && !TString(fAOD->GetFiredTriggerClasses()).Contains("EJ2") ) return; */ // cout<<fAOD->GetFiredTriggerClasses()<<endl<<endl; //////////////////////////////////////// MULTIPLICITY PART //////////////////////////////////////// // cent_ntracks->Fill(fAOD->GetCentrality()->GetCentralityPercentile("V0A"), iTracks); /////////////////////////////////////////////////////////////////////////////////////////////////// int deut_track_num_T[100]; int deut_count_T = 0; int deut_track_num_A[100]; int deut_count_A = 0; int deut_track_num_B[100]; int deut_count_B = 0; int trig_03_track_num[100]; int trig_03_track_count = 0; int trig_05_track_num[100]; int trig_05_track_count = 0; int trig_08_track_num[100]; int trig_08_track_count = 0; // loop over all these tracks // // pull out track numbers for high-pt triggers and also deutons Float_t max_03_pt = 0.0; Int_t max_03 = 0; Float_t max_05_pt = 0.0; Int_t max_05 = 0; Float_t max_08_pt = 0.0; Int_t max_08 = 0; for(Int_t i(0); i < iTracks; i++) { AliAODTrack* track = static_cast<AliAODTrack*>(fAOD->GetTrack(i)); if(!track) { continue; } if(!(track->IsHybridGlobalConstrainedGlobal())) { continue; } // if(!track->IsGlobalConstrained()) { continue; } // if(!track->IsTPCConstrained()) { continue; } // if(!track->IsPrimaryCandidate()) { continue; } Float_t pt = track->Pt(); // if(pt < 0.2) { continue; } if(pt < 0.95) { continue; } // makes for fast processings, low momentum play no part of analysis anyway Float_t dedx = track->GetTPCsignal(); if(dedx > 1000) { continue; } Float_t eta = track->Eta(); if(TMath::Abs(eta) > 0.9) { continue; } Float_t phi = track->Phi(); if(phi < -pio2){ phi = phi + twopi; } if(phi < -pio2){ phi = phi + twopi; } if(phi > 3*pio2){ phi = phi - twopi; } if(phi > 3*pio2){ phi = phi - twopi; } Float_t fraction = 0.0; fraction = track->GetTPCFoundFraction(); tpc_sector_fraction->Fill(fraction); fHistPt->Fill(pt); // markA if(pt >= 3.0) { trig_03_track_num[trig_03_track_count] = i; if(pt>max_03_pt){ max_03_pt = pt; max_03 = trig_03_track_count; } trig_03_track_count++; } if(pt >= 5.0) { trig_05_track_num[trig_05_track_count] = i; if(pt>max_05_pt){ max_05_pt = pt; max_05 = trig_05_track_count; } trig_05_track_count++; } if(pt >= 8.0) { trig_08_track_num[trig_08_track_count] = i; if(pt>max_08_pt){ max_08_pt = pt; max_08 = trig_08_track_count; } trig_08_track_count++; } Short_t charge = track->Charge(); if(pt >= 3.0) { if(charge > 0) trig_03_phi_pt_pos->Fill(pt, phi); else if(charge < 0) trig_03_phi_pt_neg->Fill(pt, phi); } if(pt >= 5.0) { if(charge > 0) trig_05_phi_pt_pos->Fill(pt, phi); else if(charge < 0) trig_05_phi_pt_neg->Fill(pt, phi); } if(pt >= 8.0) { if(charge > 0) trig_08_phi_pt_pos->Fill(pt, phi); else if(charge < 0) trig_08_phi_pt_neg->Fill(pt, phi); } // if(!(track->IsHybridGlobalConstrainedGlobal())) { continue; } Double_t nsigmaTPC = 999.0; Double_t nsigmaTOF = 999.0; AliPIDResponse::EDetPidStatus statusTPC = fPIDResponse->NumberOfSigmas(AliPIDResponse::kTPC, track, (AliPID::EParticleType) 0, nsigmaTPC); AliPIDResponse::EDetPidStatus statusTOF = fPIDResponse->NumberOfSigmas(AliPIDResponse::kTOF, track, (AliPID::EParticleType) 0, nsigmaTOF); Bool_t tpcIsOk = (statusTPC == AliPIDResponse::kDetPidOk); /* && trk->IsOn(AliESDtrack::kTPCpid)*/; Bool_t tofIsOk = (statusTOF == AliPIDResponse::kDetPidOk); if(!tpcIsOk) { continue; } if(!tofIsOk) { continue; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* // Kalweit and Sharma cuts AliExternalTrackParam trkparam; trkparam.CopyFromVTrack(track); if(trkparam.GetX() > 3.) { continue; } // only valid for propagation inside the beam pipe // dca->Fill(dcaxy, dcaz); Short_t nTPCclusters = track->GetTPCsignalN(); if(nTPCclusters<70) { continue; } // cut a Float_t fraction = 0.0; fraction = track->GetTPCFoundFraction(); tpc_sector_fraction->Fill(fraction); if(fraction < 0.8) { continue; } // cut b // if(this->GetNTPCXRowsOverFindable(trk)< 0.8 ) return kFALSE; fHistPt->Fill(pt); UChar_t map = track->GetITSClusterMap(); Int_t nITSpoints = 0; for(Int_t j=2; j<6; j++) { if(map&(1<<j)) ++nITSpoints; } if(nITSpoints < 2) { continue; } // */ /* // if(fAOD->IsKinkDaughter(track)) { continue; } // cut d AliAODVertex* vtx = track->GetProdVertex(); if(vtx == 0) { continue; } // cut d if(vtx->GetType() == AliAODVertex::kKink) { continue; } // cut d if(!track->IsOn(AliAODTrack::kTPCrefit)) { continue; } // cut e if(!track->IsOn(AliAODTrack::kITSrefit)) { continue; } // cut f // if(track->GetITSchi2PerCluster()>36) { continue; } // cut k // Double_t b[2]; // Double_t bCov[3]; // if(!trkparam.PropagateToDCA(fAOD->GetPrimaryVertex(), fAOD->GetMagneticField(), 10000., b, bCov)) continue; // Double_t dcaxy = b[0]; // Double_t dcaz = b[1]; // if(fabs(dcaxy) > 3.0) { continue; } // if(fabs(dcaz) > 2.0) { continue; } // cut h Double_t dca[2]; // 0 - dcar, 1 - dcaz -> output parameter Double_t cov[3]; // covariance matrix -> output parameter Double_t kmaxd = 10000.0; // something big AliExternalTrackParam param; param.CopyFromVTrack(track); if(!param.PropagateToDCA(fAOD->GetPrimaryVertex(), fAOD->GetMagneticField(), kmaxd, dca, cov)) continue; // don’t accept tracks for which the DCA fit failed. if(fabs(dca[0]) > 3.0) { continue; } if(fabs(dca[1]) > 2.0) { continue; } */ // if(!(track->IsHybridGlobalConstrainedGlobal())) { continue; } Double_t dca[2]; // 0 - dcar, 1 - dcaz -> output parameter Double_t cov[3]; // covariance matrix -> output parameter Double_t kmaxd = 10000.0; // something big AliExternalTrackParam param; param.CopyFromVTrack(track); if(!param.PropagateToDCA(fAOD->GetPrimaryVertex(), fAOD->GetMagneticField(), kmaxd, dca, cov)) continue; // don’t accept tracks for which the DCA fit failed. // if(fabs(dca[0]) > 3.0) { continue; } // if(fabs(dca[1]) > 2.0) { continue; } int is_global = 0; if(!track->IsGlobalConstrained()) { is_global=1; } Float_t deltat = tof_minus_tpion(track); float mom = track->P(); Float_t deut_mean = 0.0; Float_t deut_sigma = 0.0; Float_t m2tof = get_mass_squared(track); Float_t beta = 0.0; beta = Beta(track); if(charge > 0) { m2_pt_pos ->Fill(pt, m2tof); m2_pt_pos_fine ->Fill(pt, m2tof); beta_p_pos ->Fill(mom, Beta(track)); deltat_pt_pos ->Fill(pt, deltat); if(pt >= 1.0 && pt < 2.0) tof_phi_eta_pos->Fill(phi, eta); Double_t nSigmaTPCDeut = fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)5); // 5 = deuteron if(TMath::Abs(nSigmaTPCDeut) < 3.0) { m2_pt_pos_cut ->Fill(pt, m2tof); m2_pt_pos_cut_fine->Fill(pt, m2tof); beta_p_pos_cut ->Fill(mom, Beta(track)); deltat_pt_pos_cut ->Fill(pt, deltat); if(pt >= 1.0 && pt < 4.4) { for(int w=0; w<3; w++){ fit_deut_curve->SetParameter(w, deut_curves[0][0][w]); } deut_mean = fit_deut_curve->Eval(pt); for(int w=0; w<3; w++){ fit_deut_curve->SetParameter(w, deut_curves[0][1][w]); } deut_sigma = fit_deut_curve->Eval(pt); if(m2tof < deut_mean + cut_width * deut_sigma && m2tof > deut_mean - cut_width * deut_sigma) { deut_track_num_T[deut_count_T] = i; deut_count_T++; m2_pt_pos_cut_T->Fill(pt,m2tof); m2_pt_pos_cut_T_fine->Fill(pt,m2tof); DCAxy_pos->Fill(dca[0]); DCAz_pos->Fill(dca[1]); if(pt >= 1.00 && pt < 2.00){ tof_phi_eta_pos_deut->Fill(phi, eta); } if(pt >= 1.00 && pt < 1.25){ deut_pt_compare_pos->Fill(pt - get_deut_tof_pt(track)); } Float_t deut_phi = track->Phi(); if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } deut_phi_pt_pos_T->Fill(pt, deut_phi); } if(m2tof < deut_mean + 3.0 * deut_sigma && m2tof > deut_mean - 3.0 * deut_sigma) { if(is_global == 1) { m2_pt_pos_cut_G->Fill(pt,m2tof); } } if(m2tof +1.2< deut_mean + cut_width * deut_sigma && m2tof +1.2> deut_mean - cut_width * deut_sigma) { deut_track_num_A[deut_count_A] = i; deut_count_A++; m2_pt_pos_cut_A->Fill(pt,m2tof); Float_t deut_phi = track->Phi(); if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } deut_phi_pt_pos_A->Fill(pt, deut_phi); } if(m2tof -1.2< deut_mean + cut_width * deut_sigma && m2tof -1.2> deut_mean - cut_width * deut_sigma) { deut_track_num_B[deut_count_A] = i; deut_count_B++; m2_pt_pos_cut_B->Fill(pt,m2tof); Float_t deut_phi = track->Phi(); if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } deut_phi_pt_pos_B->Fill(pt, deut_phi); } } } } // end of pos charge if statement else if(charge < 0) { m2_pt_neg ->Fill(pt, m2tof); m2_pt_neg_fine ->Fill(pt, m2tof); beta_p_neg ->Fill(mom, Beta(track)); deltat_pt_neg ->Fill(pt, deltat); if(pt >= 1.0 && pt < 2.0) tof_phi_eta_neg->Fill(phi, eta); Double_t nSigmaTPCDeut = fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)5); // 5 = deuteron if(TMath::Abs(nSigmaTPCDeut) < 3.0) { m2_pt_neg_cut ->Fill(pt, m2tof); m2_pt_neg_cut_fine->Fill(pt, m2tof); beta_p_neg_cut ->Fill(mom, Beta(track)); deltat_pt_neg_cut ->Fill(pt, deltat); if(pt >= 1.0 && pt < 4.4) { for(int w=0; w<3; w++){ fit_deut_curve->SetParameter(w, deut_curves[1][0][w]); } deut_mean = fit_deut_curve->Eval(pt); for(int w=0; w<3; w++){ fit_deut_curve->SetParameter(w, deut_curves[1][1][w]); } deut_sigma = fit_deut_curve->Eval(pt); if(m2tof < deut_mean + cut_width * deut_sigma && m2tof > deut_mean - cut_width * deut_sigma) { deut_track_num_T[deut_count_T] = i; deut_count_T++; m2_pt_neg_cut_T->Fill(pt,m2tof); m2_pt_neg_cut_T_fine->Fill(pt,m2tof); DCAxy_neg->Fill(dca[0]); DCAz_neg->Fill(dca[1]); if(pt >= 1.00 && pt < 2.00){ tof_phi_eta_neg_deut->Fill(phi, eta); } if(pt >= 1.00 && pt < 1.25){ deut_pt_compare_neg->Fill(pt - get_deut_tof_pt(track)); } Float_t deut_phi = track->Phi(); if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } deut_phi_pt_neg_T->Fill(pt, deut_phi); } if(m2tof < deut_mean + 3.0 * deut_sigma && m2tof > deut_mean - 3.0 * deut_sigma) { if(is_global == 1) { m2_pt_neg_cut_G->Fill(pt,m2tof); } } if(m2tof +1.2< deut_mean + cut_width * deut_sigma && m2tof +1.2> deut_mean - cut_width * deut_sigma) { deut_track_num_A[deut_count_A] = i; deut_count_A++; m2_pt_neg_cut_A->Fill(pt,m2tof); Float_t deut_phi = track->Phi(); if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } deut_phi_pt_neg_A->Fill(pt, deut_phi); } if(m2tof -1.2< deut_mean + cut_width * deut_sigma && m2tof -1.2> deut_mean - cut_width * deut_sigma) { deut_track_num_B[deut_count_B] = i; deut_count_B++; m2_pt_neg_cut_B->Fill(pt,m2tof); Float_t deut_phi = track->Phi(); if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi < -pio2){ deut_phi = deut_phi + twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } if(deut_phi > 3*pio2){ deut_phi = deut_phi - twopi; } deut_phi_pt_neg_B->Fill(pt, deut_phi); } } } } // end of neg charge if statement } // end of track loop deut_per_event->Fill(deut_count_T); if(trig_03_track_count > 0) { trig_03_per_event->Fill(trig_03_track_count); } if(trig_05_track_count > 0) { trig_05_per_event->Fill(trig_05_track_count); } if(trig_08_track_count > 0) { trig_08_per_event->Fill(trig_08_track_count); } // markB int begin = 0; if(deut_count_T > 0 && trig_03_track_count > 0 && do_lead_only == 1) { begin = max_03; trig_03_track_count = max_03 + 1; } if(deut_count_T > 0 && trig_03_track_count > 0) { for(int i=begin; i<trig_03_track_count; i++) // trigger loop { int H = trig_03_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_T; j++) { int A = deut_track_num_T[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_03_T->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_03_T->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_03_T->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_03_T->Fill(pt_A, Sdphi); } } } } } } } begin = 0; if(deut_count_T > 0 && trig_05_track_count > 0 && do_lead_only == 1) { begin = max_05; trig_05_track_count = max_05 + 1; } if(deut_count_T > 0 && trig_05_track_count > 0) { for(int i=begin; i<trig_05_track_count; i++) // trigger loop { int H = trig_05_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_T; j++) { int A = deut_track_num_T[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_05_T->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_05_T->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_05_T->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_05_T->Fill(pt_A, Sdphi); } } } } } } } begin = 0; if(deut_count_T > 0 && trig_08_track_count > 0 && do_lead_only == 1) { begin = max_08; trig_08_track_count = max_08 + 1; } if(deut_count_T > 0 && trig_08_track_count > 0) { for(int i=begin; i<trig_08_track_count; i++) // trigger loop { int H = trig_08_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_T; j++) { int A = deut_track_num_T[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_08_T->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_08_T->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_08_T->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_08_T->Fill(pt_A, Sdphi); } } } } } } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// begin = 0; if(deut_count_A > 0 && trig_03_track_count > 0 && do_lead_only == 1) { begin = max_03; trig_03_track_count = max_03 + 1; } if(deut_count_A > 0 && trig_03_track_count > 0) { for(int i=begin; i<trig_03_track_count; i++) // trigger loop { int H = trig_03_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_A; j++) { int A = deut_track_num_A[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_03_A->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_03_A->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_03_A->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_03_A->Fill(pt_A, Sdphi); } } } } } } } begin = 0; if(deut_count_A > 0 && trig_05_track_count > 0 && do_lead_only == 1) { begin = max_05; trig_05_track_count = max_05 + 1; } if(deut_count_A > 0 && trig_05_track_count > 0) { for(int i=begin; i<trig_05_track_count; i++) // trigger loop { int H = trig_05_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_A; j++) { int A = deut_track_num_A[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_05_A->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_05_A->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_05_A->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_05_A->Fill(pt_A, Sdphi); } } } } } } } begin = 0; if(deut_count_A > 0 && trig_08_track_count > 0 && do_lead_only == 1) { begin = max_08; trig_08_track_count = max_08 + 1; } if(deut_count_A > 0 && trig_08_track_count > 0) { for(int i=begin; i<trig_08_track_count; i++) // trigger loop { int H = trig_08_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_A; j++) { int A = deut_track_num_A[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_08_A->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_08_A->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_08_A->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_08_A->Fill(pt_A, Sdphi); } } } } } } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// begin = 0; if(deut_count_B > 0 && trig_03_track_count > 0 && do_lead_only == 1) { begin = max_03; trig_03_track_count = max_03 + 1; } if(deut_count_B > 0 && trig_03_track_count > 0) { for(int i=begin; i<trig_03_track_count; i++) // trigger loop { int H = trig_03_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_B; j++) { int A = deut_track_num_B[j]; if(A != H) { if(AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A))) // if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_03_B->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_03_B->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_03_B->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_03_B->Fill(pt_A, Sdphi); } } } } } } } begin = 0; if(deut_count_B > 0 && trig_05_track_count > 0 && do_lead_only == 1) { begin = max_05; trig_05_track_count = max_05 + 1; } if(deut_count_B > 0 && trig_05_track_count > 0) { for(int i=begin; i<trig_05_track_count; i++) // trigger loop { int H = trig_05_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_B; j++) { int A = deut_track_num_B[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_05_B->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_05_B->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_05_B->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_05_B->Fill(pt_A, Sdphi); } } } } } } } begin = 0; if(deut_count_B > 0 && trig_08_track_count > 0 && do_lead_only == 1) { begin = max_08; trig_08_track_count = max_08 + 1; } if(deut_count_B > 0 && trig_08_track_count > 0) { for(int i=begin; i<trig_08_track_count; i++) // trigger loop { int H = trig_08_track_num[i]; AliAODTrack* trackH = static_cast<AliAODTrack*>(fAOD->GetTrack(H)); Float_t pt_H = trackH->Pt(); Short_t charge_H = trackH->Charge(); Float_t phi_H = trackH->Phi(); if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H < -pio2){ phi_H = phi_H + twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } if(phi_H > 3*pio2){ phi_H = phi_H - twopi; } for(int j=0; j<deut_count_B; j++) { int A = deut_track_num_B[j]; if(A != H) { AliAODTrack* trackA = static_cast<AliAODTrack*>(fAOD->GetTrack(A)); if(trackA) { Short_t charge_A = trackA->Charge(); Float_t pt_A = trackA->Pt(); Float_t phi_A = trackA->Phi(); if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A < -pio2){ phi_A = phi_A + twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } if(phi_A > 3*pio2){ phi_A = phi_A - twopi; } Float_t Sdphi = phi_A - phi_H; if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi < -pio2){ Sdphi = Sdphi + twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(Sdphi > 3*pio2){ Sdphi = Sdphi - twopi; } if(charge_H > 0) { if (charge_A > 0){ deut_dphi_pt_pos_pos_08_B->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_pos_neg_08_B->Fill(pt_A, Sdphi); } } else if(charge_H < 0){ if (charge_A > 0){ deut_dphi_pt_pos_neg_08_B->Fill(pt_A, Sdphi); } else if(charge_A < 0){ deut_dphi_pt_neg_neg_08_B->Fill(pt_A, Sdphi); } } } } } } } // continue until all the tracks are processed PostData(1, fOutputList); // stream the results the analysis of this event to // the output manager which will take care of writing // it to a file } //_____________________________________________________________________________ void AliAnalysisTaskCorPIDTOFdeut::Terminate(Option_t *) { // terminate // called at the END of the analysis (when all events are processed) } //_____________________________________________________________________________ //_____________________________________________________________________________ Double_t AliAnalysisTaskCorPIDTOFdeut::Beta(AliAODTrack *track) { Double_t startTime = fPIDResponse->GetTOFResponse().GetStartTime(((AliVTrack*)track)->P()); //in ps Double_t stoptime = track->GetTOFsignal(); Double_t c = TMath::C()*1.E-9; // m/ns Double_t length = fPIDResponse->GetTOFResponse().GetExpectedSignal(track,AliPID::kElectron)*1E-3*c; stoptime -= startTime; Double_t scaleStopTime = stoptime*1E-3; scaleStopTime = scaleStopTime*c; return length/scaleStopTime; } //_____________________________________________________________________________ Double_t AliAnalysisTaskCorPIDTOFdeut::tof_minus_tpion(AliAODTrack *track) { Double_t start_time = fPIDResponse->GetTOFResponse().GetStartTime(track->P()); // in ps Double_t stop_time = track->GetTOFsignal(); Double_t c = TMath::C()*1.E-9; // in m/ns Double_t time_of_flight = stop_time - start_time; time_of_flight = time_of_flight * 0.001; // convert from ps to ns Double_t length = fPIDResponse->GetTOFResponse().GetExpectedSignal(track,AliPID::kPion)*1E-3*c; // in meters length = length * 100; // convert to cm Double_t pion_time = fPIDResponse->GetTOFResponse().GetExpectedSignal(track,AliPID::kPion); // // take a close look at this function -<NAME>- pion_time = pion_time * 0.001; return time_of_flight - pion_time; } //_____________________________________________________________________________ Double_t AliAnalysisTaskCorPIDTOFdeut::get_mass_squared(AliAODTrack *track) { Double_t start_time = fPIDResponse->GetTOFResponse().GetStartTime(track->P()); // in ps Double_t stop_time = track->GetTOFsignal(); Double_t c = TMath::C()*1.E-9; // in m/ns Double_t tof = stop_time - start_time; tof = tof * 0.001; // convert from ps to ns Double_t length = fPIDResponse->GetTOFResponse().GetExpectedSignal(track,AliPID::kPion)*1E-3*c; // in meters length = length * 100; // convert to cm Double_t mom = track->P(); Double_t m2 = 0.0; Double_t c2 = 29.9792458; m2 = pow(mom,2) * (tof*tof * c2 * c2 / (length * length) - 1); return m2; } //_____________________________________________________________________________ Double_t AliAnalysisTaskCorPIDTOFdeut::get_deut_tof_pt(AliAODTrack *track) { Double_t start_time = fPIDResponse->GetTOFResponse().GetStartTime(track->P()); // in ps Double_t stop_time = track->GetTOFsignal(); Double_t c = TMath::C()*1.E-9; // in m/ns Double_t tof = stop_time - start_time; tof = tof * 0.001; // convert from ps to ns Double_t length = fPIDResponse->GetTOFResponse().GetExpectedSignal(track,AliPID::kPion)*1E-3*c; // in meters length = length * 100; // convert to cm // Double_t mom = track->P(); // Double_t m2 = 0.0; Double_t c2 = 29.9792458; Double_t deut_mass = 1.8756; // GeV/(c^2) // m2 = pow(mom,2) * (tof*tof * c2 * c2 / (length * length) - 1); Double_t mom = 0.00; mom = deut_mass / sqrt( (tof*tof * c2 * c2 / (length * length) - 1) ); Double_t pt = 0.00; pt = sqrt(pow(mom,2) - pow(track->Pz(),2)); return pt; } //_____________________________________________________________________________ Double_t AliAnalysisTaskCorPIDTOFdeut::get_deut_tof_p(AliAODTrack *track) { Double_t start_time = fPIDResponse->GetTOFResponse().GetStartTime(track->P()); // in ps Double_t stop_time = track->GetTOFsignal(); Double_t c = TMath::C()*1.E-9; // in m/ns Double_t tof = stop_time - start_time; tof = tof * 0.001; // convert from ps to ns Double_t length = fPIDResponse->GetTOFResponse().GetExpectedSignal(track,AliPID::kPion)*1E-3*c; // in meters length = length * 100; // convert to cm // Double_t mom = track->P(); // Double_t m2 = 0.0; Double_t c2 = 29.9792458; Double_t deut_mass = 1.8756; // GeV/(c^2) // m2 = pow(mom,2) * (tof*tof * c2 * c2 / (length * length) - 1); Double_t mom = 0.00; mom = deut_mass / sqrt( (tof*tof * c2 * c2 / (length * length) - 1) ); return mom; }
code543/leetcodequestions
src/test/test/lee/codetest/code_412__Fizz_Buzz/CodeTest.java
package lee.codetest.code_412__Fizz_Buzz; import org.junit.Test; /** testcase:1 */ public class CodeTest { @Test public void testSolution() throws Exception { //new Solution() lee.code.code_412__Fizz_Buzz.C412_MainClass.main(null);; } } /** * * * 412.Fizz Buzz * * difficulty: Easy * @see https://leetcode.com/problems/fizz-buzz/description/ * @see description_412.md * @Similiar Topics * @Similiar Problems * Run solution from Unit Test: * @see lee.codetest.code_412__Fizz_Buzz.CodeTest * Run solution from Main Judge Class: * @see lee.code.code_412__Fizz_Buzz.C412_MainClass * */
C-Otto/lnd-manageJ
web/src/test/java/de/cotto/lndmanagej/controller/StatusControllerTest.java
package de.cotto.lndmanagej.controller; import de.cotto.lndmanagej.controller.dto.ChannelsDto; import de.cotto.lndmanagej.controller.dto.PubkeysDto; import de.cotto.lndmanagej.model.ChannelId; import de.cotto.lndmanagej.model.Pubkey; import de.cotto.lndmanagej.service.ChannelService; import de.cotto.lndmanagej.service.GraphService; import de.cotto.lndmanagej.service.OwnNodeService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import java.util.List; import java.util.Set; import java.util.stream.Stream; import static de.cotto.lndmanagej.model.CoopClosedChannelFixtures.CLOSED_CHANNEL; import static de.cotto.lndmanagej.model.CoopClosedChannelFixtures.CLOSED_CHANNEL_2; import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL; import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL_2; import static de.cotto.lndmanagej.model.LocalOpenChannelFixtures.LOCAL_OPEN_CHANNEL_TO_NODE_3; import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) class StatusControllerTest { @InjectMocks private StatusController statusController; @Mock private OwnNodeService ownNodeService; @Mock private ChannelService channelService; @Mock private GraphService graphService; @Test void isSyncedToChain() { when(ownNodeService.isSyncedToChain()).thenReturn(true); assertThat(statusController.isSyncedToChain()).isTrue(); } @Test void isSyncedToChain_false() { when(ownNodeService.isSyncedToChain()).thenReturn(false); assertThat(statusController.isSyncedToChain()).isFalse(); } @Test void getOpenChannels() { when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_OPEN_CHANNEL_TO_NODE_3, LOCAL_OPEN_CHANNEL)); List<ChannelId> expectedChannelIds = List.of(LOCAL_OPEN_CHANNEL.getId(), LOCAL_OPEN_CHANNEL_TO_NODE_3.getId()); assertThat(statusController.getOpenChannels()).isEqualTo(new ChannelsDto(expectedChannelIds)); } @Test void getPubkeysForOpenChannels() { when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_OPEN_CHANNEL_TO_NODE_3, LOCAL_OPEN_CHANNEL)); List<Pubkey> expectedPubkeys = List.of(LOCAL_OPEN_CHANNEL.getRemotePubkey(), LOCAL_OPEN_CHANNEL_TO_NODE_3.getRemotePubkey()); assertThat(statusController.getPubkeysForOpenChannels()).isEqualTo(new PubkeysDto(expectedPubkeys)); } @Test void getPubkeysForOpenChannels_without_no_duplicates() { when(channelService.getOpenChannels()).thenReturn(Set.of(LOCAL_OPEN_CHANNEL, LOCAL_OPEN_CHANNEL_2)); assertThat(statusController.getPubkeysForOpenChannels().pubkeys()).containsExactly(PUBKEY_2.toString()); } @Test void getAllChannels() { when(channelService.getAllLocalChannels()).thenReturn(Stream.of(LOCAL_OPEN_CHANNEL_TO_NODE_3, CLOSED_CHANNEL)); List<ChannelId> expectedChannelIds = List.of(CLOSED_CHANNEL.getId(), LOCAL_OPEN_CHANNEL_TO_NODE_3.getId()); assertThat(statusController.getAllChannels()).isEqualTo(new ChannelsDto(expectedChannelIds)); } @Test void getPubkeysForAllChannels() { when(channelService.getAllLocalChannels()).thenReturn(Stream.of(LOCAL_OPEN_CHANNEL_TO_NODE_3, CLOSED_CHANNEL)); List<Pubkey> expectedPubkeys = List.of(CLOSED_CHANNEL.getRemotePubkey(), LOCAL_OPEN_CHANNEL_TO_NODE_3.getRemotePubkey()); assertThat(statusController.getPubkeysForAllChannels()).isEqualTo(new PubkeysDto(expectedPubkeys)); } @Test void getPubkeysForAllChannels_without_no_duplicates() { when(channelService.getAllLocalChannels()).thenReturn(Stream.of(CLOSED_CHANNEL_2, CLOSED_CHANNEL)); assertThat(statusController.getPubkeysForAllChannels().pubkeys()).containsExactly(PUBKEY_2.toString()); } @Test void getBlockHeight() { when(ownNodeService.getBlockHeight()).thenReturn(123_456); assertThat(statusController.getBlockHeight()).isEqualTo(123_456); } @Test void getKnownChannels() { when(graphService.getNumberOfChannels()).thenReturn(123); assertThat(statusController.getKnownChannels()).isEqualTo(123); } }
shuichitakano/m5dx
main/graphics/framebuffer_base.cpp
<reponame>shuichitakano/m5dx /* * author : <NAME> * since : Sun Oct 28 2018 21:3:2 */ #include "framebuffer_base.h" #include "../debug.h" #include "texture.h" #include <algorithm> namespace graphics { void FrameBufferBase::fill(int x, int y, int w, int h, uint32_t c) { int wx0 = getLeft(); int wx1 = wx0 + getWidth(); int wy0 = getTop(); int wy1 = wy0 + getHeight(); int x0 = std::max(wx0, x); int x1 = std::min(wx1, x + w); int y0 = std::max(wy0, y); int y1 = std::min(wy1, y0 + h); while (y0 < y1) { auto tx = x0; while (tx < x1) { setPixel(tx, y0, c); ++tx; } ++y0; } } void FrameBufferBase::fill(uint32_t c) { fill(0, 0, getWidth(), getHeight(), c); } void FrameBufferBase::adjustTransferRegion( int& dx, int& dy, int& sx, int& sy, int& w, int& h) const { int wx0 = getLeft(); int wx1 = wx0 + getWidth(); int wy0 = getTop(); int wy1 = wy0 + getHeight(); int dx1 = dx + w; int dy1 = dy + h; if (dx < wx0) { sx += wx0 - dx; dx = wx0; } if (dx1 > wx1) { dx1 = wx1; } if (dy < wy0) { sy += wy0 - dy; dy = wy0; } if (dy1 > wy1) { dy1 = wy1; } w = dx1 - dx; h = dy1 - dy; } void FrameBufferBase::drawBits16( int x, int y, int w, int h, int pitchInBytes, const void* img16) { // todo } void FrameBufferBase::transferTo( FrameBufferBase& dst, int dx, int dy, int sx, int sy, int w, int h) const { if (w == 0) { w = getBufferWidth(); } if (h == 0) { h = getBufferHeight(); } dst.adjustTransferRegion(dx, dy, sx, sy, w, h); if (!w || !h) { return; } for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { dst.setPixel(dx + x, dy + y, getPixel(sx + x, sy + y)); // todo: フォーマット変換 } } } void FrameBufferBase::put( const Texture& tex, int dx, int dy, int sx, int sy, int w, int h) { adjustTransferRegion(dx, dy, sx, sy, w, h); if (!w || !h) { return; } auto srcPitch = tex.getPitch(); const auto* src = tex.getBits() + sx + srcPitch * sy; const auto* pal = tex.getPalette(); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { auto c = pal[*(src + x)]; setPixel(dx + x, dy + y, c); } src += srcPitch; } } void FrameBufferBase::putTrans( const Texture& tex, int dx, int dy, int sx, int sy, int w, int h) { adjustTransferRegion(dx, dy, sx, sy, w, h); if (!w || !h) { return; } auto srcPitch = tex.getPitch(); const auto* src = tex.getBits() + sx + srcPitch * sy; const auto* pal = tex.getPalette(); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { if (auto p = *(src + x)) { auto c = pal[p]; setPixel(dx + x, dy + y, c); } } src += srcPitch; } } void FrameBufferBase::putReplaced(const Texture& tex, int dx, int dy, int sx, int sy, int w, int h, uint16_t color, uint16_t bg) { adjustTransferRegion(dx, dy, sx, sy, w, h); if (!w || !h) { return; } auto srcPitch = tex.getPitch(); const auto* src = tex.getBits() + sx + srcPitch * sy; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { auto c = *(src + x); setPixel(dx + x, dy + y, c ? color : bg); } src += srcPitch; } } void FrameBufferBase::transfer( const FrameBufferBase& src, int dx, int dy, int sx, int sy, int w, int h) { src.transferTo(*this, dx, dy, sx, sy, w, h); } void FrameBufferBase::_drawBitsLineTrans( const uint8_t* bits, int bitOfs, uint32_t color, int x, int y, int w) { while (w) { int v = bits[bitOfs >> 3]; int b = bitOfs & 7; if ((v << b) & 128) { setPixel(x, y, color); } ++bitOfs; ++x; --w; } } void FrameBufferBase::_drawBitsLine(const uint8_t* bits, int bitOfs, uint32_t color, uint32_t bgColor, int x, int y, int w) { while (w) { int v = bits[bitOfs >> 3]; int b = bitOfs & 7; if ((v << b) & 128) { setPixel(x, y, color); } else { setPixel(x, y, bgColor); } ++bitOfs; ++x; --w; } } void FrameBufferBase::drawBits( int x, int y, int w, int h, const uint8_t* bits, uint32_t color) { int wx0 = getLeft(); int wx1 = wx0 + getWidth(); int wy0 = getTop(); int wy1 = wy0 + getHeight(); int dx1 = x + w; int dy1 = y + h; int pitch = (w + 7) >> 3; int lineBitOfs = 0; if (x < wx0) { lineBitOfs = wx0 - x; x = wx0; } if (y < wy0) { bits += (wy0 - y) * pitch; y = wy0; } dx1 = std::min(dx1, wx1); dy1 = std::min(dy1, wy1); w = dx1 - x; if (w <= 0 || dy1 - y <= 0) { return; } while (y < dy1) { _drawBitsLineTrans(bits, lineBitOfs, color, x, y, w); bits += pitch; ++y; } } void FrameBufferBase::drawBits(int x, int y, int w, int h, const uint8_t* bits, uint32_t color, uint32_t bgColor) { int wx0 = getLeft(); int wx1 = wx0 + getWidth(); int wy0 = getTop(); int wy1 = wy0 + getHeight(); int dx1 = x + w; int dy1 = y + h; int pitch = (w + 7) >> 3; int lineBitOfs = 0; if (x < wx0) { lineBitOfs = wx0 - x; x = wx0; } if (y < wy0) { bits += (wy0 - y) * pitch; y = wy0; } dx1 = std::min(dx1, wx1); dy1 = std::min(dy1, wy1); w = dx1 - x; if (w <= 0 || dy1 - y <= 0) { return; } while (y < dy1) { _drawBitsLine(bits, lineBitOfs, color, bgColor, x, y, w); bits += pitch; ++y; } } void FrameBufferBase::drawBitsThick(int x, int y, int w, int h, const uint8_t* bits, uint32_t color, uint32_t edgeColor) { drawBits(x - 1, y, w, h, bits, edgeColor); drawBits(x + 1, y, w, h, bits, edgeColor); drawBits(x, y - 1, w, h, bits, edgeColor); drawBits(x, y + 1, w, h, bits, edgeColor); drawBits(x, y, w, h, bits, color); } } // namespace graphics
LiangYue1981816/AresEngine
Engine/Memory/src/MemoryHeap.h
#pragma once struct HEAP_ALLOCATOR; extern HEAP_ALLOCATOR* HEAP_Create(void); extern void HEAP_Destroy(HEAP_ALLOCATOR* pHeapAllocator); extern void* HEAP_Alloc(HEAP_ALLOCATOR* pHeapAllocator, size_t size); extern bool HEAP_Free(HEAP_ALLOCATOR* pHeapAllocator, void* pPointer);
ProjectAGI/pagi-framework
pagi/utils/image_utils.py
<reponame>ProjectAGI/pagi-framework # Copyright (C) 2019 Project AGI # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """ Helper methods for manipulating images. Some methods are adapted from https://github.com/hmishra2250/NTM-One-Shot-TF """ import os import io import math import random import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from scipy.misc import imread, imresize from scipy.ndimage import rotate, shift from skimage.draw import line_aa def degrade_image(image, label=None, degrade_type='horizontal', degrade_value=0, degrade_factor=0.5, random_value=0.0): """ :param image: :param label: :param degrade_type: the type of degradation 'vertical, horizontal, random or rect' :param degrade_value: The value to set degraded bits :param degrade_factor: if relevant for the type, generally proportion to degrade :param random_value: if relevant for the type, make it deterministic by passing in a proxy for the 'random value' :return: """ if degrade_type == 'vertical' or degrade_type == 'horizontal': return degrade_image_half(image, label=label, degrade_type=degrade_type, degrade_value=degrade_value, random_value=random_value) elif degrade_type == 'random': return degrade_image_random(image, label=label, degrade_value=degrade_value, degrade_factor=degrade_factor) elif degrade_type == 'rect' or degrade_type == 'circle': return degrade_image_shape(image, label=label, degrade_value=degrade_value, rect_size=degrade_factor, shape_type=degrade_type) else: raise RuntimeError("Degrade type {0} not supported.".format(degrade_type)) def degrade_image_shape(image, label=None, degrade_value=0, rect_size=0.0, shape_type='rect'): """ :param image: :param label: :param degrade_value: :param rect_size: radius expressed as proportion of image (half height or width for rectangle) :param shape_type: rect or circle :return: """ image_shape = image.shape.as_list() image_size = np.prod(image_shape[1:]) height = image_shape[1] width = image_shape[2] r = tf.cast(rect_size * height, tf.int64) # expressed as pixels (choose height, assume square) # random start position batch_size = image_shape[0] xs = tf.random_uniform(shape=[batch_size, 1], minval=r, maxval=width-r, dtype=tf.int64) ys = tf.random_uniform(shape=[batch_size, 1], minval=r, maxval=height-r, dtype=tf.int64) int_image = tf.range(0, image_size) col = tf.to_int64(int_image % width) # same shape as image tensor, but values are the col idx row = tf.to_int64(int_image / height) # same but for row idx col = tf.expand_dims(col, axis=0) # add a batch dimension row = tf.expand_dims(row, axis=0) if shape_type == 'rect': mask_x = tf.logical_or((col < xs), (col > xs + 2*r)) mask_y = tf.logical_or((row < ys), (row > ys + 2*r)) preserve_mask = tf.logical_or(mask_x, mask_y) elif shape_type == 'circle': circle_r = tf.square(col - xs) + tf.square(row - ys) preserve_mask = circle_r > tf.square(r) else: raise RuntimeError("Shape type : {0} not supported.".format(shape_type)) preserve_mask = tf.to_float(preserve_mask) preserve_mask = tf.reshape(preserve_mask, [-1, image_shape[1], image_shape[2], 1]) degraded_image = tf.multiply(image, preserve_mask) # now set the 'degraded' pixels to chosen value degraded_mask = 1.0 - preserve_mask degraded_mask_vals = degrade_value * degraded_mask degraded_image = degraded_image + degraded_mask_vals if label is None: return degraded_image return degraded_image, label def degrade_image_half(image, label=None, degrade_type='horizontal', degrade_value=0, random_value=0.0): """Degrade the image by randomly removing one of image halves.""" image_shape = image.shape.as_list() image_size = np.prod(image_shape[1:]) # # Miconi method # image = tf.reshape(image, [-1, image_size]) # # preserved = np.ones(image_size) # preserved[int(image_size / 2):] = 0 # [ 1's, 0's ] # # degraded_vals = np.ones(image_size) # degraded_vals[:] = degrade_value # degraded_vals[:int(image_size/2)] = 0 # [ 0's, dv's ] # dv = degrade value # deal with 1d samples (or 2d image) if len(image_shape) == 2: preserved = np.ones(image_size) degraded_vals = np.zeros(image_size) degraded_vals[:] = degrade_value preserved[int(image_size / 2):] = 0 degraded_vals[:int(image_size / 2)] = 0 # 2d image else: sample_shape = image_shape[1:] width = image_shape[1] height = image_shape[2] preserved = np.ones(sample_shape) degraded_vals = np.zeros(sample_shape) degraded_vals[:] = degrade_value if degrade_type == 'vertical': # the whole row (width), half the columns (height) preserved[:, int(width / 2):] = 0 degraded_vals[:, 0:int(width / 2)] = 0 if degrade_type == 'horizontal': # half the row (width), all the columns (width) preserved[int(height / 2):, :] = 0 degraded_vals[0:int(height / 2), :] = 0 preserved = tf.convert_to_tensor(preserved, dtype=image.dtype) degraded_vals = tf.convert_to_tensor(degraded_vals, dtype=image.dtype) # Use random number generator, or specified random value rand_value = tf.cond(tf.cast(random_value, tf.float32) > 0, lambda: random_value, lambda: tf.random_uniform([])) # Randomly remove either half of the image rand_half = rand_value < .5 # randomly choose a half preserved = tf.cond(rand_half, lambda: 1 - preserved, lambda: preserved) # swap 1's and 0's degraded_vals = tf.cond(rand_half, lambda: degrade_value - degraded_vals, lambda: degraded_vals) # swap dv's and 0's degraded_image = image * preserved # zero out non-preserved bits degraded_image = degraded_image + degraded_vals # add degrade_value at appropriate places (where it was zero) degraded_image = tf.reshape(degraded_image, image_shape, name='degraded_image') if label is None: return degraded_image return degraded_image, label def degrade_image_random(image, label=None, degrade_value=0, degrade_factor=0.5): image_shape = image.shape.as_list() image_size = np.prod(image_shape[1:]) preserve_mask = np.ones(image_size) preserve_mask[:int(degrade_factor * image_size)] = 0 preserve_mask = tf.convert_to_tensor(preserve_mask, dtype=tf.float32) preserve_mask = tf.random_shuffle(preserve_mask) degrade_vec = np.ones(image_size) degrade_vec[:] = degrade_value degrade_vec = tf.convert_to_tensor(degrade_vec, dtype=tf.float32) degrade_vec = degrade_vec * preserve_mask # preserved bits = degrade_value degrade_vec = degrade_value - degrade_vec # preserved bits = 0, else degraded_value (flipped) image = tf.reshape(image, [-1, image_size]) degraded_image = tf.multiply(image, preserve_mask) # use broadcast to element-wise multiply batch with 'preserved' degraded_image = degraded_image + degrade_vec # set non-preserved values to the 'degrade_value' degraded_image = tf.reshape(degraded_image, image_shape, name='degraded_image') if label is None: return degraded_image return degraded_image, label def add_image_noise_flat(image, label=None, minval=0., noise_type='sp_binary', noise_factor=0.2): """If the image is flat (batch, size) then use this version. It reshapes and calls the add_imagie_noise()""" image_shape = image.shape.as_list() image = tf.reshape(image, (-1, image_shape[1], 1, 1)) image = add_image_noise(image, label, minval, noise_type, noise_factor) image = tf.reshape(image, (-1, image_shape[1])) return image def add_image_noise(image, label=None, minval=0., noise_type='sp_binary', noise_factor=0.2): image_shape = image.shape.as_list() image_size = np.prod(image_shape[1:]) if noise_type == 'sp_float' or noise_type == 'sp_binary': noise_mask = np.zeros(image_size) noise_mask[:int(noise_factor * image_size)] = 1 noise_mask = tf.convert_to_tensor(noise_mask, dtype=tf.float32) noise_mask = tf.random_shuffle(noise_mask) noise_mask = tf.reshape(noise_mask, [-1, image_shape[1], image_shape[2], image_shape[3]]) noise_image = tf.random_uniform(image_shape, minval, 1.0) if noise_type == 'sp_binary': noise_image = tf.sign(noise_image) noise_image = tf.multiply(noise_image, noise_mask) # retain noise in positions of noise mask image = tf.multiply(image, (1 - noise_mask)) # zero out noise positions corrupted_image = image + noise_image # add in the noise else: if noise_type == 'none': raise RuntimeWarning("Add noise has been called despite noise_type of 'none'.") else: raise NotImplementedError("The noise_type '{0}' is not supported.".format(noise_type)) if label is None: return corrupted_image return corrupted_image, label def add_image_salt_noise_flat(image, label=None, noise_val=0., noise_factor=0., mode='add'): """If the image is flat (batch, size) then use this version. It reshapes and calls the add_image_noise()""" image_shape = image.shape.as_list() image = tf.reshape(image, (-1, image_shape[1], 1, 1)) image = add_image_salt_noise(image, label, noise_val, noise_factor, mode) image = tf.reshape(image, (-1, image_shape[1])) return image def add_image_salt_pepper_noise_flat(image, label=None, salt_val=1., pepper_val=0., noise_factor=0.): """If the image is flat (batch, size) then use this version. It reshapes and calls the add_image_noise()""" image_shape = image.shape.as_list() image = tf.reshape(image, (-1, image_shape[1], 1, 1)) image = add_image_salt_noise(image, label, salt_val, noise_factor, 'replace') image = add_image_salt_noise(image, label, pepper_val, noise_factor, 'replace') image = tf.reshape(image, (-1, image_shape[1])) return image def add_image_salt_noise(image, label=None, noise_val=0., noise_factor=0., mode='add'): """ Add salt noise. :param image: :param label: :param noise_val: value of 'salt' (can be +ve or -ve, must be non zero to have an effect) :param noise_factor: the proportion of the image :param mode: 'replace' = replace existing value, 'add' = noise adds to the existing value :return: """ image_shape = image.shape.as_list() image_size = np.prod(image_shape[1:]) # random shuffle of chosen number of active bits noise_mask = np.zeros(image_size) noise_mask[:int(noise_factor * image_size)] = 1 noise_mask = tf.convert_to_tensor(noise_mask, dtype=tf.float32) noise_mask = tf.random_shuffle(noise_mask) noise_mask = tf.reshape(noise_mask, [-1, image_shape[1], image_shape[2], image_shape[3]]) if mode == 'replace': image = tf.multiply(image, (1 - noise_mask)) # image: zero out noise positions image = image + (noise_mask * noise_val) # image: add in the noise at the chosen value if label is None: return image return image, label def pad_image(image, padding, mode='constant'): dim_pad = [padding, padding] paddings = tf.constant([dim_pad, dim_pad, [0, 0]]) # Avoid padding image channel return tf.pad(image, paddings, mode) def shift_image(image, shift_): """Shift the image.""" shifts = [] for i in np.arange(-shift_, shift_ + 1): for j in np.arange(-shift_, shift_ + 1): shifts.append([i, j]) # Get random shift from list of potential shifts shifts = tf.convert_to_tensor(shifts, dtype=image.dtype) shuffled_shifts = tf.random_shuffle(shifts) random_shift = shuffled_shifts[0] return tf.contrib.image.translate(image, random_shift) def get_shuffled_images(paths, labels, nb_samples=None): if nb_samples is not None: sampler = lambda x: random.sample(x, nb_samples) else: sampler = lambda x: x images = [(i, os.path.join(path, image)) for i, path in zip(labels, paths) for image in sampler(os.listdir(path))] random.shuffle(images) return images def time_offset_label(labels_and_images): labels, images = zip(*labels_and_images) time_offset_labels = (None,) + labels[:-1] return zip(images, time_offset_labels) def load_transform(image_path, angle=0., s=(0, 0), size=(20, 20)): """Transforms an image by rotating, shifting, resizing and inverting.""" # Load the image original = imread(image_path, flatten=True) # Rotate the image rotated = rotate(original, angle=angle, cval=1.) rotated = np.maximum(np.minimum(rotated, 1.), 0.) # pylint: disable=assignment-from-no-return # Shift the image shift(rotated, shift=s) # Resize the image resized = np.asarray(imresize(rotated, size=size), dtype=np.float32) / 255 # Note here we coded manually as np.float32, it should be tf.float32 # Invert the image inverted = 1. - resized max_value = np.max(inverted) if max_value > 0: inverted /= max_value return inverted def generate_image_labels(num=10, size_x=24, size_y=24): """Generate num labels in the form of a unique small image.""" image_labels = [] delta = int(np.floor(size_y/num)) print("delta = {0}".format(delta)) print("num*delta = {0}".format(num * delta)) for y in range(0, num * delta, delta): img = np.zeros((size_y, size_x), dtype=np.double) yy = y + int(delta*0.5) rr, cc, val = line_aa(yy, 0, yy, size_x-1) img[rr, cc] = val image_labels.append(img) return image_labels def square_image_shape_from_1d(filters): """ Make 1d tensor as square as possible. If the length is a prime, the worst case, it will remain 1d. Assumes and retains first dimension as batches. """ height = int(math.sqrt(filters)) while height > 1: width_remainder = filters % height if width_remainder == 0: break else: height = height - 1 width = filters // height area = height * width lost_pixels = filters - area shape = [-1, height, width, 1] return shape, lost_pixels def make_image_summary_shape_from_2d_shape(shape): """ If you have a 2d tensor of (width, height) that you want to view as batch of grayscale images, use this. return [-1 width, height, 1] """ shape.insert(0, -1) # as many batches as exist shape.append(1) # channels = 1 (grayscale) return shape def make_image_summary_shape_from_2d(tensor): """ If you have a 2d tensor of (width, height) that you want to view as batch of grayscale images, use this. return [-1 width, height, 1] """ shape = tensor.get_shape().as_list() shape = make_image_summary_shape_from_2d_shape(shape) return shape def get_image_summary_shape(tensor_shape): """ Convert tensor_shape into an image shape to be shown in summary. Assumes tensor is already suitable to be shown as batch of images, and ensures the 4'th dimension is 1. :param tensor_shape assumes shape [batch, dim1, dim2, dim3]. :return shape with dimension [batch, dim1, dim2-3, 1] """ from copy import deepcopy # Rules for image summary: "Tensor must be 4-D with last dim 1, 3, or 4" (so, basically 1 then) summary_shape = deepcopy(tensor_shape) if len(tensor_shape) == 2: summary_shape = make_image_summary_shape_from_2d_shape(summary_shape) elif len(tensor_shape) == 4: width = tensor_shape[2] depth = tensor_shape[3] if depth not in [1, 3, 4]: width = width * depth depth = 1 summary_shape[2] = width summary_shape[3] = depth else: logging.error('Can\'t reshape tensor shape %s for image summary', str(tensor_shape)) return summary_shape def add_square_as_square(summaries, tensor, name): """ Convenience function for adding a square image to a summary. """ image_shape = make_image_summary_shape_from_2d(tensor) image = tf.reshape(tensor, image_shape) summaries.append(tf.summary.image(name, image)) def array_to_image_string(image_array): """ Converts a NumPy array representing an image to an encoded image string to be used in tf.Summary.Image(). """ num_dims = len(image_array.shape) if num_dims != 3: raise ValueError('Expecting 3 dimensions (height, weight, channel). Found {0} dimensions.'.format(num_dims)) cmap = None if image_array.shape[2] == 1: cmap = 'gray' image_array = np.squeeze(image_array, axis=2) # Normalize to 0..1 range required by matplotlib image_array = (image_array - np.min(image_array)) / (np.max(image_array) - np.min(image_array)) output = io.BytesIO() plt.imsave(output, image_array, format='PNG', cmap=cmap) image_string = output.getvalue() output.close() return image_string def arbitrary_image_summary(summary, input_tensor, name='image', max_outputs=3, image_names=None): """ Creates an off-graph tf.Summary.Image using arbitrary inputs. input_tensor contains multiple images. max_outputs specifies how many to plot OR specify how many to plot by specifying their names in `image_names` num_images gets preference if it is defined. """ if image_names is not None: max_outputs = len(image_names) num_outputs = min(max_outputs, input_tensor.shape[0]) for i in range(num_outputs): image_array = input_tensor[i] h, w, c = image_array.shape image_string = array_to_image_string(image_array) image = tf.Summary.Image( height=h, width=w, colorspace=c, encoded_image_string=image_string) if image_names is not None: image_name = image_names[i] else: image_name = str(i) summary.value.add(tag=name + '/' + image_name, image=image) return summary def add_op_images(dual, op_names, shape, max_outputs, summaries): """ Convenience method to add a list of ops (as images) to a summary. @:param shape list of shapes (same lengths as op_names, or if same shape for all, then a single value @:param summaries are mutated """ if not isinstance(shape, list): op_shapes = [shape] * len(op_names) else: op_shapes = shape for op_name, _ in zip(op_names, op_shapes): op = dual.get_op(op_name) if op is not None: reshaped = tf.reshape(op, shape) summaries.append(tf.summary.image(op_name, reshaped, max_outputs=max_outputs)) def add_arbitrary_images_summary(summary, scope_name, images, names, combined=False, max_outputs=3): """Add multiple images to a summary off graph, optionally combine into one.""" if not combined: for image, name in zip(images, names): arbitrary_image_summary(summary, image, name='pcw/' + name, max_outputs=max_outputs) else: combined_image = None combined_name = '' for image, name in zip(images, names): if combined_image is None: combined_image = image combined_name = name continue combined_image = np.concatenate((combined_image, image), axis=1) combined_name = combined_name + '-' + name arbitrary_image_summary(summary, combined_image, name=scope_name + '/' + combined_name, max_outputs=max_outputs) def concat_images(images, batch_size, images_shape=None): """ Concatenate a list of images into one column of sub-images. Adds a 1 pixel line delineating them. If images_shape is not specified, use the shape of the first image :param images: a list of images :param batch_size: :param images_shape: first dimension is ignored (it is often not valid during graph build time) :return: the image containing concatenation of the images in `images` """ concat_image = None if not images: return concat_image if images_shape is None: images_shape = get_image_summary_shape(images[0].get_shape().as_list()) for im in images: image_reshaped = tf.reshape(im, images_shape) if concat_image is None: concat_image = image_reshaped else: # add a line in between line = tf.ones([batch_size, 1, images_shape[2], images_shape[3]]) concat_image = tf.concat([concat_image, line], axis=1) concat_image = tf.concat([concat_image, image_reshaped], axis=1) return concat_image
sirrah23/AddressBook
contact/mock/authServiceConnMock.js
<gh_stars>0 const jwt = require('jsonwebtoken') const uuidv4 = require('uuid/v4') const secretKey = 'mysecret' //hard-coded secret key for development/testing purposes async function generateAuthTokenRequest(username){ const uuid = uuidv4() const payload = {username: username, user_id: uuid} return jwt.sign(payload, secretKey) } async function sendValidateRequest(token){ try { const payload = jwt.verify(token, secretKey) return {errorFlag: 0, errorMsg: '', payload} } catch (err){ return {errorFlag: 1, errorMsg: 'Invalid token'} } } module.exports = { generateAuthTokenRequest, sendValidateRequest, }
newagebegins/BattleCity
spec/DelaySpec.js
<gh_stars>100-1000 describe("Delay", function () { it("#update", function () { var script = jasmine.createSpyObj('script', ['actionCompleted']); var delay = new Delay(script, 3); delay.update(); expect(script.actionCompleted).not.toHaveBeenCalled(); delay.update(); expect(script.actionCompleted).not.toHaveBeenCalled(); delay.update(); expect(script.actionCompleted).not.toHaveBeenCalled(); delay.update(); expect(script.actionCompleted).toHaveBeenCalled(); }); });
layerzero/cc0
src/toolchain/core/IL/ILProgram.h
<gh_stars>0 #pragma once #include <vector> #include <boost/serialization/vector.hpp> class ILClass; class SymbolScope; class ILProgram { private: friend class ::boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int) { ar & BOOST_SERIALIZATION_NVP(Claases); ar & BOOST_SERIALIZATION_NVP(Scope); } public: std::vector<ILClass *> Claases; SymbolScope *Scope; ILProgram(); virtual ~ILProgram(); };
C14427818/CollegeYr1
BCC55/C/Week 4/lab3q6_c.c
/*Doing the exercises at the end of chapter 4 Author:C14427818 Date:08/10/14 */ #include <stdio.h> main() { float principal,rate,time; principal=rate=time=0; printf("Key in principal\n"); scanf("%f",&principal); printf("Key in rate\n"); scanf("%f",&rate); printf("Key in time\n"); scanf("%f",&time); flushall(); getchar(); }
partnernetsoftware/tccrun
src/tests/osxgl2.c
<gh_stars>1-10 #include <GLUT/GLUT.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char ** argv) { glutInit(&argc, argv); glutCreateWindow("Glut Demo"); glutDisplayFunc(display); glutMainLoop(); }