Skip to content

Instantly share code, notes, and snippets.

View yohm's full-sized avatar

Yohsuke Murase yohm

View GitHub Profile
//
// Created by Yohsuke Murase on 2020/02/10.
//
#define _USE_MATH_DEFINES
#include <iostream>
#include <array>
#include <cmath>
#include <cassert>
#include <random>
@yohm
yohm / json.cpp
Created March 7, 2020 06:47
basic usage of nlohmann-json
#include <iostream>
#include <fstream>
#include <nlohmann/json.hpp>
// for convenience
using json = nlohmann::json;
namespace ns {
// a simple struct to model a person
struct person {
@yohm
yohm / hello_salib.ipynb
Created March 15, 2020 15:15
a sample code of SALib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <iostream>
#include <random>
#include <array>
// Cooperate : 1, Defect : 0
// Good : 1, Bad : 0
class AssessmentRule {
public:
AssessmentRule(size_t _id = 0) : id(_id) { assert(id >= 0 && id < 256); };
@yohm
yohm / build_run.sh
Last active October 16, 2021 02:35
a sample program of PDGESV of Scalapack in C++
#!/bin/bash -eux
mpicc pdgesv_example.cpp -lscalapack
mpirun -np 6 ./a.out 9 2 2 3
@yohm
yohm / dfa_minimization.cpp
Last active March 25, 2024 15:21
Minimization of the deterministic finite automaton (DFA) using Moore's algorithm in C++
#include <iostream>
#include <utility>
#include <vector>
#include <set>
#include <cassert>
class DFA {
public:
DFA(int n, int z, std::set<int> f, std::vector<std::vector<int>> _delta) :
N(n), Z(z), F(std::move(f)), delta(std::move(_delta)) {