7 #define LAZY_LIST_HPP 1 24 virtual size_t size(
void)
const = 0;
30 virtual T
operator[](
const size_t i)
const = 0;
36 T
at(
const size_t i)
const 51 vector<T> res(ll.
size());
52 for(
size_t i=0, endp=res.size();i<endp;++i)
69 Multiplier(
const vector<T>& v_i,
73 size_t size(
void)
const 96 template<
class T> vector<T>
trim_top(
const vector<T>& v,
97 const size_t max_index)
103 Trimmer(
const vector<T>& v_i,
104 const size_t max_index_i):
105 v_(v_i), max_index_(max_index_i) {}
107 size_t getLength(
void)
const 112 T operator()(
size_t i)
const 119 const size_t max_index_;
120 } trimmer(v,max_index);
133 for(
size_t i=0;i<vec.size();++i)
135 return static_cast<int>(res);
144 template<
class T>
void ListExchange(vector<T> &vec,vector<int>
const& indeces,
145 vector<T>
const& data)
147 if(indeces.size()!=data.size())
150 eo.
AddEntry(
"indeces length",static_cast<double>(indeces.size()));
151 eo.
AddEntry(
"data length",static_cast<double>(data.size()));
154 for(
size_t i=0;i<indeces.size();++i)
155 vec[static_cast<size_t>(indeces[i])]=data[i];
165 for(
size_t i=1;i<i2m.
size();++i)
177 for(
size_t i=1;i<i2m.getLength();++i)
178 res =
max(res,i2m(i));
189 for(
size_t i=1;i<i2m.
size();++i)
202 explicit Echo(
const vector<T>& v):
232 i2m_(i2m), low_(low), high_(high)
253 #endif // LAZY_LIST_HPP Echo(const vector< T > &v)
Class constructor.
size_t size(void) const
Returns the length of the list.
vector< T > trim_top(const vector< T > &v, const size_t max_index)
Trims a list and retains only a specific number of the first terms.
Converts a vector to a lazy list.
T operator[](size_t i) const
Returns a single member of the list.
T lazy_min(const LazyList< T > &i2m)
Finds the minimum of a lazy list.
Container for error reports.
ContiguousChunk(const LazyList< T > &i2m, size_t low, size_t high)
Class constructor.
vector< T > serial_generate(const LazyList< T > &ll)
Creates a vector from an LazyList.
void ListExchange(vector< T > &vec, vector< int > const &indeces, vector< T > const &data)
Exchanges memebers in vec with indeces given by indeces and data given by data.
double max(vector< double > const &v)
returns the maximal term in a vector
T at(const size_t i) const
bound checked access function
Creates a contiguous chunk of a lazy list.
Ordered list whose terms are evaluated lazily.
virtual T operator[](const size_t i) const =0
Returns a single member of the list.
size_t size(void) const
Returns the length of the list.
int ElementNumber(vector< vector< T > > const &vec)
Calculates the total number of elements in the 2d vector.
double min(vector< double > const &v)
Returns the minimal term in a vector.
T operator[](size_t i) const
Returns a single member of the list.
T lazy_sum(const LazyList< T > &i2m)
Sums terms of a lazy list.
vector< T > termwise_product(const vector< T > &v, const T &s)
Multiplies all terms of std::vector with a scalar.
void AddEntry(std::string const &field, double value)
Adds an entry to the list.
T lazy_max(const LazyList< T > &i2m)
Finds the maximum of a lazy list.
A class for storing error and debug information.
virtual size_t size(void) const =0
Returns the length of the list.