-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
通过在UAnsatz类中添加新的成员函数expand来实现扩展 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from paddle_quantum.circuit import UAnsatz | ||
from paddle import kron | ||
from paddle_quantum.state import vec,density_op | ||
import paddle | ||
|
||
|
||
#density_matrix | ||
def test_density_matrix(): | ||
cir = UAnsatz(1) | ||
cir.ry(paddle.to_tensor(1,dtype='float64'),0) | ||
state = cir.run_density_matrix() | ||
cir.expand(3) | ||
print(cir.get_state()) | ||
|
||
cir2 = UAnsatz(3) | ||
cir2.ry(paddle.to_tensor(1,dtype='float64'),0) | ||
cir2.run_density_matrix() | ||
print(cir2.get_state()) | ||
|
||
#state_vector | ||
def test_state_vector(): | ||
cir = UAnsatz(1) | ||
cir.ry(paddle.to_tensor(1,dtype='float64'),0) | ||
state = cir.run_state_vector() | ||
cir.expand(3) | ||
print(cir.get_state()) | ||
|
||
cir2 = UAnsatz(3) | ||
cir2.ry(paddle.to_tensor(1,dtype='float64'),0) | ||
cir2.run_state_vector() | ||
print(cir2.get_state()) | ||
|
||
test_density_matrix() | ||
test_state_vector() |