diff options
Diffstat (limited to 'macros/diric.sci')
-rw-r--r-- | macros/diric.sci | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/macros/diric.sci b/macros/diric.sci index 077bb13..f60fee8 100644 --- a/macros/diric.sci +++ b/macros/diric.sci @@ -7,7 +7,7 @@ function [y]= diric(x,n) // x: Real valued vector or matrix // n: Real positive integer or complex integer // Description -// This is an Octave function + // y=diric(x,n) returns the dirichlet function values of parameter x. // Examples // 1. diric([1 2 3],3) @@ -17,8 +17,14 @@ function [y]= diric(x,n) funcprot(0); rhs=argn(2); -if (rhs~=2) then +if (argn(2)~=2) then error ("Wrong number of input arguments.") -else y= callOctave("diric",x,n) +elseif (n <= 0 | ceil(n) ~= n) then + error("n must be an positive integer."); + + else + y = sin(n.*x./2)./(n.*sin(x./2)); + y(pmodulo(x,2*%pi)==0) = (-1).^((n-1).*x(pmodulo(x,2*%pi)==0)./(2.*%pi)); end + endfunction |