- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
喂!我希望这是一个可以接受的问题。
通过一些用于信号处理的代码,我发现了一个奇怪的函数:
let kInd = (k1, pow) => {
let k2 = 0;
let k3 = 0;
for (let i = 0; i < pow; i++) {
k3 = k1 >> 1;
k2 = 2 * (k2 - k3) + k1;
k1 = k3;
}
return k2;
};
此函数在傅立叶变换计算结束时调用,以交换实数+虚数数组对中的索引:
let fft = samples => {
let pow = Math.log2(samples.length); // `samples.length` is expected to be 2^int
// ... a bunch of code to generate `rBuff` and `iBuff` arrays representing
// real and imaginary components of fourier values
// Now make use of `kInd`; conditionally swap some indexes in `rBuff` and `iBuff`:
for (let i = 0; i < rBuff.length; i++) {
let k = kInd(i, pow);
if (k >= i) continue;
[ rBuff[i], rBuff[k] ] = [ rBuff[k], rBuff[i] ];
[ iBuff[i], iBuff[k] ] = [ iBuff[k], iBuff[i] ];
}
// ... A bit of code to convert to power spectrum and return result
};
我的问题是:kInd
到底在做什么? 我已经运行它来输出一些示例值;随着 k1
参数递增,它看起来以几乎随机的顺序输出 2 的幂和。 kInd
的小改动会导致 fft
的结果完全错误。
谢谢!
(注意:让我知道更多代码是否有帮助。为了读者的缘故,尽量保持简短!)
最佳答案
这实现了 butterfly FFT算法的操作。
例如,运行...
console.log([0,1,2,3,4,5,6,7].map(i => kInd(i, 3)))
...打印...
[ 0, 4, 2, 6, 1, 5, 3, 7 ]
...这是图中的映射:
http://www.alwayslearn.com/DFT%20and%20FFT%20Tutorial/DFTandFFT_FFT_Butterfly_8_Input.html
关于javascript - 用于信号处理的奇函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52380535/
我只是在 Mac OS X 中玩信号。 为什么在我的信号处理程序完成后,以下代码不会产生 SIGSEGV 的默认行为?在 Linux 下,代码运行良好。 #include #include #in
信号是由操作系统传给进程的中断,会提早终止一个程序。在 UNIX、LINUX、Mac OS X 或 Windows 系统上,可以通过按 Ctrl+C 产生中断。 有些信号不能被程序捕获,但是下表所
C、C++ 程序中,信号常常作为进程间通信的一种重要手段。举个例子: #include <stdio.h> #include <unistd.h> #include <
是否有关于重叠处理的任何好的(如果可能的话)科学资源(网络或书籍)。我对分析信号时使用重叠处理和窗口的效果不感兴趣,因为要求是不同的。有关以下实时情况的更多信息:(我当前正在处理音频信号) 将信号分成
在下面的代码中: #include #include #include #include #include using namespace std; void signal_callback_
我是操作系统的新手,在学习 Linux 信号处理时遇到了一些问题。 在 Linux 中,如果信号在系统调用期间到达,例如 pause(),程序将切换到内核模式并运行信号处理程序。然后根据处理函数,程序
我正在尝试在 shell 中实现一个简单的两级管道。 当我不做第二个 fork 而只是在父级中执行管道的其余实现时,它工作正常但我退出了 shell。这就是为什么我想做第二个 fork,这样我就不会退
我写了一个小脚本,用 Python 做了一些非常耗时的事情,我包含了一个信号处理模块,用于监听 SIGINT、SIGQUIT 和 SIGINFO,当用户输入 SIGQUIT 或 SIGINFO 时打印
我有一个正在读取的传感器,目前代码是用 Java 编写的,但我认为问题不是特定于语言的,更多的是与方法相关。 传感器会产生具有高脉冲和低脉冲的信号,大致类似于心跳。然而,“高”脉冲并不总是相同的电平,
使用mpirun时,是否可以在运行的代码中捕获信号(例如,^C生成的SIGINT)? 例如,我正在运行并行化的 Python 代码。在单独运行 python blah.py 时,我可以 except
如果 linux 进程正在等待 I/O(即它处于 SLEEP 状态)并且针对它发出 SIGKILL 信号,则在终止时( STOPPED 状态)是否会通过RUNNING 或READY 状态? 换句话说,
当进程正在执行阻塞系统调用时,比如读或写,信号已经到达。系统调用是否因错误 EINTR 而终止?处理系统调用后是否重启系统调用? 假设系统调用因错误 EINTR 终止,内核在返回用户空间之前处理该信号
有人可以解释为什么我们不应该从信号处理程序调用非异步函数吗?就像调用此类函数时破坏程序的确切步骤顺序一样。而且,信号是否总是在单独的堆栈上运行?如果是这样,它是一个单独的上下文还是在信号线程的上下文中
我在处理多线程服务器中的信号处理时遇到了麻烦。我为每个连接创建一个线程,但我希望有一个选项可以使用 SIGINT 终止服务器。但是,当其中一个线程捕获到信号时,事情会变得很糟糕。除了主线程之外,有什么
我写了一个扭曲的程序来处理来自 TCP 套接字和原始套接字的请求。由于 twisted 不支持原始线程,我在名为“raw_socket_loop”的函数中编写了原始套接字选择轮询循环。主 react
这个问题在这里已经有了答案: c: catch a segfault in exec() which was run in a child process (1 个回答) 关闭 6 年前。 我有一个
我有一个 repeat python 函数和一个只有一个按钮的 test.ui。我的疑问是每次单击按钮时如何准确地循环一次相同的功能。因为对我来说,每当我表演时: self.pushButton.cl
我想禁用像 SIGINT 这样的信号,它是通过按 CTRL_C 发送的,还有其他将终止 JVM 的信号。我在此处阅读了有关-Xrs 选项的信息 http://docs.oracle.com/javas
这个问题在这里已经有了答案: Getting fault address that generated a UNIX signal (2 个答案) 关闭 5 年前。 有没有办法找出被某些信号中断的机
是否可以通过 Erlang 中的处理程序捕获 Linux 信号(例如 SIGUSR1)? (无需求助于用 C 编写的驱动程序) 最佳答案 (不是真正的答案) 2001 年有人问: Does anyon
我是一名优秀的程序员,十分优秀!