コード例 #1
0
ファイル: zad8.c プロジェクト: Acee11/Studia
int main()
{
	
	printf("sqrt(%f) = %f\n",14.0, approx_sqrt(14.0, 0.001));
	printf("sqrt(%f) = %f\n",10.0, approx_sqrt(10.0, 0.001));
	printf("sqrt(%f) = %f\n",2.0, approx_sqrt(2.0, 0.001));
	printf("sqrt(%f) = %f\n",100.0, approx_sqrt(100.0, 0.001));
	return 0;
}
コード例 #2
0
ファイル: symtab.c プロジェクト: 0mp/freebsd
void
ht_dump_statistics (hash_table *table)
{
  size_t nelts, nids, overhead, headers;
  size_t total_bytes, longest;
  double sum_of_squares, exp_len, exp_len2, exp2_len;
  hashnode *p, *limit;

#define SCALE(x) ((unsigned long) ((x) < 1024*10 \
		  ? (x) \
		  : ((x) < 1024*1024*10 \
		     ? (x) / 1024 \
		     : (x) / (1024*1024))))
#define LABEL(x) ((x) < 1024*10 ? ' ' : ((x) < 1024*1024*10 ? 'k' : 'M'))

  total_bytes = longest = sum_of_squares = nids = 0;
  p = table->entries;
  limit = p + table->nslots;
  do
    if (*p)
      {
	size_t n = HT_LEN (*p);

	total_bytes += n;
	sum_of_squares += (double) n * n;
	if (n > longest)
	  longest = n;
	nids++;
      }
  while (++p < limit);

  nelts = table->nelements;
  overhead = obstack_memory_used (&table->stack) - total_bytes;
  headers = table->nslots * sizeof (hashnode);

  fprintf (stderr, "\nString pool\nentries\t\t%lu\n",
	   (unsigned long) nelts);
  fprintf (stderr, "identifiers\t%lu (%.2f%%)\n",
	   (unsigned long) nids, nids * 100.0 / nelts);
  fprintf (stderr, "slots\t\t%lu\n",
	   (unsigned long) table->nslots);
  fprintf (stderr, "bytes\t\t%lu%c (%lu%c overhead)\n",
	   SCALE (total_bytes), LABEL (total_bytes),
	   SCALE (overhead), LABEL (overhead));
  fprintf (stderr, "table size\t%lu%c\n",
	   SCALE (headers), LABEL (headers));

  exp_len = (double)total_bytes / (double)nelts;
  exp2_len = exp_len * exp_len;
  exp_len2 = (double) sum_of_squares / (double) nelts;

  fprintf (stderr, "coll/search\t%.4f\n",
	   (double) table->collisions / (double) table->searches);
  fprintf (stderr, "ins/search\t%.4f\n",
	   (double) nelts / (double) table->searches);
  fprintf (stderr, "avg. entry\t%.2f bytes (+/- %.2f)\n",
	   exp_len, approx_sqrt (exp_len2 - exp2_len));
  fprintf (stderr, "longest entry\t%lu\n",
	   (unsigned long) longest);
#undef SCALE
#undef LABEL
}
コード例 #3
0
ファイル: calc.c プロジェクト: zinuzoid/zCalculator
void approx_lni(double real,double imag,double *realans,double *imagans)
{
	*realans=approx_ln(approx_sqrt(real*real+imag*imag));
	*imagans=approx_atan(imag/real);
}
コード例 #4
0
ファイル: calc.c プロジェクト: zinuzoid/zCalculator
double approx_asin(double val)
{
	return approx_atan(val/approx_sqrt(1-val*val));
}