gcdpoly.m

来自「压缩文件中是Error Correction Coding - Mathemat」· M 代码 · 共 28 行

M
28
字号
function [g,s,t] = gcdpoly(b,c,thresh)% function [g,s,t] = gcdpoly(b,c)% Compute the GCD g = (b,c) using the Euclidean algorithm% and return s,t such that bs+ct = g, where b and c are polynomials% with real coefficients%% thresh = (optional) threhold argument used to truncate small remainders% Copyright 2004 by Todd K. Moon% Permission is granted to use this program/data% for educational/research onlyrm2 = b; rm1 = c;sm2 = 1; sm1 = 0;tm2 = 0; tm1 = 1;while(any(rm1))  [q,tr] = polydiv(rm2,rm1);  if(nargin==3)	tr(find(abs(tr) < thresh)) = 0; end; % truncate small  ts = polysub(sm2,polymult(q,sm1));  tt = polysub(tm2,polymult(q,tm1));  rm2 = rm1; sm2 = sm1;  tm2 = tm1;   rm1 = tr;  sm1 = ts;  tm1 = tt;endlc = rm2(1);					% make monicg = rm2/lc;s = sm2/lc;t = tm2/lc;

⌨️ 快捷键说明

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