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
#include <stdlib.h> | |
#include <stdio.h> | |
// Two-pass algorithm: | |
// http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Two-pass_algorithm | |
double var(double* v, size_t n) | |
{ | |
double mean = 0.0; | |
for (int i = 0; i < n; i++) { | |
mean += v[i]; |
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
{-# LANGUAGE FlexibleContexts #-} | |
import qualified Data.Vector.Generic as G | |
fooG :: (G.Vector v Int) => Int -> v Int -> v Bool | |
fooG x = G.map (> x) | |
-- hello.hs:5:10:Could not deduce (G.Vector v Bool) arising from a use of ‘G.map’ | |
-- from the context (G.Vector v Int) | |
-- bound by the type signature for | |
-- fooG :: G.Vector v Int => Int -> v Int -> v Bool |
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
UndefVarError(:x) | |
x: 10 |
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
diff --git a/src/ANMS.jl b/src/ANMS.jl | |
index b235efd..5f93caa 100644 | |
--- a/src/ANMS.jl | |
+++ b/src/ANMS.jl | |
@@ -72,6 +72,7 @@ function nelder_mead(f::Function, x₀::Vector{Float64}; iterations::Int=1_000_0 | |
u = zeros(n) | |
for i in 1:n | |
τ = x₀[i] == 0.0 ? 0.00025 : 0.05 | |
+ τ = 1.0 | |
u[i] = 1.0 |
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
# 間違い! | |
module Hoge | |
export length | |
function length() | |
0 | |
end | |
end | |
using Hoge |
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
type Foo | |
x | |
Foo(x::Int) = new(x) | |
end | |
Base.convert(::Type{Foo}, x::Integer) = Foo(convert(Int, x)) | |
@show Foo(1) # ok both on v0.3 and v0.4 | |
@show Foo(0x01) # ok on v0.4, but not on v0.3 |
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
diff --git a/src/TinySegmenter.jl b/src/TinySegmenter.jl | |
index 7fcb27a..7e73fbb 100644 | |
--- a/src/TinySegmenter.jl | |
+++ b/src/TinySegmenter.jl | |
@@ -5,6 +5,11 @@ export tokenize | |
typealias US UTF8String | |
+Base.hash(x::Tuple{Char,Char}) = hash((UInt64(x[2]) << 32) | UInt64(x[1])) | |
+Base.hash(x::Tuple{UInt8,UInt8}) = hash((UInt64(x[2]) << 8) | UInt64(x[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
open(`ls`) do stream | |
for line in eachline(stream) | |
@show line | |
end | |
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
""" | |
Nelder-Mead algorithm | |
nelder_mead(f, x0, n) | |
Arguments | |
--------- | |
* `f`: target function to optimize | |
* `x0`: initial value |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer