Mercurial > octave
annotate scripts/signal/fftshift.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 7854d5752dd2 |
children | 5d3faba0342e |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 1997-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
3426 | 7 ## |
3922 | 8 ## This file is part of Octave. |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
3922 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22671
diff
changeset
|
13 ## (at your option) any later version. |
3426 | 14 ## |
3922 | 15 ## Octave is distributed in the hope that it will be useful, but |
3191 | 16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22671
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22671
diff
changeset
|
18 ## GNU General Public License for more details. |
3426 | 19 ## |
3191 | 20 ## You should have received a copy of the GNU General Public License |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
3191 | 25 |
3449 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20237
diff
changeset
|
27 ## @deftypefn {} {} fftshift (@var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20237
diff
changeset
|
28 ## @deftypefnx {} {} fftshift (@var{x}, @var{dim}) |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
29 ## Perform a shift of the vector @var{x}, for use with the @code{fft} and |
22671
143b120ddb83
fftshift: fix definition of frequency components in docstring (bug #49436)
Mike Miller <mtmiller@octave.org>
parents:
22489
diff
changeset
|
30 ## @code{ifft} functions, in order to move the frequency 0 to the center of |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
31 ## the vector or matrix. |
3191 | 32 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
33 ## If @var{x} is a vector of @math{N} elements corresponding to @math{N} time |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
34 ## samples spaced by @nospell{@math{dt}}, then |
13233
914c0b103a3d
fftshift.m: Better explain operation in docstring (Bug #33581).
Rik <octave@nomad.inbox5.com>
parents:
12540
diff
changeset
|
35 ## @code{fftshift (fft (@var{x}))} corresponds to frequencies |
3191 | 36 ## |
3449 | 37 ## @example |
22671
143b120ddb83
fftshift: fix definition of frequency components in docstring (bug #49436)
Mike Miller <mtmiller@octave.org>
parents:
22489
diff
changeset
|
38 ## f = [ -(ceil((N-1)/2):-1:1), 0, (1:floor((N-1)/2)) ] * df |
3449 | 39 ## @end example |
3191 | 40 ## |
13929
9cae456085c2
Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13268
diff
changeset
|
41 ## @noindent |
22671
143b120ddb83
fftshift: fix definition of frequency components in docstring (bug #49436)
Mike Miller <mtmiller@octave.org>
parents:
22489
diff
changeset
|
42 ## where @nospell{@math{df = 1 / (N * dt)}}. |
13233
914c0b103a3d
fftshift.m: Better explain operation in docstring (Bug #33581).
Rik <octave@nomad.inbox5.com>
parents:
12540
diff
changeset
|
43 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
44 ## If @var{x} is a matrix, the same holds for rows and columns. If @var{x} |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
45 ## is an array, then the same holds along each dimension. |
4844 | 46 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
47 ## The optional @var{dim} argument can be used to limit the dimension along |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
48 ## which the permutation occurs. |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
49 ## @seealso{ifftshift} |
3449 | 50 ## @end deftypefn |
3191 | 51 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
52 function retval = fftshift (x, dim) |
3191 | 53 |
28891
de5f2f9a64ff
maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents:
28886
diff
changeset
|
54 if (nargin < 1) |
6046 | 55 print_usage (); |
3191 | 56 endif |
57 | |
20237
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
58 if (! (isnumeric (x) || islogical (x) || ischar (x))) |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
59 error ("fftshift: X must be a vector or matrix"); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
60 endif |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
61 |
4844 | 62 if (nargin == 2) |
13233
914c0b103a3d
fftshift.m: Better explain operation in docstring (Bug #33581).
Rik <octave@nomad.inbox5.com>
parents:
12540
diff
changeset
|
63 if (! (isscalar (dim) && dim > 0 && dim == fix (dim))) |
914c0b103a3d
fftshift.m: Better explain operation in docstring (Bug #33581).
Rik <octave@nomad.inbox5.com>
parents:
12540
diff
changeset
|
64 error ("fftshift: dimension DIM must be a positive integer"); |
4844 | 65 endif |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
66 nd = ndims (x); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
67 sz = size (x); |
4844 | 68 sz2 = ceil (sz(dim) / 2); |
69 idx = cell (); | |
12676
2783fa95cab7
Use common code idiom for creating cell array for indexing ND-arrays
Rik <octave@nomad.inbox5.com>
parents:
12540
diff
changeset
|
70 idx = repmat ({':'}, nd, 1); |
7208 | 71 idx{dim} = [sz2+1:sz(dim), 1:sz2]; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
72 retval = x(idx{:}); |
3191 | 73 else |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
74 if (isvector (x)) |
12463
189baf055143
fftshift.m: Fix broken function documented in bug 32442
Karsten Trulsen <karstent@math.uio.no>
parents:
11587
diff
changeset
|
75 xl = length (x); |
189baf055143
fftshift.m: Fix broken function documented in bug 32442
Karsten Trulsen <karstent@math.uio.no>
parents:
11587
diff
changeset
|
76 xx = ceil (xl/2); |
189baf055143
fftshift.m: Fix broken function documented in bug 32442
Karsten Trulsen <karstent@math.uio.no>
parents:
11587
diff
changeset
|
77 retval = x([xx+1:xl, 1:xx]); |
20237
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
78 else |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
79 nd = ndims (x); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
80 sz = size (x); |
4844 | 81 sz2 = ceil (sz ./ 2); |
82 idx = cell (); | |
8507 | 83 for i = 1:nd |
4844 | 84 idx{i} = [sz2(i)+1:sz(i), 1:sz2(i)]; |
85 endfor | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
86 retval = x(idx{:}); |
4844 | 87 endif |
3191 | 88 endif |
89 | |
90 endfunction | |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
91 |
13233
914c0b103a3d
fftshift.m: Better explain operation in docstring (Bug #33581).
Rik <octave@nomad.inbox5.com>
parents:
12540
diff
changeset
|
92 |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
93 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
94 %! x = [0:7]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
95 %! y = fftshift (x); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
96 %! assert (y, [4 5 6 7 0 1 2 3]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
97 %! assert (fftshift (y), x); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
98 |
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
99 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
100 %! x = [0:6]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
101 %! y = fftshift (x); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
102 %! assert (y, [4 5 6 0 1 2 3]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
103 %! assert (fftshift (y), [1 2 3 4 5 6 0]); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
104 |
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
105 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
106 %! x = [0:7]'; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
107 %! y = fftshift (x); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
108 %! assert (y, [4;5;6;7;0;1;2;3]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
109 %! assert (fftshift (y), x); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
110 |
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
111 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
112 %! x = [0:6]'; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
113 %! y = fftshift (x); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
114 %! assert (y, [4;5;6;0;1;2;3]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
115 %! assert (fftshift (y), [1;2;3;4;5;6;0]); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
116 |
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
117 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
118 %! x = [0:3]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
119 %! x = [x;2*x;3*x+1;4*x+1]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
120 %! y = fftshift (x); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
121 %! assert (y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
122 %! assert (fftshift (y), x); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
123 |
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
124 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
125 %! x = [0:3]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
126 %! x = [x;2*x;3*x+1;4*x+1]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
127 %! y = fftshift (x,1); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
128 %! assert (y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
129 %! assert (fftshift (y,1), x); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
130 |
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
131 %!test |
17314
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
132 %! x = [0:3]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
133 %! x = [x;2*x;3*x+1;4*x+1]; |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
134 %! y = fftshift (x,2); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
135 %! assert (y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); |
7f27a3cbdb41
Use Octave coding convention of 1 space after '%!' test prefix.
Rik <rik@octave.org>
parents:
16826
diff
changeset
|
136 %! assert (fftshift (y,2), x); |
12540
b3c158b8941c
Add tests for fftshift.m.
Robert T. Short <octave@phaselockedsystems.com.com>
parents:
12463
diff
changeset
|
137 |
20237
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
138 %!test |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
139 %! x = "abcdefg"; |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
140 %! y = fftshift (x); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
141 %! assert (y, "efgabcd"); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
142 %! assert (fftshift (y), "bcdefga"); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
143 |
22489
93ea313301f9
test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
144 ## Test N-dimensional input |
23573
1b4f4ec53b4a
use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents:
23572
diff
changeset
|
145 %!test <*45207> |
20237
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
146 %! x = [0:3]; |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
147 %! x = x + x' + reshape (x, [1 1 4]); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
148 %! y1 = [4 5 2 3; 5 6 3 4; 2 3 0 1; 3 4 1 2]; |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
149 %! y = fftshift (x); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
150 %! assert (y, reshape ([y1 + 2, y1 + 3, y1, y1 + 1], [4 4 4])); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
151 %! assert (fftshift (y), x); |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
152 |
20929
45a64a6c7273
fix comment character style in most .m files to be consistent
John W. Eaton <jwe@octave.org>
parents:
20852
diff
changeset
|
153 ## Test input validation |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
154 %!error <Invalid call> fftshift () |
20237
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
155 %!error fftshift (0:3, -1) |
abbe33bf0c74
fftshift.m, ifftshift.m: Restore support for N-dimensional arrays (bug #45207)
Mike Miller <mtmiller@octave.org>
parents:
20165
diff
changeset
|
156 %!error fftshift (0:3, 0:3) |