コード例 #1
0
ファイル: compute_thread.c プロジェクト: acooks/jittertrap
inline static int
calc_whoosh_err(struct slist *list, struct mq_stats_msg *m, int decim8)
{
	uint32_t whoosh_sum = 0, whoosh_max = 0, whoosh_sum2 = 0;
	struct slist *ln;
	int size = slist_size(list);

	ln = slist_idx(list, size - decim8);
	for (int i = decim8; i > 0; i--) {
		struct sample *s = ln->s;
		whoosh_sum += s->whoosh_error_ns;
		whoosh_sum2 += (s->whoosh_error_ns * s->whoosh_error_ns);
		whoosh_max = (whoosh_max > s->whoosh_error_ns)
		                 ? whoosh_max
		                 : s->whoosh_error_ns;
		ln = ln->next;
	}

	m->max_whoosh = whoosh_max;
	m->mean_whoosh = (uint64_t)ceill((double)whoosh_sum / (double)decim8);

	double variance = (long double)whoosh_sum2 / (double)decim8;
	m->sd_whoosh = (uint64_t)ceill(sqrtl(variance));

	if ((decim8 == decs[DECIMATIONS_COUNT - 1]) &&
	    ((whoosh_max >= 0.1 * m->interval_ns) ||
	     (m->sd_whoosh >= m->interval_ns))) {
		syslog(LOG_INFO, "sampling jitter! mean: %10" PRId32
		                " max: %10" PRId32 " sd: %10" PRId32 "\n",
		        m->mean_whoosh, m->max_whoosh, m->sd_whoosh);
	}

	return 0;
}
コード例 #2
0
ファイル: llroundl.c プロジェクト: 01org/CODK-A-Flashpack
long long
llroundl (long double x)
{
  long double res;

  if (x >= 0.0L)
    {
      res = ceill (x);
      if (res - x > 0.5L)
        res -= 1.0L;
    }
  else
    {
      res = ceill (-x);
      if (res + x > 0.5L)
        res -= 1.0L;
      res = -res;
    }
  if (!isfinite (res)
      || res > (double) LONG_LONG_MAX
      || res < (double) LONG_LONG_MIN)
    {
      errno = ERANGE;
      /* Undefined behaviour, so we could return anything.  */
      /* return res > 0.0 ? LONG_LONG_MAX : LONG_LONG_MIN;  */
    }
  return (long long) res;
}
コード例 #3
0
ファイル: test-ceill-ieee.c プロジェクト: ajnelson/gnulib
int
main ()
{
  DECL_LONG_DOUBLE_ROUNDING

  BEGIN_LONG_DOUBLE_ROUNDING ();

  /* See IEEE 754, section 6.3:
       "the sign of the result of the round floating-point number to
        integral value operation is the sign of the operand. These rules
        shall apply even when operands or results are zero or infinite."  */

  /* Zero.  */
  ASSERT (!signbit (ceill (0.0L)));
  ASSERT (!!signbit (ceill (minus_zerol)) == !!signbit (minus_zerol));
  /* Positive numbers.  */
  ASSERT (!signbit (ceill (0.3L)));
  ASSERT (!signbit (ceill (0.7L)));
  /* Negative numbers.  */
  ASSERT (!!signbit (ceill (-0.3L)) == !!signbit (minus_zerol));
  ASSERT (!!signbit (ceill (-0.7L)) == !!signbit (minus_zerol));

  /* [MX] shaded specification in POSIX.  */

  /* NaN.  */
  ASSERT (isnanl (ceill (NaNl ())));
  /* Infinity.  */
  ASSERT (ceill (Infinityl ()) == Infinityl ());
  ASSERT (ceill (- Infinityl ()) == - Infinityl ());

  return 0;
}
コード例 #4
0
ファイル: funcion.cpp プロジェクト: DX94/freedfd
void
Random (Token ** Pila)
{

  Token *Operando = EntornoEjecucion_BuscaSimbolo (*Pila);
  if (Buzon.GetHuboError ())
    return;
  if (NoEsReal (Operando))
    {
      BorrarTokenSiEsVariable (Operando);
      return;
    }
  long double ValorDominio = (Operando->GetDatoReal ());
  BorrarTokenSiEsVariable (Operando);
  long double ValorAleatorio = rand ();
  if (ValorDominio > 32767.0L)
    ValorAleatorio *= ValorDominio / 32767.0L;
  long double ValorRetorno = ceill (fmod (ValorAleatorio, ValorDominio));
  Token *TokenRetorno = ConsigueToken (ValorRetorno);
  if (Buzon.GetHuboError ())
    return;
  delete Desapila (Pila);
  Apila (Pila, TokenRetorno);
  return;

}
コード例 #5
0
inline static void calc_whoosh_error(struct iface_stats *stats)
{
	long double variance;
	double max = 0;
	uint64_t sum = 0;
	uint64_t sum_squares = 0;

	for (int i = 0; i < SAMPLES_PER_FRAME; i++) {
		struct sample s = stats->samples[i];
		max = (s.whoosh_error_ns > max) ? s.whoosh_error_ns : max;
		sum += s.whoosh_error_ns;
		sum_squares += (s.whoosh_error_ns * s.whoosh_error_ns);
	}
	stats->whoosh_err_max = max;
	stats->whoosh_err_mean = sum / SAMPLES_PER_FRAME;
	variance = (long double)sum_squares / (double)SAMPLES_PER_FRAME;
	stats->whoosh_err_sd = (uint64_t)ceill(sqrtl(variance));

	if ((max >= 500 * SAMPLE_PERIOD_US) ||
	    (stats->whoosh_err_sd >= 200 * SAMPLE_PERIOD_US)) {
		fprintf(stderr, "sampling jitter! mean: %10" PRId64
		                " max: %10" PRId64 " sd: %10" PRId64 "\n",
		        stats->whoosh_err_mean, stats->whoosh_err_max,
		        stats->whoosh_err_sd);
	}
}
コード例 #6
0
ファイル: math_h.pass.cpp プロジェクト: Bluerise/bitrig
void test_ceil()
{
    static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
    static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
    static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
    assert(ceil(0) == 0);
}
コード例 #7
0
ファイル: roundl.c プロジェクト: YunusIncredibl/mingw-w64-crt
long double
roundl (long double x)
{
  long double res = 0.0L;
  if (x >= 0.0L)
    {
      res = ceill (x);
      if (res - x > 0.5L)
	res -= 1.0L;
    }
  else
    {
      res = ceill (-x);
      if (res + x > 0.5L)
	res -= 1.0L;
      res = -res;
    }
  return res;
}
コード例 #8
0
unsigned int CLTreeTrainer<ImgType, nChannels, FeatType, FeatDim, nClasses>::_initHistogram(
  const TreeTrainerParameters<FeatType, FeatDim> &params)
{
  unsigned int frontierSize = m_frontierIdxMap.size();

  size_t perNodeHistogramSize = params.nFeatures*params.nThresholds*nClasses;
  unsigned int nSlices = ceill((double)frontierSize/m_histogramSize);

  return nSlices;
}
コード例 #9
0
ファイル: 10253.c プロジェクト: KimSuHeon/BOJ
long long ch(long long a,long long b){
	if (a==1)return b;
	long long g,i;
	i=ceill(b/(double)a);
	a=a*i-b;
	b*=i;
	g=gcd(a,b);
	a/=g;
	b/=g;
	return ch(a,b);
}
コード例 #10
0
ファイル: math_trait.hpp プロジェクト: kjaylee/openMVG
 inline long double MathTrait<long double>::round( const long double val )
 {
   if( val >= 0.0l )
   {
     return floorl( val + 0.5l ) ;
   }
   else
   {
     return ceill( val - 0.5l ) ;
   }
 }
