Beispiel #1
0
int
main ()
{
  test_float ();
  test_double ();
  test_long_double ();
  return 0;
}
Beispiel #2
0
static int
run_test (int, char*[])
{
    // check the prescribed values of the required constants
    rw_fatal ('\0' == std::money_base::none, 0, 0,
              "'\\0' == money_base::none, got %d", std::money_base::none);

    rw_fatal ('\1' == std::money_base::space, 0, 0,
              "'\\1' == money_base::space, got %d", std::money_base::space);

    rw_fatal ('\2' == std::money_base::symbol, 0, 0,
              "'\\2' == money_base::symbol, got %d", std::money_base::symbol);

    rw_fatal ('\3' == std::money_base::sign, 0, 0,
              "'\\3' == money_base::sign, got %d", std::money_base::sign);

    rw_fatal ('\4' == std::money_base::value, 0, 0,
              "'\\4' == money_base::value, got %d", std::money_base::value);
               
    if (rw_enabled ("char")) {
        test_long_double (char (), "char");
        test_string (char (), "char");
    }
    else
        rw_note (0, __FILE__, __LINE__, "char test disabled");

#ifndef _RWSTD_NO_WCHAR_T

    if (rw_enabled ("wchar_t")) {
        test_long_double (wchar_t (), "wchar_t");
        test_string (wchar_t (), "wchar_t");
    }
    else
        rw_note (0, __FILE__, __LINE__, "wchar_t test disabled");

#endif   // _RWSTD_NO_WCHAR_T

    return 0;
}
Beispiel #3
0
int
main (void)
{

  err = 0;

  test_float ();
  test_double ();
  test_long_double ();
  test_int ();
  test_long_int ();

  if (err != 0)
    abort ();

  return 0;
}
Beispiel #4
0
int
main ()
{
  test_float ();
  test_double ();

  {
    DECL_LONG_DOUBLE_ROUNDING

    BEGIN_LONG_DOUBLE_ROUNDING ();

    test_long_double ();

    END_LONG_DOUBLE_ROUNDING ();
  }

  return 0;
}
Beispiel #5
0
/// \internal Precompute constants for the recursive generation of Legendre associated functions, with given normalization.
/// this function is called by \ref shtns_set_size, and assumes up-to-date values in \ref shtns.
/// For the same conventions as GSL, use \c legendre_precomp(sht_orthonormal,1);
/// \param[in] norm : normalization of the associated legendre functions (\ref shtns_norm).
/// \param[in] with_cs_phase : Condon-Shortley phase (-1)^m is included (1) or not (0)
/// \param[in] mpos_renorm : Optional renormalization for m>0.
///  1.0 (no renormalization) is the "complex" convention, while 0.5 leads to the "real" convention (with FFTW).
static void legendre_precomp(shtns_cfg shtns, enum shtns_norm norm, int with_cs_phase, double mpos_renorm)
{
	double *alm, *blm;
	long int im, m, l, lm;
	real t1, t2;

#if HAVE_LONG_DOUBLE_WIDER
	test_long_double();
#endif
#if SHT_VERBOSE > 1
	if (verbose) {
		printf("        > Condon-Shortley phase = %d, normalization = %d\n", with_cs_phase, norm);
		if (long_double_caps == 3) printf("        > long double has extended precision and large exponent\n");
	}
#endif

	if (with_cs_phase != 0) with_cs_phase = 1;		// force to 1 if !=0

	alm = (double *) malloc( (2*NLM)*sizeof(double) );
	blm = alm;
	if ((norm == sht_schmidt) || (mpos_renorm != 1.0)) {
		blm = (double *) malloc( (2*NLM)*sizeof(double) );
	}
	if ((alm==0) || (blm==0)) shtns_runerr("not enough memory.");
	shtns->alm = alm;		shtns->blm = blm;

/// - Compute and store the prefactor (independant of x) of the starting value for the recurrence :
/// \f[  Y_m^m(x) = Y_0^0 \ \sqrt{ \prod_{k=1}^{m} \frac{2k+1}{2k} } \ \ (-1)^m \ (1-x^2)^{m/2}  \f]
	if ((norm == sht_fourpi)||(norm == sht_schmidt)) {
		t1 = 1.0;
		alm[0] = t1;		/// \f$ Y_0^0 = 1 \f$  for Schmidt or 4pi-normalized 
	} else {
		t1 = 0.25L/M_PIl;
		alm[0] = SQRT(t1);		/// \f$ Y_0^0 = 1/\sqrt{4\pi} \f$ for orthonormal
	}
	t1 *= mpos_renorm;		// renormalization for m>0
	for (im=1, m=0; im<=MMAX; ++im) {
		while(m<im*MRES) {
			++m;
			t1 *= ((real)m + 0.5)/m;	// t1 *= (m+0.5)/m;
		}
		t2 = SQRT(t1);
		if ( m & with_cs_phase ) t2 = -t2;		/// optional \f$ (-1)^m \f$ Condon-Shortley phase.
		alm_im(shtns, im)[0] = t2;
	}

/// - Precompute the factors alm and blm of the recurrence relation :
	#pragma omp parallel for private(im,m,l,lm, t1, t2) schedule(dynamic)
	for (im=0; im<=MMAX; ++im) {
		m = im*MRES;
		lm = im*(2*LMAX - (im-1)*MRES);
		if (norm == sht_schmidt) {		/// <b> For Schmidt semi-normalized </b>
			t2 = SQRT(2*m+1);
			alm[lm] /= t2;		/// starting value divided by \f$ \sqrt{2m+1} \f$ 
			alm[lm+1] = t2;		// l=m+1
			lm+=2;
			for (l=m+2; l<=LMAX; ++l) {
				t1 = SQRT((l+m)*(l-m));
				alm[lm+1] = (2*l-1)/t1;		/// \f[  a_l^m = \frac{2l-1}{\sqrt{(l+m)(l-m)}}  \f]
				alm[lm] = - t2/t1;			/// \f[  b_l^m = -\sqrt{\frac{(l-1+m)(l-1-m)}{(l+m)(l-m)}}  \f]
				t2 = t1;	lm+=2;
			}
		} else {			/// <b> For orthonormal or 4pi-normalized </b>
			t2 = 2*m+1;
			// starting value unchanged.
			alm[lm+1] = SQRT(2*m+3);		// l=m+1
			lm+=2;
			for (l=m+2; l<=LMAX; ++l) {
				t1 = (l+m)*(l-m);
				alm[lm+1] = SQRT(((2*l+1)*(2*l-1))/t1);			/// \f[  a_l^m = \sqrt{\frac{(2l+1)(2l-1)}{(l+m)(l-m)}}  \f]
				alm[lm] = - SQRT(((2*l+1)*t2)/((2*l-3)*t1));	/// \f[  b_l^m = -\sqrt{\frac{2l+1}{2l-3}\,\frac{(l-1+m)(l-1-m)}{(l+m)(l-m)}}  \f]
				t2 = t1;	lm+=2;
			}
		}
/// - Compute analysis recurrence coefficients if necessary
		if ((norm == sht_schmidt) || (mpos_renorm != 1.0)) {
			lm = im*(2*LMAX - (im-1)*MRES);
			t1 = 1.0;
			t2 = alm[lm+1];
			if (norm == sht_schmidt) {
				t1 = 2*m+1;
				t2 *= (2*m+3)/t1;
			}
			if (m>0) t1 /= mpos_renorm;
			blm[lm] = alm[lm]*t1;
			blm[lm+1] = t2;
			lm+=2;
			for (l=m+2; l<=LMAX; ++l) {
				t1 = alm[lm];
				t2 = alm[lm+1];
				if (norm == sht_schmidt) {
					double t3 = 2*l+1;
					t1 *= t3/(2*l-3);
					t2 *= t3/(2*l-1);
				}
				blm[lm] = t1;
				blm[lm+1] = t2;
				lm+=2;
			}
		}
	}
}
Beispiel #6
0
int
main ( int argc, char** argv )
{
    int           flag = 0;  // Bit 0: little, Bit 1: big, Bit 2: unknown
    unsigned int  k;
    long          m;
    FILE*         fp   = fopen ( "config.h", "w" );
    int           endian;

    if ( fp == NULL ) {
        fprintf ( stderr, "config: Can't write 'config.h'\n");
        return 1;
    }

    if ( argc > 1 )
        fprintf ( stderr, "\n*** Compile sources with ***\n\n%s\n\n", argv[1] );

    if ( argc > 2 )
        fprintf ( stderr, "\n*** Execute binary with ***\n\n%s\n\n", argv[2] );

    fprintf ( fp, "\n" );
    fprintf ( fp, "/* Determine Endianess of the machine */\n" );
    fprintf ( fp, "\n" );
    fprintf ( fp, "#define HAVE_LITTLE_ENDIAN  1234\n" );
    fprintf ( fp, "#define HAVE_BIG_ENDIAN     4321\n" );
    fprintf ( fp, "\n" );

        flag = 0;
    for ( k = 0; k < sizeof(v_int); k++ )
        if      ( in[k] == 0x11 * (k+1)             ) flag |= 1;
        else if ( in[k] == 0x11 * (sizeof(v_int)-k) ) flag |= 2;
        else                                          flag |= 4;

    for ( k = 0; k < sizeof(v_lng); k++ )
        if      ( lo[k] == 0x11 * (k+1)             ) flag |= 1;
        else if ( lo[k] == 0x11 * (sizeof(v_lng)-k) ) flag |= 2;
        else                                          flag |= 4;

    for ( k = 0; k < sizeof(v_sht); k++ )
        if      ( sh[k] == 0x11 * (k+1)             ) flag |= 1;
        else if ( sh[k] == 0x11 * (sizeof(v_sht)-k) ) flag |= 2;
        else                                          flag |= 4;

    switch (flag) {
    case 1:
        endian = 1;
        fprintf ( fp, "#define ENDIAN              HAVE_LITTLE_ENDIAN\n" );
        break;
    case 2:
        endian = 2;
        fprintf ( fp, "#define ENDIAN              HAVE_BIG_ENDIAN\n" );
        break;
    default:
        endian = 0;
        fprintf ( fp, "/* unknown endianess */\n" );
        break;

    }
    fprintf ( fp, "\n" );


    fprintf ( fp, "\n" );
    fprintf ( fp, "/* Test the fast float-to-int rounding trick works */\n" );
    fprintf ( fp, "\n" );
    flag = 0;
    for ( m = 0; m <= 32767; m++ ) {
        flag |= test_round_16 ( (float)(+m - 0.499) );
        flag |= test_round_16 ( (float)(+m        ) );
        flag |= test_round_16 ( (float)(+m + 0.499) );
        flag |= test_round_16 ( (float)(-m - 0.499) );
        flag |= test_round_16 ( (float)(-m        ) );
        flag |= test_round_16 ( (float)(-m + 0.499) );
    }
    if ( flag == 0 )
        fprintf ( fp, "#define HAVE_IEEE754_FLOAT\n" );
    else
        fprintf ( fp, "/* #define HAVE_IEEE754_FLOAT */\n" );


    flag = 0;
    for ( m = 0; (unsigned long)m <= 0x7FFFFFFF; m += 1 + (m>>16) ) {
        flag |= test_round_32 ( +m - 0.499 );
        flag |= test_round_32 ( +m         );
        flag |= test_round_32 ( +m + 0.499 );
        flag |= test_round_32 ( -m - 0.499 );
        flag |= test_round_32 ( -m         );
        flag |= test_round_32 ( -m + 0.499 );
    }
    if ( flag == 0 )
        fprintf ( fp, "#define HAVE_IEEE754_DOUBLE\n" );
    else
        fprintf ( fp, "/* #define HAVE_IEEE754_DOUBLE */\n" );
    fprintf ( fp, "\n" );


    fprintf ( fp, "\n" );
    fprintf ( fp, "/* Test the presence of a 80 bit floating point type for writing AIFF headers */\n" );
    fprintf ( fp, "\n" );
    if ( test_long_double(endian) )
        fprintf ( fp, "#define HAVE_IEEE854_LONGDOUBLE\n" );
    else
        fprintf ( fp, "/* #define HAVE_IEEE854_LONGDOUBLE */\n" );


    fprintf ( fp, "\n\n" );
    version ( fp );
    fprintf ( fp, "/* end of config.h */\n" );
    fclose (fp);
    return 0;
}