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
| <?php | |
| $app->get('/', function () { | |
| // Write some data to a temp file | |
| $stream = fopen('php://temp', 'w+'); | |
| for ($i = 0; $i != 100000; $i++) { | |
| fwrite($stream, str_repeat(strval($i), 100) . PHP_EOL); | |
| } | |
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
| 0.5258035496409385338996633621320518075577262895034576824436935036190909359484821735511244086357105703763089095001084909503562784106432631780885381833487161441115426324089735535648577478022198173062961599662707079574920200839277886235481421364962201726366096411855900154689889962293083318039904967542464945043705977339467548513433912472348985230682047335936507184327257718362160494751446144883847282407215005669970705901314196397855777633081493954608446354... |
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
| 3^2 - 2 * 2^2 = 1 | |
| 9^2 - 5 * 4^2 = 1 | |
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
| #include <iostream> | |
| #include <tuple> | |
| using pell = std::pair<size_t, size_t>; | |
| inline pell next(pell const &solution) | |
| { | |
| return { | |
| 2 * solution.first + 3 * solution.second, | |
| 2 * solution.second + solution.first |
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
| <?php | |
| final class User | |
| { | |
| private $name; | |
| public function __construct(string $name) | |
| { | |
| $this->name = $name; | |
| } |
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
| <?php | |
| function take(Iterator $it, int $n) { | |
| for ($i = 0; $i < $n && $it->valid(); $i++, $it->next()) { | |
| yield $it->current(); | |
| } | |
| } | |
| function filter(Iterator $it, callable $f) { | |
| foreach ($it as $item) { |
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
| using BenchmarkTools | |
| using IterativeSolvers | |
| module GMRES | |
| using Base.LinAlg.axpy! | |
| function gmres(A, b; outer::Int = 5, restart::Int = 20, tol = sqrt(eps(real(eltype(b))))) | |
| T = eltype(b) |
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
| import Base.LinAlg.BlasFloat | |
| import Base.LinAlg.BLAS: gemv!, gemv, axpy! | |
| using BenchmarkTools | |
| function classical_gram_schmidt!{T<:BlasFloat}(V::StridedMatrix{T}, w::StridedVector{T}) | |
| # orthogonalize | |
| h = gemv('T', one(T), V, w) | |
| gemv!('N', -one(T), V, h, one(T), w) |
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 literature_example() | |
| # Problem: Δu + 1000uₓ = f | |
| # u = 0 on the boundaries | |
| # f(x, y, z) = exp(xyz) sin(πx) sin(πy) sin(πz) | |
| # 2nd order central differences (shows serious wiggles) | |
| # Unknowns per dimension | |
| N = 50 | |
| # Total number of unknowns |
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
| struct UnsafeView{T, N} <: DenseArray{T, N} | |
| dim::NTuple{N, Int} | |
| ptr::Ptr{T} | |
| end | |
| const UnsafeVectorView{T} = UnsafeView{T,1} | |
| const UnsafeMatrixView{T} = UnsafeView{T,2} | |
| @inline Base.size(v::UnsafeView) = v.dim | |
| @inline Base.size(v::UnsafeVectorView, idx::Int) = idx == 1 ? v.dim[idx] : 1 |