Skip to content

Instantly share code, notes, and snippets.

View Axect's full-sized avatar
🎯
Prepare for graduation

Tae-Geun Kim Axect

🎯
Prepare for graduation
View GitHub Profile
@Axect
Axect / _multivector.py
Created January 7, 2025 01:34
Patch for _multivector.py of clifford
from numba.core.extending import NativeValue
@Axect
Axect / clifford__init__.py
Created January 7, 2025 01:33
Patch for __init__.py for clifford
def _get_mult_function(mt: sparse.COO):
"""
Get a function similar to `` lambda a, b: np.einsum('i,ijk,k->j', a, mt, b)``
Returns
-------
func : function (array_like (n_dims,), array_like (n_dims,)) -> array_like (n_dims,)
A function that computes the appropriate multiplication
"""
# unpack for numba
@Axect
Axect / _numba_utils.py
Created January 7, 2025 01:29
Patch for _numba_utils.py
# Replace last lines of clifford/_numba_utils.py
def generated_jit(f=None, **kwargs):
if f is None:
return _fake_generated_jit
else:
return _fake_generated_jit(f)
if not DISABLE_JIT:
njit = numba.njit
else:
@Axect
Axect / install_galprop.sh
Created March 5, 2024 00:33
Modified Galprop install script (on Arch linux - boost, clhep required)
#!/usr/bin/env bash
# Below are 2 example settings to build for OSX (10.15) or Linux (CentOS 8). Uncomment/modify the variables appropriate for your system -- you need to set these system variables
# User-defined variables -- this example is for OSX using a macports installation for the various tools
#MY_CMAKE=/opt/local/bin/cmake
#MY_AUTOCONF=/opt/local/bin/autoconf
#MY_CC=/opt/local/bin/clang-mp-12
#MY_CXX=/opt/local/bin/clang++-mp-12
@Axect
Axect / bisection_test.rs
Created December 11, 2023 04:39
Bisection test with Peroxide
use peroxide::fuga::*;
fn main() {
let h = |x: AD| -> AD {
let y = if x.x() < 5.0 { -5.0 } else { 5.0 };
println!("y = {:>2}", y);
AD0(y)
};
let sol = bisection(h, (0.0, 10.0), 5, 0.0001);
match sol {
def sliding_window(data, seq_length, pred_length):
x = []
y = []
for i in range(len(data) - seq_length - pred_length):
_x = data[i:(i+seq_length)]
_y = data[i+seq_length:i+seq_length+pred_length]
x.append(_x)
y.append(_y)
function r(l::T, psi::T) where { T <: Number }
return sqrt(RSOLAR^2 - 2*RSOLAR*l*cos(psi) + l^2)
end
function lmax(psi::T) where { T <: Number }
return sqrt(RH^2 - RSOLAR^2*sin(psi)^2) + RSOLAR * cos(psi)
end
function rho_nfw(l::T, psi::T) where { T<: Number }
return 0.4 * (RSOLAR/r(l,psi)) * ((1+RSOLAR/RS) / (1+r(l,psi)/RS))^2
@Axect
Axect / lazy5.hs
Created February 17, 2018 20:15
lazy5
primeFactors'' n = factors n (takeWhile (\p -> p*p <= n) primes')
@Axect
Axect / lazy4.hs
Created February 17, 2018 20:13
lazy4
factors :: Integral a => a -> [a] -> [a]
factors 1 _ = []
factors m (p:ps) | m < p*p = [m]
| r==0 = p:factors q (p:ps)
| otherwise = factors m ps
where (q,r) = quotRem m p
@Axect
Axect / lazy3.hs
Created February 17, 2018 20:10
lazy3
primeFactors' n = filter (\p -> mod n p == 0) (takeWhile (\p -> p*p <= n) primes')