comparison scripts/statistics/distributions/expinv.m @ 19867: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 d9341b422488
comparison
equal deleted inserted replaced
19866:a1acca0c2216 19867:9fc020886ae9
30 30
31 if (nargin != 2) 31 if (nargin != 2)
32 print_usage (); 32 print_usage ();
33 endif 33 endif
34 34
35 if (!isscalar (lambda)) 35 if (! isscalar (lambda))
36 [retval, x, lambda] = common_size (x, lambda); 36 [retval, x, lambda] = common_size (x, lambda);
37 if (retval > 0) 37 if (retval > 0)
38 error ("expinv: X and LAMBDA must be of common size or scalars"); 38 error ("expinv: X and LAMBDA must be of common size or scalars");
39 endif 39 endif
40 endif 40 endif
41 41
42 if (iscomplex (x) || iscomplex (lambda)) 42 if (iscomplex (x) || iscomplex (lambda))
43 error ("expinv: X and LAMBDA must not be complex"); 43 error ("expinv: X and LAMBDA must not be complex");
44 endif 44 endif
45 45
46 if (!isscalar (x)) 46 if (! isscalar (x))
47 sz = size (x); 47 sz = size (x);
48 else 48 else
49 sz = size (lambda); 49 sz = size (lambda);
50 endif 50 endif
51 51
77 %!assert (expinv (x, 2*ones (1,5)), [NaN 0 1 Inf NaN], eps) 77 %!assert (expinv (x, 2*ones (1,5)), [NaN 0 1 Inf NaN], eps)
78 %!assert (expinv (x, 2), [NaN 0 1 Inf NaN], eps) 78 %!assert (expinv (x, 2), [NaN 0 1 Inf NaN], eps)
79 %!assert (expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps) 79 %!assert (expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps)
80 %!assert (expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps) 80 %!assert (expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps)
81 81
82 %% Test class of input preserved 82 ## Test class of input preserved
83 %!assert (expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps) 83 %!assert (expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps)
84 %!assert (expinv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), eps) 84 %!assert (expinv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), eps)
85 %!assert (expinv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), eps) 85 %!assert (expinv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), eps)
86 86
87 %% Test input validation 87 ## Test input validation
88 %!error expinv () 88 %!error expinv ()
89 %!error expinv (1) 89 %!error expinv (1)
90 %!error expinv (1,2,3) 90 %!error expinv (1,2,3)
91 %!error expinv (ones (3), ones (2)) 91 %!error expinv (ones (3), ones (2))
92 %!error expinv (ones (2), ones (3)) 92 %!error expinv (ones (2), ones (3))