This file contains hidden or 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 numba.core.extending import NativeValue |
This file contains hidden or 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
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 |
This file contains hidden or 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
# 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: |
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
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 { |
This file contains hidden or 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
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) |
This file contains hidden or 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 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 |
This file contains hidden or 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
primeFactors'' n = factors n (takeWhile (\p -> p*p <= n) primes') |
This file contains hidden or 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
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 |
This file contains hidden or 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
primeFactors' n = filter (\p -> mod n p == 0) (takeWhile (\p -> p*p <= n) primes') |
NewerOlder