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
@generated function groupslices{T,N}(A::AbstractArray{T,N}, dim::Int) | |
quote | |
if !(1 <= dim <= $N) | |
ArgumentError("Input argument dim must be 1 <= dim <= $N, but is currently $dim") | |
end | |
hashes = zeros(UInt, size(A, dim)) | |
# Compute hash for each row | |
k = 0 | |
@nloops $N i A d->(if d == dim; k = i_d; end) begin |
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
_ | |
_ _ _(_)_ | A fresh approach to technical computing | |
(_) | (_) (_) | Documentation: http://docs.julialang.org | |
_ _ _| |_ __ _ | Type "?help" for help. | |
| | | | | | |/ _` | | | |
| | |_| | | | (_| | | Version 0.4.5 (2016-03-18 00:58 UTC) | |
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release | |
|__/ | i686-w64-mingw32 | |
julia> Pkg.build("JavaCall") |
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
@generated function foo{T,N}(A::AbstractArray{T,N}, dim::Int) | |
quote | |
1 <= dim <= $N || return copy(A) | |
hashes = zeros(UInt, size(A, dim)) | |
# Compute hash for each row | |
k = 0 | |
@nloops $N i A d->(if d == dim; k = i_d; end) begin | |
@inbounds hashes[k] = hash(hashes[k], hash((@nref $N A i))) | |
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
@generated function foo{T,N}(A::AbstractArray{T,N}, dim::Int) | |
quote | |
1 <= dim <= $N || return copy(A) | |
hashes = zeros(UInt, size(A, dim)) | |
# Compute hash for each row | |
k = 0 | |
@nloops $N i A d->(if d == dim; k = i_d; end) begin | |
@inbounds hashes[k] = hash(hashes[k], hash((@nref $N A i))) | |
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
module OptimTest | |
using Optim, Hadamard | |
function symcond(n,κ) | |
Q = hadamard(n) | |
D = diagm(exp(linspace(0,-log(κ),n))); | |
Q*D*Q'/n | |
end | |
A = symcond(12,1e14) |