Skip to content

Instantly share code, notes, and snippets.

View antoine-levitt's full-sized avatar

Antoine Levitt antoine-levitt

View GitHub Profile
using Random
using LinearAlgebra
function ortho(X)
Array(qr(X).Q)
end
function align(X,Y)
# returns an orthogonal combination X * c with c unitary such that X*c is closest to Y
proj = X'Y
using Random
using LinearAlgebra
function ortho(X)
Array(qr(X).Q)
end
function align(X,Y)
# returns an orthogonal combination X * c with c unitary such that X*c is closest to Y
proj = X'Y
diff --git a/src/solvers/anderson.jl b/src/solvers/anderson.jl
index 0d47b6a..60dc122 100644
--- a/src/solvers/anderson.jl
+++ b/src/solvers/anderson.jl
@@ -42,8 +42,8 @@ AndersonCache(df, ::Anderson{0}) =
@views function anderson_(df::Union{NonDifferentiable, OnceDifferentiable},
initial_x::AbstractArray{T},
- xtol::T,
- ftol::T,
import LinearAlgebra.BLAS
const libblas = Base.libblas_name
const liblapack = Base.liblapack_name
import LinearAlgebra
import LinearAlgebra: BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, stride1, chkstride1, axpy!
import Libdl
import LinearAlgebra.BLAS
const libblas = Base.libblas_name
const liblapack = Base.liblapack_name
import LinearAlgebra
import LinearAlgebra: BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, stride1, chkstride1, axpy!
import Libdl
(require 'latex nil t)
;; Math insertion in julia. Use it with
(defun julia-math-insert (s)
"Inserts math symbol given by `s'"
(when s
(let ((sym (gethash (concat "\\" s) julia-latexsubs)))
(when sym
(insert sym)))))
using FFTW
const MAX_THREADS = Threads.nthreads()
println("$(MAX_THREADS) threads")
N = 128
M = 40
println("N=$N, M=$M")
using FFTW
n = 128
m = 5
X = randn(ComplexF64, n, n, n, m)
p = plan_fft!(X, (1, 2, 3))
Y = copy(X)
GC.gc()
GC.enable(false)
## 2D Gross-Pitaevskii equation, with magnetic field, and with
## multiple electrons (of course, it doesn't make physical sense, but
## why not)
## This is pretty WIP, and only serves as a very rough demo. Nothing
## has been checked properly, so do not use for any serious purposes.
using PyCall
using DFTK
using Printf
## 2D Gross-Pitaevskii equation, with magnetic field, and with
## multiple electrons (of course, it doesn't make physical sense, but
## why not)
## This is pretty WIP, and only serves as a very rough demo. Nothing
## has been checked properly, so do not use for any serious purposes.
using PyCall
using DFTK
using Printf