annotate src/of-signal-1-fixes.patch @ 4733:1ecb1e67eaa1

* src/src-msys-dos2unix.mk: update checksum
author John Donoghue <john.donoghue@ieee.org>
date Sat, 09 Jun 2018 10:13:46 -0400
parents 85ac971a1bf0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
1 # HG changeset patch
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
2 # User Mike Miller <mtmiller@octave.org>
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
3 # Date 1525815613 25200
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
4 # Node ID 3cbff3de1ebcb28a87ca0e0f8342ea393db19908
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
5 # Parent 36e6b83ee1a1b178c58c14c5077038d7a6614118
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
6 medfilt1: rewrite memory management, fix build error on MinGW (bug #53849)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
7
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
8 * medfilt1.cc (sorted_window::sorted_window): Make buf a unique_ptr. Use
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
9 member initialiation list. (sorted_window::~sorted_window): Delete.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
10 (sorted_window::init): Use fill_n instead of bzero. (sorted_window::replace,
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
11 sorted_window::add, sorted_window::remove): Update syntax to dereference
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
12 offsets into buf.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
13
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
14 diff -r 36e6b83ee1a1 -r 3cbff3de1ebc src/medfilt1.cc
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
15 --- a/src/medfilt1.cc Sun May 06 10:17:15 2018 +0200
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
16 +++ b/src/medfilt1.cc Tue May 08 14:40:13 2018 -0700
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
17 @@ -27,9 +27,8 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
18 One dimensional median filter, for real double variables.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
19 */
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
20
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
21 -//#ifdef HAVE_CONFIG_H
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
22 -//# include "config.h"
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
23 -//#endif
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
24 +#include <algorithm>
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
25 +#include <memory>
4653
00e61c4a5657 fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents: 4591
diff changeset
26
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
27 #include "oct.h"
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
28 #include "defun-dld.h"
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
29 @@ -44,7 +43,7 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
30 // Keeps NaNs at the "top" (after Inf)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
31 class sorted_window
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
32 {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
33 - double *buf;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
34 + std::unique_ptr<double[]> buf;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
35 octave_idx_type numel;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
36 octave_idx_type numNaN;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
37 bool nan_if_any_is;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
38 @@ -70,16 +69,8 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
39 // If skip_nan then the median will consider only valid numbers within
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
40 // the window.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
41 sorted_window (octave_idx_type width, bool skip_nan = true)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
42 - {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
43 - numel = 0;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
44 - nan_if_any_is = ! skip_nan;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
45 - buf = new double [width];
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
46 - }
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
47 -
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
48 - ~sorted_window ()
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
49 - {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
50 - delete [] buf;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
51 - }
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
52 + : buf (new double [width]), numel (0), numNaN (0),
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
53 + nan_if_any_is (! skip_nan) { }
4653
00e61c4a5657 fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents: 4591
diff changeset
54
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
55 // Initialize to contain seed, and zeros additional zeros.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
56 void init (const double *seed, octave_idx_type num, octave_idx_type stride,
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
57 @@ -88,7 +79,7 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
58 numel = zeros;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
59 numNaN = 0;
4591
50aebe534e42 of-signal: don't include octave/config.h in source files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
61 - bzero (buf, zeros * sizeof (double));
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
62 + std::fill_n (&buf[0], zeros, 0.0);
4591
50aebe534e42 of-signal: don't include octave/config.h in source files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
64 // Insert from seed. Could sort if it is large
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
65 num *= stride;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
66 @@ -106,7 +97,7 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
67 n_pos = find (next);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
68 p_pos = find (prev, n_pos);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
69 if (n_pos != p_pos)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
70 - std::copy_backward (buf + n_pos, buf + p_pos, buf + p_pos + 1);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
71 + std::copy_backward (&buf[n_pos], &buf[p_pos], &buf[p_pos + 1]);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
72 }
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
73 else if (next > prev)
4653
00e61c4a5657 fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents: 4591
diff changeset
74 {
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
75 @@ -114,7 +105,7 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
76 n_pos = find (next, p_pos);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
77 if (n_pos != p_pos)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
78 {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
79 - std::copy (buf + p_pos + 1, buf + n_pos, buf + p_pos);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
80 + std::copy (&buf[p_pos + 1], &buf[n_pos], &buf[p_pos]);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
81 n_pos--; // position shifts due to deletion of p_pos
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
82 }
4653
00e61c4a5657 fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents: 4591
diff changeset
83 }
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
84 @@ -123,13 +114,13 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
85 if (next == next)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
86 {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
87 n_pos = find (next);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
88 - std::copy_backward (buf + n_pos, buf + numel - 1, buf + numel);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
89 + std::copy_backward (&buf[n_pos], &buf[numel - 1], &buf[numel]);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
90 numNaN--;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
91 }
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
92 else if (prev == prev)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
93 {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
94 p_pos = find (prev);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
95 - std::copy (buf + p_pos + 1, buf + numel, buf + p_pos);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
96 + std::copy (&buf[p_pos + 1], &buf[numel], &buf[p_pos]);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
97 n_pos = numel - 1;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
98 numNaN++;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
99 }
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
100 @@ -151,7 +142,7 @@
4653
00e61c4a5657 fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents: 4591
diff changeset
101 {
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
102 n_pos = find (next);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
103 if (n_pos < numel)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
104 - std::copy_backward (buf + n_pos, buf + numel, buf + numel + 1);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
105 + std::copy_backward (&buf[n_pos], &buf[numel], &buf[numel + 1]);
4653
00e61c4a5657 fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents: 4591
diff changeset
106 }
4702
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
107 else // NaN stored at end, so nothing to move.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
108 {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
109 @@ -170,7 +161,7 @@
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
110 if (prev == prev)
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
111 {
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
112 p_pos = find (prev);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
113 - std::copy (buf + p_pos + 1, buf + numel, buf + p_pos);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
114 + std::copy (&buf[p_pos + 1], &buf[numel], &buf[p_pos]);
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
115 }
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
116 else // NaN stored at end, so nothing to move.
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
117 numNaN--;
85ac971a1bf0 of-signal: update to v1.4.0
John Donoghue
parents: 4653
diff changeset
118