You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a line between two quantum states or operators on the Bloch sphere visualization.
331
+
Render the Bloch sphere visualization from the given [`Bloch`](@ref) object `b`.
395
332
396
333
# Arguments
397
334
398
-
- `b::Bloch`: The Bloch sphere object to modify.
399
-
- `start_point_point::QuantumObject`: The start_point_pointing quantum state or operator. Can be a `Ket`, `Bra`, or `Operator`.
400
-
- `end_point::QuantumObject`: The ending quantum state or operator. Can be a `Ket`, `Bra`, or `Operator`.
401
-
- `fmt::String="k"`: (optional) A format string specifying the line style and color (default is black `"k"`).
402
-
403
-
# Description
404
-
405
-
This function converts the given quantum objects (states or operators) into their Bloch vector representations and adds a line between these two points on the Bloch sphere visualization.
Add one or more quantum states to the Bloch sphere visualization by converting them into Bloch vectors.
431
-
432
-
# Arguments
433
-
- `b::Bloch`: The Bloch sphere object to modify
434
-
- `states::QuantumObject...`: One or more quantum states (Ket, Bra, or Operator)
435
-
436
-
# Example
437
-
438
-
```julia
439
-
x = basis(2, 0) + basis(2, 1);
440
-
y = basis(2, 0) - im * basis(2, 1);
441
-
z = basis(2, 0);
442
-
b = Bloch();
443
-
add_states!(b, [x, y, z])
444
-
```
445
-
"""
446
-
function QuantumToolbox.add_states!(b::Bloch, states::Vector{<:QuantumObject})
447
-
vecs =map(states) do state
448
-
ifisket(state) ||isbra(state)
449
-
return_state_to_bloch(state)
450
-
else
451
-
return_dm_to_bloch(state)
452
-
end
453
-
end
454
-
append!(b.vectors, [normalize(v) for v in vecs])
455
-
return b.vectors
456
-
end
457
-
458
-
@docraw"""
459
-
render(b::QuantumToolbox.Bloch; location=nothing)
460
-
461
-
Render the Bloch sphere visualization from the given `Bloch` object `b`.
462
-
463
-
# Arguments
464
-
465
-
- `b::QuantumToolbox.Bloch`
466
-
The Bloch sphere object containing states, vectors, and settings to visualize.
467
-
468
-
- `location` (optional)
469
-
Specifies where to display or save the rendered figure.
335
+
- `b::Bloch`: The Bloch sphere object containing states, vectors, and settings to visualize.
336
+
- `location`: Specifies where to display or save the rendered figure.
470
337
- If `nothing` (default), the figure is displayed interactively.
471
338
- If a file path (String), the figure is saved to the specified location.
472
339
- Other values depend on backend support.
473
340
474
341
# Returns
475
342
476
-
- A tuple `(fig, axis)` where `fig` is the figure object and `axis` is the axis object used for plotting.
477
-
These can be further manipulated or saved by the user.
343
+
- A tuple `(fig, axis)` where `fig` is the figure object and `axis` is the axis object used for plotting. These can be further manipulated or saved by the user.
478
344
"""
479
345
function QuantumToolbox.render(b::Bloch; location =nothing)
480
346
fig, ax =_setup_bloch_plot!(b, location)
@@ -859,46 +725,20 @@ function _add_labels!(b::Bloch, ax)
0 commit comments