示例#1
0
void GSL_vector::range_check(std::size_t n) const
{
   if (!vec)
      throw OutOfBoundsError(
         "GSL_vector::operator[]: index " + std::to_string(n)
         + " out of range for vector of size 0.");

   if (n >= size())
      throw OutOfBoundsError(
         "GSL_vector::operator[]: index " + std::to_string(n)
         + " out of range for vector of size " + std::to_string(size()) + ".");
}
示例#2
0
double
AxisCollection::GetBinCentre(size_t bin_, size_t dim_) const{
    if(dim_ >= fNDimensions)
        throw DimensionError("Axis Collection::Bin edge on non existent dimension!");

    if(bin_ >= fNBins)
        throw OutOfBoundsError("AxisCollection::Called bin edge on out of bounds bin!");
    
    return fAxes.at(dim_).GetBinCentre(UnflattenIndex(bin_, dim_));
}
示例#3
0
size_t 
AxisCollection::UnflattenIndex(size_t index_, size_t dim_) const{
    if(fNDimensions == 1)
        return index_;

    if (index_ >= fNBins)
        throw OutOfBoundsError("index out of bounds");
    size_t x =1;
    for (size_t i = dim_+1 ; i < fNDimensions; i++ )
        x *= fAxisNbins[i];
    return (index_/x) % fAxisNbins[dim_];
}
示例#4
0
void
AxisCollection::GetBinCentres(size_t bin_, std::vector<double>& output_) const{

    if(bin_ >= fNBins)
        throw OutOfBoundsError("Bin Edge call on out of bounds bin!");

    if(output_.size() != fNDimensions)
        throw DimensionError("wrong size vec passed to get bin edges");

    for(size_t i = 0; i <fNDimensions; i++){
        output_[i] = fAxes[i].GetBinCentre(UnflattenIndex(bin_, i));
    }
}