Tag: 复数

_Complex long int

TL;博士; 问: _Complex long int中int含义是什么? 为什么合法? 更长的版本 我将一些32位代码移植到64位安全。 在一个地方,我注意到它使用: static __complex__ long int i32X[256]; 转储搜索并替换为int32_t更改“long int”给了我一个编译错误。 complex是一个较旧的GNUism,由标准_Complex取代。这是一个重现问题的简短代码片段: #include #include typedef _Complex long int WhyAmILegal; typedef _Complex int32_t Snafu; typedef int32_t _Complex Snafu2; 在gcc下编译给出: complextest.c:6:26: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Snafu’ typedef _Complex int32_t Snafu; ^~~~~ complextest.c:8:17: error: two or more data […]

FFTW产生真实而不是复杂的输出

我正在使用以下代码来执行复数数组的COMPLEX IFFT(我必须得到复杂的结果): #include #include #include #include #include #include int main(void) { fftw_complex *in; fftw_complex *out; double re,im; int size; int i=0; FILE *file; fftw_plan ifft; printf(“Insert size”); if (scanf(“%d”, &size) != 1 || size < 1) return 1; in = fftw_malloc(sizeof(*in)*size); out = fftw_malloc(sizeof(*out)*size); file = fopen("numbers.txt", "r"); for (i = 0; i < size […]

为什么clang说_Imaginary_I没有声明?

运行 clang test.c -o test 在这个文件上 #include #include int main() { _Complex double z = 1.0 + _Imaginary_I * 2.0; return 0; } 由于没有编译失败 error: use of undeclared identifier ‘_Imaginary_I’. 根据onlinepubs , _Imaginary_I已定义。 发生了什么?

在C中执行具有复数的矩阵运算

我正在尝试执行涉及矩阵运算和复杂数学的计算 – 有时在C中。我非常熟悉Matlab,我知道这些类型的计算可以简单有效地执行。 例如,相同大小的两个矩阵A和B,每个都具有复数值的元素,可以通过表达式A + B容易地求和。 是否有任何软件包或技术可以建议在C或Objective C中使用这些类型的表达式编程? 我知道complex.h允许对复数执行操作,但我不知道如何在复杂矩阵上执行操作,这就是我真正想要的。 同样,我知道允许对矩阵进行操作的包,但不认为它们在处理复杂矩阵时会有用。

c ++和在单独的文件中包含

笔记: 我正在使用Apple LLVM 6.0版(clang-600.0.56)编译OSX(基于LLVM 3.5svn) 具体来说,我正在尝试从LibIIR编译一个单片源, 这是Laurence Withers 在这里维护的filter库。 我已经在这里看到了关于在同一个文件中同时使用和答案。 建立: 我有一个像iir.h这样的文件: #include #ifdef __cplusplus extern “C” { #endif … 我有C ++源代码和头文件libiir++.cpp和iir++.h喜欢这样: /*** libiir++.cpp ***/ // we need to include “iir.h” first, as it pulls in , which we need // to take effect before “iir++.h” pulls in #include “iir.h” // now remove the preprocessor […]

使用complex.h库在Visual Studio 2013中编译C代码

http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx C99支持添加了visual studio 2013,但我无法在我的“C”代码中使用complex.h。 #include #include int main(void) { double complex dc1 = 3 + 2 * I; double complex dc2 = 4 + 5 * I; double complex result; result = dc1 + dc2; printf(” ??? \n”, result); return 0; } 我得到语法错误。 编辑:抱歉缺少部分。 error C2146: syntax error : missing ‘;’ before identifier ‘dc1’ error […]

C99复杂支持与visual studio

我想使用C99中定义的复数,但我需要支持不支持它的编译器(MS编译器会浮现在脑海中)。 我不需要很多function,并且在没有支持的情况下在编译器上实现所需的function并不困难。 但我很难实现’类型’本身。 理想情况下,我想做的事情如下: #ifndef HAVE_CREAL double creal(complex z) { /* …. */ } #endif #ifndef HAVE_CREALF float creal(float complex z) { /* … */ } #endif 但是如果编译器无法识别’float complex’,我不确定如何做到这一点。 我实际上认为这是不可能的,但Dinkumware的C库似乎表明不是这样。 解决办法是什么 ? 我不介意使用函数/宏来对类型进行操作,但是我需要一种方法来为复数赋值,并以与C99兼容的方式返回其实/虚部分。 解 我最终做了这样的事情: #ifdef USE_C99_COMPLEX #include typedef complex my_complex; #else typedef struct { double x, y; } my_complex; #endif /* * Those unions […]