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
#!/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 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 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 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 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 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 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') |
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
primes' = 2 : [x | x <- [3..], isPrime' x] | |
isPrime' x = all (\p -> x `rem` p > 0) (factorsToTry x) | |
where | |
factorsToTry x = takeWhile (\p -> p*p <= x) primes' |
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
main = print $ head [1..] |
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
print [i for i in range(1,100000000001)][0] |
NewerOlder