mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
vectorUtils.hpp File Reference

Header for the std::vector utilities. More...

Header for the std::vector utilities.

Definition in file vectorUtils.hpp.

#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include "func/gaussian.hpp"

Go to the source code of this file.

Namespaces

namespace  mx
 The mxlib c++ namespace.

Functions

template<typename vectorT>
void mx::math::vectorScale (vectorT &vec, size_t N=0, typename vectorT::value_type scale=0, typename vectorT::value_type offset=0)
 Fill in a vector with a regularly spaced scale.
template<typename memberT>
std::vector< size_t > mx::math::vectorSortOrder (std::vector< memberT > const &values)
 Return the indices of the vector in sorted order, without altering the vector itself.
template<typename valueT>
valueT mx::math::vectorSum (const valueT *vec, size_t sz)
 Calculate the sum of a vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorSum (const vectorT &vec)
 Calculate the sum of a vector.
template<typename valueT>
valueT mx::math::vectorMean (const valueT *vec, size_t sz)
 Calculate the mean of a vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorMean (const vectorT &vec)
 Calculate the mean of a vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorMean (const vectorT &vec, const vectorT &w)
 Calculate the weighted mean of a vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorMedianInPlace (vectorT &vec)
 Calculate median of a vector in-place, altering the vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorMedian (const vectorT &vec, vectorT *work=0)
 Calculate median of a vector, leaving the vector unaltered.
template<typename valueT>
valueT mx::math::vectorVariance (const valueT *vec, size_t sz, valueT mean)
 Calculate the variance of a vector relative to a supplied mean value.
template<typename vectorT>
vectorT::value_type mx::math::vectorVariance (const vectorT &vec, const typename vectorT::value_type &mean)
 Calculate the variance of a vector relative to a supplied mean value.
template<typename valueT>
valueT mx::math::vectorVariance (const valueT *vec, size_t sz)
 Calculate the variance of a vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorVariance (const vectorT &vec)
 Calculate the variance of a vector.
template<typename vectorT, typename sigmaT>
vectorT::value_type mx::math::vectorSigmaMean (const vectorT &vec, const vectorT *weights, const sigmaT &sigma, int &maxPasses)
 Calculate the sigma-clipped mean of a vector.
template<typename vectorT>
vectorT::value_type mx::math::vectorSigmaMean (const vectorT &vec, typename vectorT::value_type sigma)
template<typename vectorT>
vectorT::value_type mx::math::vectorSigmaMean (const vectorT &vec, const vectorT &weights, typename vectorT::value_type sigma, int &maxPasses)
template<typename vectorT>
vectorT::value_type mx::math::vectorSigmaMean (const vectorT &vec, const vectorT &weights, typename vectorT::value_type sigma)
template<typename valueT, typename constT>
void mx::math::vectorSub (valueT *vec, size_t sz, const constT &c)
 Subtract a constant value from a vector.
template<typename vecT, typename constT>
void mx::math::vectorSub (vecT &vec, const constT &c)
 Subtract a constant value from a vector.
template<typename valueT>
void mx::math::vectorMeanSub (valueT *vec, size_t sz)
 Subtract the mean from a vector.
template<typename vecT>
void mx::math::vectorMeanSub (vecT &vec)
 Subtract the mean from a vector.
template<typename vecT>
void mx::math::vectorMedianSub (vecT &vec)
 Subtract the median from a vector.
template<typename realT>
int mx::math::vectorSmoothMean (realT *smVec, realT *vec, size_t vecSize, int win)
 Smooth a vector using the mean in a window specified by its full-width.
template<typename realT>
int mx::math::vectorSmoothMean (std::vector< realT > &smVec, std::vector< realT > &vec, int win)
 Smooth a vector using the mean in a window specified by its full-width.
template<typename realT>
int mx::math::vectorSmoothMean (std::vector< realT > &smVec, std::vector< realT > &vec, std::vector< int > &wins, bool norm=false)
 Smooth a vector using the mean in windows specified by their full-widths.
template<typename realT>
int mx::math::vectorSmoothMedian (std::vector< realT > &smVec, std::vector< realT > &vec, int win)
 Smooth a vector using the median in a window specified by its full width.
template<typename realT>
int mx::math::vectorSmoothMax (std::vector< realT > &smVec, std::vector< realT > &vec, int win)
 Smooth a vector using the max in a window specified by its full-width.
template<typename vectorT>
int mx::math::vectorRebin (vectorT &binv, const vectorT &v, unsigned n, bool binMean=false)
 Re-bin a vector by summing (or averaging) in bins of size n points.
template<typename vectorT, typename binVectorT>
int mx::math::vectorBinMeans (std::vector< vectorT > &means, binVectorT &binSzs, const vectorT &v)
 Calculate and accumulate the means of a timeseries in bins of various sizes.
template<typename realT, typename fwhmT, typename winhwT>
int mx::math::vectorGaussConvolve (std::vector< realT > &dataOut, const std::vector< realT > &dataIn, const std::vector< realT > &scale, const fwhmT fwhm, const winhwT winhw)
 Convolve (smooth) a vector with a Gaussian.
template<typename floatT>
int mx::math::vectorCumHist (std::vector< floatT > &svec, std::vector< floatT > &sum, std::vector< floatT > &vec)
 Calculate a cumulative histogram of a vector.
template<typename floatT>
int mx::math::vectorCumHistReverse (std::vector< floatT > &svec, std::vector< floatT > &sum, std::vector< floatT > &vec)
 Calculate a reverse cumulative histogram of a vector.