nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
pulse_metrics.hpp
Go to the documentation of this file.
1
3// toolboxes/signal/include/nk/signal/measurements/pulse_metrics.hpp
4//
5// Pulse and transition metrics for digital / step-shaped time-series.
6// The pulse-metric family: `risetime / falltime / overshoot /
7// undershoot / settlingtime / dutycycle / midcross / pulsewidth /
8// pulseperiod / pulsesep / slewrate / statelevels` family.
9//
10// Conventions:
11// * `x` is a real, sampled time-series (1-D vector).
12// * `fs` is the sample rate in Hz. `Value::Empty` (default) → fs = 1,
13// so samples are the time unit. When supplied, returned times are in
14// seconds.
15// * Reference levels come from `statelevels(x)` unless explicit levels
16// are supplied. State boundaries use the canonical defaults:
17// 10% / 90% for rise / fall, 50% for mid-state, 2% for "settled".
18// * Outputs are column vectors; empty when no transition / pulse found.
19
20#pragma once
21
22#include <memory_resource>
23#include <nk/value/value.hpp>
24
25namespace nk::signal {
26
29
30
43 std::pmr::memory_resource * mr = nullptr);
44
58 const Value & fs = Value::Empty,
59 std::pmr::memory_resource * mr = nullptr);
60
73 const Value & fs = Value::Empty,
74 std::pmr::memory_resource * mr = nullptr);
75
85Value falltime(const Value &x, const Value &fs = Value::Empty,
86 std::pmr::memory_resource *mr = nullptr);
87
100 const Value & fs = Value::Empty,
101 std::pmr::memory_resource * mr = nullptr);
102
113Value overshoot(const Value &x, const Value &fs = Value::Empty,
114 std::pmr::memory_resource *mr = nullptr);
115
126 std::pmr::memory_resource *mr = nullptr);
127
141 const Value & fs = Value::Empty,
142 double tol = 0.02,
143 std::pmr::memory_resource * mr = nullptr);
144
154 const Value & fs = Value::Empty,
155 std::pmr::memory_resource * mr = nullptr);
156
165 std::pmr::memory_resource *mr = nullptr);
166
174Value pulsesep(const Value &x, const Value &fs = Value::Empty,
175 std::pmr::memory_resource *mr = nullptr);
176
187 const Value & fs = Value::Empty,
188 std::pmr::memory_resource * mr = nullptr);
189
190
192} // namespace nk::signal
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
static const Value Empty
MATLAB-style empty matrix sentinel — a 0×0 DOUBLE value.
Definition value.hpp:136
Value undershoot(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Percent undershoot below the lower state level.
Value pulseperiod(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Period between consecutive same-direction mid-state crossings.
Value risetime(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Rise time of positive-going transitions.
Value pulsewidth(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Duration each pulse stays above the mid-state.
Value settlingtime(const Value &x, const Value &fs=Value::Empty, double tol=0.02, std::pmr::memory_resource *mr=nullptr)
Settling time of each transition.
Value statelevels(const Value &x, std::pmr::memory_resource *mr=nullptr)
Estimate the [low, high] state levels of a step-shaped signal.
Value overshoot(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Percent overshoot above the upper state.
Value pulsesep(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Separation between consecutive pulses (time below mid-state).
Value falltime(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Fall time of negative-going transitions (90% → 10%).
Value dutycycle(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Duty cycle: fraction of each pulse period spent above the mid-state.
Value midcross(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Mid-state crossing times.
Value slewrate(const Value &x, const Value &fs=Value::Empty, std::pmr::memory_resource *mr=nullptr)
Slew rate of each transition.