Commit 47cbbe0d authored by Alessandro 's avatar Alessandro

small bug fixed (linalg)

parent 0efabd0b
...@@ -60,8 +60,8 @@ function get_matrix(corr_diag::Vector{Vector{uwreal}}, corr_upper::Vector{Vector ...@@ -60,8 +60,8 @@ function get_matrix(corr_diag::Vector{Vector{uwreal}}, corr_upper::Vector{Vector
return nothing return nothing
end end
res = Vector{Matrix}(undef, time) # array with all the matrices at each time step. res = Vector{Matrix}(undef, time) # array with all the matrices at each time step.
aux = Matrix{uwreal}(undef, n, n)
for t in 1:time for t in 1:time
aux = Matrix{uwreal}(undef, n, n)
count=0 count=0
#testing = corr_upper[1][1] #testing = corr_upper[1][1]
for i in range(n-1,1, step=-1) for i in range(n-1,1, step=-1)
...@@ -89,13 +89,14 @@ function energies(evals::Vector{Vector{uwreal}}) ...@@ -89,13 +89,14 @@ function energies(evals::Vector{Vector{uwreal}})
time = length(evals) time = length(evals)
n = length(evals[1]) n = length(evals[1])
eff_en = Vector{Vector}(undef, n) eff_en = Vector{Vector}(undef, n)
aux_en = Vector{uwreal}(undef, time-1) #aux_en = Vector{uwreal}(undef, time-1)
for i in 1:n for i in 1:n
aux_en = Vector{uwreal}(undef, time-1)
for t in 1:time-1 for t in 1:time-1
ratio = evals[t][i] / evals[t+1][i] ratio = evals[t][i] / evals[t+1][i]
aux_en[t] = log(sqrt(ratio * ratio)) aux_en[t] = log(sqrt(ratio * ratio))
end end
#uwerr.(aux_en) uwerr.(aux_en)
eff_en[i] = aux_en eff_en[i] = aux_en
end end
return eff_en return eff_en
...@@ -115,7 +116,7 @@ The columns of such matrix are the eigenvectors associated with eigenvalues eval ...@@ -115,7 +116,7 @@ The columns of such matrix are the eigenvectors associated with eigenvalues eval
The keyword iter, set by default to 30, selects the number of iterations of the qr algorithm before stopping. The keyword iter, set by default to 30, selects the number of iterations of the qr algorithm before stopping.
""" """
function uwgevp_tot(mat_list::Vector{Array{uwreal, 2}}, tnot::Int64; iter::Int64 = 30, evec::Bool = false) function uwgevp_tot(mat_list::Vector{Matrix}, tnot::Int64; iter::Int64 = 30, evec::Bool = false)
if !evec if !evec
aux_evals = uwgevp.(mat_list, c_tnot=mat_list[tnot], iter = iter) aux_evals = uwgevp.(mat_list, c_tnot=mat_list[tnot], iter = iter)
evals = get_diag.(aux_evals) evals = get_diag.(aux_evals)
...@@ -244,7 +245,7 @@ function make_householder(a::Vector{uwreal}) ...@@ -244,7 +245,7 @@ function make_householder(a::Vector{uwreal})
end end
v[1] = uwreal(1.0) v[1] = uwreal(1.0)
H = idty(n) H = idty(n)
H = H - (2.0 / uwdot(v,v)) * uwdot(v, v) H = H - (2.0 / uwdot(v,v)) * uwdot(reshape(v, :,1), transpose(v)) #this last term is a vector product
#H = H - (2.0 / dot(value.(v),value.(v))) * uwdot(reshape(v, :,1), reshape(v, 1 ,:)) #H = H - (2.0 / dot(value.(v),value.(v))) * uwdot(reshape(v, :,1), reshape(v, 1 ,:))
for i in 1:n for i in 1:n
for j in 1:n for j in 1:n
...@@ -382,7 +383,7 @@ function uwnorm(a::Vector{uwreal}) ...@@ -382,7 +383,7 @@ function uwnorm(a::Vector{uwreal})
end end
""" """
Return the transpose of a matrix of uwreals Return the transpose of a matrix or vector of uwreals
""" """
function transpose(a::Matrix{uwreal}) function transpose(a::Matrix{uwreal})
res = similar(a) res = similar(a)
...@@ -398,6 +399,10 @@ function transpose(a::Matrix{uwreal}) ...@@ -398,6 +399,10 @@ function transpose(a::Matrix{uwreal})
res[n,n] = a[n,n] res[n,n] = a[n,n]
return res return res
end end
function transpose(vec::Vector{uwreal})
res = deepcopy(vec)
return reshape(res,1,:)
end
""" """
uwcopysign(a::uwreal, b::uwreal) uwcopysign(a::uwreal, b::uwreal)
...@@ -432,7 +437,7 @@ end ...@@ -432,7 +437,7 @@ end
# operator overloading # operator overloading
#=
""" """
Base.:*(x::uwreal, y::Matrix{uwreal}) Base.:*(x::uwreal, y::Matrix{uwreal})
...@@ -451,4 +456,3 @@ function Base.:*(x::uwreal, y::Matrix{uwreal}) ...@@ -451,4 +456,3 @@ function Base.:*(x::uwreal, y::Matrix{uwreal})
end end
return res return res
end end
=#
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment