📄 angle2rotate.m
字号:
%% decriptioin
% this file is very important for at least two reasons.
% the one is DATAs, which is suppose to be stored in ROM,
% will be provided in the first part of the routine. The
% other is, in fact, it has great effect on the steps of
% iteration.Of course, the angle to rotate at each step
% is based on the stored DATAs. And angles will be chosen
% to get the result as quickly as possible accordingly.
% How many DATAs are required to obtain the acceptable
% results,further study is badly needed.
% inputs
% y or z can be both chosen to decrease.HOWEVER,
% the same algorithm was employed.
% NumofData and wordwidth offer the parameters to
% generate those DATAs. The method is discussed
% below.
% Since wordwidth limits range of the datas,
% and the smallest angle to rotate is
% arctan(2^(-wordwidth)),the second smallest
% one is arctan(2^(-wordwidth+1)), and so on.
% There will be NumOfData of those smallest
% datas generated and stored unless the last
% parameter is provided.Or those angles are
% defined in ROM.
% outputs
% out, the best choice for the places to shift
% and the current angle to rotate
% format Fi arctan(2^(-Fi))
% data format in ROM
% F0 arctanh(2^-(F0))
% F1 arctanh(2^-(F1))
% ...
% and so on
%% code
function [Fi ei]=Angle2rotate(z,m,wordwidth,NumOfData,ROM)
% DATAs generator
if(nargin<4)
wordwidth=64;
end
if(nargin<5)
NumOfData=wordwidth+1;
end
if(nargin<6)
% F is in an increasing order
F=wordwidth-(NumOfData-1:-1:0)';
theta=2.^(-F);
if(m~=-1)
ROM=[F atan(theta)];
else% m=-1
ROM=[F atanh(theta)];
if(~F(1))% F0=0 must be removed
ROM=[F(2:end),atanh(theta(2:end))];
end
end
save ROM.dat ROM -ascii
end
% FIND THE BEST CHOICE FOR ANGLE TO ROTATE
% there's only one angle stored
if(NumOfData==1 || length(ROM)==1)
Fi=ROM(1);ei=ROM(2);
% there's more than one choice
else% find the minumal difference
for i=1:length(z)
Remaider=abs(z(i,1));
[v,index]=min(abs(Remaider-ROM(:,2)));
% v is useless
Fi(i)=ROM(index(1),1);
ei(i)=ROM(index(1),2);
end
Fi=Fi';ei=ei';
end
% ends function
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -