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
void demo(){ | |
double r = 0.5 ; | |
double area = M_PI * r * r; | |
double** samples = new double*[sample_count]; | |
for(int i=0;i<sample_count;i++){ | |
samples[i] = new double[2]; | |
samples[i][0] = 1.0*rand()/INT_MAX; | |
samples[i][1] = 1.0*rand()/INT_MAX; | |
} | |
cout << "The exact area is " << area << 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
void verify(double r, double** samples){ | |
DT dt2; | |
VD vd; | |
Cropped_voronoi_from_delaunay vor; | |
Iso_rectangle_2 bbox(0,0,1,1); | |
vor = Cropped_voronoi_from_delaunay(bbox); | |
for(int i=0;i< sample_count;i++){ | |
vd.insert( Site_2( samples[i][0], samples[i][1] ) ); | |
} |
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
void mc(double r, double** samples){ | |
cout << "Monte Carlo simulation" << endl ; | |
using namespace boost::math; | |
double sample_inside=0; | |
cout << "sizeof(sample_count)=" << sizeof(samples) << endl ; | |
for(int i=0;i<sample_count;i++){ | |
double x = samples[i][0]; | |
double y = samples[i][1]; | |
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
Run("C:\WINDOWS\system32\control.exe desk.cpl", "C:\Windows\system32\") | |
WinWait("Screen Resolution") | |
ControlCommand("Screen Resolution", "", "ComboBox3", "SetCurrentSelection", "1") | |
ControlClick("Screen Resolution", "", "Button4") | |
WinWait("Display Settings") | |
ControlClick("Display Settings", "", "Button1") |
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 "utility.h" | |
#include <iostream> | |
#include <ctime> | |
#include <cstdlib> | |
namespace utility { | |
using namespace std; | |
// Generate a random number between 0 and 1 | |
// return a uniform number in [0,1]. |
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 <cstring> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <string> | |
#include "utils.h" | |
using namespace std; | |
namespace utils { |
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
unsigned long long int v; //counts the number of bits set in v | |
unsigned int count=0; // counts is the total bits set in v | |
while(v){ | |
v &= v-1; | |
c++; | |
} |
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<bitset> | |
unsigned long long int v; | |
bitset<64> n(v); | |
int count = n.count(); | |
auto v2 = n.to_ullong(); |
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
size_t count() const | |
{ // count number of set bits | |
static char _Bitsperhex[] = "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4"; | |
size_t _Val = 0; | |
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos) | |
for (_Ty _Wordval = _Array[_Wpos]; _Wordval != 0; _Wordval >>= 4) | |
_Val += _Bitsperhex[_Wordval & 0xF]; | |
return (_Val); | |
} |
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
//list is basically a linked-list | |
int bfs_list(Graph* g){ | |
int sig=0; | |
vector<bool> visited(g->getSize(), false); | |
list<int> q; | |
auto init = rand()%g->getSize(); | |
q.push_back(init); | |
visited[init]=true; | |
while(!q.empty()){ | |
auto u = q.front(); |
OlderNewer