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 Optim | |
struct Box <: Optim.Manifold | |
min | |
max | |
end | |
import Optim.retract! | |
import Optim.project_tangent! | |
retract!(B::Box, x) = (x .= min.(B.max,max.(B.min, x))) | |
function project_tangent!(B::Box,g,x) | |
for i in eachindex(x) |
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
n = 100 | |
A = randn(n,n) | |
A = A'A + I | |
b = randn(n) | |
f(x) = vecdot(x,A*x)/2 - vecdot(b,x) | |
g(x) = A*x-b | |
g!(stor,x) = copy!(stor,g(x)) | |
x0 = randn(n) |
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
module Anderson | |
export anderson | |
function anderson(g,x0,m::Int,niter::Int,eps::Real,warming=0) | |
@assert length(size(x0)) == 1 #1D array input | |
N = size(x0,1) | |
T = eltype(x0) | |
#xs: ring buffer storing the iterates, from newest to oldest | |
xs = zeros(T,N,m+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
function build_A(κ) | |
N = length(κ) | |
A = zeros(N,N) | |
for n=2:N-2 | |
# A[n,n] = 2*κ[n] | |
# A[n,n+1] = 1/4*(κ[n-1] - κ[n+1] - 4κ[n]) | |
# A[n+1,n] = 1/4*(κ[n+2] - κ[n] - 4κ[n+1]) | |
#Reference case: we know that AK is symmetric with K = diag(1/κ) | |
A[n,n] = -2*(κ[n+1] + κ[n-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
using BenchmarkTools | |
BLAS.set_num_threads(1) | |
function BLAS2(A,x) | |
A*x | |
end | |
function loop_mn(A,x) | |
m,n = size(A) | |
y = zeros(m) | |
@inbounds @simd for i=1:m |
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
(gdb) bt | |
#0 0x00007ffff6bf3428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 | |
#1 0x00007ffff6bf502a in __GI_abort () at abort.c:89 | |
#2 0x00007ffff6c357ea in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7ffff6d4ee98 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175 | |
#3 0x00007ffff6c3b814 in malloc_printerr (action=<optimized out>, str=0x7ffff6d4eee0 "corrupted double-linked list (not small)", ptr=<optimized out>, | |
ar_ptr=<optimized out>) at malloc.c:5006 | |
#4 0x00007ffff6c40b54 in _int_malloc (av=av@entry=0x7ffff6f82b20 <main_arena>, bytes=bytes@entry=88) at malloc.c:3727 | |
#5 0x00007ffff6c42184 in __GI___libc_malloc (bytes=88) at malloc.c:2913 | |
#6 0x00007ffff4a80e78 in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | |
#7 0x00007ffff52a39c1 in llvm::User::operator new(unsigned long, unsigned int) () from /home/antoine/julia-0.6.0/usr/bin/../lib/libLLVM-3.9.so |
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
diff --git a/Julia/BeginROPTLIB.jl b/Julia/BeginROPTLIB.jl | |
index ea53bd6..d56b1fc 100644 | |
--- a/Julia/BeginROPTLIB.jl | |
+++ b/Julia/BeginROPTLIB.jl | |
@@ -2,12 +2,12 @@ | |
using Cxx | |
# to the path of ROPTLIB | |
-cd("/home/whuang/Documents/ROPTLIB") | |
+cd("/home/antoine/ROPTLIB") |
NewerOlder