Mercurial > hg > octave-nkf
annotate scripts/image/spinmap.m @ 20771:87b557ee8e5d
clean up and vectorize code for dense output in ode45
* scripts/ode/private/ode_rk_interpolate.m: new file
* scripts/ode/private/ode_rk_interpolate.m(hermite_quartic_interpolation):
move to internal function, use vectorization and broadcasting.
* scripts/ode/private/hermite_quartic_interpolation.m: remove file
* scripts/ode/module.mk: list added and removed files
* scripts/ode/private/integrate_adaptive.m: use new interpolation code.
author | Carlo de Falco <carlo.defalco@polimi.it> |
---|---|
date | Tue, 06 Oct 2015 19:28:59 +0200 |
parents | 7503499a252b |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19790
diff
changeset
|
1 ## Copyright (C) 2007-2015 Kai Habel |
7163 | 2 ## |
7164 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
7163 | 6 ## under the terms of the GNU General Public License as published by |
7164 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
7163 | 9 ## |
7164 | 10 ## Octave is distributed in the hope that it will be useful, but |
7163 | 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 | |
7164 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
7163 | 18 |
19 ## -*- texinfo -*- | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
20 ## @deftypefn {Function File} {} spinmap () |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
21 ## @deftypefnx {Function File} {} spinmap (@var{t}) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
22 ## @deftypefnx {Function File} {} spinmap (@var{t}, @var{inc}) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
23 ## @deftypefnx {Function File} {} spinmap ("inf") |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
24 ## Cycle the colormap for @var{t} seconds with a color increment of @var{inc}. |
20368
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
25 ## |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
26 ## Both parameters are optional. The default cycle time is 5 seconds and the |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
14264
diff
changeset
|
27 ## default increment is 2. If the option @qcode{"inf"} is given then cycle |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
28 ## continuously until @kbd{Control-C} is pressed. |
7164 | 29 ## |
20368
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
30 ## When rotating, the original color 1 becomes color 2, color 2 becomes |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
31 ## color 3, etc. A positive or negative increment is allowed and a higher |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
32 ## value of @var{inc} will cause faster cycling through the colormap. |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
33 ## @seealso{colormap} |
7163 | 34 ## @end deftypefn |
35 | |
36 ## Author: Kai Habel <kai.habel at gmx.de> | |
37 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
38 function spinmap (t = 5, inc = 2) |
7163 | 39 |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
40 if (nargin > 2) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
41 print_usage (); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
42 elseif (ischar (t)) |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
43 if (strcmpi (t, "inf")) |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
44 t = Inf; |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
45 else |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
46 error ('spinmap: time T must be a real scalar or "inf"'); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
47 endif |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
48 elseif (! isscalar (t) || ! isreal (t)) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
49 error ("spinmap: time T must be a real scalar"); |
7163 | 50 endif |
51 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
52 cmap = cmap_orig = get (gcf (), "colormap"); |
7163 | 53 |
54 t0 = clock; | |
7164 | 55 while (etime (clock, t0) < t) |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 cmap = shift (cmap, inc, 1); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 set (gcf (), "colormap", cmap); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 drawnow (); |
7164 | 59 endwhile |
60 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
61 set (gcf (), "colormap", cmap_orig); |
7164 | 62 |
63 endfunction | |
64 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
65 |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
66 %!demo |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
67 %! clf; |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
68 %! colormap (rainbow (128)); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
69 %! imagesc (1:8); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
70 %! axis off; |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
71 %! title ("Rotate color bars to the right"); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
72 %! spinmap (3, 1); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
73 |