Skip to content

Commit

Permalink
Initial zeroing out operator
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlevy committed Apr 25, 2024
1 parent bbdec04 commit 15d6163
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ITensorNumericalAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const_itensornetwork,
fourth_derivative_operator,
identity_operator,
delta_x,
delta_xyz
delta_xyz,
zero_point_op
export const_itn,
poly_itn, cosh_itn, sinh_itn, tanh_itn, exp_itn, sin_itn, cos_itn, rand_itn
export calculate_fx, calculate_fxyz
Expand Down
21 changes: 21 additions & 0 deletions src/elementary_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,27 @@ function identity_operator(s::IndsNetworkMap; kwargs...)
return ITensorNetwork(Op("I"), operator_inds)
end

" Create an operator which is 0 for points in xs "
function zero_point_op(s::IndsNetworkMap, xs::Vector, dimension::Int; truncate_kwargs...)
ttn_op = OpSum()
# build I- ∑_p ∏(bit string p)
for p in xs
ind_to_ind_value_map = calculate_ind_values(s, p, dimension)
string_site = []
for v in dimension_vertices(s, dimension)
op = ind_to_ind_value_map[only(s[v])] == 1 ? "Dup" : "Ddn"
push!(string_site, (op, v))
end
add!(ttn_op, -1.0, (string_site...)...)
end
add!(ttn_op, 1.0, "I", first(dimension_vertices(s, dimension)))
return ttn(ttn_op, indsnetwork(s); algorithm="svd", truncate_kwargs...)
end

function zero_point_op(s::IndsNetworkMap, x::Number, dimension::Int; truncate_kwargs...)
return zero_point_op(s, [x], dimension; truncate_kwargs...)
end

function operator(fx::ITensorNetworkFunction)
fx = copy(fx)
operator = itensornetwork(fx)
Expand Down

0 comments on commit 15d6163

Please sign in to comment.