示例#1
0
int64 FE(int n, int d) {
	if (n == 0) {
		if (d == 0) return 1;
		return 0;
	}
	if (d < 0 || n < d || n < 0) return 0;
	if (n == 1) {
		if (d == 1) return 1;
		return 0;
	}
	if (fe[n][d] != -1) return fe[n][d];
	int64 ret = 0, t;
	for (int i = 0; i < n; ++i) {
		t = FE(i, d-1) * FL(n-1-i, d-1) % MOD + 
			FL(i, d-1) * FE(n-1-i, d-1) % MOD - 
			FE(i, d-1) * FE(n-1-i, d-1) % MOD;
		_MOD(t);
		if (i < n-1 && c[n-2][i] > 0) t *= c[n-2][i];
		_MOD(t);
		ret += t;
		_MOD(ret);
	}
	ret *= n;
	_MOD(ret);
	return fe[n][d] = ret;
}
示例#2
0
void Aes256Encoder::expand_enc_key(byte* rkey, unsigned char* rc)
{
	unsigned char i;

	rkey[0] = rkey[0] ^ sbox[rkey[29]] ^ (*rc);
	rkey[1] = rkey[1] ^ sbox[rkey[30]];
	rkey[2] = rkey[2] ^ sbox[rkey[31]];
	rkey[3] = rkey[3] ^ sbox[rkey[28]];
	*rc = FE(*rc);

	for (i = 4; i < 16; i += 4) {
		rkey[i] = rkey[i] ^ rkey[i - 4];
		rkey[i + 1] = rkey[i + 1] ^ rkey[i - 3];
		rkey[i + 2] = rkey[i + 2] ^ rkey[i - 2];
		rkey[i + 3] = rkey[i + 3] ^ rkey[i - 1];
	}
	rkey[16] = rkey[16] ^ sbox[rkey[12]];
	rkey[17] = rkey[17] ^ sbox[rkey[13]];
	rkey[18] = rkey[18] ^ sbox[rkey[14]];
	rkey[19] = rkey[19] ^ sbox[rkey[15]];

	for (i = 20; i < 32; i += 4) {
		rkey[i] = rkey[i] ^ rkey[i - 4];
		rkey[i + 1] = rkey[i + 1] ^ rkey[i - 3];
		rkey[i + 2] = rkey[i + 2] ^ rkey[i - 2];
		rkey[i + 3] = rkey[i + 3] ^ rkey[i - 1];
	}
}
示例#3
0
void Aes256::expand_enc_key(unsigned char* rc)
{
    register unsigned char i;

    m_rkey[0] = m_rkey[0] ^ sbox[m_rkey[29]] ^ (*rc);
    m_rkey[1] = m_rkey[1] ^ sbox[m_rkey[30]];
    m_rkey[2] = m_rkey[2] ^ sbox[m_rkey[31]];
    m_rkey[3] = m_rkey[3] ^ sbox[m_rkey[28]];
    *rc = FE(*rc);

    for (i = 4; i < 16; i += 4) {
        m_rkey[i] = m_rkey[i] ^ m_rkey[i - 4];
        m_rkey[i + 1] = m_rkey[i + 1] ^ m_rkey[i - 3];
        m_rkey[i + 2] = m_rkey[i + 2] ^ m_rkey[i - 2];
        m_rkey[i + 3] = m_rkey[i + 3] ^ m_rkey[i - 1];
    }
    m_rkey[16] = m_rkey[16] ^ sbox[m_rkey[12]];
    m_rkey[17] = m_rkey[17] ^ sbox[m_rkey[13]];
    m_rkey[18] = m_rkey[18] ^ sbox[m_rkey[14]];
    m_rkey[19] = m_rkey[19] ^ sbox[m_rkey[15]];

    for (i = 20; i < 32; i += 4) {
        m_rkey[i] = m_rkey[i] ^ m_rkey[i - 4];
        m_rkey[i + 1] = m_rkey[i + 1] ^ m_rkey[i - 3];
        m_rkey[i + 2] = m_rkey[i + 2] ^ m_rkey[i - 2];
        m_rkey[i + 3] = m_rkey[i + 3] ^ m_rkey[i - 1];
    }
}
示例#4
0
void calcDeltaFE(map<int, double>* deltaFE, double deltaEta)
{
     double base = F();
          map<int, double>::iterator dfit;
     for(dfit = (*deltaFE).begin(); dfit != (*deltaFE).end(); dfit++)
     {   
         dfit->second = (FE(deltaEta, dfit->first) - base) / deltaEta;
     }
}
示例#5
0
文件: gmxfio.c 项目: aar2163/GROMACS
static bool do_binwrite(void *item,int nitem,int eio,
                        const char *desc,const char *srcfile,int line)
{
    size_t size=0,wsize;
    int    ssize;

    check_nitem();
    switch (eio) {
    case eioREAL:
        size = sizeof(real);
        break;
    case eioDOUBLE:
        size = sizeof(double);
        break;
    case eioINT:
        size = sizeof(int);
        break;
    case eioGMX_STEP_T:
        size = sizeof(gmx_step_t);
        break;
    case eioUCHAR:
        size = sizeof(unsigned char);
        break;
    case eioNUCHAR:
        size = sizeof(unsigned char);
        break;
    case eioUSHORT:
        size = sizeof(unsigned short);
        break;
    case eioRVEC:
        size = sizeof(rvec);
        break;
    case eioNRVEC:
        size = sizeof(rvec);
        break;
    case eioIVEC:
        size = sizeof(ivec);
        break;
    case eioSTRING:
        size = ssize = strlen((char *)item)+1;
        do_binwrite(&ssize,1,eioINT,desc,srcfile,line);
        break;
    default:
        FE();
    }
    wsize = fwrite(item,size,nitem,curfio->fp);

    if ((wsize != nitem) && curfio->bDebug) {
        fprintf(stderr,"Error writing %s %s to file %s (source %s, line %d)\n",
                eioNames[eio],desc,curfio->fn,srcfile,line);
        fprintf(stderr,"written size %u bytes, source size %u bytes\n",
                (unsigned int)wsize,(unsigned int)size);
    }
    return (wsize == nitem);
}
示例#6
0
static void _dump_DIEFFECT_flags(DWORD dwFlags)
{
    if (TRACE_ON(dinput)) {
        unsigned int   i;
        static const struct {
            DWORD       mask;
            const char  *name;
        } flags[] = {
#define FE(x) { x, #x}
            FE(DIEFF_CARTESIAN),
            FE(DIEFF_OBJECTIDS),
            FE(DIEFF_OBJECTOFFSETS),
            FE(DIEFF_POLAR),
            FE(DIEFF_SPHERICAL)
#undef FE
        };
        for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
            if (flags[i].mask & dwFlags)
                TRACE("%s ", flags[i].name);
        TRACE("\n");
    }       
}
示例#7
0
int main() {
	memset(c, 0, sizeof(c));
	c[0][0] = 1;
	for (int i = 1; i < MAXN; ++i) c[i][0] = c[i][i] = 1;
	for (int i = 1; i < MAXN; ++i) {
		for (int j = 1; j < i; ++j) {
			c[i][j] = c[i-1][j] + c[i-1][j-1];
			if (c[i][j] >= MOD) c[i][j] %= MOD;
		}
	}
	int runs;
	scanf("%d", &runs);
	memset(fl, -1, sizeof(fl));
	memset(fe, -1, sizeof(fe));
	FE(360, 360);
	for (int run = 1; run <= runs; ++run) {
		int n, d;
		scanf("%d%d", &n, &d);
		printf("Case #%d: %lld\n", run, FE(n, d));
	}
	return 0;
}
示例#8
0
static void _dump_EnumDevices_dwFlags(DWORD dwFlags) {
    if (TRACE_ON(dinput)) {
        unsigned int   i;
        static const struct {
            DWORD       mask;
            const char  *name;
        } flags[] = {
#define FE(x) { x, #x}
            FE(DIEDFL_ALLDEVICES),
            FE(DIEDFL_ATTACHEDONLY),
            FE(DIEDFL_FORCEFEEDBACK),
            FE(DIEDFL_INCLUDEALIASES),
            FE(DIEDFL_INCLUDEPHANTOMS)
#undef FE
        };
        if (dwFlags == 0) {
            DPRINTF("DIEDFL_ALLDEVICES");
            return;
        }
        for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
            if (flags[i].mask & dwFlags)
                DPRINTF("%s ",flags[i].name);
    }
}
示例#9
0
void DataCollector::onMouse( int event, int x, int y, int, void* ptr) {
  if( event != cv::EVENT_LBUTTONDOWN )
    return;

  try {
    DataCollector* that  = (DataCollector*) ptr;
    std::string image_path1 = makePngName(std::to_string(that->label), that->sub_dir);
    std::string image_path2 = makeJp2Name(std::to_string(that->label), that->sub_dir);
    if( imwrite(image_path1, that->rgb_ptr->image) && imwrite(image_path2, that->depth_ptr->image)) {
      ROS_INFO_STREAM("Write to:" << image_path1<<"\n"<<image_path2);
      that->label++;
    } else {
      ROS_ERROR_STREAM("error writing!");
    }
    
    Mat depthRead = imread(image_path2, CV_LOAD_IMAGE_ANYDEPTH);
    FeatureExtractor FE(that->rgb_ptr->image ,depthRead);
    FE.extract_feats();
    FE.visualize_feats();
  }
  catch (cv::Exception& ex) {
    fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what());
  }
}
示例#10
0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cpu.h"

