<commit_before>/* Copyright (C) 2012,2013 IBM Corp.
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
#include <iostream>
#include <vector>
#include <iomanip>
#include <cassert>

using namespace std;


/**
 * @class Cube
 * @brief Indexing into a hypercube
 **/
class Cube {
class Cube {
private:
   vector<int> dims;  // dims[i] is the size along the i'th diemnsion
   vector<int> prods; // prods[i] = \prod_{j=i}^{n-1} dims[i]
   vector<int> data;
   int size;

   Cube();

public:
   Cube(const vector<int>& idims) {
      dims = idims;
      int n = dims.size();
      assert(n > 0);

      
      prods.resize(n+1);
      prods[n] = 1;
      for (int i = n-1; i >= 0; i--) {
         assert(dims[i] > 0);
         prods[i] = dims[i]*prods[i+1];
      }


      size = prods[0];
      data.resize(size);
      for (int i = 0; i < size; i++) data[i] = 0; 
   }

   bool operator==(const Cube& that) const {
      return dims == that.dims && data == that.data;
   }

   bool operator!=(const Cube& that) const {
      return !(*this == that);
   }

   const vector<int>& getDims() const { return dims; }

   int getSize() const { return size; }

   int getNumDims() const { return dims.size(); }

   int getDim(int d) const { return dims.at(d); }

   int getCoord(int i, int d) const {
      assert(i >= 0 && i < size);
   
      return (i % prods.at(d)) / prods.at(d+1); 
   }

   int addCoord(int i, int d, int offset) const {
      assert(i >= 0 && i < size);
      
      offset = offset % dims.at(d);
      if (offset < 0) offset += dims.at(d);

      int i_d = getCoord(i, d);
      int i_d1 = (i_d + offset) % dims.at(d);

      int i1 = i + (i_d1 - i_d) * prods.at(d+1);

      return i1;

   }

   int& at(int i) { return data.at(i); }

   const int& at(int i) const { return data.at(i); }

};



Cube simpleRotate(const Cube& c, int offset) {

   assert(offset >= 0);
   Cube c1(c.getDims());

   int size = c.getSize();

   for (int i = 0; i < size; i++) {
      c1.at((i+offset)%size) = c.at(i);
   }

   return c1;

}

Cube rotate1D(const Cube& c, int d, int offset) {

   assert(offset >= 0);

   Cube c1(c.getDims());

   int size = c.getSize();

   for (int i = 0; i < size; i++) {
      c1.at(c.addCoord(i, d, offset)) = c.at(i);
   }

   return c1;

}

Cube operator+(const Cube& c1, const Cube& c2) {
   const vector<int>& dims1 = c1.getDims();
   const vector<int>& dims2 = c2.getDims();
   assert(dims1 == dims2);

   Cube c(dims1);
   int size = c.getSize();

   for (int i = 0; i < size; i++) 
      c.at(i) = c1.at(i) + c2.at(i); 
   
   return c;
}
<commit_msg>deleted empty lines to much overall coding style<commit_after>/* Copyright (C) 2012,2013 IBM Corp.
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
#include <iostream>
#include <vector>
#include <iomanip>
#include <cassert>

using namespace std;


/**
 * @class Cube
 * @brief Indexing into a hypercube
 **/
class Cube {
class Cube {
private:
   vector<int> dims;  // dims[i] is the size along the i'th diemnsion
   vector<int> prods; // prods[i] = \prod_{j=i}^{n-1} dims[i]
   vector<int> data;
   int size;

   Cube();

public:
   Cube(const vector<int>& idims) {
      dims = idims;
      int n = dims.size();
      assert(n > 0);

      
      prods.resize(n+1);
      prods[n] = 1;
      for (int i = n-1; i >= 0; i--) {
         assert(dims[i] > 0);
         prods[i] = dims[i]*prods[i+1];
      }


      size = prods[0];
      data.resize(size);
      for (int i = 0; i < size; i++) data[i] = 0; 
   }

   bool operator==(const Cube& that) const {
      return dims == that.dims && data == that.data;
   }

   bool operator!=(const Cube& that) const {
      return !(*this == that);
   }

   const vector<int>& getDims() const { return dims; }

   int getSize() const { return size; }

   int getNumDims() const { return dims.size(); }

   int getDim(int d) const { return dims.at(d); }

   int getCoord(int i, int d) const {
      assert(i >= 0 && i < size);
   
      return (i % prods.at(d)) / prods.at(d+1); 
   }

   int addCoord(int i, int d, int offset) const {
      assert(i >= 0 && i < size);
      
      offset = offset % dims.at(d);
      if (offset < 0) offset += dims.at(d);

      int i_d = getCoord(i, d);
      int i_d1 = (i_d + offset) % dims.at(d);

      int i1 = i + (i_d1 - i_d) * prods.at(d+1);

      return i1;

   }

   int& at(int i) { return data.at(i); }

   const int& at(int i) const { return data.at(i); }

};



Cube simpleRotate(const Cube& c, int offset) {

   assert(offset >= 0);
   Cube c1(c.getDims());

   int size = c.getSize();

   for (int i = 0; i < size; i++) {
      c1.at((i+offset)%size) = c.at(i);
   }

   return c1;
}

Cube rotate1D(const Cube& c, int d, int offset) {

   assert(offset >= 0);

   Cube c1(c.getDims());

   int size = c.getSize();

   for (int i = 0; i < size; i++) {
      c1.at(c.addCoord(i, d, offset)) = c.at(i);
   }

   return c1;
}

Cube operator+(const Cube& c1, const Cube& c2) {
   const vector<int>& dims1 = c1.getDims();
   const vector<int>& dims2 = c2.getDims();
   assert(dims1 == dims2);

   Cube c(dims1);
   int size = c.getSize();

   for (int i = 0; i < size; i++) 
      c.at(i) = c1.at(i) + c2.at(i); 
   
   return c;
}

{'fraction_non_alphanumeric': 0.1492582963755926, 'fraction_numerical': 0.02018657287046949, 'mean_word_length': 2.542795232936078, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7415817', 'n_tokens_mistral': 2524, 'n_tokens_neox': 2390, 'n_words': 783}