Ejemplo n.º 1
0
VALUE rb_gsl_multiset_fprintf(VALUE mm, VALUE name, VALUE format)
{
  gsl_multiset *m;
  FILE *fp = NULL;
  int ret;
  Data_Get_Struct(mm, gsl_multiset, m);
  fp = fopen(STR2CSTR(name), "w");
  if (fp == NULL) {
    rb_raise(rb_eIOError, "Cannot open file %s", STR2CSTR(name));
  }
  ret = gsl_multiset_fprintf(fp, m, STR2CSTR(format));
  fclose(fp);
  return INT2FIX(ret);
}
int main(void) {
	gsl_multiset * c;
	size_t i;

	printf("All multisets of {0,1,2,3} by size:\n");
	for (i = 0; i <= 4; i++) {
		c = gsl_multiset_calloc(4, i);
		do {
			printf("{");
			gsl_multiset_fprintf(stdout, c, " %u");
			printf(" }\n");
		} while (gsl_multiset_next(c) == GSL_SUCCESS);
		gsl_multiset_free(c);
	}

	return 0;
}