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
import Base: start, next, done | |
immutable Terminator #Stores information related to when the algorithm should terminate | |
maxiter :: Int | |
resabsthresh :: Real | |
resrelthresh :: Real | |
end | |
Terminator(maxiter::Integer) = Terminator(maxiter, eps(), eps()) | |
Terminator() = Terminator(0) #By default, always terminate. |
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
#Computes the dispatch ratio for each generic function defined in a module | |
#all: iterate over exported methods, or all methods? | |
function dispatchratio(M::Module=Base, all=false) | |
methodcount = Dict{Symbol, Int}() | |
for name in names(M, all) | |
try #name may not represent a function or function-able type | |
methodcount[name] = length(methods(eval(M, name))) | |
catch continue end | |
end | |
methodcount |
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
RawUnicodeData=readdlm(download("http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt"), ';', String) | |
#UAX11 - http://www.unicode.org/reports/tr11/ | |
widthmap={ | |
"A "=>0, #ambiguous | |
"W "=>2, #wide | |
"F "=>2, #full | |
"N "=>0, #neutral | |
"Na "=>1, #narrow | |
"H "=>1, #half |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
el = Float64 | |
types=(el, Vector{el}, Matrix{el}) | |
functions=Dict() | |
for mytype in types | |
functions[mytype]={} | |
for method in methodswith(mytype, true) | |
(length(method.sig) == 1) || #Unary functions | |
(length(method.sig) == 2 && method.va) || #Binary function with varargs | |
continue | |
method.func.code.name in functions[mytype] && continue #Don't duplicate |
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
import Base: +, -, ⋅, *, /, √, convert | |
export DoublelengthFloat | |
immutable DoublelengthFloat{T<:FloatingPoint} <: FloatingPoint | |
head :: T | |
tail :: T | |
end | |
DoublelengthFloat(x::FloatingPoint) = DoublelengthFloat(x, zero(x)) | |
convert{T<:FloatingPoint}(::Type{DoublelengthFloat{T}}, x::T) = DoublelengthFloat(x) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 axpy!{T}(a::T, b::StridedVector{T}, c::StridedVector{T}) | |
# @simd for i=1:size(b, 1) | |
# c[i] += a*b[i] | |
# end | |
#end | |
mgs(A)=mgs!(copy(A)) | |
function mgs!(Q) #Does not store R | |
m, n = size(Q) | |
Qc= [slice(Q,:,k) for k=1:n] |
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 BrokenArrowBidiagonal{T} <: AbstractMatrix{T} | |
dv::Vector{T} | |
av::Vector{T} | |
ev::Vector{T} | |
end | |
Base.size(B::BrokenArrowBidiagonal) = (n=length(B.dv); (n, n)) | |
function Base.size(B::BrokenArrowBidiagonal, n::Int) | |
if n==1 || n==2 | |
return length(B.dv) | |
else |
OlderNewer