Skip to content

Instantly share code, notes, and snippets.

View cuda_zygote.jl
using LinearAlgebra
using CUDA, StaticArrays, Zygote
dihedral_angle(p₁, p₂, p₃, p₄) = dihedral_angle(p₂ - p₁, p₃ - p₂, p₄ - p₃)
@inline function dihedral_angle(a, b, c)
p = a × b
q = b × c
return atan((p × q) b, (p q) * norm(b))
end
View plum-parametric+jax-pytree.py
from jaxlib.xla_extension import DeviceArray as JaxArray
from jax.tree_util import register_pytree_node
from plum import dispatch, parametric
from typing import Tuple
import jax.numpy as jnp
def register_pytree_parametric(cls):
register_pytree_node(
View hw2.jl
# Esta opción es suficiente para pasar el ejercicio,
# pero abajo hay una opción aún más rápida
function remove_in_each_row_no_vcat(img, column_numbers)
@assert size(img, 1) == length(column_numbers) # same as the number of rows
m, n = size(img)
local img′ = similar(img, m, n-1) # create a similar image with one less column
for (i, j) in enumerate(column_numbers)
# EDIT THE FOLLOWING LINE and split it into two lines
@pabloferz
pabloferz / example.log
Created Jun 8, 2020
ADP in water SSAGES - Gromacs example
View example.log
:-) GROMACS - ssages, VERSION 5.1.3-dev-20160713-01db2c5752-dirty (-:
GROMACS is written by:
Emile Apol Rossen Apostolov Herman J.C. Berendsen Par Bjelkmar
Aldert van Buuren Rudi van Drunen Anton Feenstra Sebastian Fritsch
Gerrit Groenhof Christoph Junghans Anca Hamuraru Vincent Hindriksen
Dimitrios Karkoulis Peter Kasson Jiri Kraus Carsten Kutzner
Per Larsson Justin A. Lemkul Magnus Lundborg Pieter Meulenhoff
Erik Marklund Teemu Murtola Szilard Pall Sander Pronk
Roland Schulz Alexey Shvetsov Michael Shirts Alfons Sijbers
View mpi_installer.sh
#!/bin/sh
# This configuration file was taken from <https://github.com/JuliaParallel/MPI.jl>
set -e
set -x
MPI_IMPL="$1"
os=`uname`
OMPIVER=4.0.3
MPICHVER=3.3.2
View compress.jl
# This example work for strings but can be easily adapted to other streams of data
function compress(str::String, hdict)
nbits = sum(c -> hdict[c][2], str)
bv = falses(nbits)
n = 0
for c in str
code, i = hdict[c] # code and number of bits
d = div(n, 64) + 1 # current storage chunk
r = 64 * d - n # number of bits available in the current chunk
u = (i < r) ? (code << (r - i)) : (code >> (i - r))
View unique_recursive.jl
function unique_recursive(itr)
T = Base._default_eltype(typeof(itr))
out = Vector{T}()
seen = Set{T}()
i = start(itr)
if done(itr, i)
return out
end
x, i = next(itr, i)
if !isleaftype(T)
View Free Electron.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View PrimeSieves.jl
#==============================================================================#
# Optimized Sieve of Atkin
#==============================================================================#
function atkin(n::Int)
s = zeros(Bool, n < 2 ? 0 : n)
n < 2 && return s; s[2] = true
n < 3 && return s; s[3] = true
for x = 1:floor(Int,sqrt(n/4))
j = 4 * x * x