物理の駅 Physics station by 現役研究者

テクノロジーは共有されてこそ栄える

2019-09-01から1ヶ月間の記事一覧

C++のstd::asyncでメンバー関数を使ったマルチスレッド処理

#include <future> #include <mutex> #include <iostream> std::mutex mtx3; class MyClass3 { int long_calc1(int j) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); mtx3.lock(); std::cout << "1 a" << std::endl; mtx3.unlock(); std::this_thread::sleep_for(</iostream></mutex></future>…

C++でstd::asyncを使ったマルチスレッド処理

#include <future> #include <thread> #include <vector> #include <iostream> #include <mutex> // 標準出力のmutex std::mutex mtx_; int long_calc(int i) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); mtx_.lock(); std::cout << "a" << i << std::endl; mtx_.unlock(); std:</mutex></iostream></vector></thread></future>…

C++でSleep

#include <thread> std::this_thread::sleep_for(std::chrono::milliseconds(1));</thread>

Python+matplotlibのsubplotsで共通のカラーバーを表示する

stackoverflow のコードがシンプルで良いだろう。 stackoverflow.com import matplotlib.pyplot as plt import numpy as np fig, axes = plt.subplots(nrows=2, ncols=1, sharex=True) for ax in axes: mesh = ax.pcolormesh(np.random.randn(30, 30), vmin=…

7-Zipのオプション日本語訳

アーカイブファイル内のファイルのハッシュ値(CRC32)を取得するには、 l コマンドに加え、 -slt を使うべし。 -sltスイッチで得られる情報 Path Size Packed Size Modified Attributes CRC Encrypted Method Block 7-Zip 18.05 (x64) : Copyright (c) 1999-2…

Windows 10 Pro で 更新プログラムの再起動を抑止するための設定

Windows Updateのタイミングを自分で調整する方法 スケジュールされた自動更新のインストールで、ログオンしているユーザーがいる場合には自動的に再起動しない 自動更新を構成する -> ダウンロードと自動インストールを通知

Python scipyのcurve_fitで正規分布でフィッティングし、各パラメータとカイ二乗を得る汎用的な関数を作ってみる

最新の投稿 phst.hateblo.jp 過去の投稿 phst.hateblo.jp これを少し汎用化して、リスト、ビンの数、最小値、最大値を与えて、正規分布でフィッティングする関数を作ってみた。 オプションで平均値の初期値、標準偏差の初期値、グラフを描画するかどうかを与…