当前位置: 首页>>代码示例>>C++>>正文


C++ setval函数代码示例

本文整理汇总了C++中setval函数的典型用法代码示例。如果您正苦于以下问题:C++ setval函数的具体用法?C++ setval怎么用?C++ setval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PronyModel

double PronyModel(double t, matrix* beta, void *params)
{
    matrix *Ji, *taui;
    double *p;
    double J0, J, Jval, tauval;
    int n, i;
    p = (double*) params;
    J0 = *p;

    /* Pull out all the parameter values */
    n = nRows(beta)/2;
    Ji = CreateMatrix(n, 1);
    taui = CreateMatrix(n, 1);

    for(i=0; i<n; i++) {
        setval(Ji, val(beta, 2*i, 0), i, 0);
        setval(taui, val(beta, 2*i+1, 0), i, 0);
    }

    J = J0;
    for(i=0; i<n; i++) {
        Jval = val(Ji, i, 0)*val(Ji, i, 0);
        tauval = val(taui, i, 0)*val(taui, i, 0);
        J += Jval * (1-exp(-t/tauval));
    }
    DestroyMatrix(Ji);
    DestroyMatrix(taui);
    return J;
}
开发者ID:mirrorscotty,项目名称:regression,代码行数:29,代码来源:nlin-fitcreepv2.c

示例2: aout_addsym

static unsigned long aout_addsym(char *name,taddr value,int bind,
                                 int info,int type,int desc,int be)
/* add a new symbol, return its symbol table index */
{
  struct SymbolNode **chain = &aoutsymlist.hashtab[hashcode(name)%SYMHTABSIZE];
  struct SymbolNode *sym;

  while (sym = *chain)
    chain = &sym->hashchain;
  /* new symbol table entry */
  *chain = sym = mycalloc(sizeof(struct SymbolNode));

  if (!name)
    name = emptystr;
  sym->name = name;
  sym->index = aoutsymlist.nextindex++;
  setval(be,sym->s.n_strx,4,aout_addstr(name));
  sym->s.n_type = type;
  /* GNU binutils don't use BIND_LOCAL/GLOBAL in a.out files! We do! */
  sym->s.n_other = ((bind&0xf)<<4) | (info&0xf);
  setval(be,sym->s.n_desc,2,desc);
  setval(be,sym->s.n_value,4,value);
  addtail(&aoutsymlist.l,&sym->n);
  return sym->index;
}
开发者ID:EgoIncarnate,项目名称:mist-board,代码行数:25,代码来源:output_aout.c

示例3: _start

void _start(void)
{
    struct uart *const uart = get_base_uart(0);
    struct dma *const dma =((struct dma *)get_base_dmas()) + 0;

    /*开启uart0 的DMA received 功能*/
    //uart->UCON |= 0x2 << 2;
    uart->UCON = 9;

    /* 设置源 */
    dma->DISRC = (unsigned int)buf;
    dma->DISRCC = 0; /* 数据源在内存中,ahb */

    /* 设置目的地址 */
    dma->DIDST =(unsigned int)&uart->UTXH;
    dma->DIDSTC |= 3;  /* 目的地址uart连接在apb上*/

    setval(dma->DCON, 0x001, 3, 24); /* 接上uart0  */
    setval(dma->DCON, 0x1, 1, 23); /*  硬件DMA*/
    setval(dma->DCON, 0x1, 1, 22); /* 关闭重载 */
    setval(dma->DCON, sizeof(buf), 20, 0);

    /* 激活DMA  */
    dma->DMASKTRIG |= 0x2;

    return;
}
开发者ID:yumm007,项目名称:C,代码行数:27,代码来源:dma.c

示例4: run

/* Of a 209-line interpreter, the actual interpreting function is only 17 lines... */
void run() {
    // run the program
    for (ip = 0; ip < n_of_lines; ip++) {
        switch (pgm[ip].instruction) {
        case LBL:
            break; // don't do anything, labels have already been stored.
        case CPY:
            setval(value(pgm[ip].op2),value(pgm[ip].op1));
            break;
        case INC:
            setval(value(pgm[ip].op1),memval(value(pgm[ip].op1))+1);
            break;
        case DEC:
            if (memval(value(pgm[ip].op1))) {
                setval(value(pgm[ip].op1), memval(value(pgm[ip].op1))-1);
            } else {
                ip = getlbl(pgm[ip].op2);
            };
            break;
        case OUT:
            putchar(value(pgm[ip].op1));
            break;
        case INP:
            setval(value(pgm[ip].op1),feof(stdin)?0:getchar());
            break;
        }
    }
}
开发者ID:pdrakos,项目名称:esofiles,代码行数:29,代码来源:pointy.c

示例5: CreateElementMatrix

