Mercurial > octave-nkf
comparison scripts/general/rat.m @ 10540:952d4df5b686
Eliminate NaN*ones and Inf*ones constructs and just use Nan() and Inf()
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Thu, 22 Apr 2010 14:03:47 -0700 |
parents | 1bf0ce0930be |
children | 95c3e38098bf |
comparison
equal
deleted
inserted
replaced
10539:8db807a0eb78 | 10540:952d4df5b686 |
---|---|
69 while (1) | 69 while (1) |
70 ## Determine which fractions have not yet converged. | 70 ## Determine which fractions have not yet converged. |
71 idx = find(abs (y-n./d) >= tol); | 71 idx = find(abs (y-n./d) >= tol); |
72 if (isempty(idx)) | 72 if (isempty(idx)) |
73 if (isempty (steps)) | 73 if (isempty (steps)) |
74 steps = NaN .* ones (nsz, 1); | 74 steps = NaN (nsz, 1); |
75 endif | 75 endif |
76 break; | 76 break; |
77 endif | 77 endif |
78 | 78 |
79 ## Grab the next step in the continued fraction. | 79 ## Grab the next step in the continued fraction. |
80 flip = 1./frac(idx); | 80 flip = 1./frac(idx); |
81 ## Next element in the continued fraction. | 81 ## Next element in the continued fraction. |
82 step = round(flip); | 82 step = round(flip); |
83 | 83 |
84 if (nargout < 2) | 84 if (nargout < 2) |
85 tsteps = NaN .* ones (nsz, 1); | 85 tsteps = NaN (nsz, 1); |
86 tsteps (idx) = step; | 86 tsteps (idx) = step; |
87 steps = [steps, tsteps]; | 87 steps = [steps, tsteps]; |
88 endif | 88 endif |
89 | 89 |
90 frac(idx) = flip-step; | 90 frac(idx) = flip-step; |