comparison scripts/statistics/distributions/binoinv.m @ 19833:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents 4197fc428c7d
children
comparison
equal deleted inserted replaced
19832:a1acca0c2216 19833:9fc020886ae9
32 32
33 if (nargin != 3) 33 if (nargin != 3)
34 print_usage (); 34 print_usage ();
35 endif 35 endif
36 36
37 if (!isscalar (n) || !isscalar (p)) 37 if (! isscalar (n) || ! isscalar (p))
38 [retval, x, n, p] = common_size (x, n, p); 38 [retval, x, n, p] = common_size (x, n, p);
39 if (retval > 0) 39 if (retval > 0)
40 error ("binoinv: X, N, and P must be of common size or scalars"); 40 error ("binoinv: X, N, and P must be of common size or scalars");
41 endif 41 endif
42 endif 42 endif
93 %!assert (binoinv (x, 2*ones (1,5), 0.5), [NaN 0 1 2 NaN]) 93 %!assert (binoinv (x, 2*ones (1,5), 0.5), [NaN 0 1 2 NaN])
94 %!assert (binoinv (x, 2*[0 -1 NaN 1.1 1], 0.5), [NaN NaN NaN NaN NaN]) 94 %!assert (binoinv (x, 2*[0 -1 NaN 1.1 1], 0.5), [NaN NaN NaN NaN NaN])
95 %!assert (binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN]) 95 %!assert (binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN])
96 %!assert (binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN]) 96 %!assert (binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN])
97 97
98 %% Test class of input preserved 98 ## Test class of input preserved
99 %!assert (binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN]) 99 %!assert (binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN])
100 %!assert (binoinv (single ([x, NaN]), 2, 0.5), single ([NaN 0 1 2 NaN NaN])) 100 %!assert (binoinv (single ([x, NaN]), 2, 0.5), single ([NaN 0 1 2 NaN NaN]))
101 %!assert (binoinv ([x, NaN], single (2), 0.5), single ([NaN 0 1 2 NaN NaN])) 101 %!assert (binoinv ([x, NaN], single (2), 0.5), single ([NaN 0 1 2 NaN NaN]))
102 %!assert (binoinv ([x, NaN], 2, single (0.5)), single ([NaN 0 1 2 NaN NaN])) 102 %!assert (binoinv ([x, NaN], 2, single (0.5)), single ([NaN 0 1 2 NaN NaN]))
103 103
104 %% Test input validation 104 ## Test input validation
105 %!error binoinv () 105 %!error binoinv ()
106 %!error binoinv (1) 106 %!error binoinv (1)
107 %!error binoinv (1,2) 107 %!error binoinv (1,2)
108 %!error binoinv (1,2,3,4) 108 %!error binoinv (1,2,3,4)
109 %!error binoinv (ones (3), ones (2), ones (2)) 109 %!error binoinv (ones (3), ones (2), ones (2))