core

Core functions defined in header <scicpp/core.hpp>

Quick overview comparing function calls for fixed and variable size arrays.

Mathematical functions

Provides vectorized versions of standard mathematical functions.

A vectorized version applies the function element-wise on the input array(s).

Function naming follows the NumPy definitions, which sometimes differs from the C++ definitions (ex. arcsin vs asin).

Trigonometric functions

sin, cos, tan, arcsin, arccos, arctan, arctan2, hypot, sinc.

Hyperbolic functions

sinh, cosh, tanh, arcsinh, arccosh, arctanh.

Exponents and logarithms

exp, expm1, exp2, log, log2, log10, log1p.

Rounding

around, floor, ceil, trunc, rint.

Complex numbers

real, imag, angle, conj, norm, polar

NB: norm and polar are not provided by NumPy, but are vectorized versions of the std::complex functions.

Rational routines

gcd, lcm.

Miscellaneous

absolute, sqrt, cbrt, pow.

Arithmetic operators

Provides arithmetic operators +, -, *, /, % for std::array and std::vector.

The statement using namespace scicpp::operators must be included in the scope where operators are used.

Ones and zeros

empty
Return an empty std::vector of a given type.
zeros
Return a new array of given shape and type, filled with zeros.
ones
Return a new array of given shape and type, filled with ones.
full
Return a new array of given shape and type, filled with fill_value.

Array manipulations

Operator | is used for array concatenation.

concatenate
Join a sequence of arrays.
flip
Reverse the order of elements in an array.

Ranges

linspace
Return evenly spaced numbers over a specified interval.
logspace
Return numbers spaced evenly on a log scale.
arange
Return evenly spaced values within a given interval.

Create arrays from existing data

fromstring
Load a vector from a string.
TxtLoader
Load data from a character separated values text file.

Save arrays to file

TxtSaver
Save an array to a text file.

Sums, products, differences

sum
Sum of array elements.
nansum
Sum of array elements excluding NaNs.
prod
Product of array elements.
nanprod
Product of array elements excluding NaNs.
cumsum
Cumulative sum of array elements.
nancumsum
Cumulative sum of array elements excluding NaNs.
cumprod
Cumulative products of array elements.
nancumprod
Cumulative products of array elements excluding NaNs.
trapz
Integrate using the trapezoidal rule.
diff
The n-th discrete difference between consecutive elements of an array.
inner or dot
Ordinary inner product of arrays (without complex conjugation).
vdot
Return the dot product of two vectors.

Searching

argmax, nanargmax
Returns the indices of the maximum value of an array.
argmin, nanargmin
Returns the indices of the minimum value of an array.
argwhere
Returns the indices of array elements matching a given condition.
nonzero
Return the indices of the elements that are non-zero.

Comparisons and Logical

Operators for element-wise comparison between an array and a scalar ==, !=, >, >=, <, <=.

For element-wise comparison between arrays, operators are not available because the C++ standard defines them for lexicographical comparison. The comparison functions (same as Numpy) can be used instead: equal, not_equal, less, less_equal, greater and greater_equal.

Operators && and || are defined for element-wise logical operations.

almost_equal
Compare floating points or arrays of floating points.

Random

random::rand
Return uniformly distributed random samples.
random::randn
Return normaly distributed random samples.
random::normal
Draw random samples from a normal (Gaussian) distribution.

Statistics

stats::amax
Return the maximum value of an array.
stats::amin
Return the minimum value of an array.
stats::ptp
Return the peak-to-peak span of an array.
stats::average
Compute the weighted average.
stats::quantile, nanquantile
Compute the q-th quantile.
stats::percentile, nanpercentile
Compute the p-th percentile.
stats::iqr, naniqr
Compute the interquartile range.
stats::median, nanmedian
Compute the median.
stats::mean, nanmean, tmean
Compute the arithmetic mean.
stats::gmean, nangmean
Compute the geometric mean.
stats::var, nanvar, tvar
Compute the variance.
stats::std, nanstd, tstd
Compute the standard deviation.
stats::sem, nansem, tsem
Compute the standard error of measurement.
stats::moment, nanmoment
Calculate the nth moment about the mean for a sample.
stats::kurtosis, nankurtosis
Compute the kurtosis (Fisher or Pearson) of a dataset.
stats::skew, nanskew
Compute the sample skewness of a data set.
stats::covariance, nancovariance
Compute the covariance between two data sets.
stats::cov, nancov
Compute the covariance matrix between two data sets.
stats::histogram_bin_edges
Compute the the edges of the bins for an histogram.
stats::histogram
Compute the histogram of a dataset.

Interpolate

lerp
Linear interpolation between two points.
interpolate::interp1d
Interpolate a 1D array.

Units

units::quantity
An arithmetic-like type representing a quantity.
Quantities
Defined quantities.
Units
Defined units.

Masking

mask
Return a vector with masked values.
mask_array
Mask a vector in-place.

Functional programming

map
Apply a function to each elements of an array.
vectorize
Convert a function to accept array argument(s).
filter
Filter a std::vector according to a predicate.
filter_reduce
Reduce filtered elements of an array.
reduce
Reduce elements of an array.
cumacc
Cumulative accumulation of array elements.

Printing

print
Print an array onto the screen.
array2string
Format a array to a string.