This is the mail archive of the
cygwin
mailing list for the Cygwin project.
tgmath.h and fftw3l
- From: KIMURA Masaru <hiyuh dot root at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 24 Jul 2013 18:54:44 +0900
- Subject: tgmath.h and fftw3l
Hi,
anyone can reproduce following symptoms?
cygwin does not support some long double math functions?
and no fftw3l available?
Peace,
-----
hiyuh@lynx /tmp
$ uname -a
CYGWIN_NT-6.1-WOW64 lynx 1.7.22(0.268/5/3) 2013-07-22 17:06 i686 Cygwin
hiyuh@lynx /tmp
$ gcc -std=gnu11 -Wall -DUSE_FLOAT -DUSE_SWS -O3 -march=native -o
preamble preamble.c $(pkg-config --cflags --libs fftw3f)
preamble.c: In function âmainâ:
preamble.c:86:6: warning: implicit declaration of function âcsqrtlâ
[-Wimplicit-function-declaration]
preamble.c:86:19: warning: incompatible implicit declaration of
built-in function âcsqrtlâ [enabled by default]
preamble.c:86:6: warning: implicit declaration of function âsqrtlâ
[-Wimplicit-function-declaration]
preamble.c:86:19: warning: incompatible implicit declaration of
built-in function âsqrtlâ [enabled by default]
preamble.c:211:4: warning: implicit declaration of function âcreallâ
[-Wimplicit-function-declaration]
preamble.c:211:4: warning: incompatible implicit declaration of
built-in function âcreallâ [enabled by default]
preamble.c:212:4: warning: implicit declaration of function âcimaglâ
[-Wimplicit-function-declaration]
preamble.c:212:4: warning: incompatible implicit declaration of
built-in function âcimaglâ [enabled by default]
hiyuh@lynx /tmp
$ gcc -std=gnu11 -Wall -DUSE_DOUBLE -DUSE_SWS -O3 -march=native -o
preamble preamble.c $(pkg-config --cflags --libs fftw3)
preamble.c: In function âmainâ:
preamble.c:86:6: warning: implicit declaration of function âcsqrtlâ
[-Wimplicit-function-declaration]
preamble.c:86:19: warning: incompatible implicit declaration of
built-in function âcsqrtlâ [enabled by default]
preamble.c:86:6: warning: implicit declaration of function âsqrtlâ
[-Wimplicit-function-declaration]
preamble.c:86:19: warning: incompatible implicit declaration of
built-in function âsqrtlâ [enabled by default]
preamble.c:211:4: warning: implicit declaration of function âcreallâ
[-Wimplicit-function-declaration]
preamble.c:211:4: warning: incompatible implicit declaration of
built-in function âcreallâ [enabled by default]
preamble.c:212:4: warning: implicit declaration of function âcimaglâ
[-Wimplicit-function-declaration]
preamble.c:212:4: warning: incompatible implicit declaration of
built-in function âcimaglâ [enabled by default]
hiyuh@lynx /tmp
$ gcc -std=gnu11 -Wall -DUSE_LONG_DOUBLE -DUSE_SWS -O3 -march=native
-o preamble preamble.c $(pkg-config --cflags --libs fftw3l)
Package fftw3l was not found in the pkg-config search path.
Perhaps you should add the directory containing `fftw3l.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fftw3l' found
preamble.c: In function âmainâ:
preamble.c:86:6: warning: implicit declaration of function âcsqrtlâ
[-Wimplicit-function-declaration]
preamble.c:86:19: warning: incompatible implicit declaration of
built-in function âcsqrtlâ [enabled by default]
preamble.c:86:6: warning: implicit declaration of function âsqrtlâ
[-Wimplicit-function-declaration]
preamble.c:86:19: warning: incompatible implicit declaration of
built-in function âsqrtlâ [enabled by default]
preamble.c:211:4: warning: implicit declaration of function âcreallâ
[-Wimplicit-function-declaration]
preamble.c:211:4: warning: incompatible implicit declaration of
built-in function âcreallâ [enabled by default]
preamble.c:212:4: warning: implicit declaration of function âcimaglâ
[-Wimplicit-function-declaration]
preamble.c:212:4: warning: incompatible implicit declaration of
built-in function âcimaglâ [enabled by default]
/tmp/ccC2hDZs.o:preamble.c:(.text.startup+0x19): undefined reference
to `fftwl_malloc'
/tmp/ccC2hDZs.o:preamble.c:(.text.startup+0x27): undefined reference
to `fftwl_malloc'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld:
/tmp/ccC2hDZs.o: bad reloc address 0x27 in section `.text.startup'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld:
final link failed: Invalid operation
collect2: error: ld returned 1 exit status
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <tgmath.h>
#include <fftw3.h>
#if defined(USE_LONG_DOUBLE)
typedef long double real_t;
typedef long double complex complex_t;
typedef fftwl_complex fftw_complex_t;
typedef fftwl_plan fftw_plan_t;
#define MACHINE_EPSILON LDBL_EPSILON
#define REAL_C(x) x ## l
#define PRIr "Lf"
#define SCNr "Lf"
#define FFTW_MALLOC(size) fftwl_malloc(size)
#define FFTW_PLAN_DFT_1D(n, in, out, sign, flag) fftwl_plan_dft_1d(n, in, out, sign, flag)
#define FFTW_EXECUTE(plan) fftwl_execute(plan)
#define FFTW_DESTROY_PLAN(plan) fftwl_destroy_plan(plan)
#define FFTW_FREE(p) fftwl_free(p)
#elif defined(USE_DOUBLE)
typedef double real_t;
typedef double complex complex_t;
typedef fftw_complex fftw_complex_t;
typedef fftw_plan fftw_plan_t;
#define MACHINE_EPSILON DBL_EPSILON
#define REAL_C(x) x
#define PRIr "f"
#define SCNr "lf"
#define FFTW_MALLOC(size) fftw_malloc(size)
#define FFTW_PLAN_DFT_1D(n, in, out, sign, flag) fftw_plan_dft_1d(n, in, out, sign, flag)
#define FFTW_EXECUTE(plan) fftw_execute(plan)
#define FFTW_DESTROY_PLAN(plan) fftw_destroy_plan(plan)
#define FFTW_FREE(p) fftw_free(p)
#elif defined(USE_FLOAT)
typedef float real_t;
typedef float complex complex_t;
typedef fftwf_complex fftw_complex_t;
typedef fftwf_plan fftw_plan_t;
#define MACHINE_EPSILON FLT_EPSILON
#define REAL_C(x) x ## f
#define PRIr "f"
#define SCNr "f"
#define FFTW_MALLOC(size) fftwf_malloc(size)
#define FFTW_PLAN_DFT_1D(n, in, out, sign, flag) fftwf_plan_dft_1d(n, in, out, sign, flag)
#define FFTW_EXECUTE(plan) fftwf_execute(plan)
#define FFTW_DESTROY_PLAN(plan) fftwf_destroy_plan(plan)
#define FFTW_FREE(p) fftwf_free(p)
#else
#error "Specify USE_* for floating point precision!"
#endif
#define N_FFT 64
#define M_SP 10
#define N_SP 16
#define M_LP 2
#define N_LP 64
#define N_GI 16
#define N_PRE (M_SP * N_SP + M_LP * N_GI + M_LP * N_LP)
int main(int argc, char *argv[]) {
fftw_complex_t *pre;
fftw_complex_t *in, *out;
fftw_plan_t plan;
pre = (fftw_complex_t *)FFTW_MALLOC(sizeof(fftw_complex_t) * N_PRE);
in = (fftw_complex_t *)FFTW_MALLOC(sizeof(fftw_complex_t) * N_FFT);
out = (fftw_complex_t *)FFTW_MALLOC(sizeof(fftw_complex_t) * N_FFT);
plan = FFTW_PLAN_DFT_1D(N_FFT, in, out, FFTW_BACKWARD, FFTW_ESTIMATE);
// SP
{
for (int f = -N_FFT/2; f < N_FFT/2; f++) {
// NOTE: FFTW maps positive frequencies [0, N_FFT/2) to array index [0, N_FFT/2),
// and negative frequencies [-N_FFT/2, 0) to array index [N_FFT/2, N_FFT).
int i =
(f < 0) ? f + N_FFT:
f;
in[i] =
(f == -24 ||
f == -16 ||
f == -4 ||
f == 12 ||
f == 16 ||
f == 20 ||
f == 24) ? sqrt(REAL_C(13.0) / REAL_C(6.0)) * (REAL_C(1.0) + REAL_C(1.0) * I) :
(f == -20 ||
f == -12 ||
f == -8 ||
f == 4 ||
f == 8) ? -sqrt(REAL_C(13.0) / REAL_C(6.0)) * (REAL_C(1.0) + REAL_C(1.0) * I) :
REAL_C(0.0) + REAL_C(0.0) * I;
}
FFTW_EXECUTE(plan);
// NOTE: FFTW calculate backward FFT w/o 1/N_FFT scaling.
for (int i = 0; i < N_FFT; i++) out[i] /= (real_t)N_FFT;
for (int m = 0; m < M_SP; m++) {
for (int n = 0; n < N_SP; n++) {
// NOTE: FFTW maps positive samples [0, N_FFT/2) to array index [0, N_FFT/2),
// and negative samples [-N_FFT/2, 0) to array index [N_FFT/2, N_FFT).
int i = n;
pre[m * N_SP + n] = out[i];
}
}
}
// LP
{
for (int f = -N_FFT/2; f < N_FFT/2; f++) {
// NOTE: FFTW maps positive frequencies [0, N_FFT/2) to array index [0, N_FFT/2),
// and negative frequencies [-N_FFT/2, 0) to array index [N_FFT/2, N_FFT).
int i =
(f < 0) ? f + N_FFT :
f;
in[i] =
(f == -26 ||
f == -25 ||
f == -22 ||
f == -21 ||
f == -19 ||
f == -17 ||
f == -16 ||
f == -15 ||
f == -14 ||
f == -13 ||
f == -12 ||
f == -9 ||
f == -8 ||
f == -6 ||
f == -4 ||
f == -3 ||
f == -2 ||
f == -1 ||
f == 1 ||
f == 4 ||
f == 5 ||
f == 7 ||
f == 9 ||
f == 15 ||
f == 16 ||
f == 19 ||
f == 21 ||
f == 23 ||
f == 24 ||
f == 25 ||
f == 26) ? REAL_C(1.0) + REAL_C(0.0) * I :
(f == -24 ||
f == -23 ||
f == -20 ||
f == -18 ||
f == -11 ||
f == -10 ||
f == -7 ||
f == -5 ||
f == 2 ||
f == 3 ||
f == 6 ||
f == 8 ||
f == 10 ||
f == 11 ||
f == 12 ||
f == 13 ||
f == 14 ||
f == 17 ||
f == 18 ||
f == 20 ||
f == 22) ? REAL_C(-1.0) + REAL_C(0.0) * I :
REAL_C(0.0) + REAL_C(0.0) * I;
}
FFTW_EXECUTE(plan);
// NOTE: FFTW calculate backward FFT w/o 1/N_FFT scaling.
for (int i = 0; i < N_FFT; i++) out[i] /= (real_t)N_FFT;
for (int m = 0; m < M_LP; m++) {
for (int n = 0; n < N_LP; n++) {
// NOTE: FFTW maps positive samples [0, N_FFT/2) to array index [0, N_FFT/2),
// and negative samples [-N_FFT/2, 0) to array index [N_FFT/2, N_FFT).
int i = n;
pre[M_SP * N_SP + M_LP * N_GI + m * N_LP + n] = out[i];
}
}
}
// 2GI
{
for (int m = 0; m < M_LP; m++) {
for (int n = 0; n < N_GI; n++) {
pre[M_SP * N_SP + (m * N_GI + n)] = pre[N_PRE - M_LP * N_GI + m * N_GI + n];
}
}
}
#if defined(USE_SWS)
// symbol wave shaping
// FIXME: This should be performed in reverse order, ATM...
pre[M_SP * N_SP] += pre[0];
pre[M_SP * N_SP] /= REAL_C(2.0);
pre[0] /= REAL_C(2.0);
#endif
// dump
printf("# PRE \n");
for (int n = 0; n < N_PRE; n++) {
printf("%d %" PRIr " %" PRIr "\n",
n,
creal(pre[n]),
cimag(pre[n])
);
}
FFTW_DESTROY_PLAN(plan);
FFTW_FREE(out);
FFTW_FREE(in);
FFTW_FREE(pre);
return 0;
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple