mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Vector Utilities

Utilities for working with std::vector.

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. More...
 
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. More...
 
template<typename valueT >
valueT mx::math::vectorSum (const valueT *vec, size_t sz)
 Calculate the sum of a vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorSum (const vectorT &vec)
 Calculate the sum of a vector. More...
 
template<typename valueT >
valueT mx::math::vectorMean (const valueT *vec, size_t sz)
 Calculate the mean of a vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorMean (const vectorT &vec)
 Calculate the mean of a vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorMean (const vectorT &vec, const vectorT &w)
 Calculate the weighted mean of a vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorMedianInPlace (vectorT &vec)
 Calculate median of a vector in-place, altering the vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorMedian (const vectorT &vec, vectorT *work=0)
 Calculate median of a vector, leaving the vector unaltered. More...
 
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. More...
 
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. More...
 
template<typename valueT >
valueT mx::math::vectorVariance (const valueT *vec, size_t sz)
 Calculate the variance of a vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorVariance (const vectorT &vec)
 Calculate the variance of a vector. More...
 
template<typename vectorT >
vectorT::value_type mx::math::vectorSigmaMean (const vectorT &vec, const vectorT *weights, typename vectorT::value_type sigma, int &maxPasses)
 Calculate the sigma-clipped mean of a vector. More...
 
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. More...
 
template<typename vecT , typename constT >
void mx::math::vectorSub (vecT &vec, const constT &c)
 Subtract a constant value from a vector. More...
 
template<typename valueT >
void mx::math::vectorMeanSub (valueT *vec, size_t sz)
 Subtract the mean from a vector. More...
 
template<typename vecT >
void mx::math::vectorMeanSub (vecT &vec)
 Subtract the mean from a vector. More...
 
template<typename vecT >
void mx::math::vectorMedianSub (vecT &vec)
 Subtract the median from a vector. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename realT >
int mx::math::vectorGaussConvolve (std::vector< realT > &dataOut, const std::vector< realT > &dataIn, const std::vector< realT > &scale, const realT fwhm, const int winhw)
 Convolve (smooth) a vector with a Gaussian. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ vectorBinMeans()

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.

Useful mainly to calculate the variance of the mean as a function of sample size. The output is a vector of vectors, where each element is a vector which contains the means in the unique bins of size corresponding to the same index in the in put binSzs vector.

Returns
0 on success.
Parameters
[out]meansthe means in each distinct bin. Not cleared, but Will be resized with new means appended.
[in]binSzsthe bin sizes in which to calculate the means
[in]vthe input vector to bin .

Definition at line 730 of file vectorUtils.hpp.

References mx::math::vectorRebin().

◆ vectorCumHist()

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.

Sorts the vector and sums.

Return values
0on success, -1 otherwise.
Template Parameters
floatTthe floating point type of the vector contens.
Parameters
[out]svecContains the sorted vector.
[out]sumContains the cumulative or running sum of the sorted vector
[in]vecThe vector to sort and sum.

Definition at line 805 of file vectorUtils.hpp.

◆ vectorCumHistReverse()

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.

Reverse-sorts the vector and sums.

Return values
0on success, -1 otherwise.
Template Parameters
floatTthe floating point type of the vector contens.
Parameters
[out]svecContains the reverse-sorted vector.
[out]sumContains the cumulative or running sum of the reverse-sorted vector
[in]vecThe vector to reverse-sort and sum.

Definition at line 834 of file vectorUtils.hpp.

◆ vectorGaussConvolve()

template<typename realT >
int mx::math::vectorGaussConvolve ( std::vector< realT > &  dataOut,
const std::vector< realT > &  dataIn,
const std::vector< realT > &  scale,
const realT  fwhm,
const int  winhw 
)

Convolve (smooth) a vector with a Gaussian.

Returns
0 on success.
-1 on error.
Template Parameters
realTis the real floating point type of the data.
Parameters
[out]dataOutThe smoothed data vector. Resized.
[in]dataInThe data vector to smooth.
[in]scaleThe scale vector used to calculate the kernel.
[in]fwhmThe FWHM of the Gaussian kernel, same units as scale.
[in]winhwThe window half-width in pixels.

Definition at line 758 of file vectorUtils.hpp.

References mx::astro::constants::G(), and mx::astro::constants::sigma().

◆ vectorMean() [1/3]

template<typename valueT >
valueT mx::math::vectorMean ( const valueT *  vec,
size_t  sz 
)

Calculate the mean of a vector.

Returns
the mean of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector
[in]szthe size of the vector

Definition at line 150 of file vectorUtils.hpp.

Referenced by mx::improc::imCenterCircleSym< realT >::center(), mx::improc::eigenCube< dataT >::mean(), and mx::improc::sourceFinder< _realT >::operator()().

◆ vectorMean() [2/3]

template<typename vectorT >
vectorT::value_type mx::math::vectorMean ( const vectorT &  vec)

Calculate the mean of a vector.

Returns
the mean of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector

Definition at line 172 of file vectorUtils.hpp.

◆ vectorMean() [3/3]

template<typename vectorT >
vectorT::value_type mx::math::vectorMean ( const vectorT &  vec,
const vectorT &  w 
)

Calculate the weighted mean of a vector.

Returns
the weighted mean of vec
Template Parameters
vectorTthe std::vector type of vec and w
Parameters
[in]vecthe vector *‍/
[in]wthe weights

Definition at line 191 of file vectorUtils.hpp.

Referenced by mx::math::vectorMeanSub(), mx::math::vectorSigmaMean(), and mx::math::vectorVariance().

◆ vectorMeanSub() [1/2]

template<typename valueT >
void mx::math::vectorMeanSub ( valueT *  vec,
size_t  sz 
)

Subtract the mean from a vector.

Parameters
vec[in.out] the vector, each element will have the mean subtracted from it
[in]szthe vector size

Definition at line 505 of file vectorUtils.hpp.

References mx::math::vectorMean(), and mx::math::vectorSub().

◆ vectorMeanSub() [2/2]

template<typename vecT >
void mx::math::vectorMeanSub ( vecT &  vec)

Subtract the mean from a vector.

Parameters
vec[in.out] the vector, each element will have the mean subtracted from it

Definition at line 515 of file vectorUtils.hpp.

◆ vectorMedian()

template<typename vectorT >
vectorT::value_type mx::math::vectorMedian ( const vectorT &  vec,
vectorT *  work = 0 
)

Calculate median of a vector, leaving the vector unaltered.

Returns the center element if vec has an odd number of elements. Returns the mean of the center 2 elements if vec has an even number of elements.

Returns
the median of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector for which the median is desired
[in]work[optional] an optional vector to use as workspace, use to avoid re-allocation

Definition at line 247 of file vectorUtils.hpp.

References mx::math::vectorMedianInPlace().

Referenced by mx::improc::aperturePhotometer< realT >::cumPhotWork(), mx::improc::sourceFinder< _realT >::operator()(), mx::math::vectorMedianSub(), and mx::math::vectorSigmaMean().

◆ vectorMedianInPlace()

template<typename vectorT >
vectorT::value_type mx::math::vectorMedianInPlace ( vectorT &  vec)

Calculate median of a vector in-place, altering the vector.

Returns the center element if vec has an odd number of elements. Returns the mean of the center 2 elements if vec has an even number of elements.

Returns
the median of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector, is altered by std::nth_element

Definition at line 218 of file vectorUtils.hpp.

Referenced by mx::improc::imageMedian(), mx::improc::medianSmooth(), mx::math::vectorMedian(), and mx::math::vectorSmoothMedian().

◆ vectorMedianSub()

template<typename vecT >
void mx::math::vectorMedianSub ( vecT &  vec)

Subtract the median from a vector.

Parameters
vec[in.out] the vector, each element will have the median subtracted from it

Definition at line 522 of file vectorUtils.hpp.

References mx::math::vectorMedian(), and mx::math::vectorSub().

◆ vectorRebin()

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.

Returns
0 on success
-1 on error
Template Parameters
vectorTis any vector-like type with resize(), size(), and the operator()[].
Parameters
[out]binvthe re-binned vector. will be resized.
[in]vthe vector to bin.
[in]nthe size of the bins, in points
[in]binMean[optional] flag controlling whether sums (false) or means (true) are calculated.

Definition at line 691 of file vectorUtils.hpp.

Referenced by mx::math::vectorBinMeans().

◆ vectorScale()

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.

Fills in the vector with a 0....N-1 scale. The spacing of the points can be changed with the scale parameter, and the starting point can be changed with the offset.

Example:

std::vector vec;
mx::vectorScale(vec, 1000, 0.001, 0.001); // Produces a vector with values 0.001,0.002,.... 1.000
void 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.
Definition: vectorUtils.hpp:62
Template Parameters
vectorTis a std::vector type.
Parameters
[out]vecthe vector to fill in, can be pre-allocated or not
[in]N[optional] if specified > 0, then vec is resize()-ed. Default is 0, and vec is not resize()-ed.
[in]scale[optional] if specified !=0, then the points are spaced by this value. Default spacing is 1.
[in]offset[optional] if specified !=0, then the starting point of the scale is this value.

Definition at line 62 of file vectorUtils.hpp.

Referenced by mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::makePSDGrid().

◆ vectorSigmaMean() [1/4]

template<typename vectorT >
vectorT::value_type mx::math::vectorSigmaMean ( const vectorT &  vec,
const vectorT &  weights,
typename vectorT::value_type  sigma 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[in]vecthe vector (unaltered)
[in]weights[optional] the weights (unaltered)
[in]sigmathe standard deviation threshold to apply.

Definition at line 473 of file vectorUtils.hpp.

References mx::astro::constants::sigma().

Referenced by mx::math::vectorSigmaMean().

◆ vectorSigmaMean() [2/4]

template<typename vectorT >
vectorT::value_type mx::math::vectorSigmaMean ( const vectorT &  vec,
const vectorT &  weights,
typename vectorT::value_type  sigma,
int &  maxPasses 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[in]vecthe vector (unaltered)
[in]weights[optional] the weights (unaltered)
[in]sigmathe standard deviation threshold to apply.
maxPasses[in.out] [optional] the maximum number of sigma-clipping passes. Set to actual number of passes on return.

Definition at line 459 of file vectorUtils.hpp.

References mx::astro::constants::sigma(), and mx::math::vectorSigmaMean().

◆ vectorSigmaMean() [3/4]

template<typename vectorT >
vectorT::value_type mx::math::vectorSigmaMean ( const vectorT &  vec,
const vectorT *  weights,
typename vectorT::value_type  sigma,
int &  maxPasses 
)

Calculate the sigma-clipped mean of a vector.

Performas sigma-clipping relative to the median, removing any values with deviation from the median > sigma. Continues until either no values are removed, or maxPasses iterations. If maxPasses == 0, then it is ignored.

Returns
the sigma clipped mean of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector (unaltered)
[in]weights[optional] the weights (unaltered)
[in]sigmathe standard deviation threshold to apply.
maxPasses[in.out] [optional] the maximum number of sigma-clipping passes. Set to actual number of passes on return.

Definition at line 365 of file vectorUtils.hpp.

References mx::astro::constants::sigma(), mx::math::vectorMean(), mx::math::vectorMedian(), and mx::math::vectorVariance().

Referenced by mx::improc::eigenCube< dataT >::sigmaMean().

◆ vectorSigmaMean() [4/4]

template<typename vectorT >
vectorT::value_type mx::math::vectorSigmaMean ( const vectorT &  vec,
typename vectorT::value_type  sigma 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[in]vecthe vector (unaltered)
[in]sigmathe standard deviation threshold to apply.

Definition at line 446 of file vectorUtils.hpp.

References mx::astro::constants::sigma(), and mx::math::vectorSigmaMean().

◆ vectorSmoothMax()

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.

Parameters
[out]smVecthe smoothed version of the vector
[in]vecthe input vector, unaltered.
[in]winthe full-width of the smoothing window

Definition at line 659 of file vectorUtils.hpp.

◆ vectorSmoothMean() [1/3]

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.

Parameters
[out]smVecthe smoothed version of the vector. At least as large as vec.
[in]vecthe input vector, unaltered.
[in]vecSizethe size of vec
[in]winthe full-width of the smoothing window. Should be even. 0 results in a slow memcpy.

Definition at line 530 of file vectorUtils.hpp.

◆ vectorSmoothMean() [2/3]

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.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[out]smVecthe smoothed version of the vector. Will be resize()-ed.
[in]vecthe input vector, unaltered.
[in]winthe full-width of the smoothing window. Should be even. 0 results in a slow memcpy.

Definition at line 562 of file vectorUtils.hpp.

References mx::math::vectorSmoothMean().

◆ vectorSmoothMean() [3/3]

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.

You supply a window width for each point. This is useful for, say, logarithmically growing bin sizes in a PSD.

Returns
0 on success
-1 but who are we kidding it we don't check for errors
Parameters
[out]smVecthe smoothed version of the vector
[in]vecthe input vector, unaltered.
[in]winsthe full-widths of the smoothing windows, same size as vec.
[in]normif true the output will normalized to have the same integral as the input.

Definition at line 580 of file vectorUtils.hpp.

Referenced by mx::math::vectorSmoothMean().

◆ vectorSmoothMedian()

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.

Parameters
[out]smVecthe smoothed version of the vector
[in]vecthe input vector, unaltered.
[in]winthe full-width of the smoothing window

Definition at line 629 of file vectorUtils.hpp.

References mx::math::vectorMedianInPlace().

◆ vectorSortOrder()

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.

Example:

std::vector<double> x;
// -> fill in x with values
std::vector<size_t> idx;
idx = mx::sortOrder(x);
//Print x to stdout in sorted order
for(int i=0; i< x.size(); ++i) std::cout << x[idx[i]] << "\n";
Template Parameters
memberTis the member type of the vector. Must have < comparison defined.
Returns
the indices of the vector in sorted order.
Parameters
[in]valuesthe vector to sort

Definition at line 92 of file vectorUtils.hpp.

Referenced by mx::astro::rewritePhoenixSpectrum().

◆ vectorSub() [1/2]

template<typename valueT , typename constT >
void mx::math::vectorSub ( valueT *  vec,
size_t  sz,
const constT &  c 
)

Subtract a constant value from a vector.

Parameters
vec[in.out] the vector, each element will have the constant subtracted from it
[in]szthe size of the vector
[in]cthe constant to subtract from each element

Definition at line 486 of file vectorUtils.hpp.

References mx::astro::constants::c().

◆ vectorSub() [2/2]

template<typename vecT , typename constT >
void mx::math::vectorSub ( vecT &  vec,
const constT &  c 
)

Subtract a constant value from a vector.

Parameters
vec[in.out] the vector, each element will have the constant subtracted from it
[in]cthe constant to subtract from each element

Definition at line 496 of file vectorUtils.hpp.

References mx::astro::constants::c().

Referenced by mx::math::vectorMeanSub(), and mx::math::vectorMedianSub().

◆ vectorSum() [1/2]

template<typename valueT >
valueT mx::math::vectorSum ( const valueT *  vec,
size_t  sz 
)

Calculate the sum of a vector.

Returns
the sum of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector
[in]szthe size of the vector

Definition at line 112 of file vectorUtils.hpp.

◆ vectorSum() [2/2]

template<typename vectorT >
vectorT::value_type mx::math::vectorSum ( const vectorT &  vec)

Calculate the sum of a vector.

Returns
the sum of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector

Definition at line 132 of file vectorUtils.hpp.

◆ vectorVariance() [1/4]

template<typename valueT >
valueT mx::math::vectorVariance ( const valueT *  vec,
size_t  sz 
)

Calculate the variance of a vector.

Returns
the variance of vec
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector
[in]szthe size of the vector

Definition at line 327 of file vectorUtils.hpp.

References mx::math::vectorMean(), and mx::math::vectorVariance().

◆ vectorVariance() [2/4]

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.

Returns
the variance of vec w.r.t. mean
Template Parameters
valueTthe data type
Parameters
[in]vecthe vector
[in]szthe size of the vector
[in]meanthe mean value with which to calculate the variance

Definition at line 282 of file vectorUtils.hpp.

Referenced by mx::improc::imCenterCircleSym< realT >::center(), mx::improc::sourceFinder< _realT >::operator()(), mx::sigproc::averagePeriodogram< realT >::operator()(), SCENARIO(), and mx::improc::stddevImage().

◆ vectorVariance() [3/4]

template<typename vectorT >
vectorT::value_type mx::math::vectorVariance ( const vectorT &  vec)

Calculate the variance of a vector.

Returns
the variance of vec
Template Parameters
vectorTthe std::vector type of vec

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[in]vecthe vector

Definition at line 346 of file vectorUtils.hpp.

References mx::math::vectorMean().

Referenced by mx::math::vectorSigmaMean(), and mx::math::vectorVariance().

◆ vectorVariance() [4/4]

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.

Returns
the variance of vec w.r.t. mean
Template Parameters
vectorTthe std::vector type of vec
Parameters
[in]vecthe vector
[in]meanthe mean value with which to calculate the variance

Definition at line 305 of file vectorUtils.hpp.