annotate scripts/general/fliplr.m @ 31706:597f3ee61a48 stable

update Octave Project Developers copyright for the new year
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2023 13:11:27 -0500
parents 5d3faba0342e
children 2e484f9f1f18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30875
diff changeset
3 ## Copyright (C) 1993-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27898
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/>.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
7 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
8 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
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: 23220
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: 22323
diff changeset
13 ## (at your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
19 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
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: 23220
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 ########################################################################
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
25
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
26 ## -*- texinfo -*-
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
27 ## @deftypefn {} {@var{B} =} fliplr (@var{A})
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
28 ## Flip array left to right.
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
29 ##
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
30 ## Return a copy of @var{A} with the order of the columns reversed. In other
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
31 ## words, @var{A} is flipped left-to-right about a vertical axis. For example:
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3420
diff changeset
32 ##
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
33 ## @example
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
34 ## @group
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
35 ## fliplr ([1, 2; 3, 4])
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
36 ## @result{} 2 1
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
37 ## 4 3
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
38 ## @end group
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
39 ## @end example
5053
c08cb1098afc [project @ 2004-10-19 23:10:54 by jwe]
jwe
parents: 4869
diff changeset
40 ##
19154
76baa2d10abb flip.m: Add input validation test.
Rik <rik@octave.org>
parents: 19126
diff changeset
41 ## @seealso{flipud, flip, rot90, rotdim}
3369
f37ca3017116 [project @ 1999-11-21 16:26:02 by jwe]
jwe
parents: 2847
diff changeset
42 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
43
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
44 function B = fliplr (A)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
45
28891
de5f2f9a64ff maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents: 28886
diff changeset
46 if (nargin < 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
47 print_usage ();
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
48 endif
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 28891
diff changeset
49
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
50 B = flip (A, 2);
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
51
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
52 endfunction
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
53
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
54
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
55 %!assert (fliplr ([1, 2; 3, 4]), [2, 1; 4, 3])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
56 %!assert (fliplr ([1, 2; 3, 4; 5, 6]), [2, 1; 4, 3; 6, 5])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
57 %!assert (fliplr ([1, 2, 3; 4, 5, 6]), [3, 2, 1; 6, 5, 4])
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
58 %!assert (fliplr ([1 2 3].'), [1 2 3].')
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
59
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
60 ## Test NDArrays
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
61 %!test
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
62 %! a(:,:,1) = [ 1 2; 3 4; 5 6];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
63 %! a(:,:,2) = [ 7 8; 9 10; 11 12];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
64 %! b(:,:,1) = [ 2 1; 4 3; 6 5];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
65 %! b(:,:,2) = [ 8 7; 10 9; 12 11];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
66 %! assert (fliplr (a), b);
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
67
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
68 ## Test NDArray with singleton dimensions
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
69 %!test
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
70 %! a(:,:,:,1) = [ 1 2; 3 4; 5 6];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
71 %! a(:,:,:,2) = [ 7 8; 9 10; 11 12];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
72 %! b(:,:,:,1) = [ 2 1; 4 3; 6 5];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
73 %! b(:,:,:,2) = [ 8 7; 10 9; 12 11];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
74 %! assert (fliplr (a), b);
19126
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
75
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
76 ## Test for 1 row, i.e., returns the same
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
77 %!test
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
78 %! a(:,1,:,1) = [ 1 2 3 4];
995df67fc912 Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents: 17744
diff changeset
79 %! a(:,1,:,2) = [ 5 6 7 8];
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 20852
diff changeset
80 %! assert (fliplr (a), a);
7411
83a8781b529d [project @ 2008-01-22 21:52:25 by jwe]
jwe
parents: 7017
diff changeset
81
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 27923
diff changeset
82 ## Test input validation
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 28891
diff changeset
83 %!error <Invalid call> fliplr ()