6#include <memory_resource>
9#include <nk/value/value.hpp>
10#include <nk/ops/rng.hpp>
12namespace nk::builtin {
18using ::nk::ops::RngContext;
20using ::nk::ops::randn;
21using ::nk::ops::randND;
22using ::nk::ops::randnND;
23using ::nk::ops::randi;
24using ::nk::ops::randperm;
50Value sum(
const Value &x,
int dim, std::pmr::memory_resource *mr =
nullptr);
87std::tuple<Value, Value>
max(
const Value &x, std::pmr::memory_resource *mr =
nullptr);
94std::tuple<Value, Value>
max(
const Value &x,
int dim, std::pmr::memory_resource *mr =
nullptr);
108std::tuple<Value, Value>
maxOmitNan(
const Value &x,
int dim, std::pmr::memory_resource *mr =
nullptr);
122std::tuple<Value, Value>
min(
const Value &x, std::pmr::memory_resource *mr =
nullptr);
129std::tuple<Value, Value>
min(
const Value &x,
int dim, std::pmr::memory_resource *mr =
nullptr);
143std::tuple<Value, Value>
minOmitNan(
const Value &x,
int dim, std::pmr::memory_resource *mr =
nullptr);
220Value diff(
const Value &x,
int n,
int dim = 0, std::pmr::memory_resource *mr =
nullptr);
262 bool hasNumBins =
false;
263 double numBins = 0.0;
264 bool hasBinWidth =
false;
265 double binWidth = 0.0;
266 bool hasBinLimits =
false;
294std::tuple<Value, Value, Value>
uniqueWithIndices(
const Value &x, std::pmr::memory_resource *mr =
nullptr,
bool stable =
false,
bool last =
false);
302std::tuple<Value, Value, Value>
uniqueRowsWithIndices(
const Value &x, std::pmr::memory_resource *mr =
nullptr,
bool stable =
false,
bool last =
false);
480 const std::string &method,
481 std::pmr::memory_resource *mr =
nullptr);
495 const std::string &method,
496 std::pmr::memory_resource *mr =
nullptr);
525 std::pmr::memory_resource *mr =
nullptr);
Core MATLAB-compatible multidimensional array and scalar value type.
GroupcountsResult groupcounts(const Value &g, std::pmr::memory_resource *mr=nullptr)
Count elements per group ([C, GR, P] = groupcounts(g)).
Value setIntersect(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr, bool stable=false)
Set intersection of two arrays (intersect(a, b)).
std::tuple< Value, Value, Value > uniqueWithIndices(const Value &x, std::pmr::memory_resource *mr=nullptr, bool stable=false, bool last=false)
Unique values with index mappings ([C, ia, ic] = unique(x)).
Value grouptransform(const Value &A, const Value &G, const std::string &method, std::pmr::memory_resource *mr=nullptr)
Group transformation (grouptransform(A, G, method)).
Value diff(const Value &x, std::pmr::memory_resource *mr=nullptr)
Differences between adjacent elements (diff(x)).
std::tuple< Value, Value, Value > uniqueRowsWithIndices(const Value &x, std::pmr::memory_resource *mr=nullptr, bool stable=false, bool last=false)
Unique rows with index mappings ([C, ia, ic] = unique(x, 'rows')).
Value setDiff(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr, bool stable=false)
Set difference (setdiff(a, b)).
Value cummin(const Value &x, std::pmr::memory_resource *mr=nullptr)
Cumulative minimum of array elements (cummin(x)).
Value unique(const Value &x, std::pmr::memory_resource *mr=nullptr, bool stable=false)
Unique values in array (unique(x)).
Value discretize(const Value &x, const Value &edges, std::pmr::memory_resource *mr=nullptr)
Groups numeric data into bins (discretize(x, edges)).
std::tuple< Value, Value > max(const Value &x, std::pmr::memory_resource *mr=nullptr)
Largest elements in array.
Value maxOmitNanBinary(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr)
Element-wise maximum of two arrays omitting NaNs (max(a, b, 'omitnan')).
Value setxor(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr)
Set exclusive OR (setxor(a, b)).
Value setUnion(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr, bool stable=false)
Set union of two arrays (union(a, b)).
Value cumprod(const Value &x, std::pmr::memory_resource *mr=nullptr)
Cumulative product of array elements (cumprod(x)).
Value ismembertol(const Value &a, const Value &s, double tol=1e-6, std::pmr::memory_resource *mr=nullptr)
Membership test within numerical tolerance (ismembertol(a, s, tol)).
Value prod(const Value &x, std::pmr::memory_resource *mr=nullptr)
Product of array elements along first non-singleton dimension (prod(x)).
Value sum(const Value &x, std::pmr::memory_resource *mr=nullptr)
Sum of array elements along first non-singleton dimension (sum(x)).
Value anyOf(const Value &x, int dim=0, std::pmr::memory_resource *mr=nullptr)
True if any element along dimension is nonzero (any(x, dim)).
Value numunique(const Value &x, std::pmr::memory_resource *mr=nullptr)
Number of unique elements in array (numunique(x)).
std::tuple< Value, Value > min(const Value &x, std::pmr::memory_resource *mr=nullptr)
Smallest elements in array.
Value uniquetol(const Value &x, double tol=1e-6, std::pmr::memory_resource *mr=nullptr)
Unique elements within numerical tolerance (uniquetol(x, tol)).
Value minOmitNanBinary(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr)
Element-wise minimum of two arrays omitting NaNs (min(a, b, 'omitnan')).
Value allOf(const Value &x, int dim=0, std::pmr::memory_resource *mr=nullptr)
True if all elements along dimension are nonzero (all(x, dim)).
Value ismember(const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr)
Tests if array elements are members of set (ismember(a, b)).
GroupsummaryResult groupsummary(const Value &A, const Value &G, const std::string &method, std::pmr::memory_resource *mr=nullptr)
Per-group reduction ([B, BG, BC] = groupsummary(A, G, method)).
Value cummax(const Value &x, std::pmr::memory_resource *mr=nullptr)
Cumulative maximum of array elements (cummax(x)).
std::pair< Value, Value > ismemberComplex(const Value &a, const Value &b, bool wantLoc, std::pmr::memory_resource *mr)
Tests membership for complex/general types with location indices ([lia, loc] = ismember(....
AccumReducer
Built-in reducers recognised by accumarray.
Value allunique(const Value &x, std::pmr::memory_resource *mr=nullptr)
True if all elements in array are unique (allunique(x)).
Value uniqueRows(const Value &x, std::pmr::memory_resource *mr=nullptr, bool stable=false)
Unique rows of 2-D matrix (unique(x, 'rows')).
Value histc(const Value &x, const Value &edges, std::pmr::memory_resource *mr=nullptr)
Histogram count of data into bins (histc(x, edges)).
Value accumarray(const Value &subs, const Value &vals, Span< const size_t > outShape, AccumReducer op=AccumReducer::Sum, double fillVal=0.0, std::pmr::memory_resource *mr=nullptr)
Group-by reduction (A = accumarray(subs, vals, sz, fn, fillVal)).
HistNorm
Histogram normalization type.
HistBinMethod
Binning method for histograms.
std::tuple< Value, Value > minOmitNan(const Value &x, int dim, std::pmr::memory_resource *mr=nullptr)
Smallest elements in array along dimension omitting NaNs (min(x, [], dim, 'omitnan')).
std::tuple< Value, Value > maxOmitNan(const Value &x, int dim, std::pmr::memory_resource *mr=nullptr)
Largest elements in array along dimension omitting NaN values (max(x, [], dim, 'omitnan')).
Value histcounts(const Value &x, const Value &edges, std::pmr::memory_resource *mr=nullptr)
Computes histogram bin counts (histcounts(x, edges)).
Value histcountsAutoEdges(const Value &x, const HistBinSpec &spec, std::pmr::memory_resource *mr=nullptr)
Computes histogram with automatic bin edges selection (histcounts(x, spec)).
FindgroupsResult findgroups(const Value &g, std::pmr::memory_resource *mr=nullptr)
Assign 1-based group IDs ([G, ID] = findgroups(g)).
Value mean(const Value &x, std::pmr::memory_resource *mr=nullptr)
Mean (arithmetic average) of array elements (mean(x)).
Value cumsum(const Value &x, std::pmr::memory_resource *mr=nullptr)
Cumulative sum of array elements (cumsum(x)).
@ Prod
@prod (multiplicative identity 1).
@ Sum
@sum (additive identity 0).
Result of findgroups — [G, ID].
Value G
Group index per element (shape of input; NaN = missing).
Value ID
Column of unique non-NaN values (sorted ascending).
Result of groupcounts — [C, GR, P].
Value GR
Group representatives (sorted unique; NaN trailing).
Value P
Percentage 100 * count / total per group.
Value C
Count per group (trailing NaN bucket if g has any NaN).
Result of the array form of groupsummary — [B, BG, BC].
Value BC
Element count per group.
Value B
nGroups x cols(A) per-group, per-column reduction.
Value BG
Group representatives (sorted unique; NaN trailing).
Specification for automatic histogram bin estimation.