This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct Node { | |
int value = 0; | |
Node* left = nullptr; | |
Node* right = nullptr; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <random> | |
#include <algorithm> | |
#include <numeric> | |
#include <cstdlib> | |
#include <Eigen/Dense> | |
#define T(X) cerr << #X": " << X << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <map> | |
#include <utility> | |
#include <cassert> | |
class SparseMatrix { | |
public: | |
SparseMatrix(size_t rows, size_t cols) : | |
rows_(rows), cols_(cols) | |
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <Eigen/Dense> | |
using namespace std; | |
using Point2 = Eigen::Vector2d; | |
using Polygon = vector<Point2>; | |
Point2 EdgeNormal(const Point2& p1, const Point2& p2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <map> | |
#include <functional> | |
using namespace std; | |
template<typename T> | |
class Node; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <variant> | |
#include <string> | |
#include <iostream> | |
#include <vector> | |
namespace detail { | |
// create a variant with Ts... and add NewT iff Add == true. | |
template<bool Add, typename NewT, typename... Ts> | |
struct add_if_unique_helper { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <utility> | |
#include <algorithm> | |
#include <iostream> | |
class SparseMatrix { | |
public: | |
void setElement(int i, int j, double value) { | |
auto element_iter = findElement(i,j); | |
bool is_zero = (value==0.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <cassert> | |
#include <cmath> | |
#include <iostream> | |
#define P(X)\ | |
std::cerr << #X": " << X << std::endl; | |
class Matrix { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
using namespace std; | |
int main(int, char**) { | |
long long inside = 0; | |
for(long long ii = 0; ii < 1e9; ++ii) { | |
double x = rand()/double(RAND_MAX); |