This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define N 1000 | |
__global__ | |
void add(int *a, int *b) { | |
int i = blockIdx.x; | |
if (i<N) { | |
b[i] = 2*a[i]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// | |
// Nearly minimal CUDA example. | |
// Compile with: | |
// | |
// nvcc -o example example.cu | |
// | |
#define N 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// On MacOSX compile with: | |
// g++ -framework OpenGL -framework GLUT -o example example.cpp | |
// | |
#include <stdlib.h> | |
#include <GLUT/glut.h> | |
GLuint program; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> {-# LANGUAGE ExplicitForAll, RankNTypes #-} | |
> import Control.Monad.Cont | |
An Eilenberg-Moore algebra for a monad t (a t-algebra) is one of these: | |
> type Algebra t x = t x -> x | |
satisfying these laws (page 3): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dm(Pa, Pb, y, β, n) | |
for i in 1:n | |
if i%100 == 0 | |
print("Iteration $i/$n\n") | |
end | |
fay = (1-1/β)*Pa(y)+(1/β)*y | |
fby = (1+1/β)*Pb(y)-(1/β)*y | |
y = y+β*(Pa(fby)-Pb(fay)) | |
# @show(y) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
import Data.Array | |
import Data.Array.IO | |
import Data.Foldable | |
import Data.List hiding (sum) | |
import System.Random | |
import Control.Monad.State | |
import Prelude hiding (sum) | |
--import Debug.Trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Ratio | |
import Data.List | |
import Control.Monad | |
-- I'm using two Haskell types for the two vertex types in | |
-- a bipartite graph. | |
-- Edges only go from type a to type b. | |
data BipartiteGraph a b = G [a] [b] [(a, b)] | |
instance (Show a, Show b) => Show (BipartiteGraph a b) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import random | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 129 | |
# Number of samples to use for integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 256 | |
# Number of samples to use for integration | |
M = 257 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 256 | |
# Number of samples to use for integration | |
M = 257 |
OlderNewer