コード例 #11
0
ファイル: main.cpp プロジェクト: martyu/CS311_Assignment3
indexes_t bit_indexes_from_number(unsigned long long number){
	indexes_t indexes;
	
	indexes.x = ceill(number / bits_in_element);
	
	if(indexes.x == 0)
		indexes.y = number;
	else
		indexes.y = number - indexes.x*bits_in_element;
	
	return indexes;
}
コード例 #12
0
ファイル: euler.c プロジェクト: cnh/polyeuler
/* Euler #3:
 * Answer: 6857
 *
 * The prime factors of 13195 are 5, 7, 13 and 29.
 *
 * What is the largest prime factor of the number 600851475143 ?
 */
int euler3() {
    unsigned long target = 600851475143;
    int i;
    double s = sqrtl(target);
    double c = (long double)ceill(s);
    for (i = c; i > 0; i--) {
        if ((target % i == 0) && (is_prime(i))) {
            return i;
        }
    }
    return -1;
}
コード例 #13
0
long double
roundl (long double x)
{
   long double t;
   if (!isfinite (x))
     return (x);

   if (x >= 0.0)
    {
      t = ceill (x);
      if (t - x > 0.5)
	t -= 1.0;
      return (t);
    } 
   else 
    {
      t = ceill (-x);
      if (t + x > 0.5)
	t -= 1.0;
      return (-t);
    }
}
コード例 #14
0
ファイル: timer.c プロジェクト: RAHUL04/RIPv1
/* -----------------------------------------------  Function to obtain the current time ----------------------------------------------------- */
void get_current_time()
{
  struct timeval timestruct;
    
  /* Get current time in the struct timeval. It stores time in two members tv_sec = seconds, tv_usec = microseconds */
  gettimeofday(&timestruct,NULL);
  
  /* Convert the time in struct timeval into milliseconds */
  timer_ds.current_time = timestruct.tv_sec*1000ULL + timestruct.tv_usec/1000;

  /* Round up the current time to the time granularity */
  timer_ds.current_time = (timer_time_t)ceill((long double)timer_ds.current_time/(long double)50)*50ULL;
}
コード例 #15
0
ファイル: timer.c プロジェクト: RAHUL04/RIPv1
/* -----------------------------------------------  Function to find the position where the new timer should be inserted --------------------- */
int get_position(timer_time_t duration, timer_time_t *current_endtime)
{
  /* dval tells how many rounds of hash table are required for timer to expire */
  unsigned long long dval = (unsigned long long)ceill((long double)duration/(long double)TIME_GRANULARITY) - 1;

  /* position is in which bucket should the new timer go into */
  int position = (timer_ds.current_bucket + dval)%MAX;
    
  /* When this timer will expire */
  *current_endtime = timer_ds.current_time + TIME_GRANULARITY * dval;
  
  /* Return the bucket number */
  return(position);
}
コード例 #16
0
ファイル: easy_dash#2.c プロジェクト: hemanshu95/programs
int main()
{
    int t;
    scanf("%d",&t);
    long long a,b,x;
    while(t-->0)
    {
        scanf("%lld%lld",&a,&b);
        a=(long long)ceill(sqrt((double)a));
        b=(long long)(sqrt((double)a));
        x=b-a+1;
        printf("%lld\n",x);
    }
    return 0;
}
コード例 #17
0
ファイル: hyperspace.cpp プロジェクト: 07zjw/DENCLUE
// Constructor
HyperSpace::HyperSpace( const vector<double>& up_bound , const vector<double>& lw_bound, double sigma , double xi, const unsigned num_dimensions) : dimension(num_dimensions), sigma(sigma), xi(xi) {


    /* Allocate storage for spatial bounds */
    this->lower_bounds = new double[num_dimensions];
    this->upper_bounds = new double[num_dimensions];


    double edge_length = this->hypercubeEdgeLenght();
    for(unsigned i=0 ; i < num_dimensions ; i++){

        this->lower_bounds[i] = lw_bound[i];
        this->upper_bounds[i] = edge_length * ceill(up_bound[i] / edge_length ); // Ensure that all regions will have the same size
    }

}
コード例 #18
0
ファイル: tempo2pred.c プロジェクト: ARO-user/work-share
int T2Predictor_GetPlan_Ext(char *filename,
			long double mjd_start,
			long double mjd_end,
			long double step, // seconds
			long double freq, // MHz
			// remaining arguments are returned
			char *psrname, char *sitename,
			long double *phase0,
			int *nsegments,
			long double *pulse_frequencies)
{
  int iseg, ret;
  long double lastphase, phase, mjd, lastmjd;
  T2Predictor pred;

  if ((ret=T2Predictor_Read(&pred, filename)))
    return ret;
  if (psrname)
    strcpy(psrname, T2Predictor_GetPSRName(&pred));
  if (sitename)
    strcpy(sitename, T2Predictor_GetSiteName(&pred));

  *nsegments = (int)ceill((mjd_end-mjd_start)*86400.0L/step);
  *phase0 = lastphase = T2Predictor_GetPhase(&pred, mjd_start, freq);
  lastmjd = mjd_start;
  printf("SILLY UPDATE IN POLYCO: REMOVE\n");
  printf("lastmjd = %.20Lf\n",mjd_start);

  for (iseg=0; iseg < *nsegments; iseg++)
  {
    mjd = mjd_start +(iseg+1)*step/86400.0L;
    if (mjd > mjd_end)
      mjd = mjd_end;
    phase = T2Predictor_GetPhase(&pred, mjd, freq);
    pulse_frequencies[iseg] = (phase-lastphase)/(mjd-lastmjd)/86400.0L;
    lastphase = phase;
    lastmjd = mjd;
  }

  T2Predictor_Destroy(&pred);

  return 0;
}
コード例 #19
0
ファイル: eval.c プロジェクト: patmanteau/iclc
LONG_DOUBLE eval_expr_func(eval_context *ctx, ast_node *tree) {
    expr_func_data *func_data = (expr_func_data*)tree->data;
    if (strcmp(func_data->name, "sin") == 0) return sinl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "cos") == 0) return cosl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "tan") == 0) return tanl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "acos") == 0) return acosl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "asin") == 0) return asinl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "atan") == 0) return atanl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "cosh") == 0) return coshl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "sinh") == 0) return sinhl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "tanh") == 0) return tanhl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "log") == 0) return logl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "log10") == 0) return log10l(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "ceil") == 0) return ceill(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "fabs") == 0) return fabsl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "floor") == 0) return floorl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "sqrt") == 0) return sqrtl(eval_expr(ctx, func_data->rhs));
    else return eval_emit_error(ctx, "Unknown function %s.", func_data->name);
}
コード例 #20
0
ファイル: pixel.c プロジェクト: acarnero/pymangle
int64
get_pixel_simple(int64 pixelres, struct Point* pt)
{
    int64 pix=0;

    int64 i=0;
    int64 ps=0, p2=1;
    long double cth=0;
    int64 n=0, m=0;
    if (pixelres > 0) {
        for (i=0; i<pixelres; i++) { // Work out # pixels/dim and start pix.
            p2  = p2<<1;
            ps += (p2/2)*(p2/2);
        }
      cth = cosl(pt->theta);
      n   = (cth==1.0) ? 0: (int64) ( ceill( (1.0-cth)/2 * p2 )-1 );
      m   = (int64) ( floorl( (pt->phi/2./M_PI)*p2 ) );
      pix = p2*n+m + ps;

    }
    return pix;
}
コード例 #21
0
int generate_trial(const char *filename, int verbose, int output_on_file, char *outfilename, double **output, uint *index, double srate, double dt)
{
char mytext[500];
double **parsed_data;
double T;                           // Total duration [s].
uint Ni;                             // Partial duration [points].
uint N;                              // Size of the output waveform (i.e. N = T / dt).
FILE *fp;

size_t cols, nlines;
uint  current_line;
uint i, return_code;

 //--------------------------------------------------------------------------------------
 // Data structure containing the input file is defined and created here. 

 parsed_data = (double **) calloc(MAXROWS, sizeof(double *));
 if (parsed_data == NULL) { error("Unable to allocate memory for <parsed_data> !", verbose);  return -1; } 
 for (i=0; i<MAXROWS; i++)  { 
  parsed_data[i] = (double *) calloc(MAXCOLS, sizeof(double)); 
  if (parsed_data[i] == NULL) { error("Unable to allocate memory for <parsed_data[i]> !", verbose);  return -1; } 
 }
 //--------------------------------------------------------------------------------------

 //--------------------------------------------------------------------------------------
 // The input-file parsing routine is invoked here..

 if (readmatrix(filename, parsed_data, &nlines, &cols) == -1) {
  error("impossible to proceed.", verbose);  return -1; }
    
  sprintf(mytext,"[%s] acquired correctly: %d lines, %d columns", filename, (int) nlines, (int) cols); msg(mytext, verbose);
  if (nlines == 0) { warning("No stimulus to be parsed: file empty!", verbose);  return -1; }

/*
  printf("The parsed file was:\n"); 
  for (i=0; i<nlines; i++) {
   for (j=0; j<cols+2; j++)
    printf("%f ", parsed_data[i][j]); 
   printf("\n"); 
   } // end for()
*/
 //--------------------------------------------------------------------------------------


 //--------------------------------------------------------------------------------------
 // Data structure containing the output file is defined and created here. 
 T      = how_long_lasts_trial(parsed_data, nlines);
 if (T <= 0) { error("Zero trial duration !", verbose);  return -1; }
 sprintf(mytext, "Total time: %.2f s @ %.1f Hz", T, srate); msg(mytext, verbose);
 N      = (uint) ceill(T * srate) + nlines - 1;
 (*output) = (double *) calloc(N, sizeof(double));   // Please note: "c"-alloc is indeed required here!
 if ((*output) == NULL) { error("Unable to allocate memory for <output> !", verbose);  return -1; } 

 //--------------------------------------------------------------------------------------

 //--------------------------------------------------------------------------------------
 // Let's start managing the input file..

 current_line = 0;      // Starting from the first entry
 (*index)     = 0;      // Index of the output data structure "output" is set to "0".
 
 while (current_line < nlines) {
 
  if (parsed_data[current_line][CODE] > 0) {
  Ni = (uint) ceill(parsed_data[current_line][DURATION] * srate);
  if (((*index)+Ni) > N) { fprintf(stderr, "%d > %d\n", (*index)+Ni, N); error("Out of range in <output> !", verbose);  return -1; } 
  return_code = simple_waveform(parsed_data[current_line], (*output), index, Ni, srate, dt, verbose); 
  if (return_code == -1) { error("simple_waveform returned -1", verbose); return -1;}
  current_line++;
  }
 else
  {
  i = composite_waveform(parsed_data, current_line, (*output), index, N, srate, dt, verbose); 
  if (i == -1) { error("composite_waveform returned -1", verbose); return -1;}
  current_line += i; 
  }
 
 } // end while()
 //--------------------------------------------------------------------------------------

if (output_on_file) {
fp = fopen(outfilename, "w");
for (i=0; i<(*index); i++)
 fprintf(fp, "%f %f\n", i*dt, (*output)[i]);
}
//--------------------------------------------------------------------------------------
// Allocated memory is released here.
for (i=0; i<MAXROWS; i++)  free(parsed_data[i]);
free(parsed_data);
//free((*output));    // NOT HERE FOR THIS VERSION OF MULTICHANNEL!!
//--------------------------------------------------------------------------------------

return 0;
}
コード例 #22
0
long double test3l(long double x)
{
  return ceill(x);
}
コード例 #23
0
ファイル: printf_impl.c プロジェクト: Mirmik/glib
static int print_f(void (*printchar_handler)(struct printchar_handler_data *d, int c),
		struct printchar_handler_data *printchar_data, long double r, int width,
		int precision, unsigned int ops, int base, int with_exp, int is_shortened) {
	char buff[PRINT_F_BUFF_SZ], *str, *end, *prefix, *postfix;
	DOUBLE ip, fp, ep;
	int pc, i, ch, len, prefix_len, postfix_len, pad_count, sign_count, zero_left, letter_base;

	assert(printchar_handler != NULL);
	assert(width >= 0);
	assert(precision >= 0);

	postfix = end = str = &buff[0] + sizeof buff / sizeof buff[0] - 1;
	*end = '\0';
	prefix = signbit(r) ? (r = -r, base == 16)
				? ops & OPS_SPEC_UPPER_CASE ? "-0X" : "-0x"
				: "-"
			: ops & OPS_FLAG_WITH_SIGN ? base == 16
				? ops & OPS_SPEC_UPPER_CASE ? "+0X" : "+0x"
				: "+"
			: ops & OPS_FLAG_EXTRA_SPACE ? base == 16
				? ops & OPS_SPEC_UPPER_CASE ? " 0X" : " 0x"
				: " "
			: base == 16 ? ops & OPS_SPEC_UPPER_CASE ? "0X" : "0x"
			: "";
	sign_count = i = pc = 0;
	prefix_len = strlen(prefix);
	letter_base = ops & OPS_SPEC_UPPER_CASE ? 'A' : 'a';
	precision = ops & OPS_PREC_IS_GIVEN ? is_shortened ?
				max(precision, 1) : precision
			: base == 16 ? 12 : PRINT_F_PREC_DEFAULT;

	fp = MODF(r, &ip);
	if (with_exp || is_shortened) {
		ep = 0.0L;
		while (ip >= base) fp = MODF((ip + fp) / base, &ip), ep += 1.0L;
		if (fp != 0.0L) while (ip == 0.0L) fp = MODF((ip + fp) * base, &ip), ep -= 1.0L;
		if ((ep < -4) || (ep >= precision)) with_exp = 1;
	}
	fp = with_exp ? fp : MODF(r, &ip);
	precision -= is_shortened ? ceill(LOG10(ip)) + (ip != 0.0L) : 0;
	assert(precision >= 0);
	for (; (sign_count < precision) && (FMOD(fp, 1.0L) != 0.0L); ++sign_count) fp *= base;
	fp = roundl(fp);
	ip = precision ? fp != POW(base, sign_count)
			? ip : ip + 1.0L : roundl(ip + fp);
	fp = fp != POW(base, sign_count) ? fp : 0.0L;
	if (with_exp && (ip >= base)) fp = MODF((ip + fp) / base, &ip), ep += 1.0L;

	if (with_exp) {
		do {
			ch = FMOD(FABS(ep), base);
			assert((ch >= 0) && (ch < base));
			if (ch >= 10) ch += letter_base - 10 - '0';
			*--postfix = ch + '0';
			MODF(ep / base, &ep);
		} while (ep != 0.0L);
		if ((strlen(postfix) == 1) && (base != 16)) *--postfix = '0';
		*--postfix = signbit(ep) ? '-' : '+';
		*--postfix = base == 16 ? ops & OPS_SPEC_UPPER_CASE ?
					'P' : 'p'
				: ops & OPS_SPEC_UPPER_CASE ? 'E' : 'e';
		str = end = postfix - 1;
		*end = '\0';
	}

	for (; i < sign_count; ++i) {
		ch = FMOD(fp, base);
		assert((ch >= 0) && (ch < base));
		if (ch >= 10) ch += letter_base - 10 - '0';
		*--str = ch + '0';
		MODF(fp / base, &fp);
	}

	if ((precision && !is_shortened) || sign_count
			|| (ops & OPS_FLAG_WITH_SPEC)) {
		*--str = '.';
	}

	do {
		ch = (int)FMOD(ip, (long double)base);
		assert((ch >= 0) && (ch < base));
		if (ch >= 10) ch += letter_base - 10 - '0';
		*--str = ch + '0';
		MODF(ip / base, &ip);
	} while (ip != 0.0L);

	len = end - str;
	postfix_len = strlen(postfix);
	zero_left = is_shortened ? 0 : precision - sign_count;
	pad_count = max(width - prefix_len - len - zero_left - postfix_len, 0);

	if (!(ops & (OPS_FLAG_ZERO_PAD | OPS_FLAG_LEFT_ALIGN))) {
		pc += pad_count;
		while (pad_count--) printchar_handler(printchar_data, ' ');
	}

	pc += prefix_len;
	while (prefix_len--) printchar_handler(printchar_data, *prefix++);

	if (ops & OPS_FLAG_ZERO_PAD) {
		pc += pad_count;
		while (pad_count--) printchar_handler(printchar_data, '0');
	}

	pc += len;
	while (len--) printchar_handler(printchar_data, *str++);

	pc += zero_left;
	while (zero_left--) printchar_handler(printchar_data, '0');

	pc += postfix_len;
	while (postfix_len--) printchar_handler(printchar_data, *postfix++);

	if (ops & OPS_FLAG_LEFT_ALIGN) {
		pc += pad_count;
		while (pad_count--) printchar_handler(printchar_data, ' ');
	}

	return pc;
}
コード例 #24
0
ファイル: g_zcoord.c プロジェクト: orbeckst/g_count
int main(int argc,char *argv[])
{
  const char *desc[] = {
    "g_zcoord can output the z(t) coordinates of atoms which are located in a "
    "cylindrical region. "
    "This region is defined by its radius R, the axis, and a point on this axis."
    "It takes an index file with atom, ",
    "and generates an output file with the ",
    "z coordinates for each entry in the index file. Coordinates of particles "
    "that are NOT in the cylinder are set to a special value, which is set "
    "with the [TT]-nan[TT] option.",

    "[PAR]For quicker visualisation the [TT]-mat[tt] option is useful. It creates ",
    "an xpm matrix file. The boundaries of the graph in z are taken from "
    "z1 and z2; the spacing can be set with the hidden option "
    "[TT]-matspacing[TT]. Its default is " xstr(XPM_Z_SPACING) " nm.",

    "[PAR]Due to the huge amount of diskspace that the .dat and .xvg file can "
    "take up these options have been all made optional. YOU NEED TO SET AT LEAST "
    "ONE OF [TT]-dat[TT], [TT]-o[TT], or [TT]-mat[TT] to generate any output."
  };

  t_cavity   cavity = {   /* define volume to count mols in */
    {0, 0, 1},            /* axis */
    {0, 0, 0},            /* cpoint */
    -1,                   /* radius */
    -1,                   /* z1 < z2 */
    -1,
    0                     /* volume - calculate later */
  };

  real spacing = XPM_Z_SPACING;    /* spacing in nm (!) for conversion to xpm */
  int  ngroups = 1;      /* not used yet >1 */
  real invalid = 9999.0; /* mark coordinates of particles not in cylinder */ 
  t_pargs pa[] = {
    { "-axis",   FALSE, etRVEC, {&(cavity.axis)},
      "Vector pointing parallel to the pore axis"},
    { "-cpoint", FALSE, etRVEC, {&(cavity.cpoint)},
      "Point on the pore axis"},
    { "-R",      FALSE, etREAL, {&(cavity.radius)},
      "Radius of the cylindrical pore cavity"},
    { "-z1",     FALSE, etREAL, {&(cavity.z1)},
      "Confine waters to have a z coordinate larger than z1, and"},
    { "-z2",     FALSE, etREAL, {&(cavity.z2)},
      "smaller than z2 (in nm). Also the z-boundaries for the xpm matrix."},
    { "-nan",    FALSE, etREAL, {&invalid},
      "number that is used in output files for coordinates when the particle "
      "is not in the cylinder"},
    { "-matspacing", FALSE, etREAL, {&spacing},
      "HIDDENz spacing (in nm) for the xpm matrix"},
    { "-ng",       FALSE, etINT, {&ngroups},
      "HIDDENNumber of groups to consider" },    
  }; 
  FILE       *out = NULL;    /* xmgr file with coordinates */
  FILE       *fData= NULL;   /* simple data file: t z      */
  t_topology top;            /* topology                   */
  rvec       *xtop;
  int        ePBC;
  char       title[STRLEN];
  gmx_bool       bTop;
  rvec       *x,*x_s;        /* coord, with and without pbc*/
  rvec       xcm;            /* center of mass of molecule */
  matrix     box;            /* box matrix (3x3)           */
  real       t,tm;           /* time, total mass molecule  */
  int        natoms;         /* number of atoms in system  */
  t_trxstatus *status;
  int        i,j;            /* loopcounters               */
  int        k_frame;        /* counts frames */

  const char *indexfn;
  char       **grpname;      /* groupnames for all groups */  
  int        *isize;
  atom_id    **index;        /* molecule numbers in index for each group  */
  atom_id    *atndx = NULL;  /* indices from block.        */
  t_block    *mols= NULL;    /* all molecules in system    */  

  char       *ggrpname;      /* name of the FIRST group       */
  int        gnx = 0;        /* number of atoms in FIRST group*/
  atom_id    *gindex = NULL; /* index of FIRST group */

  real maxzval = MINZVAL_DEFAULT; /* max z in nm (!) for conversion to xpm */
  real minzval = MAXZVAL_DEFAULT; /* min z in nm (!) for conversion to xpm */
  int        nbins = 0;           /* number of bins for conv to xpm */
  real       **zbins = NULL; /* bins for conversion to xpm */
  FILE       *xpmOut = NULL; /* xpm matrix file */
  t_rgb      rlo, rhi;       /* low and high colors for matrix */
  int nlevels = 2;
  int max_frames = XPM_INITIAL_FRAMES; 
                            /* current max number of frames in xpm matrix */
  real       *x_axis = NULL;/* x-axis labels */
  real       *y_axis = NULL;/* y-axis labels */
  gmx_bool   bXPM = FALSE;  /* produce XPM matrix ?*/
  gmx_bool   bXVG = FALSE;  /* no output generated by default */
  gmx_bool   bDAT = FALSE; 

  t_filenm fnm[] = {
    { efTRX, "-f",   NULL,     ffREAD  },
    { efTPS, NULL,   NULL,     ffREAD },
    { efXVG, "-o",   "zcoord", ffOPTWR },
    { efXPM, "-mat", "zcoord", ffOPTWR }, /* this is for xpm output */
    { efDAT, "-dat", "zcoord", ffOPTWR },
    { efNDX, NULL,   NULL,     ffOPTRD }
  };
  output_env_t oenv;

#define NFILE asize(fnm)
#define NPA   asize(pa)
#define NDFILES 2
  FILE       *dfiles[NDFILES+1]; /* output files to dump data to 
				    terminate with NULL */
 
  const char *bugs[] = { 
    "Even if the cylinder axis is not (0,0,1), the top and bottom of the cylinder are"
    "still determined by the z-coordinates z1 and z2.",
    "ATTENTION: no data is generated by default !!!",
    "xpm graph: If no proper (i.e. |z| < " xstr(Z_SANITY) "nm) z-limits are "
    "given they are set to "
    "the arbitrary values z_min=" xstr(MINZVAL_DEFAULT) " and "
    "z_max=" xstr(MAXZVAL_DEFAULT),
  };


  CopyRight(stderr,argv[0]);

  parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW,
		    NFILE,fnm,asize(pa),pa,asize(desc),desc,asize(bugs),bugs,
		    &oenv);
  
  bDAT = (opt2fn_null("-dat", NFILE, fnm)) ? TRUE : FALSE;
  bXVG = (opt2fn_null("-o",   NFILE, fnm)) ? TRUE : FALSE;
  bXPM = (opt2fn_null("-mat", NFILE, fnm)) ? TRUE : FALSE;

  if (! (bXPM  || bXVG || bDAT)) {
    /* check if this is a pointless run */
    msg("No output selected. I stop here.\n");
    return (1);
  }

  bTop = read_tps_conf(ftp2fn(efTPS,NFILE,fnm),title,&top,&ePBC,&xtop,NULL,box,TRUE);
  sfree(xtop);

  if (!bTop) {
    gmx_fatal(FARGS, "Need a run input file");
  }

  indexfn = ftp2fn_null(efNDX,NFILE,fnm);

  if (ngroups != 1) {
    gmx_fatal(FARGS, "Sorry, only a single group currently allowed.");
  }

  snew(grpname,ngroups);
  snew(isize,ngroups);
  snew(index,ngroups);
  get_index(&(top.atoms),indexfn,ngroups,isize,index,grpname);
  
  /* ngroups == 1 at moment */
  gnx = isize[0];
  gindex = index[0];
  ggrpname = grpname[0];
  mols = &(top.mols);
  atndx = mols->index;
  
  natoms=read_first_x(oenv,&status,ftp2fn(efTRX,NFILE,fnm),&t,&x,box);
  snew(x_s,natoms);


  /* look at cavity */
  if (cavity.z1 >= cavity.z2) {
    gmx_fatal(FARGS, "z-boundaries have worng values: They must be z1 < z2.");
  }
  
  /* look at cavity 
     set defaults from the simulation box size
  */
  msg("\n");
  autoset_cavity(&cavity,box,NPA,pa);
  cavity.vol = sqr(cavity.radius) * PI * (cavity.z2 - cavity.z1); // not needed, just for completeness

  if (bXPM) {
    /* for xpm output: set limits to z1 and z2 */
    /* mild sanity check */
    minzval = cavity.z1 < -Z_SANITY  ? MINZVAL_DEFAULT : cavity.z1;
    maxzval = cavity.z2 >  Z_SANITY  ? MAXZVAL_DEFAULT : cavity.z2;

    /* xpm graphics: initialize bins  */
    nbins = (int)ceill((maxzval - minzval) / spacing);
    snew(zbins,max_frames);
    snew(x_axis,max_frames);

    msg("Limits for xpm matrix: %g nm < z < %g nm\n", minzval, maxzval);
  }

  /* initialize dfiles: use it to dump data to different files simultanously */
  for (i = 0; i < NDFILES+1; i++) dfiles[i] = NULL;
  i = 0;       /* use to count how many output files are open */
  if (bXVG) {
    out    = xmgropen(opt2fn("-o",NFILE,fnm),
		      "z coordinate",
		      "Coordinate",
		      "Time (ps)","z (nm)");
    dfiles[i++] = out;
  }
  if (bDAT) {
    fData  = ffopen (opt2fn("-dat", NFILE, fnm), "w");
    dfiles[i++] = fData;
  }


  k_frame = 0;     /*! counts the frames */
  do {
    dump_data (dfiles,  "%10g", t);

    if (bXPM) {
      // new timeframe
      // check if we need more memory
      if (k_frame >= max_frames) {
        max_frames += XPM_INITIAL_FRAMES;
        if (!(srenew(zbins,max_frames)) ||
            !(srenew(x_axis,max_frames)) ) {
          msg("Out of memory for xpm graph: I abort and try to process what "
              "I have got so far (frame = %g).\n", k_frame);
          break;
        }
      }
      snew(zbins[k_frame],nbins);
      x_axis[k_frame]=t/1000;  // in ns

      // initialize bins to zero
      for (i=0; i<nbins; i++) 
        zbins[k_frame][i] = 0.0;
    }

    /* We are not interested in molecules, just in the z-coordinates 
       of atoms */
    for(i=0; i<gnx; i++) {
      if ( bInCavity (x[gindex[i]], &cavity) ) {  // only look at cylinder
	if (bXPM) {
	  if ( (x[gindex[i]][ZZ] >= minzval) && (x[gindex[i]][ZZ] <= maxzval))
	    zbins[k_frame][(int)floorl((x[gindex[i]][ZZ] - minzval) / spacing)]=1.0;
	}
      } 
      else {
	/* particle OUTSIDE cylinder: mark coordinates as 'invalid'
	   but keep them in the output file */
	for(j=0; j<3; j++) {
	  x[gindex[i]][j] = invalid;
	}
      }
      dump_data (dfiles,"\t%10g", x[gindex[i]][ZZ]);
    }

    /* some printout for debugging/development - MB 
    for (i=0; i<nbins; i++) 
    for (i=0; i<10; i++) 
      printf("%1d",(int)zbins[k_frame][i]);
    printf("\n");
    */

    dump_data (dfiles, "\n");
    k_frame++;
  } while(read_next_x(oenv,status,&t,natoms,x,box));
  close_trj(status);

  if (bXPM) {
    /* colors for matrix */
    rlo.r = 1.0, rlo.g = 1.0, rlo.b = 1.0; // no water color
    rhi.r = 0.4, rhi.g = 0.4, rhi.b = 1.0; // water color
  
    /* create labels */
    snew(y_axis,nbins+1);
    for(i=0; i<=nbins; i++) {                   // n+1 labels with MAT_SPATIAL_Y
      y_axis[i]=10 * (minzval + (i * spacing)); // Yes, I WANT Angstroms !!!
    }
    /* write xpm matrix */
    xpmOut = fopen(opt2fn("-mat", NFILE, fnm),"w");
    write_xpm(xpmOut,
	      MAT_SPATIAL_Y,
	      "g_zcoord matrix",     // title
	      "existence",           // label for the continuous legend
	      "timeframe / ns",      // label for the x-axis
	      "z coordinate / A",    // label for the y-axis - where the F**k is the
                          	      // bloody Angstrom
	      k_frame, nbins,        // size of the matrix
	      x_axis,            // the x-ticklabels
	      // would be nice to have the times here
	      y_axis,            // the y-ticklabels
	      // would be nice to have the zcoordinate label in nm or A
	      zbins,             // element x,y is matrix[x][y]
	      0.0,               // output lower than lo is set to lo
	      1.0,               // output higher than hi is set to hi
	      rlo,               // rgb value for level lo
	      rhi,               // rgb value for level hi
	      &nlevels);         // number of color levels for the output
    fclose(xpmOut);
  };

  /* clean up a bit */
  fprintf(stderr,"\n");

  if (bDAT) fclose(fData);
  if (bXVG) fclose(out);
  
  if (bXPM) {
    // free memory from xpm matrix data
    for (i=0; i<k_frame; i++)
      sfree(zbins[i]);
    sfree(zbins);
    sfree(x_axis);
  }


  thanx(stdout);
  
  return 0;
}
コード例 #25
0
ファイル: mxqd_control.c プロジェクト: mariux/mxq
static void _group_list_init(struct mxq_group_list *glist)
{
    struct mxq_server *server;
    struct mxq_group *group;

    long double memory_per_job_thread;
    long double memory_available_for_group;

    unsigned long slots_per_job;
    unsigned long slots_per_job_memory;
    unsigned long slots_per_job_cpu;
    unsigned long jobs_max;
    unsigned long slots_max;
    unsigned long memory_max;

    assert(glist);
    assert(glist->user);
    assert(glist->user->server);

    server = glist->user->server;
    group  = &glist->group;

    memory_per_job_thread = (long double)group->job_memory / (long double)group->job_threads;

    /* max_memory_per_server_slot_soft < memory_per_job_thread => limit total memory for group default: avg_memory_per_server_slot*/
    /* max_memory_per_server_slot_hard < memory_per_job_thread => do not start jobs for group  default: memory_total */

    /* memory_available_for_group = memory_total * max_memory_per_server_slot_soft / memory_per_job_thread */
    memory_available_for_group = (long double)server->memory_total * (long double)server->memory_limit_slot_soft / memory_per_job_thread;

    if (memory_available_for_group > (long double)server->memory_total)
        memory_available_for_group = (long double)server->memory_total;

    /* memory_slots_per_job = memory_per_job / memory_per_server_slot */
    /* cpu_slots_per_job    = job_threads */
    /* slots_per_job        = max(memory_slots_per_job, cpu_slots_per_job) */

    slots_per_job_memory = (unsigned long)ceill((long double)group->job_memory / server->memory_avg_per_slot);
    slots_per_job_cpu    = group->job_threads;

    if (slots_per_job_memory < slots_per_job_cpu)
        slots_per_job = slots_per_job_cpu;
    else
        slots_per_job = slots_per_job_memory;

    if (memory_per_job_thread > server->memory_limit_slot_hard) {
        jobs_max = 0;
    } else if (memory_per_job_thread > server->memory_avg_per_slot) {
        jobs_max = (unsigned long)ceill(memory_available_for_group / (long double)group->job_memory);
    } else {
        jobs_max = server->slots / group->job_threads;
    }

    if (jobs_max > server->slots / slots_per_job)
        jobs_max = server->slots / slots_per_job;

    /* limit maximum number of jobs on user/group request */
    if (group->job_max_per_node && jobs_max > group->job_max_per_node)
        jobs_max = group->job_max_per_node;

    slots_max  = jobs_max * slots_per_job;
    memory_max = jobs_max * group->job_memory;

    if (glist->memory_per_job_thread != memory_per_job_thread
       || glist->memory_available_for_group != memory_available_for_group
       || glist->slots_per_job != slots_per_job
       || glist->jobs_max != jobs_max
       || glist->slots_max != slots_max
       || glist->memory_max != memory_max) {
        mx_log_info("  group=%s(%u):%lu jobs_max=%lu slots_max=%lu memory_max=%lu slots_per_job=%lu memory_per_job_thread=%Lf :: group %sinitialized.",
                    group->user_name,
                    group->user_uid,
                    group->group_id,
                    jobs_max,
                    slots_max,
                    memory_max,
                    slots_per_job,
                    memory_per_job_thread,
                    glist->orphaned ? "re" : "");
    }

    glist->memory_per_job_thread      = memory_per_job_thread;
    glist->memory_available_for_group = memory_available_for_group;

    glist->slots_per_job = slots_per_job;

    glist->jobs_max   = jobs_max;
    glist->slots_max  = slots_max;
    glist->memory_max = memory_max;

    glist->orphaned = 0;
}
コード例 #26
0
void
domathl (void)
{
#ifndef NO_LONG_DOUBLE
  long double f1;
  long double f2;

  int i1;

  f1 = acosl(0.0);
  fprintf( stdout, "acosl          : %Lf\n", f1);

  f1 = acoshl(0.0);
  fprintf( stdout, "acoshl         : %Lf\n", f1);

  f1 = asinl(1.0);
  fprintf( stdout, "asinl          : %Lf\n", f1);

  f1 = asinhl(1.0);
  fprintf( stdout, "asinhl         : %Lf\n", f1);

  f1 = atanl(M_PI_4);
  fprintf( stdout, "atanl          : %Lf\n", f1);

  f1 = atan2l(2.3, 2.3);
  fprintf( stdout, "atan2l         : %Lf\n", f1);

  f1 = atanhl(1.0);
  fprintf( stdout, "atanhl         : %Lf\n", f1);

  f1 = cbrtl(27.0);
  fprintf( stdout, "cbrtl          : %Lf\n", f1);

  f1 = ceill(3.5);
  fprintf( stdout, "ceill          : %Lf\n", f1);

  f1 = copysignl(3.5, -2.5);
  fprintf( stdout, "copysignl      : %Lf\n", f1);

  f1 = cosl(M_PI_2);
  fprintf( stdout, "cosl           : %Lf\n", f1);

  f1 = coshl(M_PI_2);
  fprintf( stdout, "coshl          : %Lf\n", f1);

  f1 = erfl(42.0);
  fprintf( stdout, "erfl           : %Lf\n", f1);

  f1 = erfcl(42.0);
  fprintf( stdout, "erfcl          : %Lf\n", f1);

  f1 = expl(0.42);
  fprintf( stdout, "expl           : %Lf\n", f1);

  f1 = exp2l(0.42);
  fprintf( stdout, "exp2l          : %Lf\n", f1);

  f1 = expm1l(0.00042);
  fprintf( stdout, "expm1l         : %Lf\n", f1);

  f1 = fabsl(-1.123);
  fprintf( stdout, "fabsl          : %Lf\n", f1);

  f1 = fdiml(1.123, 2.123);
  fprintf( stdout, "fdiml          : %Lf\n", f1);

  f1 = floorl(0.5);
  fprintf( stdout, "floorl         : %Lf\n", f1);
  f1 = floorl(-0.5);
  fprintf( stdout, "floorl         : %Lf\n", f1);

  f1 = fmal(2.1, 2.2, 3.01);
  fprintf( stdout, "fmal           : %Lf\n", f1);

  f1 = fmaxl(-0.42, 0.42);
  fprintf( stdout, "fmaxl          : %Lf\n", f1);

  f1 = fminl(-0.42, 0.42);
  fprintf( stdout, "fminl          : %Lf\n", f1);

  f1 = fmodl(42.0, 3.0);
  fprintf( stdout, "fmodl          : %Lf\n", f1);

  /* no type-specific variant */
  i1 = fpclassify(1.0);
  fprintf( stdout, "fpclassify     : %d\n", i1);

  f1 = frexpl(42.0, &i1);
  fprintf( stdout, "frexpl         : %Lf\n", f1);

  f1 = hypotl(42.0, 42.0);
  fprintf( stdout, "hypotl         : %Lf\n", f1);

  i1 = ilogbl(42.0);
  fprintf( stdout, "ilogbl         : %d\n", i1);

  /* no type-specific variant */
  i1 = isfinite(3.0);
  fprintf( stdout, "isfinite       : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreater(3.0, 3.1);
  fprintf( stdout, "isgreater      : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreaterequal(3.0, 3.1);
  fprintf( stdout, "isgreaterequal : %d\n", i1);

  /* no type-specific variant */
  i1 = isinf(3.0);
  fprintf( stdout, "isinf          : %d\n", i1);

  /* no type-specific variant */
  i1 = isless(3.0, 3.1);
  fprintf( stdout, "isless         : %d\n", i1);

  /* no type-specific variant */
  i1 = islessequal(3.0, 3.1);
  fprintf( stdout, "islessequal    : %d\n", i1);

  /* no type-specific variant */
  i1 = islessgreater(3.0, 3.1);
  fprintf( stdout, "islessgreater  : %d\n", i1);

  /* no type-specific variant */
  i1 = isnan(0.0);
  fprintf( stdout, "isnan          : %d\n", i1);

  /* no type-specific variant */
  i1 = isnormal(3.0);
  fprintf( stdout, "isnormal       : %d\n", i1);

  /* no type-specific variant */
  f1 = isunordered(1.0, 2.0);
  fprintf( stdout, "isunordered    : %d\n", i1);

  f1 = j0l(1.2);
  fprintf( stdout, "j0l            : %Lf\n", f1);

  f1 = j1l(1.2);
  fprintf( stdout, "j1l            : %Lf\n", f1);

  f1 = jnl(2,1.2);
  fprintf( stdout, "jnl            : %Lf\n", f1);

  f1 = ldexpl(1.2,3);
  fprintf( stdout, "ldexpl         : %Lf\n", f1);

  f1 = lgammal(42.0);
  fprintf( stdout, "lgammal        : %Lf\n", f1);

  f1 = llrintl(-0.5);
  fprintf( stdout, "llrintl        : %Lf\n", f1);
  f1 = llrintl(0.5);
  fprintf( stdout, "llrintl        : %Lf\n", f1);

  f1 = llroundl(-0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);
  f1 = llroundl(0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);

  f1 = logl(42.0);
  fprintf( stdout, "logl           : %Lf\n", f1);

  f1 = log10l(42.0);
  fprintf( stdout, "log10l         : %Lf\n", f1);

  f1 = log1pl(42.0);
  fprintf( stdout, "log1pl         : %Lf\n", f1);

  f1 = log2l(42.0);
  fprintf( stdout, "log2l          : %Lf\n", f1);

  f1 = logbl(42.0);
  fprintf( stdout, "logbl          : %Lf\n", f1);

  f1 = lrintl(-0.5);
  fprintf( stdout, "lrintl         : %Lf\n", f1);
  f1 = lrintl(0.5);
  fprintf( stdout, "lrintl         : %Lf\n", f1);

  f1 = lroundl(-0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);
  f1 = lroundl(0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);

  f1 = modfl(42.0,&f2);
  fprintf( stdout, "lmodfl         : %Lf\n", f1);

  f1 = nanl("");
  fprintf( stdout, "nanl           : %Lf\n", f1);

  f1 = nearbyintl(1.5);
  fprintf( stdout, "nearbyintl     : %Lf\n", f1);

  f1 = nextafterl(1.5,2.0);
  fprintf( stdout, "nextafterl     : %Lf\n", f1);

  f1 = powl(3.01, 2.0);
  fprintf( stdout, "powl           : %Lf\n", f1);

  f1 = remainderl(3.01,2.0);
  fprintf( stdout, "remainderl     : %Lf\n", f1);

  f1 = remquol(29.0,3.0,&i1);
  fprintf( stdout, "remquol        : %Lf\n", f1);

  f1 = rintl(0.5);
  fprintf( stdout, "rintl          : %Lf\n", f1);
  f1 = rintl(-0.5);
  fprintf( stdout, "rintl          : %Lf\n", f1);

  f1 = roundl(0.5);
  fprintf( stdout, "roundl         : %Lf\n", f1);
  f1 = roundl(-0.5);
  fprintf( stdout, "roundl         : %Lf\n", f1);

  f1 = scalblnl(1.2,3);
  fprintf( stdout, "scalblnl       : %Lf\n", f1);

  f1 = scalbnl(1.2,3);
  fprintf( stdout, "scalbnl        : %Lf\n", f1);

  /* no type-specific variant */
  i1 = signbit(1.0);
  fprintf( stdout, "signbit        : %i\n", i1);

  f1 = sinl(M_PI_4);
  fprintf( stdout, "sinl           : %Lf\n", f1);

  f1 = sinhl(M_PI_4);
  fprintf( stdout, "sinhl          : %Lf\n", f1);

  f1 = sqrtl(9.0);
  fprintf( stdout, "sqrtl          : %Lf\n", f1);

  f1 = tanl(M_PI_4);
  fprintf( stdout, "tanl           : %Lf\n", f1);

  f1 = tanhl(M_PI_4);
  fprintf( stdout, "tanhl          : %Lf\n", f1);

  f1 = tgammal(2.1);
  fprintf( stdout, "tgammal        : %Lf\n", f1);

  f1 = truncl(3.5);
  fprintf( stdout, "truncl         : %Lf\n", f1);

  f1 = y0l(1.2);
  fprintf( stdout, "y0l            : %Lf\n", f1);

  f1 = y1l(1.2);
  fprintf( stdout, "y1l            : %Lf\n", f1);

  f1 = ynl(3,1.2);
  fprintf( stdout, "ynl            : %Lf\n", f1);
#endif
}
コード例 #27
0
ファイル: lib_frexpl.c プロジェクト: FreddieChopin/NuttX
long double frexpl(long double x, int *exponent)
{
  *exponent = (int)ceill(log2(x));
  return x / ldexpl(1.0, *exponent);
}
コード例 #28
0
ファイル: npy_math.c プロジェクト: bjacksonuk/InteractiveVis
npy_longdouble npy_ceill(npy_longdouble x)
{
    return ceill(x);
}
コード例 #29
0
ファイル: builtins-67.c プロジェクト: 0day-ci/gcc
long long llceill (long double a) { return (long long) ceill (a); }
コード例 #30
0
ファイル: builtins-67.c プロジェクト: 0day-ci/gcc
int iceill (long double a) { return (int) ceill (a); }