#define OS_SIZE 8 /* Just some arbitrary number for now */

uint32_t test_program[] = {
  ST(0, 1), /* Store value from reg0 into address in reg1*/ 
  FE(1, 2), /* Fetch value from address in reg1 into reg2 */
  FE(1, 7), /* Fetch value from address in reg1 into reg7 */
  ST(3, 1)  /* Store value from reg3 into address in reg1 */
};

int main() {
  registers regs; /* Registers */
  memory mem; /* Main memory */
  int i; /* Instruction count */

  /* 
   * 'Boot up'??
   */

  /* Initialize memory/registers to zero */
  memset(mem.data, 0, MEMSIZE);
  memset(&regs, 0, sizeof(registers));

  /* 'Load' sample program into memory */
  memcpy(mem.data + OS_SIZE, test_program, sizeof(test_program));

  /* Initialize some register and memory values 
示例#11
0
static void COMDLG32_DumpSBSPFlags(UINT uflags)
{
    if (TRACE_ON(commdlg))
    {
	unsigned int   i;
	static const struct {
	    DWORD       mask;
	    const char  *name;
	} flags[] = {
#define FE(x) { x, #x}
            /* SBSP_DEFBROWSER == 0 */
            FE(SBSP_SAMEBROWSER),
            FE(SBSP_NEWBROWSER),

            /* SBSP_DEFMODE == 0 */
            FE(SBSP_OPENMODE),
            FE(SBSP_EXPLOREMODE),
            FE(SBSP_HELPMODE),
            FE(SBSP_NOTRANSFERHIST),

            /* SBSP_ABSOLUTE == 0 */
            FE(SBSP_RELATIVE),
            FE(SBSP_PARENT),
            FE(SBSP_NAVIGATEBACK),
            FE(SBSP_NAVIGATEFORWARD),
            FE(SBSP_ALLOW_AUTONAVIGATE),

            FE(SBSP_NOAUTOSELECT),
            FE(SBSP_WRITENOHISTORY),

            FE(SBSP_REDIRECT),
            FE(SBSP_INITIATEDBYHLINKFRAME),
        };
