Mercurial > hg > octave-nkf
annotate scripts/signal/sinc.m @ 19830:884e0c55d92c
Fix complex compare operation for issorted (bug #44071).
* Array-C.cc (nan_ascending_compare, nan_descending_compare): Fix typo where
comparison was made between x and x rather than between x and y.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 26 Jan 2015 15:32:49 -0800 |
parents | d63878346099 |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
14868
diff
changeset
|
1 ## Copyright (C) 1994-2013 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
2303 | 18 |
3367 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} sinc (@var{x}) | |
21 ## Return | |
22 ## @tex | |
23 ## $ \sin (\pi x)/(\pi x)$. | |
24 ## @end tex | |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7125
diff
changeset
|
25 ## @ifnottex |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14363
diff
changeset
|
26 ## sin (pi*x) / (pi*x). |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7125
diff
changeset
|
27 ## @end ifnottex |
3367 | 28 ## @end deftypefn |
559 | 29 |
3367 | 30 ## Author: jwe ??? |
2314 | 31 |
2311 | 32 function result = sinc (x) |
559 | 33 |
7125 | 34 if (nargin != 1) |
35 print_usage (); | |
36 endif | |
37 | |
3486 | 38 result = ones (size (x)); |
559 | 39 |
3486 | 40 i = (x != 0); |
559 | 41 |
4807 | 42 if (any (i(:))) |
3486 | 43 t = pi * x(i); |
44 result(i) = sin (t) ./ t; | |
559 | 45 endif |
46 | |
47 endfunction | |
12816
cd59f5271941
codesprint: Wrote 4 tests for sinc.m
Giles Anderson <agander@gmail.com>
parents:
11523
diff
changeset
|
48 |
cd59f5271941
codesprint: Wrote 4 tests for sinc.m
Giles Anderson <agander@gmail.com>
parents:
11523
diff
changeset
|
49 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
50 %!assert (sinc (0), 1) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
51 %!assert (sinc (1), 0,1e-6) |
12816
cd59f5271941
codesprint: Wrote 4 tests for sinc.m
Giles Anderson <agander@gmail.com>
parents:
11523
diff
changeset
|
52 %!assert (sinc (1/2), 2/pi, 1e-6) |
cd59f5271941
codesprint: Wrote 4 tests for sinc.m
Giles Anderson <agander@gmail.com>
parents:
11523
diff
changeset
|
53 |
cd59f5271941
codesprint: Wrote 4 tests for sinc.m
Giles Anderson <agander@gmail.com>
parents:
11523
diff
changeset
|
54 %!error sinc() |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 |