This file contains hidden or 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> | |
class Kernel { | |
int cnt; | |
public: | |
Kernel() { | |
std::cout << "Empty constructor\n"; | |
} | |
Kernel(const int i) : cnt(i) { | |
std::cout << "Initialize constructor\n"; |
This file contains hidden or 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 <iomanip> | |
#include <cstdint> | |
#include <map> | |
#include <unordered_map> | |
#include <assert.h> | |
const int lens[] = {1, 256, 65536, 16777216}; | |
__inline__ uint64_t rdtsc() { |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import re | |
import sys | |
import json | |
import argparse | |
def ver_cmp(ver_list): | |
latest = 0 | |
for idx in range(1, len(ver_list)): |
This file contains hidden or 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 <mpi.h> | |
#define MPI_CHECK(expr, err_str) \ | |
{ int err_no = expr; \ | |
if (err_no) { \ | |
std::cout << "MPI error " << err_no << ": " << err_str << std::endl; \ | |
return err_no; \ | |
} \ | |
} |
This file contains hidden or 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
auto eq = [vid](int dst) -> bool { return dst == vid; }; |
This file contains hidden or 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 <stack> | |
#include <bits/stdc++.h> | |
using namespace std; | |
#define MAX 101 | |
struct Graph { | |
vector<int> * v; | |
vector<int> * vi; |
This file contains hidden or 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
int * topoSort(vector<int> graph[], int N) | |
{ | |
int * p = new int[N]; // caller should delete after use | |
int idx = N - 1; // fill the array from back | |
bool * visited = new bool[N]; | |
// initialize all vertices as unvisited | |
for (int i = 0; i < N; ++i) { | |
visited[i] = false; | |
} | |
// DFS starts from all vertices |
This file contains hidden or 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> | |
int main() { | |
int * num = new int; // pointer = new type | |
std::cout << "Input number of numbers: "; | |
std::cin >> *num; // get a number at runtime | |
if (0 >= *num) { | |
return - 1; | |
} | |
//float * accs = new float[*num]; // pointer = new type [number_of_elements] |
This file contains hidden or 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
/* BFS (label propogation) */ | |
int findCircleNum(vector<vector<int>>& M) { | |
int num = M.size(); | |
vector<int> root; | |
int ans = 0; | |
// initial labels to vertices' ids | |
for (int i = 0; i < num; ++i) { | |
root.push_back(i); | |
} | |
// let each vetex propogate label in a BFS way |
This file contains hidden or 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
uint64_t Cantor(uint64_t x, uint64_t y) { | |
uint64_t res; | |
res = (x + y) * (x + y + 1) / 2 + x; | |
return res; | |
} |
NewerOlder