Skip to content

Instantly share code, notes, and snippets.

View lmiq's full-sized avatar

Leandro Martínez lmiq

View GitHub Profile
@lmiq
lmiq / agents_with_celllistmap.jl
Created December 10, 2024 12:51
Simulation of Lennard-Jones particles in 2D using Agents.jl and CellListMap.jl
# # Integrating Agents.jl with CellListMap.jl
# ```@raw html
# <video width="auto" controls autoplay loop>
# <source src="../celllistmap.mp4" type="video/mp4">
# </video>
# ```
# This example illustrates how to integrate Agents.jl with
# [CellListMap.jl](https:://github.com/m3g/CellListMap.jl), to accelerate the
julia> function min_max(xs::AbstractVector, n::Int)
nmin = fill(typemax(Int), n)
nmin_xmax, nmin_imax = nmin[1], 1
nmax = fill(typemin(Int), n)
nmax_xmin, nmax_imin = nmax[1], 1
for val in xs
if val < nmin_xmax
nmin[nmin_imax] = val
nmin_xmax, nmin_imax = findmax(nmin)
end
@lmiq
lmiq / onehot.jl
Last active November 18, 2021 13:18
simple onehot
struct OneHotCode{T} <: AbstractVector{T}
i::T
length::T
end
Base.getindex(o::OneHotCode,i) = i == o.i ? 1 : 0
Base.size(o::OneHotCode) = (o.length,)
Base.length(o::OneHotCode) = o.length
@lmiq
lmiq / apricot.py
Last active August 17, 2021 01:46
apricot
import seaborn; seaborn.set_style('whitegrid')
import time
import scipy
import numpy as np
from numba import njit
from numba import prange
from sklearn.datasets import fetch_covtype
digits_data = fetch_covtype()