matrix* CreateElementMatrix(struct fe *p, Elem2D *elem, matrix *guess)
{
    basis *b;
    b = p->b;

    int nvars = p->nvars;

    int i, j;
    double value = 0;
    matrix *m;

    m = CreateMatrix(b->n*nvars, b->n*nvars);

    for(i=0; i<b->n*nvars; i+=nvars) {
        for(j=0; j<b->n*nvars; j+=nvars) {
            /* dRx/dx */
            value = quad2d3generic(p, guess, elem, &ElemJdRxdx, i/2, j/2);
            setval(m, value, i, j);

            /* dRy/dx */
            value = quad2d3generic(p, guess, elem, &ElemJdRydx, i/2, j/2);
            setval(m, value, i+1, j);

            /* dRx/dy */
            value = quad2d3generic(p, guess, elem, &ElemJdRxdy, i/2, j/2);
            setval(m, value, i, j+1);

            /* dRy/dy */
            value = quad2d3generic(p, guess, elem, &ElemJdRydy, i/2, j/2);
            setval(m, value, i+1, j+1);
        }
    }

    return m;
}
开发者ID:mirrorscotty,项目名称:fe-problems,代码行数:35,代码来源:ce675p1.c

示例6: setval

void Filter::sliderValueChanged (Slider* sliderThatWasMoved)
{
    //[UsersliderValueChanged_Pre]
    //[/UsersliderValueChanged_Pre]

    if (sliderThatWasMoved == lower_cutoffslider)
    {
        //[UserSliderCode_lower_cutoffslider] -- add your slider handling code here..
      setval(filter,lower_cutoff);
        //[/UserSliderCode_lower_cutoffslider]
    }
    else if (sliderThatWasMoved == upper_cutoffslider)
    {
        //[UserSliderCode_upper_cutoffslider] -- add your slider handling code here..
      setval(filter,upper_cutoff);
        //[/UserSliderCode_upper_cutoffslider]
    }
    else if (sliderThatWasMoved == sharpnessslider)
    {
        //[UserSliderCode_sharpnessslider] -- add your slider handling code here..
      setval(filter,sharpness);
        //[/UserSliderCode_sharpnessslider]
    }

    //[UsersliderValueChanged_Post]
    //[/UsersliderValueChanged_Post]
}
开发者ID:jeremysalwen,项目名称:mammut-updated,代码行数:27,代码来源:Filter.cpp

示例7: main

int main(int argc, char *argv[])
{
    int i, j, k;
    double Ti, Mj, percent;
    vector *T, *M;
    matrix *t, *Jij, *betaij, *output, *ttmp;

    /*
    if(argc < 3) {
        printf("Usage:\n"
               "fitcreep: <file> <t1> <t2> ... <tn>\n"
               "<file>: Filename containing the creep function data.\n"
               "<t1>: First retardation time\n"
               "<t2>: Second retardation time\n"
               "...\n"
               "<tn>: Nth retardation time.\n");
        exit(0);
    }
    */

    T = linspaceV(333, 363, 10);
    M = linspaceV(.05, .4, 10);

    ttmp = linspace(1e-3, 1e3, 1000);
    t = mtxtrn(ttmp);
    DestroyMatrix(ttmp);

    output = CreateMatrix(len(T)*len(M), 2+5);

    for(i=0; i<len(T); i++) {
        Ti = valV(T, i);
        for(j=0; j<len(M); j++) {
            Mj = valV(M, j);
            Jij = makedata(t, Ti, Mj);
            betaij = fitdata(t, Jij);

            setval(output, Ti, i*len(M)+j, 0);
            setval(output, Mj, i*len(M)+j, 1);
            setval(output, val(Jij, 0, 0), i*len(M)+j, 2);
            for(k=0; k<nRows(betaij); k++)
                setval(output, pow(val(betaij, k, 0), 2), i*len(T)+j, k+3);
            DestroyMatrix(Jij);
            DestroyMatrix(betaij);

            /* Print the percent done */
            percent = (1.*i*len(M)+j)/(len(M)*len(T))*100.;
            printf("%3.2f %%\r", percent);
            fflush(stdout);
        }
    }
    
    DestroyMatrix(t);
    DestroyVector(T);
    DestroyVector(M);
    mtxprntfilehdr(output, "output.csv", "T,M,J0,J1,tau1,J2,tau2\n");
    DestroyMatrix(output);
    return 0;
}
开发者ID:mirrorscotty,项目名称:regression,代码行数:58,代码来源:nlin-fitcreepv2.c

示例8: CreateElementLoad

/* Create the load vector */
matrix* CreateElementLoad(double Pe, double h) {
    matrix *f;

    f = CreateMatrix(2, 1);

    setval(f, 0, 0, 0);
    setval(f, 0, 1, 0);

    return f;
}
开发者ID:mirrorscotty,项目名称:material-data,代码行数:11,代码来源:fe-solver.c

示例9: testload

matrix* testload(double Pe, double h) {
    matrix *f;

    f = CreateMatrix(2, 1);

    setval(f, h/2, 0, 0);
    setval(f, h/2, 1, 0);

    return f;
}
开发者ID:mirrorscotty,项目名称:material-data,代码行数:10,代码来源:fe-solver.c

