Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<double>&& Grid2::uploadGrid(const std::string& fileName, const std::vector<double>& mainGrid) const {
- std::vector<double> result;
- std::ifstream in(fileName);
- for (int curElem = 0; curElem < mainGrid.size() - 1; curElem++) {
- double start = mainGrid[curElem];
- double end = mainGrid[curElem + 1];
- double n, k, h;
- in >> n >> k;
- n = n - 1;
- result.push_back(start);
- if (k != 1.) {
- h = (end - start) * (1 - k) / (1 - pow(k, n));
- for (int i = 1; i < n; i++) {
- result.push_back(result.back() + h);
- h *= k;
- }
- }
- else {
- h = (end - start) / (n);
- for (int i = 1; i < n; i++) {
- result.push_back(result.back() + h);
- }
- }
- }
- result.push_back(mainGrid.back());
- in.close();
- return std::move(result);
- }
- Grid2&& Grid2::procreate(const std::string& xKoeff, const std::string& yKoeff) const {
- Grid2 result;
- result.xGrid = uploadGrid(xKoeff, this->xGrid);
- result.yGrid = uploadGrid(yKoeff, this->yGrid);
- return std::move(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement