namespace alan { class stuff { public: static std::string spaces(unsigned int); static double random_double_0_to_1(); template static T1 most(T1, T2); template static T1 at_or_other(std::vector* vec, T2 other, unsigned int pos); static void error(std::string error); }; template class range { public: std::vector center; std::vector size; std::vector min; // left std::vector max; // right void complete_center() { unsigned short dims = 0; dims = alan::stuff::most(dims, center.size()); dims = alan::stuff::most(dims, min.size()); dims = alan::stuff::most(dims, max.size()); T min = alan::stuff::at_or_other(&min, 0, n); T max = alan::stuff::at_or_other(&max, 0, n); unsigned short center_calc; for (unsigned int n = 0; n < dims; n++) { center_calc = (min + max) * 0.5; if (n > center.size()) { center.push_back(center_calc); } else { center.at(n) = center_calc; } } } bool intersect(range in) { bool out = false; unsigned short dims = 0; dims = alan::stuff::most(dims, min.size()); dims = alan::stuff::most(dims, max.size()); dims = alan::stuff::most(dims, in.min.size()); dims = alan::stuff::most(dims, in.max.size()); T min; T max; T in_min; T in_max; for (unsigned int n = 0; n < dims; n++) { min = alan::stuff::at_or_other(&min, 0, n); max = alan::stuff::at_or_other(&max, 0, n); in_min = alan::stuff::at_or_other(&in.min, 0, n); in_max = alan::stuff::at_or_other(&in.max, 0, n); if (in_min < max & in_max > min) { out = true; } } return out; } }; template class un_number { T n; bool defined; un_number(); }; } std::string alan::stuff::spaces(unsigned int n) { std::string out; for (; n > 0; n--) { out += " "; } return out; } double alan::stuff::random_double_0_to_1() { return rand() / (double)RAND_MAX; } template T1 alan::stuff::most(T1 one, T2 two) { return one > two ? one: (T1)two; } template T1 alan::stuff::at_or_other(std::vector* vec, T2 other, unsigned int pos) { T1 out; if (pos < vec->size()) { out = vec->at(pos); } else { out = other; } return out; } void alan::stuff::error(std::string error) { std::cout<<"ending program due to error: "<