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
#==============================================================================# | |
# 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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) |
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
# 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)) |
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
#!/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 |
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
:-) 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 |
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
# 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 |
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 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( |
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 | |
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 |
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
cd | |
rsync -a --exclude=*/__pycache__ /data/scratch/pysages-ase . &> /dev/null | |
find pysages-ase -type f \( -name *.py -name *.sh \) -exec sed -i "s|/data/scratch|$HOME|g" {} + | |
module purge | |
module load cuda | |
source $HOME/pysages-ase/bin/activate | |
alias python="python3" |
OlderNewer