Mercurial > hg > octave-nkf
annotate scripts/general/del2.m @ 20076:781adfc2958c draft obsolete nkf
Build qt graphics toolkit menus with uimenu
* libgui/graphics/Figure.cc, libgui/graphics/Figure.h: Revert cset 7335cc071ab0
and remove all menu items.
* scripts/gui/private/__get_funcname__.m: Fix typo
* scripts/plot/util/private/__add_default_menu__.m: Enable uimenu for qt
graphics toolkit and fix setting pan/rotate/zoom for qt and fltk
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 18:36:05 +0100 |
parents | 9fc020886ae9 |
children | 7503499a252b |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19318
diff
changeset
|
1 ## Copyright (C) 2000-2015 Kai Habel |
6788 | 2 ## Copyright (C) 2007 David Bateman |
3 ## | |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
6788 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
6788 | 19 |
20 ## -*- texinfo -*- | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
21 ## @deftypefn {Function File} {@var{d} =} del2 (@var{M}) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{d} =} del2 (@var{M}, @var{h}) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{d} =} del2 (@var{M}, @var{dx}, @var{dy}, @dots{}) |
6788 | 24 ## |
9165
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
25 ## Calculate the discrete Laplace |
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
26 ## @tex |
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
27 ## operator $( \nabla^2 )$. |
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
28 ## @end tex |
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
29 ## @ifnottex |
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
30 ## operator. |
8c71a86c4bf4
Update section 17.5 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
31 ## @end ifnottex |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
32 ## For a 2-dimensional matrix @var{M} this is defined as |
6788 | 33 ## @tex |
8499 | 34 ## $$d = {1 \over 4} \left( {d^2 \over dx^2} M(x,y) + {d^2 \over dy^2} M(x,y) \right)$$ |
6788 | 35 ## @end tex |
36 ## @ifnottex | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
37 ## |
6788 | 38 ## @example |
39 ## @group | |
40 ## 1 / d^2 d^2 \ | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
41 ## D = --- * | --- M(x,y) + --- M(x,y) | |
6788 | 42 ## 4 \ dx^2 dy^2 / |
43 ## @end group | |
44 ## @end example | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
45 ## |
6788 | 46 ## @end ifnottex |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
47 ## For N-dimensional arrays the sum in parentheses is expanded to include second |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
48 ## derivatives over the additional higher dimensions. |
6788 | 49 ## |
50 ## The spacing between evaluation points may be defined by @var{h}, which is a | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 ## scalar defining the equidistant spacing in all dimensions. Alternatively, |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
52 ## the spacing in each dimension may be defined separately by @var{dx}, |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
53 ## @var{dy}, etc. A scalar spacing argument defines equidistant spacing, |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
54 ## whereas a vector argument can be used to specify variable spacing. The |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
55 ## length of the spacing vectors must match the respective dimension of |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
56 ## @var{M}. The default spacing value is 1. |
6788 | 57 ## |
9141
c1fff751b5a8
Update section 17.1 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
58 ## At least 3 data points are needed for each dimension. Boundary points are |
c1fff751b5a8
Update section 17.1 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
59 ## calculated from the linear extrapolation of interior points. |
6788 | 60 ## |
61 ## @seealso{gradient, diff} | |
62 ## @end deftypefn | |
63 | |
64 ## Author: Kai Habel <kai.habel@gmx.de> | |
65 | |
66 function D = del2 (M, varargin) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
67 |
6788 | 68 if (nargin < 1) |
69 print_usage (); | |
70 endif | |
71 | |
72 nd = ndims (M); | |
73 sz = size (M); | |
74 dx = cell (1, nd); | |
75 if (nargin == 2 || nargin == 1) | |
76 if (nargin == 1) | |
77 h = 1; | |
78 else | |
7669 | 79 h = varargin{1}; |
6788 | 80 endif |
81 for i = 1 : nd | |
82 if (isscalar (h)) | |
10549 | 83 dx{i} = h * ones (sz (i), 1); |
6788 | 84 else |
10549 | 85 if (length (h) == sz (i)) |
86 dx{i} = diff (h)(:); | |
87 else | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
88 error ("del2: dimensionality mismatch in %d-th spacing vector", i); |
10549 | 89 endif |
6788 | 90 endif |
91 endfor | |
92 elseif (nargin - 1 == nd) | |
93 ## Reverse dx{1} and dx{2} as the X-dim is the 2nd dim of the ND array | |
94 tmp = varargin{1}; | |
95 varargin{1} = varargin{2}; | |
96 varargin{2} = tmp; | |
97 | |
98 for i = 1 : nd | |
99 if (isscalar (varargin{i})) | |
10549 | 100 dx{i} = varargin{i} * ones (sz (i), 1); |
6788 | 101 else |
10549 | 102 if (length (varargin{i}) == sz (i)) |
103 dx{i} = diff (varargin{i})(:); | |
104 else | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
105 error ("del2: dimensionality mismatch in %d-th spacing vector", i); |
10549 | 106 endif |
6788 | 107 endif |
108 endfor | |
109 else | |
110 print_usage (); | |
111 endif | |
112 | |
113 idx = cell (1, nd); | |
114 for i = 1: nd | |
115 idx{i} = ":"; | |
116 endfor | |
117 | |
118 D = zeros (sz); | |
119 for i = 1: nd | |
120 if (sz(i) >= 3) | |
121 DD = zeros (sz); | |
122 idx1 = idx2 = idx3 = idx; | |
123 | |
124 ## interior points | |
125 idx1{i} = 1 : sz(i) - 2; | |
126 idx2{i} = 2 : sz(i) - 1; | |
127 idx3{i} = 3 : sz(i); | |
128 szi = sz; | |
129 szi (i) = 1; | |
130 | |
131 h1 = repmat (shiftdim (dx{i}(1 : sz(i) - 2), 1 - i), szi); | |
132 h2 = repmat (shiftdim (dx{i}(2 : sz(i) - 1), 1 - i), szi); | |
133 DD(idx2{:}) = ((M(idx1{:}) - M(idx2{:})) ./ h1 + ... | |
10549 | 134 (M(idx3{:}) - M(idx2{:})) ./ h2) ./ (h1 + h2); |
6788 | 135 |
136 ## left and right boundary | |
137 if (sz(i) == 3) | |
10549 | 138 DD(idx1{:}) = DD(idx3{:}) = DD(idx2{:}); |
6788 | 139 else |
10549 | 140 idx1{i} = 1; |
141 idx2{i} = 2; | |
142 idx3{i} = 3; | |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
143 DD(idx1{:}) = (dx{i}(1) + dx{i}(2)) / dx{i}(2) * DD(idx2{:}) - ... |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
144 dx{i}(1) / dx{i}(2) * DD(idx3{:}); |
6788 | 145 |
10549 | 146 idx1{i} = sz(i); |
147 idx2{i} = sz(i) - 1; | |
148 idx3{i} = sz(i) - 2; | |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
149 DD(idx1{:}) = (dx{i}(sz(i) - 1) + dx{i}(sz(i) - 2)) / ... |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
150 dx{i}(sz(i) - 2) * DD(idx2{:}) - ... |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
151 dx{i}(sz(i) - 1) / dx{i}(sz(i) - 2) * DD(idx3{:}); |
6788 | 152 endif |
153 | |
154 D += DD; | |
155 endif | |
156 endfor | |
157 | |
158 D = D ./ nd; | |
159 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
160 |
18765
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
161 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
162 ## 3x3 constant test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
163 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
164 %! a = ones (3,3); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
165 %! b = del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
166 %! assert (b(:,1), [0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
167 %! assert (b(:,2), [0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
168 %! assert (b(:,3), [0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
169 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
170 ## 3x3 planar test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
171 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
172 %! a = [1,2,3;2,3,4;3,4,5]; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
173 %! b = del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
174 %! assert (b(:,1), [0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
175 %! assert (b(:,2), [0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
176 %! assert (b(:,3), [0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
177 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
178 ## 3x3 corner test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
179 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
180 %! a = zeros (3,3); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
181 %! a(1,1) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
182 %! b = 2*del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
183 %! assert (b(:,1), [1.00;0.50;0.50]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
184 %! assert (b(:,2), [0.50;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
185 %! assert (b(:,3), [0.50;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
186 %! assert (b, flipud (2*del2 (flipud (a)))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
187 %! assert (b, fliplr (2*del2 (fliplr (a)))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
188 %! assert (b, flipud (fliplr (2*del2 (fliplr (flipud (a)))))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
189 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
190 ## 3x3 boundary test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
191 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
192 %! a = zeros (3,3); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
193 %! a(2,1)=1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
194 %! b = 2*del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
195 %! assert (b(:,1), [-1.00;-0.50;-1.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
196 %! assert (b(:,2), [0.00;0.50;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
197 %! assert (b(:,3), [0.00;0.50;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
198 %! assert (b, flipud (2*del2 (flipud (a)))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
199 %! assert (b, fliplr (2*del2 (fliplr (a)))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
200 %! assert (b, flipud (fliplr (2*del2 (fliplr (flipud (a)))))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
201 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
202 ## 3x3 center test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
203 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
204 %! a = zeros (3,3); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
205 %! a(2,2) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
206 %! b = del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
207 %! assert (b(:,1), [0.00;-0.50;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
208 %! assert (b(:,2), [-0.50;-1.00;-0.50]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
209 %! assert (b(:,3), [0.00;-0.50;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
210 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
211 ## 4x4 constant test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
212 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
213 %! a = ones (4,4); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
214 %! b = del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
215 %! assert (b(:,1), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
216 %! assert (b(:,2), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
217 %! assert (b(:,3), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
218 %! assert (b(:,4), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
219 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
220 ## 4x4 planar test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
221 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
222 %! a = [1,2,3,4;2,3,4,5;3,4,5,6;4,5,6,7]; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
223 %! b = del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
224 %! assert (b(:,1), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
225 %! assert (b(:,2), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
226 %! assert (b(:,3), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
227 %! assert (b(:,4), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
228 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
229 ## 4x4 corner test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
230 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
231 %! a = zeros (4,4); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
232 %! a(1,1) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
233 %! b = 2*del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
234 %! assert (b(:,1), [2.00;0.50;0.00;-0.50]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
235 %! assert (b(:,2), [0.50;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
236 %! assert (b(:,3), [0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
237 %! assert (b(:,4), [-0.50;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
238 %! assert (b, flipud (2*del2 (flipud (a)))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
239 %! assert (b, fliplr (2*del2 (fliplr (a)))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
240 %! assert (b, flipud (fliplr (2*del2 (fliplr (flipud (a)))))); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
241 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
242 ## 9x9 center test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
243 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
244 %! a = zeros (9,9); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
245 %! a(5,5) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
246 %! b = 2*del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
247 %! assert (b(:,1), [0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
248 %! assert (b(:,2), [0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
249 %! assert (b(:,3), [0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
250 %! assert (b(:,4), [0.00;0.00;0.00;0.00;0.50;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
251 %! assert (b(:,5), [0.00;0.00;0.00;0.50;-2.00;0.50;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
252 %! assert (b(:,6), b(:,4)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
253 %! assert (b(:,7), b(:,3)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
254 %! assert (b(:,8), b(:,2)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
255 %! assert (b(:,9), b(:,1)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
256 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
257 ## 9x9 boundary test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
258 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
259 %! a = zeros (9,9); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
260 %! a(1,5) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
261 %! b = 2*del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
262 %! assert (b(1,:), [0.00,0.00,0.00,0.50,0.00,0.50,0.00,0.00,0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
263 %! assert (b(2,:), [0.00,0.00,0.00,0.00,0.50,0.00,0.00,0.00,0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
264 %! assert (b(3:9,:), zeros (7,9)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
265 %! a(1,5) = 0.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
266 %! a(5,1) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
267 %! b = 2*del2 (a); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
268 %! assert (b(:,1), [0.00;0.00;0.00;0.50;0.00;0.50;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
269 %! assert (b(:,2), [0.00;0.00;0.00;0.00;0.50;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
270 %! assert (b(:,3:9), zeros (9,7)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
271 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
272 ## 9x9 dh center test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
273 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
274 %! a = zeros (9,9); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
275 %! a(5,5) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
276 %! b = 8*del2 (a,2); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
277 %! assert (b(:,1:3), zeros (9,3)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
278 %! assert (b(:,4), [0.00;0.00;0.00;0.00;0.50;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
279 %! assert (b(:,5), [0.00;0.00;0.00;0.50;-2.00;0.50;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
280 %! assert (b(:,6), b(:,4)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
281 %! assert (b(:,7:9), zeros (9,3)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
282 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
283 ## 9x9 dx test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
284 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
285 %! a = zeros (9,9); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
286 %! a(5,5) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
287 %! b = 4*del2 (a,2,1); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
288 %! assert (b(1:3,:), zeros (3,9)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
289 %! assert (b(4,:), [0.00;0.00;0.00;0.00;1.00;0.00;0.00;0.00;0.00]'); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
290 %! assert (b(5,:), [0.00;0.00;0.00;0.25;-2.5;0.25;0.00;0.00;0.00]'); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
291 %! assert (b(6,:), b(4,:)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
292 %! assert (b(7:9,:), zeros (3,9)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
293 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
294 ## 9x9 dy test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
295 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
296 %! a = zeros (9,9); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
297 %! a(5,5) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
298 %! b = 4*del2 (a,1,2); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
299 %! assert (b(:,1:3), zeros (9,3)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
300 %! assert (b(:,4), [0.00;0.00;0.00;0.00;1.00;0.00;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
301 %! assert (b(:,5), [0.00;0.00;0.00;0.25;-2.5;0.25;0.00;0.00;0.00]); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
302 %! assert (b(:,6), b(:,4)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
303 %! assert (b(:,7:9), zeros (9,3)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
304 |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
305 ## 3D test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
306 %!test |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
307 %! a = zeros (9,9,9); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
308 %! a(5,5,5) = 1.0; |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
309 %! b = 8*3*del2 (a,2); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
310 %! assert (b(:,:,1:3), zeros (9,9,3)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
311 %! assert (b(:,1:3,:), zeros (9,3,9)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
312 %! assert (b(1:3,:,:), zeros (3,9,9)); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
313 %! assert (b(4:5,4,4), [0.0,0.0]'); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
314 %! assert (b(5,5,4), 1.00); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
315 %! assert (b(4,4,5), 0.00); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
316 %! assert (b(5,4,5), 1.00); |
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
317 %! assert (b(5,5,5),-6.00); |
19318
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
18765
diff
changeset
|
318 %! assert (b, flip (b,1)); |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
18765
diff
changeset
|
319 %! assert (b, flip (b,2)); |
995df67fc912
Flip arrays - ND support for fliplr and flipud, and replace flipdim with flip.
Carnë Draug <carandraug+dev@gmail.com>
parents:
18765
diff
changeset
|
320 %! assert (b, flip (b,3)); |
18765
21e5205679d0
del2.m: Add %!tests (bug #42005).
Allan Jacobs <jacobsallanster@gmail.com>
parents:
17744
diff
changeset
|
321 |