Skip to content

Commit

Permalink
Resolve notation and consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
lpawela committed Oct 18, 2020
1 parent 80ccefb commit c4258b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ for (T, N) in ((:MPO, 4), (:MPS, 3))
end
end

function MPO::MPS{T}) where {T <: AbstractArray{<:Number, 3}}
function MPO::MPS{T}) where {T}
_verify_square(ψ)
L = length(ψ)
O = MPO(T.name.wrapper, eltype(T), L)
Expand All @@ -48,7 +48,7 @@ function MPO(ψ::MPS{T}) where {T <: AbstractArray{<:Number, 3}}
O
end

function MPS(O::MPO{T}) where T <: AbstractArray{<:Number, 4}
function MPS(O::MPO{T}) where {T}
L = length(O)
ψ = MPS(T.name.wrapper, eltype(T), L)

Expand All @@ -71,7 +71,7 @@ function Base.randn(::Type{MPS{T}}, L::Int, D::Int, d::Int) where {T}
ψ
end

function Base.randn(::Type{MPO{T}}, L::Int, D::Int, d::Int) where T <: AbstractArray{<:Number, 4}
function Base.randn(::Type{MPO{T}}, L::Int, D::Int, d::Int) where {T}
S = newdim(T, 3)
ψ = randn(MPS{S}, L, D, d^2)
MPO(ψ)
Expand Down
10 changes: 5 additions & 5 deletions src/contractions.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export dot, norm, left_env
export left_env

function LinearAlgebra.dot::MPS, ψ::MPS)
C = ones(eltype(ψ), 1, 1)
Expand Down Expand Up @@ -32,9 +32,9 @@ end

LinearAlgebra.norm::MPS) = sqrt(abs(dot(ψ, ψ)))

function LinearAlgebra.dot::MPS, O::Vector{S}, ψ::MPS) where {S <: AbstractMatrix}
R = eltype(ψ)
C = ones(R, 1, 1)
function LinearAlgebra.dot::MPS, O::Vector{T}, ψ::MPS) where {T <: AbstractMatrix}
S = eltype(ψ)
C = ones(S, 1, 1)

for i 1:length(ψ)
M = ψ[i]
Expand All @@ -61,7 +61,7 @@ end

Base.:(*)(O::MPO, ψ::MPS) = return dot(O, ψ)

function LinearAlgebra.dot(O1::MPO{T}, O2::MPO{T}) where T <: AbstractArray{<:Number, 4}
function LinearAlgebra.dot(O1::MPO{T}, O2::MPO{T}) where {T}
L = length(O1)
tensors = Vector{T}(undef, L)

Expand Down

1 comment on commit c4258b5

@bartekGardas
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, yet MPS/MPO (as they are defined right now -- meta programming) are not properly identified by VSCode. There is no error, obnly annoying underlines ...
Can we do something about it?

Please sign in to comment.