#undef FE
        TRACE("SBSP Flags: %08x =", uflags);
	for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
	    if (flags[i].mask & uflags)
		TRACE("%s ", flags[i].name);
	TRACE("\n");
    }
}
示例#12
0
void dump_effect(const DIEFFECTINFO *pdei) {
    unsigned int i;
    REFGUID guid = &pdei->guid;
    static const struct {
    const GUID *guid;
    const char *name;
    } guids[] = {
#define FE(x) { &x, #x}
    FE(GUID_ConstantForce), FE(GUID_RampForce), FE(GUID_Square),
    FE(GUID_Sine), FE(GUID_Triangle), FE(GUID_SawtoothUp),
    FE(GUID_SawtoothDown), FE(GUID_Spring), FE(GUID_Damper),
    FE(GUID_Inertia), FE(GUID_Friction), FE(GUID_CustomForce)
#undef FE
    };

#define X(x) if (pdei->dwEffType & x) printf("\tEffectType |= "#x"\n");
    X(DIEFT_CONSTANTFORCE);
    X(DIEFT_PERIODIC);
    X(DIEFT_RAMPFORCE);
    X(DIEFT_CONDITION);
#undef X

    for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++)
        if (IsEqualGUID(guids[i].guid, guid))
            printf("%s\n", guids[i].name);
}
示例#13
0
文件: utility.c 项目: RPG-7/reactos
static const char *get_callback_name(DWORD dwInternetStatus) {
    static const wininet_flag_info internet_status[] = {
#define FE(x) { x, #x }
	FE(INTERNET_STATUS_RESOLVING_NAME),
	FE(INTERNET_STATUS_NAME_RESOLVED),
	FE(INTERNET_STATUS_CONNECTING_TO_SERVER),
	FE(INTERNET_STATUS_CONNECTED_TO_SERVER),
	FE(INTERNET_STATUS_SENDING_REQUEST),
	FE(INTERNET_STATUS_REQUEST_SENT),
	FE(INTERNET_STATUS_RECEIVING_RESPONSE),
	FE(INTERNET_STATUS_RESPONSE_RECEIVED),
	FE(INTERNET_STATUS_CTL_RESPONSE_RECEIVED),
	FE(INTERNET_STATUS_PREFETCH),
	FE(INTERNET_STATUS_CLOSING_CONNECTION),
	FE(INTERNET_STATUS_CONNECTION_CLOSED),
	FE(INTERNET_STATUS_HANDLE_CREATED),
	FE(INTERNET_STATUS_HANDLE_CLOSING),
	FE(INTERNET_STATUS_REQUEST_COMPLETE),
	FE(INTERNET_STATUS_REDIRECT),
	FE(INTERNET_STATUS_INTERMEDIATE_RESPONSE),
	FE(INTERNET_STATUS_USER_INPUT_REQUIRED),
	FE(INTERNET_STATUS_STATE_CHANGE),
	FE(INTERNET_STATUS_COOKIE_SENT),
	FE(INTERNET_STATUS_COOKIE_RECEIVED),
	FE(INTERNET_STATUS_PRIVACY_IMPACTED),
	FE(INTERNET_STATUS_P3P_HEADER),
	FE(INTERNET_STATUS_P3P_POLICYREF),
	FE(INTERNET_STATUS_COOKIE_HISTORY)
#undef FE
    };
    DWORD i;

    for (i = 0; i < (sizeof(internet_status) / sizeof(internet_status[0])); i++) {
	if (internet_status[i].val == dwInternetStatus) return internet_status[i].name;
    }
    return "Unknown";
}
示例#14
0
文件: gmxfio.c 项目: aar2163/GROMACS
static bool do_xdr(void *item,int nitem,int eio,
                   const char *desc,const char *srcfile,int line)
{
    unsigned char ucdum,*ucptr;
    bool_t res=0;
    float  fvec[DIM];
    double dvec[DIM];
    int    j,m,*iptr,idum;
    gmx_step_t sdum;
    real   *ptr;
    unsigned short us;
    double d=0;
    float  f=0;

    check_nitem();
    switch (eio) {
    case eioREAL:
        if (curfio->bDouble) {
            if (item && !curfio->bRead) d = *((real *)item);
            res = xdr_double(curfio->xdr,&d);
            if (item) *((real *)item) = d;
        }
        else {
            if (item && !curfio->bRead) f = *((real *)item);
            res = xdr_float(curfio->xdr,&f);
            if (item) *((real *)item) = f;
        }
        break;
    case eioDOUBLE:
        if (item && !curfio->bRead) d = *((double *)item);
        res = xdr_double(curfio->xdr,&d);
        if (item) *((double *)item) = d;
        break;
    case eioINT:
        if (item && !curfio->bRead) idum = *(int *)item;
        res = xdr_int(curfio->xdr,&idum);
        if (item) *(int *)item = idum;
        break;
    case eioGMX_STEP_T:
        /* do_xdr will not generate a warning when a 64bit gmx_step_t
         * value that is out of 32bit range is read into a 32bit gmx_step_t.
         */
        if (item && !curfio->bRead) sdum = *(gmx_step_t *)item;
        res = xdr_gmx_step_t(curfio->xdr,&sdum,NULL);
        if (item) *(gmx_step_t *)item = sdum;
        break;
    case eioUCHAR:
        if (item && !curfio->bRead) ucdum = *(unsigned char *)item;
        res = xdr_u_char(curfio->xdr,&ucdum);
        if (item) *(unsigned char *)item = ucdum;
        break;
    case eioNUCHAR:
        ucptr = (unsigned char *)item;
        res   = 1;
        for(j=0; (j<nitem) && res; j++) {
            res = xdr_u_char(curfio->xdr,&(ucptr[j]));
        }
        break;
    case eioUSHORT:
        if (item && !curfio->bRead) us = *(unsigned short *)item;
        res = xdr_u_short(curfio->xdr,(unsigned short *)&us);
        if (item) *(unsigned short *)item = us;
        break;
    case eioRVEC:
        if (curfio->bDouble) {
            if (item && !curfio->bRead)
                for(m=0; (m<DIM); m++)
                    dvec[m] = ((real *)item)[m];
            res=xdr_vector(curfio->xdr,(char *)dvec,DIM,(unsigned int)sizeof(double),
                           (xdrproc_t)xdr_double);
            if (item)
                for(m=0; (m<DIM); m++)
                    ((real *)item)[m] = dvec[m];
        }
        else {
            if (item && !curfio->bRead)
                for(m=0; (m<DIM); m++)
                    fvec[m] = ((real *)item)[m];
            res=xdr_vector(curfio->xdr,(char *)fvec,DIM,(unsigned int)sizeof(float),
                           (xdrproc_t)xdr_float);
            if (item)
                for(m=0; (m<DIM); m++)
                    ((real *)item)[m] = fvec[m];
        }
        break;
    case eioNRVEC:
        ptr = NULL;
        res = 1;
        for(j=0; (j<nitem) && res; j++) {
            if (item)
                ptr = ((rvec *)item)[j];
            res = do_xdr(ptr,1,eioRVEC,desc,srcfile,line);
        }
        break;
    case eioIVEC:
        iptr = (int *)item;
        res  = 1;
        for(m=0; (m<DIM) && res; m++) {
            if (item && !curfio->bRead) idum = iptr[m];
            res = xdr_int(curfio->xdr,&idum);
            if (item) iptr[m] = idum;
        }
        break;
    case eioSTRING: {
        char *cptr;
        int  slen;

        if (item) {
            if (!curfio->bRead)
                slen = strlen((char *)item)+1;
            else
                slen = 0;
        }
        else
            slen = 0;

        if (xdr_int(curfio->xdr,&slen) <= 0)
            gmx_fatal(FARGS,"wrong string length %d for string %s"
                      " (source %s, line %d)",slen,desc,srcfile,line);
        if (!item && curfio->bRead)
            snew(cptr,slen);
        else
            cptr=(char *)item;
        if (cptr)
            res = xdr_string(curfio->xdr,&cptr,slen);
        else
            res = 1;
        if (!item && curfio->bRead)
            sfree(cptr);
        break;
    }
    default:
        FE();
    }
    if ((res == 0) && (curfio->bDebug))
        fprintf(stderr,"Error in xdr I/O %s %s to file %s (source %s, line %d)\n",
                eioNames[eio],desc,curfio->fn,srcfile,line);
    return (res != 0);
}
示例#15
0
文件: gmxfio.c 项目: aar2163/GROMACS
static bool do_binread(void *item,int nitem,int eio,
                       const char *desc,const char *srcfile,int line)
{
    size_t size=0,rsize;
    int    ssize;

    check_nitem();
    switch (eio) {
    case eioREAL:
        if (curfio->bDouble)
            size = sizeof(double);
        else
            size = sizeof(float);
        break;
    case eioDOUBLE:
        size = sizeof(double);
        break;
    case eioINT:
        size = sizeof(int);
        break;
    case eioGMX_STEP_T:
        size = sizeof(gmx_step_t);
        break;
    case eioUCHAR:
        size = sizeof(unsigned char);
        break;
    case eioNUCHAR:
        size = sizeof(unsigned char);
        break;
    case eioUSHORT:
        size = sizeof(unsigned short);
        break;
    case eioRVEC:
    case eioNRVEC:
        if (curfio->bDouble)
            size = sizeof(double)*DIM;
        else
            size = sizeof(float)*DIM;
        break;
    case eioIVEC:
        size = sizeof(ivec);
        break;
    case eioSTRING:
        do_binread(&ssize,1,eioINT,desc,srcfile,line);
        size = ssize;
        break;
    default:
        FE();
    }
    if (item)
        rsize = fread(item,size,nitem,curfio->fp);
    else {
        /* Skip over it if we have a NULL pointer here */
#ifdef HAVE_FSEEKO
        fseeko(curfio->fp,(off_t)(size*nitem),SEEK_CUR);
#else
        fseek(curfio->fp,(size*nitem),SEEK_CUR);
#endif
        rsize = nitem;
    }
    if ((rsize != nitem) && (curfio->bDebug))
        fprintf(stderr,"Error reading %s %s from file %s (source %s, line %d)\n",
                eioNames[eio],desc,curfio->fn,srcfile,line);

    return (rsize == nitem);
}
示例#16
0
static void ff_dump_effect(struct ff_effect *effect)
{
    const char *type = "(Unknown)", *length = "INFINITE";
    struct ff_envelope *env = NULL;
    double angle;
#define FE(x) case x: type = #x; break
    switch (effect->type)
    {
        FE(FF_RUMBLE);
        FE(FF_PERIODIC);
        FE(FF_CONSTANT);
        FE(FF_SPRING);
        FE(FF_FRICTION);
        FE(FF_DAMPER);
        FE(FF_INERTIA);
        FE(FF_RAMP);
    }
#undef FE

    /* rotate so 0 points right */
    angle = 360 - ff_effect_direction_to_rad(effect->direction + 0xc000) * 180 / M_PI;

    if (effect->replay.length)
      length = wine_dbg_sprintf("%u ms", effect->replay.length);

    TRACE("type 0x%x %s, id %d, direction 0x%x (source angle %.2f), time length %s, start delay %u ms\n",
          effect->type, type, effect->id, effect->direction, angle, length, effect->replay.delay);
    if (effect->trigger.button || effect->trigger.interval)
        TRACE(" -> trigger button %u, re-trigger interval %u ms\n",
              effect->trigger.button, effect->trigger.interval);

    if (effect->type == FF_PERIODIC)
    {
        struct ff_periodic_effect *per = &effect->u.periodic;
        const char *wave = "(Unknown)";
#define FE(x) case x: wave = #x; break
        switch (per->waveform)
        {
            FE(FF_SQUARE);
            FE(FF_TRIANGLE);
            FE(FF_SINE);
            FE(FF_SAW_UP);
            FE(FF_SAW_DOWN);
            FE(FF_CUSTOM);
        }
#undef FE
        angle = ff_effect_direction_to_rad(per->phase) * 180 / M_PI;
        TRACE(" -> waveform 0x%x %s, period %u ms, magnitude %d, offset %d, phase 0x%x (angle %.2f), custom len %d\n",
              per->waveform, wave, per->period, per->magnitude, per->offset, per->phase, angle, per->custom_len);
        env = &per->envelope;
    }
    else if (effect->type == FF_CONSTANT)
    {
        struct ff_constant_effect *cons = &effect->u.constant;
        TRACE(" -> level %d\n", cons->level);
        env = &cons->envelope;
    }
    else if (effect->type == FF_RAMP)
    {
        struct ff_ramp_effect *ramp = &effect->u.ramp;
        TRACE(" -> start/end level %d/%d\n", ramp->start_level, ramp->end_level);
        env = &ramp->envelope;
    }
    else if (effect->type == FF_RUMBLE)
    {
        struct ff_rumble_effect *rumble = &effect->u.rumble;
        TRACE(" -> strong/weak magnitude %u/%u\n", rumble->strong_magnitude, rumble->weak_magnitude);
    }
    else if (effect->type == FF_SPRING || effect->type == FF_FRICTION ||
             effect->type == FF_DAMPER || effect->type == FF_INERTIA)
    {
        struct ff_condition_effect *cond = effect->u.condition;
        int i;
        for (i = 0; i < 2; i++)
        {
            /* format numbers here to make them align correctly */
            TRACE(" -> [%d] right/left saturation %5u/%5u, right/left coefficient %5d/%5d,"
                  " deadband %5u, center %5d\n", i, cond[i].right_saturation, cond[i].left_saturation,
                  cond[i].right_coeff, cond[i].left_coeff, cond[i].deadband, cond[i].center);
        }
    }

    if (env)
        TRACE(" -> envelope attack length(ms)/level %u/%u, fade length(ms)/level %u/%u\n",
              env->attack_length, env->attack_level, env->fade_length, env->fade_level);
}
示例#17
0
文件: gmxfio.c 项目: aar2163/GROMACS
static bool do_ascread(void *item,int nitem,int eio,
                       const char *desc,const char *srcfile,int line)
{
    FILE   *fp = curfio->fp;
    int    i,m,res=0,*iptr,ix;
    gmx_step_t s;
    double d,x;
    real   *ptr;
    unsigned char uc,*ucptr;
    char   *cptr;

    check_nitem();
    switch (eio) {
    case eioREAL:
    case eioDOUBLE:
        res = sscanf(next_item(fp),"%lf",&d);
        if (item) *((real *)item) = d;
        break;
    case eioINT:
        res = sscanf(next_item(fp),"%d",&i);
        if (item) *((int *)item) = i;
        break;
    case eioGMX_STEP_T:
        res = sscanf(next_item(fp),gmx_step_pfmt,&s);
        if (item) *((gmx_step_t *)item) = s;
        break;
    case eioUCHAR:
        res = sscanf(next_item(fp),"%c",&uc);
        if (item) *((unsigned char *)item) = uc;
        break;
    case eioNUCHAR:
        ucptr = (unsigned char *)item;
        for(i=0; (i<nitem); i++) {
            res = sscanf(next_item(fp),"%d",&ix);
            if (item) ucptr[i] = ix;
        }
        break;
    case eioUSHORT:
        res = sscanf(next_item(fp),"%d",&i);
        if (item) *((unsigned short *)item) = i;
        break;
    case eioRVEC:
        ptr = (real *)item;
        for(m=0; (m<DIM); m++) {
            res = sscanf(next_item(fp),"%lf\n",&x);
            ptr[m] = x;
        }
        break;
    case eioNRVEC:
        for(i=0; (i<nitem); i++) {
            ptr = ((rvec *)item)[i];
            for(m=0; (m<DIM); m++) {
                res = sscanf(next_item(fp),"%lf\n",&x);
                if (item) ptr[m] = x;
            }
        }
        break;
    case eioIVEC:
        iptr = (int *)item;
        for(m=0; (m<DIM); m++) {
            res = sscanf(next_item(fp),"%d\n",&ix);
            if (item) iptr[m] = ix;
        }
        break;
    case eioSTRING:
        cptr = next_item(fp);
        if (item) {
            decode_string(strlen(cptr)+1,(char *)item,cptr);
            /* res = sscanf(cptr,"%s",(char *)item);*/
            res = 1;
        }
        break;
    default:
        FE();
    }
    if ((res <= 0) && curfio->bDebug)
        fprintf(stderr,"Error reading %s %s from file %s (source %s, line %d)\n",
                eioNames[eio],desc,curfio->fn,srcfile,line);

    return (res > 0);
}
示例#18
0
文件: gmxfio.c 项目: aar2163/GROMACS
static bool do_ascwrite(void *item,int nitem,int eio,
                        const char *desc,const char *srcfile,int line)
{
    int  i;
    int  res=0,*iptr;
    real *ptr;
    char strbuf[256];
    unsigned char *ucptr;

    check_nitem();
    switch (eio) {
    case eioREAL:
    case eioDOUBLE:
        res = fprintf(curfio->fp,"%18.10e%s\n",*((real *)item),dbgstr(desc));
        break;
    case eioINT:
        res = fprintf(curfio->fp,"%18d%s\n",*((int *)item),dbgstr(desc));
        break;
    case eioGMX_STEP_T:
        sprintf(strbuf,"%s%s%s","%",gmx_step_fmt,"\n");
        res = fprintf(curfio->fp,strbuf,*((gmx_step_t *)item),dbgstr(desc));
        break;
    case eioUCHAR:
        res = fprintf(curfio->fp,"%4d%s\n",*((unsigned char *)item),dbgstr(desc));
        break;
    case eioNUCHAR:
        ucptr = (unsigned char *)item;
        for(i=0; (i<nitem); i++)
            res = fprintf(curfio->fp,"%4d",(int)ucptr[i]);
        fprintf(curfio->fp,"%s\n",dbgstr(desc));
        break;
    case eioUSHORT:
        res = fprintf(curfio->fp,"%18d%s\n",*((unsigned short *)item),
                      dbgstr(desc));
        break;
    case eioRVEC:
        ptr = (real *)item;
        res = fprintf(curfio->fp,"%18.10e%18.10e%18.10e%s\n",
                      ptr[XX],ptr[YY],ptr[ZZ],dbgstr(desc));
        break;
    case eioNRVEC:
        for(i=0; (i<nitem); i++) {
            ptr = ((rvec *)item)[i];
            res = fprintf(curfio->fp,"%18.10e%18.10e%18.10e%s\n",
                          ptr[XX],ptr[YY],ptr[ZZ],dbgstr(desc));
        }
        break;
    case eioIVEC:
        iptr= (int *)item;
        res = fprintf(curfio->fp,"%18d%18d%18d%s\n",
                      iptr[XX],iptr[YY],iptr[ZZ],dbgstr(desc));
        break;
    case eioSTRING:
        encode_string(256,strbuf,(char *)item);
        res = fprintf(curfio->fp,"%-18s%s\n",strbuf,dbgstr(desc));
        break;
    default:
        FE();
    }
    if ((res <= 0) && curfio->bDebug)
        fprintf(stderr,"Error writing %s %s to file %s (source %s, line %d)\n",
                eioNames[eio],desc,curfio->fn,srcfile,line);
    return (res > 0);
}
示例#19
0
文件: proj15.cpp 项目: dmm/cegis
void proj15::setParamNames( const int projNumber )
{
   projName m_name;
   setName( m_name.projectionName( projNumber ) );
   setTrueName( m_projName );
   switch( projNumber )
   {
    case 0:     //"Geographic:"
    case 2:     // "State Plane":
         break;

    case 1:     //"UTM":
         setParamName( 0, lonZ( 0 ) );
         setParamName( 1, latZ( 1 ) );
         break;

    case 3:     //"Albers Equal Area:"
    case 4:     //"Lambert Conformal Conic":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 2, stdPR1() );
         setParamName( 3, stdPR2() );
         setParamName( 4, centMer() );
         setParamName( 5, originLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 5:     //"Mercator":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 4, centMer() );
         setParamName( 5, trueScale() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 6:     //"Polar Stereographic":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 4, longPol() );
         setParamName( 5, trueScale() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 7:     //"Polyconic":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 4, centMer() );
         setParamName( 5, originLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 8:     //"Equidistant Conic A\\B":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 4, centMer() );
         setParamName( 5, originLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         if( getParamValue( 8 ) == 1 )
         {
             setTrueName( "Equidistant Conic B" );
             setParamName( 2, stdPR1() );
             setParamName( 3, stdPR2() );
         }
         else
         {
             setTrueName( "Equidistant Conic A" );
             setParamName( 2, stdPAR() );
         }
         break;

    case 9:     //"Transverse Mercator":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 2, factor() );
         setParamName( 4, centMer() );
         setParamName( 5, originLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 10:    //"Stereographic":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 11:    //"Lambert Azimuthal":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 12:    //"Azimuthal":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 13:    //"Gnomonic":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 14:    //"Orthographic":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 15:    //"Gen. Vert. Near Per":
         setParamName( 0, sphere( 0 ) );
         setParamName( 2, height() );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 16:    //"Sinusiodal":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 17:    //"Equirectangular":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 5, trueScale() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 18:    //"Miller Cylindrical":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 19:    //"Van der Grinten":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 5, originLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 20:    //"Hotine Oblique Merc A\\B":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 2, factor() );
         setParamName( 5, originLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         if( getParamValue( 12 ) == 1 )
         {
             setTrueName( "Hotine Oblique Merc B" );
             setParamName( 3, aziAng() );
             setParamName( 4, azmthPt() );
         }
         else
         {
             setTrueName( "Hotine Oblique Merc A" );
             setParamName( 8, long1() );
             setParamName( 9, lat1() );
             setParamName( 10, long2() );
             setParamName( 11, lat2() );
         }
         break;

    case 21:    //"Robinson":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 22:    //"Space Oblique Merc A\\B":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         if( getParamValue( 12 ) == 1 )
         {
             setTrueName( "Space Oblique Merc B" );
             setParamName( 2, satNum() );
             setParamName( 3, path( 3 ) );
         }
         else
         {
             setTrueName( "Space Oblique Merc A" );
             setParamName( 3, incAng() );
             setParamName( 4, ascLong() );
             setParamName( 8, psRev() );
             setParamName( 9, lRat() );
             setParamName( 10, pFlag( 10 ) );
         }
         break;

    case 23:    //"Alaska Conformal":
         setParamName( 0, semiMajor( 0 ) );
         setParamName( 1, semiMinor( 1 ) );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 24:    //"Interrupted Goode":
         setParamName( 0, sphere( 0 ) );
         break;

    case 25:    //"Mollweide":
         setParamName( 0, sphere( 0 ) );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 26:    //"Interrupted Mollweide":
         setParamName( 0, sphere( 0 ) );
         break;

    case 27:    //"Hammer":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 28:    //"Wagner IV":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 29:    //"Wagner VII":
         setParamName( 0, sphere( 0 ) );
         setParamName( 4, centMer() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         break;

    case 30:   //"Oblated Equal Area":
         setParamName( 0, sphere( 0 ) );
         setParamName( 2, shapeM() );
         setParamName( 3, shapeN() );
         setParamName( 4, centLon() );
         setParamName( 5, centerLat() );
         setParamName( 6, FE() );
         setParamName( 7, FN() );
         setParamName( 8, angle() );
         break;
    default:
         setInvalid();
         break;
   }

   return;
}
示例#20
0
/* This function is a helper to convert a GUID into any possible DInput GUID out there */
const char *_dump_dinput_GUID(const GUID guid) {
    unsigned int i;
    static const struct {
	const GUID guid;
	const char *name;
    } guids[] = {
#define FE(x) { x, #x}
	FE(GUID_XAxis),
	FE(GUID_YAxis),
	FE(GUID_ZAxis),
	FE(GUID_RxAxis),
	FE(GUID_RyAxis),
	FE(GUID_RzAxis),
	FE(GUID_Slider),
	FE(GUID_Button),
	FE(GUID_Key),
	FE(GUID_POV),
	FE(GUID_Unknown),
	FE(GUID_SysMouse),
	FE(GUID_SysKeyboard),
	FE(GUID_Joystick),
	FE(GUID_ConstantForce),
	FE(GUID_RampForce),
	FE(GUID_Square),
	FE(GUID_Sine),
	FE(GUID_Triangle),
	FE(GUID_SawtoothUp),
	FE(GUID_SawtoothDown),
	FE(GUID_Spring),
	FE(GUID_Damper),
	FE(GUID_Inertia),
	FE(GUID_Friction),
	FE(GUID_CustomForce)
#undef FE
    };
    for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
	if (IsEqualGUID(guids[i].guid, guid)) {
	    return guids[i].name;
	}
    }
    return debugstr_guid(&guid);
}