Skip to content

Commit dc9d324

Browse files
committed
Fixed Unit Test for Householder
1 parent d495a11 commit dc9d324

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Unit_tests.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,15 +1604,29 @@
16041604
(*Check Methods based on Householder decomposition*)
16051605

16061606

1607-
checkDenseHouseholder[v_]:=Module[{st,iso},(
1607+
checkDenseHouseholder[v_]:=Module[{st,iso,n,nIso},(
16081608
st=DenseHouseholderDec[v];
1609+
n = Log2[Dimensions[v][[1]]];
16091610
iso=NCreateOperationFromGateList[st];
1611+
nIso = Log2[Dimensions[iso][[1]]];
1612+
If[nIso < n,
1613+
iso=NCreateOperationFromGateList[st,n];
1614+
(*Ensure that the dimension is correct, even if the gates are
1615+
only acting on a part of the available qubits*)
1616+
];
16101617
isIdentityUpToPhase[N[ConjugateTranspose[v] . iso]]
16111618
)
16121619
]
1613-
checkSparseHouseholder[v_]:=Module[{st,iso},(
1620+
checkSparseHouseholder[v_]:=Module[{st,iso,n,nIso},(
16141621
st=SparseHouseholderDec[v];
1622+
n = Log2[Dimensions[v][[1]]];
16151623
iso=NCreateOperationFromGateList[st];
1624+
nIso = Log2[Dimensions[iso][[1]]];
1625+
If[nIso < n,
1626+
iso=NCreateOperationFromGateList[st,n];
1627+
(*Ensure that the dimension is correct, even if the gates are
1628+
only acting on a part of the available qubits*)
1629+
];
16161630
isIdentityUpToPhase[N[ConjugateTranspose[v] . iso]]
16171631
)
16181632
]

0 commit comments

Comments
 (0)