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
class CEnv: | |
def __init__(self): | |
self.executable = None | |
def compile(self, code: str) -> str: | |
with tempfile.NamedTemporaryFile(mode="w", suffix=".c", delete=False) as temp_c: | |
temp_c.write(code) | |
c_file = temp_c.name | |
try: |
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
# %% | |
from jupyc import c | |
# %% | |
%%c | |
int x = 5; | |
int y = 2; | |
x + y |
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 numpy as np | |
import xarray as xr | |
import matplotlib.pyplot as plt | |
from scipy.optimize import basinhopping | |
from scipy.ndimage import gaussian_filter1d | |
from sklearn.model_selection import KFold | |
def cv_bandwidth(X, y, bandwidths=np.logspace(-1, 1, 10)): | |
kf = KFold(n_splits=5) |
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
// gcc -O3 -g -I/opt/OpenBLAS/include -L/opt/OpenBLAS/lib -lopenblas -march=native main.c -o main && ./main | |
#include <math.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <time.h> | |
#include <arm_neon.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <cblas.h> |
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
######################################################################## PREP | |
import numpy as np | |
from scipy.linalg.blas import sgemm | |
import jax | |
import jax.numpy as jnp | |
DIM = 4096 | |
accelerate = ctypes.cdll.LoadLibrary( |
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 time | |
import jax | |
from jax import numpy as jnp | |
import numpy as np | |
N=4096 | |
flops_ish = N*N*2*N | |
for i in range(5): | |
A = np.random.rand(N,N).astype(np.float64) | |
B = np.random.rand(N,N).astype(np.float64) | |
t1 = time.monotonic() |
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
using Gadfly | |
import Cairo, Fontconfig | |
using Printf | |
using FFMPEG | |
#################################### This is pretty much the same code as in https://github.com/JuliaPlots/Plots.jl/blob/master/src/animation.jl | |
struct Animation | |
dir::String | |
frames::Vector{String} | |
kwargs::Iterators.Pairs |
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
### A Pluto.jl notebook ### | |
# v0.12.21 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local el = $(esc(element)) |
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
using MacroTools | |
using Symbolics | |
function parse(strexpr) | |
expr = Meta.parse(strexpr) | |
freevars = Set() | |
expr = MacroTools.postwalk(x -> begin | |
if isa(x, Symbol) && !isdefined(Base, x) | |
push!(freevars, Variable(x)) | |
Expr(:call, Variable, QuoteNode(x)) |
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
using LinearAlgebra, BenchmarkTools, SparseArrays, SymbolicUtils, Symbolics | |
## Problem setup | |
const z = zeros; | |
wx = Float64[ 0 -1 0; | |
1 0 0; | |
0 0 0;]; | |
Ak_1 = [ wx -I zeros(3,12); |
NewerOlder