static void compare_f(
    const pnfftl_complex *f_pnfft, const pnfftl_complex *f_nfft, ptrdiff_t local_M,
    long double f_hat_sum, const char *name, MPI_Comm comm
    )
{
  long double error = 0, error_max;

  for(ptrdiff_t j=0; j<local_M; j++)
    if( cabsl(f_pnfft[j]-f_nfft[j]) > error)
      error = cabsl(f_pnfft[j]-f_nfft[j]);

  MPI_Reduce(&error, &error_max, 1, MPI_LONG_DOUBLE, MPI_MAX, 0, comm);
  pfftl_printf(comm, "%s absolute error = %6.2Le\n", name, error_max);
  pfftl_printf(comm, "%s relative error = %6.2Le\n", name, error_max/f_hat_sum);
}
示例#2
0
long double complex
clog10l (long double complex z)
{
  long double complex v;

  COMPLEX_ASSIGN (v, log10l (cabsl (z)), cargl (z));
  return v;
}
示例#3
0
int
main (void)
{
  /* For each type, test both runtime and compile time (constant folding)
     optimization.  */
  float _Complex fc = 3.0F + 4.0iF;
  double _Complex dc = 3.0 + 4.0i;
  long double _Complex ldc = 3.0L + 4.0iL;

#ifdef HAVE_C99_RUNTIME
  /* Test floats.  */
  if (cabsf (fc) != 5.0F)
    link_error ();
  if (__builtin_cabsf (fc) != 5.0F)
    link_error ();
  if (cabsf (3.0F + 4.0iF) != 5.0F)
    link_error ();
  if (__builtin_cabsf (3.0F + 4.0iF) != 5.0F)
    link_error ();
#endif

  /* Test doubles.  */
  if (cabs (dc) != 5.0)
    link_error ();
  if (__builtin_cabs (dc) != 5.0)
    link_error ();
  if (cabs (3.0 + 4.0i) != 5.0)
    link_error ();
  if (__builtin_cabs (3.0 + 4.0i) != 5.0)
    link_error ();

#ifdef HAVE_C99_RUNTIME
  /* Test long doubles.  */
  if (cabsl (ldc) != 5.0L)
    link_error ();
  if (__builtin_cabsl (ldc) != 5.0L)
    link_error ();
  if (cabsl (3.0L + 4.0iL) != 5.0L)
    link_error ();
  if (__builtin_cabsl (3.0L + 4.0iL) != 5.0L)
    link_error ();
#endif

  return 0;
}
示例#4
0
文件: clogl.c 项目: Alexpux/Cygwin
long double complex
clogl(long double complex z)
{
	long double complex w;
	long double p, rr;

	rr = cabsl(z);
	p = logl(rr);
	rr = atan2l(cimagl(z), creall(z));
	w = p + rr * I;
	return w;
}
示例#5
0
文件: s_clogl.c 项目: acw/openlibm
long double complex
clogl(long double complex z)
{
	long double complex w;
	long double p, rr;

	/*rr = sqrt(z->r * z->r  +  z->i * z->i);*/
	p = cabsl(z);
	p = logl(p);
	rr = atan2l(cimagl(z), creall(z));
	w = p + rr * I;
	return (w);
}
示例#6
0
double
update_psi2(struct TwoDimSystem *sys)
{
    uint i,j;
    double norm = 0;
    double temp;
    for (i=0; i<sys->DIM; ++i) {
        for (j=0; j<sys->DIM; ++j) {
            temp = pow(cabsl(sys->psi[i*sys->DIM+j]),2);
            sys->psi2[i*sys->DIM+j] = temp;
            norm += pow(sys->dxy,2) * temp;
        }
    }

    return norm;
}
示例#7
0
static int calc_escape(long double complex* z,const long double complex* c,int maxIter) {

    int iter = 0;
    
    while(iter < maxIter){
        ++iter;
        *z = *z * *z; //squares the complex number z and stores it
        *z = *z + *c; //adds complex number c to complex number stored at z and stores it

        // check whether the iteration leads to escape */
         if(cabsl(*z) > 2.0)
            return iter; //provides an int that can be used for color palette generation
    }
    
    // Point didn't escape but we might need more iterations//
    return 0;
}
matriz * divMatricesElemAElem(matriz * A, matriz * B) // División elemento a elemento de A/B: A11/B11, A12/B12, etc. Si número es no finito, lo hace cero.
{
    assert(A&&B);
    assert(A->filas==B->filas);
    assert(A->columnas==B->columnas);
    matriz * division;
    division=nuevaMatriz(A->filas,A->columnas); // A == B
    int fila, columna;
    for (columna=A->columnas;columna>=1;columna--)
        for (fila=A->filas;fila>=1;fila--){
           elem(division,fila,columna)=elem(A,fila,columna)/elem(B,fila,columna);
           long double divResultadoAbs=cabsl(elem(division,fila,columna));
           //if(isfinite(elem(division,fila,columna))==0)
           if(isfinite(divResultadoAbs)==0)
            elem(division,fila,columna)=0;
        }
    return division;
}
示例#9
0
long double complex
cpowl(long double complex a, long double complex z)
{
	long double complex w;
	long double x, y, r, theta, absa, arga;

	x = creall(z);
	y = cimagl(z);
	absa = cabsl(a);
	if (absa == 0.0L) {
		return (0.0L + 0.0L * I);
	}
	arga = cargl(a);
	r = powl(absa, x);
	theta = x * arga;
	if (y != 0.0L) {
		r = r * expl(-y * arga);
		theta = theta + y * logl(absa);
	}
	w = r * cosl(theta) + (r * sinl(theta)) * I;
	return (w);
}
示例#10
0
void tst_notcomplex (int *pi, long *pl, long double *pld)
{
  *pi = cabs (*pi);   /* { dg-warning "using complex absolute value function" } */
  *pl = cabs (*pl);   /* { dg-warning "using complex absolute value function" } */
  *pld = cabsl (*pld);/* { dg-warning "using complex absolute value function" } */
}
示例#11
0
void testl (long double x)
{
    if (cabsl (x) != fabsl (x))
        link_error ();
}
示例#12
0
void test_long(long x) {
  (void)abs(x);  // no warning - int and long are same length for this target
  (void)labs(x);
  (void)llabs(x);

  (void)fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
  (void)fabs(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"
  (void)fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"

  (void)cabsf(x);
  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
  (void)cabs(x);
  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"
  (void)cabsl(x);
  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"

  (void)__builtin_abs(x);  // no warning - int and long are same length for
                           // this target
  (void)__builtin_labs(x);
  (void)__builtin_llabs(x);

  (void)__builtin_fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
  (void)__builtin_fabs(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"
  (void)__builtin_fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"

  (void)__builtin_cabsf(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
  (void)__builtin_cabs(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"
  (void)__builtin_cabsl(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_labs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
}
示例#13
0
void test_unsigned_long(unsigned long x) {
  (void)abs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
  (void)labs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
  (void)llabs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""

  (void)fabsf(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
  (void)fabs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
  (void)fabsl(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""

  (void)cabsf(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
  (void)cabs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
  (void)cabsl(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""

  (void)__builtin_abs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
  (void)__builtin_labs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
  (void)__builtin_llabs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""

  (void)__builtin_fabsf(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
  (void)__builtin_fabs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
  (void)__builtin_fabsl(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""

  (void)__builtin_cabsf(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
  (void)__builtin_cabs(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
  (void)__builtin_cabsl(x);
  // expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
  // expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
}
示例#14
0
void test_complex_long_double(_Complex long double x) {
  (void)abs(x);
  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl"
  (void)labs(x);
  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
  (void)llabs(x);
  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"

  (void)fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
  (void)fabs(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
  (void)fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"

  (void)cabsf(x);
  // expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
  (void)cabs(x);
  // expected-warning@-1 {{absolute value function 'cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
  // expected-note@-2 {{use function 'cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
  (void)cabsl(x);

  (void)__builtin_abs(x);
  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl"
  (void)__builtin_labs(x);
  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
  (void)__builtin_llabs(x);
  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"

  (void)__builtin_fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
  (void)__builtin_fabs(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
  (void)__builtin_fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"

  (void)__builtin_cabsf(x);
  // expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
  (void)__builtin_cabs(x);
  // expected-warning@-1 {{absolute value function '__builtin_cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
  // expected-note@-2 {{use function '__builtin_cabsl' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
  (void)__builtin_cabsl(x);
}
示例#15
0
void test_complex_float(_Complex float x) {
  (void)abs(x);
  // expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf"
  (void)labs(x);
  // expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
  (void)llabs(x);
  // expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"

  (void)fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
  (void)fabs(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
  (void)fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
  // expected-note@-2 {{use function 'cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"

  (void)cabsf(x);
  (void)cabs(x);
  (void)cabsl(x);

  (void)__builtin_abs(x);
  // expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf"
  (void)__builtin_labs(x);
  // expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
  (void)__builtin_llabs(x);
  // expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"

  (void)__builtin_fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
  (void)__builtin_fabs(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
  (void)__builtin_fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
  // expected-note@-2 {{use function '__builtin_cabsf' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"

  (void)__builtin_cabsf(x);
  (void)__builtin_cabs(x);
  (void)__builtin_cabsl(x);
}
示例#16
0
void test_long_long(long long x) {
  (void)abs(x);
  // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
  // expected-note@-2{{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"llabs"
  (void)labs(x);
  // expected-warning@-1{{absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
  // expected-note@-2{{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
  (void)llabs(x);

  (void)fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
  (void)fabs(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
  (void)fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"

  (void)cabsf(x);
  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
  (void)cabs(x);
  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
  (void)cabsl(x);
  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"

  (void)__builtin_abs(x);
  // expected-warning@-1{{absolute value function '__builtin_abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
  // expected-note@-2{{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_llabs"
  (void)__builtin_labs(x);
  // expected-warning@-1{{absolute value function '__builtin_labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
  // expected-note@-2{{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
  (void)__builtin_llabs(x);

  (void)__builtin_fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
  (void)__builtin_fabs(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
  (void)__builtin_fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"

  (void)__builtin_cabsf(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
  (void)__builtin_cabs(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
  (void)__builtin_cabsl(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
  // expected-note@-2 {{use function '__builtin_llabs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
}
示例#17
0
void test_int(int x) {
  (void)std::abs(x);

  (void)abs(x);
  (void)labs(x);
  (void)llabs(x);

  (void)fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
  (void)fabs(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
  (void)fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"

  (void)cabsf(x);
  // expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"
  (void)cabs(x);
  // expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"std::abs"
  (void)cabsl(x);
  // expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"std::abs"

  (void)__builtin_abs(x);
  (void)__builtin_labs(x);
  (void)__builtin_llabs(x);

  (void)__builtin_fabsf(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
  (void)__builtin_fabs(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
  (void)__builtin_fabsl(x);
  // expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"

  (void)__builtin_cabsf(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
  (void)__builtin_cabs(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"std::abs"
  (void)__builtin_cabsl(x);
  // expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
  // expected-note@-2 {{use function 'std::abs' instead}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"std::abs"
}
static void pnfft_perform_guru(
    const ptrdiff_t *N, const ptrdiff_t *n, ptrdiff_t local_M,
    int m, const long double *x_max, unsigned window_flag,
    const int *np, MPI_Comm comm
    )
{
  int myrank;
  ptrdiff_t local_N[3], local_N_start[3];
  long double lower_border[3], upper_border[3];
  long double local_sum = 0;
  double time, time_max;
  MPI_Comm comm_cart_3d;
  pnfftl_complex *f_hat, *f, *f1;
  long double *x, f_hat_sum;
  pnfftl_plan pnfft;

  /* create three-dimensional process grid of size np[0] x np[1] x np[2], if possible */
  if( pnfftl_create_procmesh(3, comm, np, &comm_cart_3d) ){
    pfftl_fprintf(comm, stderr, "Error: Procmesh of size %d x %d x %d does not fit to number of allocated processes.\n", np[0], np[1], np[2]);
    pfftl_fprintf(comm, stderr, "       Please allocate %d processes (mpiexec -np %d ...) or change the procmesh (with -pnfft_np * * *).\n", np[0]*np[1]*np[2], np[0]*np[1]*np[2]);
    MPI_Finalize();
    exit(1);
  }

  MPI_Comm_rank(comm_cart_3d, &myrank);

  /* get parameters of data distribution */
  pnfftl_local_size_guru(3, N, n, x_max, m, comm_cart_3d, PNFFT_TRANSPOSED_NONE,
      local_N, local_N_start, lower_border, upper_border);

  /* plan parallel NFFT */
  pnfft = pnfftl_init_guru(3, N, n, x_max, local_M, m,
      PNFFT_MALLOC_X| PNFFT_MALLOC_F_HAT| PNFFT_MALLOC_F| window_flag, PFFT_ESTIMATE,
      comm_cart_3d);

  /* get data pointers */
  f_hat = pnfftl_get_f_hat(pnfft);
  f     = pnfftl_get_f(pnfft);
  x     = pnfftl_get_x(pnfft);

  /* initialize Fourier coefficients */
  pnfftl_init_f_hat_3d(N, local_N, local_N_start, PNFFT_TRANSPOSED_NONE,
      f_hat);

  /* initialize nonequispaced nodes */
  srand(myrank);
  init_random_x(lower_border, upper_border, x_max, local_M,
      x);
 
  /* execute parallel NFFT */
  time = -MPI_Wtime();
  pnfftl_trafo(pnfft);
  time += MPI_Wtime();
  
  /* print timing */
  MPI_Reduce(&time, &time_max, 1, MPI_DOUBLE, MPI_MAX, 0, comm);
  pfftl_printf(comm, "pnfftl_trafo needs %6.2e s\n", time_max);
 
  /* calculate norm of Fourier coefficients for calculation of relative error */ 
  for(ptrdiff_t k=0; k<local_N[0]*local_N[1]*local_N[2]; k++)
    local_sum += cabsl(f_hat[k]);
  MPI_Allreduce(&local_sum, &f_hat_sum, 1, MPI_LONG_DOUBLE, MPI_SUM, comm_cart_3d);

  /* store results of NFFT */
  f1 = pnfftl_alloc_complex(local_M);
  for(ptrdiff_t j=0; j<local_M; j++) f1[j] = f[j];

  /* execute parallel NDFT */
  time = -MPI_Wtime();
  pnfftl_direct_trafo(pnfft);
  time += MPI_Wtime();

  /* print timing */
  MPI_Reduce(&time, &time_max, 1, MPI_DOUBLE, MPI_MAX, 0, comm);
  pfftl_printf(comm, "pnfftl_direct_trafo needs %6.2e s\n", time_max);

  /* calculate error of PNFFT */
  compare_f(f1, f, local_M, f_hat_sum, "* Results in", MPI_COMM_WORLD);

  /* free mem and finalize */
  pnfftl_free(f1);
  pnfftl_finalize(pnfft, PNFFT_FREE_X | PNFFT_FREE_F | PNFFT_FREE_F_HAT);
  MPI_Comm_free(&comm_cart_3d);
}
示例#19
0
 TEST_TRACE(C99 7.3.6.6)
 d = ctanh(d);
 f = ctanhf(f);
 ld = ctanhl(ld);
 TEST_TRACE(C99 7.3.7.1)
 d = cexp(d);
 f = cexpf(f);
 ld = cexpl(ld);
 TEST_TRACE(C99 7.3.7.2)
 d = clog(d);
 f = clogf(f);
 ld = clogl(ld);
 TEST_TRACE(C99 7.3.8.1)
 d = cabs(d);
 f = cabsf(f);
 ld = cabsl(ld);
 TEST_TRACE(C99 7.3.8.2)
 d = cpow(d, d);
 f = cpowf(f, f);
 ld = cpowl(ld, ld);
 TEST_TRACE(C99 7.3.8.3)
 d = csqrt(d);
 f = csqrtf(f);
 ld = csqrtl(ld);
 TEST_TRACE(C99 7.3.9.1)
 d = carg(d);
 f = cargf(f);
 ld = cargl(ld);
 TEST_TRACE(C99 7.3.9.2)
 d = cimag(d);
 f = cimagf(f);
示例#20
0
TEST(complex, cabsl) {
  ASSERT_EQ(0.0, cabsl(0));
}