ransort.m

来自「Polynomial Root Finder is a reliable and」· M 代码 · 共 26 行

M
26
字号
function [ind] = ransort(n)% function [ind] = ransort(n)%% function computes an index vector ind of length n which contains% all integers 1:n but in a quasi random order.%% m-file bitrev must be available% author: m. lang 17.12.91% This is very advantageous for example for the function poly:% compute z = roots([1 zeros(1:m) 1]); p = poly(z).% There is a large error in p, which stems from the second operation% poly. If the roots z are sorted with increasing angle in zs, then% ph = poly(zs(ransort(n))) yields much less error than p.%% ransort uses bitreversal which is known as van der corput sequence% in the theory of uniform distributed sequences.m = ceil(log2(n));ind = 1:2^m;ind =  bitrev(ind);ind = ind(find(ind<=n));  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?