Пример #1
0
inline void pls100_device::update_outputs()
{
	m_s = 0;

	for (int term = 0; term < PAL_TERMS; term++)
	{
		if (get_product(term))
		{
			m_s |= m_or[term];
		}
	}
}
Пример #2
0
int main(int argc, char **argv)
{
    product_t prods[8];
    int rv = -1;
    int i;
    int rmCnt = 0;
    btlogger_debug( "TxLog %s:%d", __FUNCTION__, __LINE__);

    if (argc > 1) {
        for (i = 1; i < argc; i++) {
            product_t *p = get_product(argv[i]);

            if (p == NULL) {
                btlogger_debug("TxLog product id %s not found", argv[i]);
                for (p = products; p->id != -1; p++)
                    btlogger_debug("TxLog product id %d", p->id);
                //return fatal("Requested db is not supported\n");
            } else {
                prods[rmCnt++] = *p;
            }
        }

        prods[rmCnt].id = -1;
        prods[rmCnt].access = 0;
        prods[rmCnt].xaflags = 0;
    } else {
        for (i = 0; products[i].id != -1; i++)
            prods[i] = products[i];

        prods[i] = products[i];
    }

    for (i = 0; prods[i].id != -1; i++) {
        btlogger_debug("TxLog INFO: %s (%s) id=%d flags=0x%x",
            prods[i].pname, prods[i].dbname, prods[i].id, prods[i].xaflags());
    }

    rv = run_tests(prods);

    btlogger("TxLog Test %s (%d)\n", (rv ? "failed" : "passed"), rv);

    return rv;
}
Пример #3
0
int capture_baseline_data(int baseline, int *real_raw, int *imag_raw, double *power, double *phase, int num_chan)
{
	int count;

	if( power == NULL || phase == NULL || real_raw == NULL || imag_raw == NULL){
		fprintf(stderr,"capture_baseline_data: dodgy parameters\n");
		return -1;
	}

	/*loop through channels getting all products for specified baseline*/
	for( count = 0; count < num_chan; count++){
		if( get_product(baseline, real_raw + (count*NUM_BASELINE_PRODUCTS), imag_raw + (count*NUM_BASELINE_PRODUCTS), power+(count*3), phase+(count*3)) < 0 ){
			fprintf(stderr,"capture_baseline_data: error getting products for baseline %d\n", baseline);
			free(real_raw);
			free(imag_raw);
		}
	}

	return 0;
}
Пример #4
0
Файл: p008.c Проект: nunoi/euler
int find_greatest_product(char *a)
{
    int len, res, i;
    int digits, prod;

    digits = 5;
    res = 0;
    len = strlen(a);
    for (i = 0; i < len - digits; i++) {
        char *substr;
 
        substr = get_substr(a, i, digits);
        prod = get_product(atoi(substr));
        /* printf("prod: %s - substr: %s\n", prod, substr); */
        if (res < prod) {
            res = prod;
        }
        free(substr);
   }
    return res;
}
Пример #5
0
static int get_terms(SEXP factors, const struct variables *v,
		     struct design *s, struct design *r, struct design2 *d,
		     struct terms *tm)
{
	SEXP dim, dimnames, colnames;
	int j, m, n, *xfactors;
	size_t *ind, order;
	int err = 0;
	const char *name;

	if (!IS_INTEGER(factors))
		DOMAIN_ERROR("'factors' should be integer");
	if (!(isMatrix(factors) || LENGTH(factors) == 0))
		DOMAIN_ERROR("'factors' should be a matrix or an empty integer vector");


	/* validate factor matrix */
	if (isMatrix(factors)) {
		dim = GET_DIM(factors);
		m = INTEGER(dim)[0];
		n = INTEGER(dim)[1];
		xfactors = INTEGER_POINTER(factors);

		if ((size_t)m != v->count)
			DOMAIN_ERROR("'factors' should have"
				     " rows equal to the number of variables");

		dimnames = GET_DIMNAMES(factors);
		colnames = GET_COLNAMES(dimnames);
	} else {
		m = 0;
		n = 0;
		xfactors = NULL;
	}

	ind = (void *)R_alloc(v->count, sizeof(*ind));


	tm->item = (void *)R_alloc(n, sizeof(*tm->item));
	tm->count = n;

	for (j = 0; j < n; j++) {
		name = CHAR(STRING_ELT(colnames, j));
		err = get_term_factors(name, xfactors, v, j, ind, &order);
		if (err < 0)
			goto out;

		if (order == 0) {
			DOMAIN_ERROR("intercepts are not allowed");
		} else if (order == 1) {
			memcpy(&tm->item[j], &v->item[ind[0]],
			       sizeof(struct variable));
		} else if (order == 2) {
			err = get_product(name,
					  v->item + ind[0], v->item + ind[1],
					  s, r, d, tm->item + j);
			if (err < 0)
				goto out;
		} else {
			DOMAIN_ERROR("interactions of order >= 3 are not implemented yet");
		}

	}

out:
	return err;
}
Пример #6
0
 /**
  * @param [out] product product name of of ftdi device
  * @return 0 on success<br>-1 on failure
  * @sa get_serial_id(unsigned int, std::string&), get_serial_id(std::string&)
  * , get_manufacturer(unsigned int, std::string&), get_manufacturer(std::string&)
  * , get_product(unsigned int, std::string&), get_product(std::string&)
  **/
 int get_product (std::string &product) { return get_product(0, product); }