#ifndef M1UNE_SHIFTED_ARRAY_HPP
#define M1UNE_SHIFTED_ARRAY_HPP 1
#include<stdexcept>
#include<vector>namespacem1une{// bool is not allowed// if you want to use bool, use char insteadtemplate<typenameT>structshifted_array{private:longlong_offset;longlong_step;int_size;std::vector<T>_data;public:// make an array with indices from L to R (including both L and R)// [L, R] (closed interval)shifted_array(longlongL,longlongR,Tinit_value=T(),longlongstep=1):_offset(L),_step(step),_size((R-L)/step+1),_data(_size,init_value){if(step<=0){throwstd::invalid_argument("Step must be positive");}if(L>R){throwstd::invalid_argument("Left bound must be less than or equal to right bound");}}T&operator[](longlongi){intindex=(i-_offset)/_step;if(index<0||index>=_size){throwstd::out_of_range("Index out of range");}return_data[index];};constT&operator[](longlongi)const{intindex=(i-_offset)/_step;if(index<0||index>=_size){throwstd::out_of_range("Index out of range");}return_data[index];};longlongindex(longlongi)const{intindex=(i-_offset)/_step;if(index<0||index>=_size){throwstd::out_of_range("Index out of range");}returnindex;}};}// namespace m1une#endif // M1UNE_SHIFTED_ARRAY_HPP
#line 1 "utilities/shifted_array.hpp"
#include<stdexcept>
#include<vector>namespacem1une{// bool is not allowed// if you want to use bool, use char insteadtemplate<typenameT>structshifted_array{private:longlong_offset;longlong_step;int_size;std::vector<T>_data;public:// make an array with indices from L to R (including both L and R)// [L, R] (closed interval)shifted_array(longlongL,longlongR,Tinit_value=T(),longlongstep=1):_offset(L),_step(step),_size((R-L)/step+1),_data(_size,init_value){if(step<=0){throwstd::invalid_argument("Step must be positive");}if(L>R){throwstd::invalid_argument("Left bound must be less than or equal to right bound");}}T&operator[](longlongi){intindex=(i-_offset)/_step;if(index<0||index>=_size){throwstd::out_of_range("Index out of range");}return_data[index];};constT&operator[](longlongi)const{intindex=(i-_offset)/_step;if(index<0||index>=_size){throwstd::out_of_range("Index out of range");}return_data[index];};longlongindex(longlongi)const{intindex=(i-_offset)/_step;if(index<0||index>=_size){throwstd::out_of_range("Index out of range");}returnindex;}};}// namespace m1une