Example #1
0
/**
 * @details  Cleans a ledger object. Specifically, calls condense 
 *           and sort_by_status.
 */
err_t clean(Ledger *ledger, int sort_locked){
  
  if(condense(ledger) == LFAILURE)
    return LFAILURE;

  if(sort_by_status(ledger, sort_locked) == LFAILURE)
    return LFAILURE;
 
  return LSUCCESS;
}
Example #2
0
constexpr
typename std::enable_if<N==N_2*2,recarr<T,N>>::type
fft_helper(recarr<T,N> v, recarr<T,N_2> rofu) {
  return cat(zipWith(sum<T>,fft_helper(condense(v), condense(rofu)),
                            zipWith(product<T>,fft_helper(condense(cshift1(v)),
                                                          condense(rofu)),
                                               rofu)),
             zipWith(sub<T>,fft_helper(condense(v), condense(rofu)),
                            zipWith(product<T>,fft_helper(condense(cshift1(v)),
                                                          condense(rofu)),
                                               rofu)));
}
Example #3
0
File: cfft.hpp Project: respu/ctfft
constexpr
typename enable_if<sizeof...(Ts)==(2*sizeof...(Us)),tuple<Ts...>>::type
fft_helper(tuple<Ts...> v, tuple<Us...> rofu) {
  typedef typename pack_head<Ts...>::type T;   // T is usually cx<double>
  return cat(zipWith(sum<T>,fft_helper(condense(v), condense(rofu)),
                            zipWith(product<T>,fft_helper(condense(cshift1(v)),
                                                          condense(rofu)),
                                               rofu)),
             zipWith(sub<T>,fft_helper(condense(v), condense(rofu)),
                            zipWith(product<T>,fft_helper(condense(cshift1(v)),
                                                          condense(rofu)),
                                               rofu)));
}
Example #4
0
void
recopy(char *fnam)
{
	int c;
	int *wref = NULL;
	int wcnt = 0;
	int wsize = 50;
	int finalrn;
	char sig[MXSIG];
	extern int *realloc();

	wref = (int *)calloc((unsigned)wsize, (unsigned)sizeof (int));
	fclose(ftemp);
	ftemp = fopen(fnam, "r");
	if (ftemp == NULL) {
		fprintf(stderr, gettext("Can't reopen %s\n"), fnam);
		exit(1);
	}
	while ((c = getc(ftemp)) != EOF) {
		if (c == FLAG) {
			char tb[10];
			char *s = tb;
			while ((c = getc(ftemp)) != FLAG)
				*s++ = c;
			*s = 0;
			/*
			 * If sort was done, permute the reference number
			 * to obtain the final reference number, finalrn.
			 */
			if (sort)
				finalrn = newr[atoi(tb)];
			else
				finalrn = atoi(tb);
			if ((++wcnt > wsize) && ((wref = realloc(wref,
			    (wsize += 50) * sizeof (int))) == NULL)) {
				fprintf(stderr, gettext(
				    "Ref condense out of memory."));
				exit(1);
			}
			wref[wcnt-1] = finalrn;
			if ((c = getc(ftemp)) == AFLAG)
				continue;
			wref[wcnt] = 0;
			condense(wref, wcnt, sig);
			wcnt = 0;
			printf("%s", sig);
		}
		putchar(c);
	}
	fclose(ftemp);
	unlink(fnam);
}
Example #5
0
int optimize(ins_t *code) {
  int changed;

  // keep optimizing until there's nothing left
  do {
    changed = 0;
    changed |= fold(code);
    changed |= condense(code);
    changed |= unloop(code);
    changed |= dce(code);
    changed |= peep(code);
  } while (changed);

  peepfinal(code);

  int opt_size;
  for (opt_size = 0; code[opt_size].op != OP_EOF; ++opt_size) {}
  return opt_size;
}
Example #6
0
constexpr
recarr<T,N/2> condense(recarr<T,N> arr) {
  return recarr_cons(arr.head(),condense(arr.tail().tail()));
}