Skip to content

Instantly share code, notes, and snippets.

View YukiSakamoto's full-sized avatar

Yuki Sakamoto YukiSakamoto

  • Osaka, Japan
  • 13:23 (UTC +09:00)
View GitHub Profile
@YukiSakamoto
YukiSakamoto / mod_mdoc.sh
Created December 7, 2023 15:34
mdoc modify
mkdir -p mod_mdoc
cd mod_mdoc
for i in {01..20}
do
filename=`printf "tomo_%02d.mrc.mdoc" ${i}`
outfilename=`printf "tomo_%02d.mod.mrc.mdoc" ${i}`
grep -v DateTime ../${filename} > ${outfilename}
# echo ${filename}
done
@YukiSakamoto
YukiSakamoto / build_qe.md
Last active November 18, 2022 08:20
How to build QE

Quantum ESPRESSOは、オープンソースの第一原理計算ソフトウェアです。 QEのビルド・テスト・ポテンシャルの作成あたりまでやります。

前提

ここでは、Intel compiler及びIntelMKLを使った並列計算用のビルド方法を書きます。 OpenMPは使っていません。

pw.x のビルド

@YukiSakamoto
YukiSakamoto / order.cpp
Created March 14, 2022 07:39
The order of the arguments evaluation in C++
#include <cstdio>
void func(int a, int b, int c) {
std::printf("%d %d %d\n", a, b, c);
}
int main(void)
{
int i = 0;
func(i++, i++, i++);
@YukiSakamoto
YukiSakamoto / .gitignore
Last active February 13, 2021 09:32
sincos_add
*.eps
*.pdf
*.png
*.dat
@YukiSakamoto
YukiSakamoto / makefile
Last active November 23, 2020 08:02
Practice of Matrix product implementation
OPT_FLAG=-O3
all: matrix.x
matrix.x: matrix.cpp
g++ -std=c++11 $(OPT_FLAG) matrix.cpp -o matrix.x
.PHONY: run
run: matrix.x
./matrix.x
@YukiSakamoto
YukiSakamoto / binary_type.cpp
Last active February 19, 2020 12:20
Get binary type on Mac.
#include <mach-o/loader.h>
#include <cstdio>
void print_filetype(const uint32_t filetype)
{
const char *msg;
switch(filetype) {
case MH_OBJECT:
msg = "MH_OBJECT";
break;
@YukiSakamoto
YukiSakamoto / cputype.cpp
Created February 19, 2020 11:59
Get CPU type of Mac
#include <mach-o/arch.h>
#include <iostream>
int main(void)
{
const NXArchInfo *pNXArchInfo = NXGetLocalArchInfo();
std::cout << pNXArchInfo->name << std::endl;
std::cout << pNXArchInfo->description << std::endl;
return 0;
}
dyld: lazy symbol binding failed: Symbol not found: ___emutls_get_address
Referenced from: /Users/swakamoto/opt/gcc-9.2/lib/libmpfr.4.dylib
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: ___emutls_get_address
Referenced from: /Users/swakamoto/opt/gcc-9.2/lib/libmpfr.4.dylib
Expected in: /usr/lib/libSystem.B.dylib
def wl2wn( lambda_in_nm )
return 10000000.0/lambda_in_nm
end
def diff_cross_section(wn)
return 5e-48 * (wn - 2331.0)**4
end
[633, 515, 488, 458, 436].each do |wavelength|
puts "#{wavelength}\t#{1.0e32*diff_cross_section(wl2wn(wavelength))}"
@YukiSakamoto
YukiSakamoto / ch3cho.cpp
Created December 21, 2017 00:19
ch3cho.cpp
#include "common.hpp"
#include "math_helper.hpp"
#include "gto.hpp"
#include "gto_eval.hpp"
#include "orbitals.hpp"
#include "system.hpp"
#include "hf.hpp"
#include <iostream>