Esempio n. 1
0
int main() {
      float start[SIZE];
      int i;
      
      for (i=0; i<SIZE; i++) start[i] = (float)(i+1);
      
      printf("Starting out: ");
      for (i=0; i<SIZE; i++) printf(" %f ", (start[i])); printf("\n");

      _Complex float middle[SIZE/2 + 1];
      
      fftwf_plan plan = fftwf_plan_dft_r2c_1d(SIZE, start, (fftwf_complex*)middle, FFTW_ESTIMATE);
      fftwf_execute(plan);
      fftwf_destroy_plan(plan);

      printf("Done with forward transform: ");
      for (i=0; i< SIZE/2 + 1; i++) printf(" %g+%gi ", __real__ (middle[i]),  __imag__ (middle[i]));
      printf("\n");

      float end[SIZE];

      fftwf_plan plan2 = fftwf_plan_dft_c2r_1d(SIZE, (fftwf_complex*)middle, end, FFTW_ESTIMATE);
      fftwf_execute(plan2);
      fftwf_destroy_plan(plan2);

      printf("Done with reverse transform transform: ");
      for (i=0; i<SIZE; i++) printf(" %fi ", (end[i]));
      printf("\n");
}
Esempio n. 2
0
inline Quad Arg( const Complex<Quad>& alphaPre )
{
    __complex128 alpha;
    __real__(alpha) = alphaPre.real();
    __imag__(alpha) = alphaPre.imag();

    return cargq(alpha);
}
Esempio n. 3
0
static Obj COMPLEX_ROOTS (Obj self, Obj coeffs)
{
  Obj result;
  Int i, numroots, degree = LEN_PLIST(coeffs)-1;
  xcomplex op[degree+1], zero[degree];

  if (degree < 1)
    return Fail;

  for (i = 0; i <= degree; i++) {
    __real__(op)[degree-i] = VAL_FLOAT(ELM_PLIST(ELM_PLIST(coeffs,i+1),1));
    __imag__(op)[degree-i] = VAL_FLOAT(ELM_PLIST(ELM_PLIST(coeffs,i+1),2));
    if (isnan(__real__(op)[degree-i]) || isnan(__imag__(op)[degree-i]))
      return Fail;
  }

#ifdef DEBUG_COMPLEX_ROOTS
  fprintf(stderr,"coeffs");
  for (i = 0; i <= degree; i++)
    fprintf(stderr," %g+I*%g",(double)opr[i],(double)opi[i]);
   /* __asm__ __volatile__ ("int3"); */
  fprintf(stderr,"\n");
#endif

  numroots = cpoly (degree, op, zero);

  if (numroots == -1)
    return Fail;

#ifdef DEBUG_COMPLEX_ROOTS
  fprintf(stderr,"roots");
  for (i = 0; i < numroots; i++)
    fprintf(stderr," %g+I*%g",__real__(zero)[i],__imag__(zero)[i]);
  fprintf(stderr,"\n");
#endif

  result = ALLOC_PLIST(numroots);
  for (i = 1; i <= numroots; i++) {
    Obj t = ALLOC_PLIST(2);
    set_elm_plist(t,1, NEW_FLOAT(__real__(zero)[i-1]));
    set_elm_plist(t,2, NEW_FLOAT(__imag__(zero)[i-1]));
    set_elm_plist(result,i, t);
  }
  return result;
}
Esempio n. 4
0
inline Complex<Quad> Atanh( const Complex<Quad>& alphaPre )
{
    __complex128 alpha;
    __real__(alpha) = alphaPre.real();
    __imag__(alpha) = alphaPre.imag();
    
    __complex128 atanhAlpha = catanhq(alpha);
    return Complex<Quad>(crealq(atanhAlpha),cimagq(atanhAlpha));
}
Esempio n. 5
0
inline Complex<Quad> Asin( const Complex<Quad>& alphaPre )
{
    __complex128 alpha;
    __real__(alpha) = alphaPre.real();
    __imag__(alpha) = alphaPre.imag();
    
    __complex128 asinAlpha = casinq(alpha);
    return Complex<Quad>(crealq(asinAlpha),cimagq(asinAlpha));
}
Esempio n. 6
0
inline Complex<Quad> Cos( const Complex<Quad>& alphaPre )
{
    __complex128 alpha;
    __real__(alpha) = alphaPre.real();
    __imag__(alpha) = alphaPre.imag();
    
    __complex128 cosAlpha = ccosq(alpha);
    return Complex<Quad>(crealq(cosAlpha),cimagq(cosAlpha));
}
Esempio n. 7
0
inline Complex<Quad> Sqrt( const Complex<Quad>& alphaPre )
{ 
    __complex128 alpha;
    __real__(alpha) = alphaPre.real();
    __imag__(alpha) = alphaPre.imag();

    __complex128 sqrtAlpha = csqrtq(alpha);
    return Complex<Quad>(crealq(sqrtAlpha),cimagq(sqrtAlpha));
}
Esempio n. 8
0
inline Complex<Quad> Log( const Complex<Quad>& alphaPre )
{
    __complex128 alpha;
    __real__(alpha) = alphaPre.real();
    __imag__(alpha) = alphaPre.imag();

    __complex128 logAlpha = clogq(alpha);
    return Complex<Quad>(crealq(logAlpha),cimagq(logAlpha));
}
static void
sse2_test (void)
{
  _Complex128 a = 1.3q + 3.4qi, b = 5.6q + 7.8qi, c;

  c = foo (a, b);
  if (__real__(c) == 0.0q || __imag__ (c) == 0.0q)
    abort ();
}
Esempio n. 10
0
File: complex.c Progetto: aaasz/SHP
void f1(int * p) {
  
  // This branch should be infeasible
  // because __imag__ p is 0.
  if (!p && __imag__ (intptr_t) p)
    *p = 1; // no-warning

  // If p != 0 then this branch is feasible; otherwise it is not.
  if (__real__ (intptr_t) p)
    *p = 1; // no-warning
    
  *p = 2; // expected-warning{{Dereference of null pointer}}
}
Esempio n. 11
0
File: dft.c Progetto: wicker/dft
// some examples of working with complex.h library
void complex_demo() {

  int i;
  double complex a,b,c;

  printf("---------------------------------------\n");
  printf("some examples of working with complex.h\n");
  printf("---------------------------------------\n");

  // access real and imaginary parts with these operators
  __real__ a = 1.4f;
  __imag__ a = 2.0f;

  // or set entire number in this form
  c = 1.0 + 3.0I;

  // otherwise, they work like regular variables
  b = a;
  double complex x[3] = {a,b,c};

  // access the contents with the same operators
  printf("a = %.2f %.2fi\n",__real__(a), __imag__(a));
  printf("b = %.2f %.2fi\n",__real__(b), __imag__(b));
  printf("c = %.2f %.2fi\n",__real__(c), __imag__(c));

  for (i = 0; i < 3; i++) {
    printf("x[%d] = %.2f %.2fi\n",i,__real__(x[i]),__imag__(x[i]));
  }

  // add complex numbers
  c = a + b;
  printf("a + b = %.2f + %.2fi\n",__real__(c),__imag__(c));
  
  // multiply complex numbers
  c = a * b;
  printf("a * b = %.2f + %.2fi\n",__real__(c),__imag__(c));

  // print out pi
  printf("pi = %.10f\n",M_PI);
  printf("---------------------------------------\n");

}
Esempio n. 12
0
void
f (void)
{
  int i = 0;
  int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */
  enum e1 {
    /* Integer constant expressions may not contain statement
       expressions (not a permitted operand).  */
    E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */
    /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } 16 } */
    /* Real and imaginary parts act like other arithmetic
       operators.  */
    E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
    E3 = __real__ 0,
    E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
    E5 = __imag__ 0,
    /* __alignof__ always constant.  */
    E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */
    E7 = __alignof__ (a), /* { dg-error "__alignof__ \\(expression\\)" } */
    /* __extension__ ignored for constant expression purposes.  */
    E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
    E9 = __extension__ 0,
    /* Conditional expressions with omitted arguments act like the
       standard type.  */ 
    E10 = (1 ? : i++), /* { dg-error "constant expression" } */
    /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } 32 } */
    E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */
  };
  enum e2 {
    /* Complex integer constants may be cast directly to integer
Esempio n. 13
0
static void xscalbln (xcomplex *z, int e) {
  __real__(*z) = scalbln(__real__(*z), e);
  __imag__(*z) = scalbln(__imag__(*z), e);
}
Esempio n. 14
0
static xreal xnorm(xcomplex z) { return __real__(z)*__real(z)+__imag__(z)*__imag__(z);}