Example #1
0
int z_incr_key(void *cptr, char *arg) {
	redisClient *c = (redisClient *)cptr;
	robj *argv[2], *cmd, *key;
	int i, increment_max = 1000;

	printf("z_incr_key: %s\n", arg);

	z_set(c, "incr", "1");

	cmd = createStringObject("INCR", 4);
	key = createStringObject("incr", 4);

	argv[0] = cmd;
	argv[1] = key;
	
	c->argv = argv;
	c->argc = 2;

	if(arg) {
		increment_max = atoi(arg);
	}

	for(i = 0; i < increment_max; i++) {
		incrDecrCommand(c, 1);
	}

	freeStringObject(cmd);
	freeStringObject(key);

	c->argv = NULL;
	c->argc = 0;

	return 0;
}
Example #2
0
void zmat_vec_mult(Zvector *prod, Zmatrix *m, Zvector *v) {
  int i, j;
  if (!(m->nrows == prod->size && v->size == m->ncols))
    die("ERROR zmat_vec_mult: bad dimensions\n");
  for (i = 0; i < m->nrows; i++) {
    prod->data[i] = z_set(0, 0);
    for (j = 0; j < m->ncols; j++) {
      prod->data[i] = z_add(prod->data[i],
			    z_mul(m->data[i][j], v->data[j]));
    }
  }
}
Example #3
0
/* multiply two complex matrices whose product is expected to be real */
void zmat_mult_real(Matrix *prod, Zmatrix *m1, Zmatrix *m2) {
  int i, j, k;
  if (!(m1->ncols == m2->nrows && m1->nrows == m2->ncols &&
	prod->nrows == m1->nrows && prod->ncols == m2->ncols))
    die("ERROR zmat_mult_real: bad dimensions\n");
  mat_zero(prod);
  for (i = 0; i < prod->nrows; i++) {
    for (j = 0; j < prod->ncols; j++) {
      Complex z = z_set(0, 0);
      for (k = 0; k < m1->ncols; k++)
	z = z_add(z, z_mul(m1->data[i][k], m2->data[k][j]));
      if (z.y > 1e-6)
	die("ERROR in zmat_mult_real: product of complex matrices not real.\n");
      mat_set(prod, i, j, z.x);
    }
  }
}
Example #4
0
int z_set_incremental(void *cptr, char *arg) {
	redisClient *c = (redisClient *)cptr;
	char buf[10];
	int i, iterator = 1000;

	printf("z_set_incremental: %s\n", arg);
	
	if(arg) {
		iterator = atoi(arg);
	}

	for(i = 0; i < iterator; i++) {
		snprintf(buf,sizeof(buf)-1,"%i",i);
		z_set(c, buf, "world");
	}

	return 0;
}
Example #5
0
void zmat_zero(Zmatrix *m) {
  int i, j;
  for (i = 0; i < m->nrows; i++)
    for (j = 0; j < m->ncols; j++)
      m->data[i][j] = z_set(0, 0);
}
Example #6
0
void zmat_set_identity(Zmatrix *m) {
  int i, j;
  for (i = 0; i < m->nrows; i++)
    for (j = 0; j < m->ncols; j++)
      m->data[i][j] = z_set(i == j ? 1 : 0, 0);
}