Skip to content

Instantly share code, notes, and snippets.

View hi2p-perim's full-sized avatar
💭
Nothing just works

Hisanari Otsu hi2p-perim

💭
Nothing just works
View GitHub Profile
@hi2p-perim
hi2p-perim / gatest.cpp
Created June 18, 2012 16:46
Solve f(x)=0 by GA
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <ctime>
const int maxGeneration = 1024;
const int populationSize = 1024;
const int gtypeLength = 20;
@hi2p-perim
hi2p-perim / 3dmathbench.cpp
Created July 12, 2013 12:52
Simple benchmark of 3D math libraries
//
// 3D math library benchmark
// Entries
// - glm 0.9.4.4
// -- http://glm.g-truc.net/
// - Eigen 3.1.3
// -- http://eigen.tuxfamily.org
// - DirectXMath
// -- http://msdn.microsoft.com/en-us/library/ee415571(v=vs.85).aspx
// -- http://code.msdn.microsoft.com/windowsdesktop/Direct3D-Tutorial-Win32-829979ef
@hi2p-perim
hi2p-perim / ssecheck.cpp
Last active March 17, 2024 14:50
Check SSE/AVX instruction support.
/*
Check SSE/AVX support.
This application can detect the instruction support of
SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, SSE5, and AVX.
*/
#include <iostream>
#ifdef _MSC_VER
#include <intrin.h>
#endif
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <random>
#include <iostream>
#include <intrin.h>
#include <stdint.h>
#include <chrono>
#define M_PI 3.14159265358979323846
@hi2p-perim
hi2p-perim / rdrandsmallpt.cpp
Last active December 29, 2023 23:39
RdRand version of smallpt (http://www.kevinbeason.com/smallpt/)
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <random>
#include <iostream>
#include <intrin.h>
#include <stdint.h>
#include <chrono>
#define M_PI 3.14159265358979323846
@hi2p-perim
hi2p-perim / bugged.cpp
Created January 21, 2014 09:13
A bug. Segmentation fault with g++ 4.7.2, boost 1.54.0
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <chrono>
#include <boost/signals2.hpp>
class A
{
public:
@hi2p-perim
hi2p-perim / loadhdr.py
Created March 4, 2014 12:48
Load Radiance HDR file (.hdr) with python. Used : smc.freeimage, Pillow, OpenCV
import array
import smc.freeimage as fi
from PIL import Image
import numpy as np
import cv2
def gamma_correction(a, gamma):
return np.power(a, 1/gamma)
def load_hdr(file):
@hi2p-perim
hi2p-perim / boostpoolperf.cpp
Created August 5, 2014 07:05
Simple performance test of boost::pool
#include <iostream>
#include <boost/pool/object_pool.hpp>
#include <vector>
#include <chrono>
class Pool
{
public:
virtual ~Pool() {}
@hi2p-perim
hi2p-perim / assumetest.cpp
Last active August 29, 2015 14:07
Tricky compilation error with __assume. Checked with VS2013 (/W4 /WX options enabled)
#include <iostream>
struct A
{
int n;
A(int n) : n(n) {}
};
A Func(int n)
{
@hi2p-perim
hi2p-perim / cocoa.cpp
Created January 17, 2015 10:34
Composite numbers that Cocoa-chan should be careful to remember (cf. Gochiusa episode #10)
#include <iostream>
#include <vector>
int main()
{
for (int n = 2; n <= 9719; n++)
{
bool found = false;
int nn = n;
std::vector<int> a;