070*_*220 0 c# matlab ilnumerics
我想将以下 Matlab 代码转换为 C#:
nfft=2^nextpow2(nn);
Run Code Online (Sandbox Code Playgroud)
其中NEXTPOW2(N)
表示 Matlab 中 2 的下一个更高的幂。
那么我们如何自己用C#代码或者借助ilnumerics Lab来实现同样的功能呢?
unsigned int v; // compute the next highest power of 2 of 32-bit v
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
Run Code Online (Sandbox Code Playgroud)