Skip to content

Instantly share code, notes, and snippets.

@taroyabuki
taroyabuki / cuda-cos-vs-fcos.cu
Last active February 8, 2016 12:55
(インテルCPUの)三角関数は不要 http://blog.unfindable.net/archives/8991
//On Ubuntu, you need to install CUDA and:
//sudo apt-get install libboost-dev
//On Windows, I don't know the way to build this code.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cuda_runtime.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
@taroyabuki
taroyabuki / cuda-cos.cu
Last active February 8, 2016 12:55
(インテルCPUの)三角関数は不要 http://blog.unfindable.net/archives/8991
//On Ubuntu, you need to install CUDA and:
//sudo apt-get install libboost-dev
//On Windows, I don't know the way to build this code.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cuda_runtime.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
@taroyabuki
taroyabuki / quad.cpp
Last active February 8, 2016 12:55
(インテルCPUの)三角関数は不要 http://blog.unfindable.net/archives/8991
//Pre build: sudo apt-get install libboost-dev
//To build: g++ quad.cpp -lquadmath
#include <cmath>
#include <ctime>
#include <quadmath.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
namespace mp = boost::multiprecision;
@taroyabuki
taroyabuki / fcos.cpp
Last active June 8, 2017 15:00
(インテルCPUの)三角関数は不要 http://blog.unfindable.net/archives/8991
//On Ubuntu, you need:
//sudo apt-get install libboost-dev
#include <iostream>
#include <cmath>
#include <ctime>
#include <boost/multiprecision/cpp_bin_float.hpp>
using namespace std;
using namespace boost::multiprecision;
960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719
factor[n_] := Reverse[Flatten[
Map[Table[#[[1]], {#[[2]]}] &, FactorInteger[n]]]]
On[Assert];
Assert[factor[24] == {3, 2, 2, 2}];
draw[origin_, frame_, delta_, {p_, rest___}, start_] := {
Circle[origin, frame],
With[{r = If[p == 1, 1, frame Sin[Pi/p]/(1 + Sin[Pi/p])]},
Table[
roll = 10;
surface[s_, t_] :=
RotationMatrix[s, {0, 0, 1}].{3 + t Cos[t]/(roll Pi), 0, t Sin[t]/(roll Pi)}
donut[t_] :=
ParametricPlot3D[surface[s, u], {s, 0, 2 Pi}, {u, 0, t},
Axes -> False, Boxed -> False, Mesh -> None, PlotPoints -> 40]
bugs[t_, n_] :=
@taroyabuki
taroyabuki / floyd.cpp
Created August 2, 2014 11:28
Toy problemsは役立たずか(Floydの問題・ネタバレ) http://blog.unfindable.net/archives/6103
//Are Toy Problems Useful?
//in Selected Papers on Computer Science by Knuth (p.172)
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_map> // faster than map
#include <algorithm>
@taroyabuki
taroyabuki / onepage-aj16.tex
Last active August 29, 2015 14:04
Adobe-Japan1-6のすべてのグリフを1ページで http://blog.unfindable.net/archives/7785
\documentclass[a4paper]{jsarticle}
\usepackage[top=5mm,right=0mm,bottom=0mm,left=4mm]{geometry}
\usepackage{otf}
\usepackage{color}
\usepackage{pgffor}
\pagestyle{empty}
\openup -0.2mm
\newlength{\unit}
\setlength\unit{1.4mm}
\newcount \i
Manipulate[MandelbrotSetPlot[
{center[[1]] - 10^scale + I (center[[2]] - 10^scale),
center[[1]] + 10^scale + I (center[[2]] + 10^scale)},
MaxIterations -> iterations],
{{center, {-0.5, 0}}, Locator},
{{scale, 0, "Scale"}, -9, 1},
{{iterations, 20, "MaxIterations"}, 10, 2000, 10}]