Skip to content

Instantly share code, notes, and snippets.

@sasekazu
sasekazu / gist:32f966816ad6d9244259
Created June 19, 2014 11:54
SVD numerical recipes in c
/*
An implementation of SVD from Numerical Recipes in C and Mike Erhdmann's lectures
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define SIGN(a,b) ((b) > 0.0 ? fabs(a) : - fabs(a))
static double maxarg1, maxarg2;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>audio test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#puyon1Button").click(function () {
@sasekazu
sasekazu / gist:827ca7d5dadda0c34ac6
Created November 6, 2014 03:08
Intel TBB sort time measure
/*
* tbbTest.cpp
*
* Created on: 2014/11/05
* Author: sase
*/
#include <iostream>
#include <math.h>
#include <sys/time.h>
@sasekazu
sasekazu / gist:34b8dcdbdfd4175246b5
Created November 6, 2014 03:09
Thrust sort time measure
/*
* main.cu
*
* Created on: 2014/11/05
* Author: sase
*/
/*
* tbbTest.cpp
@sasekazu
sasekazu / gist:1c1acd437b7a4466d50c
Last active August 29, 2015 14:11
ロジスティック写像の分岐図
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>logistic</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var canvas = document.getElementById('myCanvas');
@sasekazu
sasekazu / gist:37a4a522b4ef9e7b0fcd
Last active August 29, 2015 14:11
ロジスティック写像の分岐図 写像の可視化付き
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>logistic</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
@sasekazu
sasekazu / gist:2faafd364daa849d937f
Created January 5, 2015 13:35
HTML5 canvas 画像処理 グレースケール化
// グレースケール化
// canvasコンテキスト contextIn をグレースケール化して contextOut に書き出す
// ただしアルファ値が 0 のピクセルはそのままにする
function grayScale(contextIn, contextOut, width, height) {
var imgData = contextIn.getImageData(0, 0, width, height);
var gray;
for(var i=0; i<imgData.width*imgData.height; ++i) {
if(imgData.data[4*i+3]!=0) {
gray = 0.299*imgData.data[4*i]+0.587*imgData.data[4*i+1]+0.114*imgData.data[4*i+2];
gray = Math.floor(gray);
@sasekazu
sasekazu / gist:ca74de14c92d48acfe91
Created January 5, 2015 13:36
HTML5 canvas 画像処理 二値化
// 二値化
// canvasコンテキスト contextIn を閾値 threshold の元で二値化して contextOut に書き出す
// 入力画像はグレースケール画像であることを想定している(RGB値がすべて同じ)
// アルファ値が 0 のピクセルは閾値に関わらず白にする
function binarization(contextIn, contextOut, width, height, threshold) {
var imgData = contextIn.getImageData(0, 0, width, height);
var gray;
for(var i=0; i<imgData.width*imgData.height; ++i) {
if(imgData.data[4*i+3]==0) {
imgData.data[4*i] = 255;
@sasekazu
sasekazu / gist:bac785784e17e625a724
Created January 5, 2015 13:38
HTML5 canvas 画像処理 輪郭追跡 Freeman chain code
// 輪郭追跡を行い,輪郭部のみに色を出力する
function contourDetection(contextIn, contextOut, width, height) {
var imgData=contextIn.getImageData(0, 0, width, height);
// 読み取り用ピクセルデータ(書き換えない)
var pixelData = new Array(width);
for(var i=0; i<width; ++i) {
pixelData[i] = new Array(height);
for(var j=0; j<height; ++j) {
pixelData[i][j] = imgData.data[4*(width*j+i)];
}
@sasekazu
sasekazu / gist:b1471424607cc37174a9
Created January 8, 2015 08:24
点列データをSVGに変換して書き出す
#include <iostream>
#include <fstream>
#include <list>
#include <math.h>
#define N 2000
#define PI 3.141592
using namespace std;