示例10: addRel64

static void addRel64(int be,taddr o,taddr a,taddr i)
{
  struct RelocNode *rn = mymalloc(sizeof(struct RelocNode));

  setval(be,rn->r.r_offset,8,o);
#if RELA
  setval(be,rn->r.r_addend,8,a);
#endif
  setval(be,rn->r.r_info,8,i);
  addtail(&relalist,&(rn->n));
}
开发者ID:ezrec,项目名称:vasm,代码行数:11,代码来源:output_elf.c

示例11: CreateElementMatrix

/* Create the element matrix for the specified values of Pe and h */
matrix* CreateElementMatrix(double Pe, double h)
{
    matrix *elem;

    elem = CreateMatrix(2, 2);
    setval(elem, 1/h-Pe/2, 0, 0);
    setval(elem, -1/h+Pe/2, 0, 1);
    setval(elem, -1/h-Pe/2, 1, 0);
    setval(elem, 1/h+Pe/2, 1, 1);

    return elem;
}
开发者ID:mirrorscotty,项目名称:material-data,代码行数:13,代码来源:fe-solver.c

示例12: testelem

/* Test functions to create the element and load matricies based on the equation
 * in Problem 1
 */
matrix* testelem(double Pe, double h)
{
    matrix *elem;

    elem = CreateMatrix(2, 2);
    setval(elem, -1/h+h/3, 0, 0);
    setval(elem, 1/h+h/6, 0, 1);
    setval(elem, 1/h+h/6, 1, 0);
    setval(elem, -1/h+h/3, 1, 1);

    return elem;
}
开发者ID:mirrorscotty,项目名称:material-data,代码行数:15,代码来源:fe-solver.c

示例13: GetDeformedCoords

matrix* GetDeformedCoords(struct fe *p, matrix *Soln)
{
    matrix *Def;
    int i;
    Def = CreateMatrix(nRows(Soln)/2, 2);

    for(i=0; i<nRows(Soln)/2; i++) {
        setval(Def, val(Soln, 2*i, 0) + valV(GetNodeCoordinates(p->mesh, i), 0),  i, 0);
        setval(Def, val(Soln, 2*i+1, 0) + valV(GetNodeCoordinates(p->mesh, i), 1), i, 1);
    }

    return Def;
}
开发者ID:mirrorscotty,项目名称:fe-problems,代码行数:13,代码来源:ce675p1.c

示例14: FormatDisplacements

matrix* FormatDisplacements(struct fe *p, matrix *Soln)
{
    matrix *Def;
    int i;
    Def = CreateMatrix(nRows(Soln)/2, 2);

    for(i=0; i<nRows(Soln)/2; i++) {
        setval(Def, val(Soln, 2*i, 0),  i, 0);
        setval(Def, val(Soln, 2*i+1, 0), i, 1);
    }

    return Def;
}
开发者ID:mirrorscotty,项目名称:fe-problems,代码行数:13,代码来源:ce675p1.c

示例15: main

/**
 * Fit the GAB parameters given water activity
 */
int main(int argc, char *argv[])
{
    matrix *data, *aw, *Xdb, *tmp0, *tmp1, *beta0, *beta;

    if(argc != 2) {
        puts("Usage:");
        puts("gab <aw.csv>");
    }
    //data = mtxloadcsv("Andrieu.csv", 0);
    data = mtxloadcsv(argv[1], 0);

    /* Get the water activity from column 1 and the moisture content from
     * column 6. */
    aw = ExtractColumn(data, 0);
    Xdb = ExtractColumn(data, 5);

    /* Stick the two matricies together and delete any rows that contain
     * empty values */
    tmp0 = AugmentMatrix(aw, Xdb);
    tmp1 = DeleteNaNRows(tmp0);
    DestroyMatrix(aw);
    DestroyMatrix(Xdb);

    /* Pull the two columns back apart */
    aw = ExtractColumn(tmp1, 0);
    Xdb = ExtractColumn(tmp1, 1);
    DestroyMatrix(tmp0);
    DestroyMatrix(tmp1);

    /* Set up the beta matrix with some initial guesses at the GAB constants.
     * The solver needs these to be pretty close to the actual values, or it
     * will fail to converge */
    beta0 = CreateOnesMatrix(3, 1);
    setval(beta0, 6, 0, 0);
    setval(beta0, .5, 1, 0);
    setval(beta0, .04, 2, 0);

    /* Attempt to fit the gab parameters to the supplied data */
    beta = fitnlm(&gab, aw, Xdb, beta0);

    /* Print out the fitted values */
    printf("C = %g\nk = %g\nXm = %g\n",
            val(beta, 0, 0),
            val(beta, 1, 0),
            val(beta, 2, 0));

    return 0;
}
开发者ID:mirrorscotty,项目名称:regression,代码行数:51,代码来源:gab.c


注:本文中的setval函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。