SHARE
TWEET

Untitled

a guest Feb 27th, 2020 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. std::vector<double>&& Grid2::uploadGrid(const std::string& fileName, const std::vector<double>& mainGrid) const  {
  2.    
  3.     std::vector<double> result;
  4.    
  5.     std::ifstream in(fileName);
  6.     for (int curElem = 0; curElem < mainGrid.size() - 1; curElem++) {
  7.         double start = mainGrid[curElem];
  8.         double end = mainGrid[curElem + 1];
  9.  
  10.         double n, k, h;
  11.         in >> n >> k;
  12.         n = n - 1;
  13.         result.push_back(start);
  14.         if (k != 1.) {
  15.             h = (end - start) * (1 - k) / (1 - pow(k, n));
  16.             for (int i = 1; i < n; i++) {
  17.                 result.push_back(result.back() + h);
  18.                 h *= k;
  19.             }
  20.         }
  21.         else {
  22.             h = (end - start) / (n);
  23.             for (int i = 1; i < n; i++) {
  24.                 result.push_back(result.back() + h);
  25.             }
  26.         }
  27.     }
  28.     result.push_back(mainGrid.back());
  29.     in.close();
  30.     return std::move(result);
  31. }
  32.  
  33. Grid2&& Grid2::procreate(const std::string& xKoeff, const std::string& yKoeff) const {
  34.     Grid2 result;
  35.     result.xGrid = uploadGrid(xKoeff, this->xGrid);
  36.     result.yGrid = uploadGrid(yKoeff, this->yGrid);
  37.     return std::move(result);
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top