Skip to content

Commit

Permalink
Removed repeating patters as well as cleaned up some whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosfrenkel committed Feb 20, 2024
1 parent 80d8f09 commit 07d17ad
Show file tree
Hide file tree
Showing 46 changed files with 157 additions and 176 deletions.
14 changes: 7 additions & 7 deletions Tests/test_bloch_orthogonality_001.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test_bloch_orthogonality_001 ← {
correct_answer ← 0
result ← (0 #.quapl.sng.bloch(○1)) +.× (0 #.quapl.sng.bloch(○0))
result ← #.quapl._r_ result
test_bloch_orthogonality_001 ← {
correct_answer ← 0
result ← (0 #.quapl.sng.bloch(○1)) +.× (0 #.quapl.sng.bloch(○0))
result ← #.quapl._r_ result

'cross product of 2 opposing vectors should be 0'⊢correct_answer Assert result:
''
}
'cross product of 2 opposing vectors should be 0'⊢correct_answer Assert result:
''
}
1 change: 0 additions & 1 deletion Tests/test_dagger_001.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ test_dagger_001 ← {

'Taking the dagger to an arbitrary matrix'⊢ correct_result Assert result:
''

}
13 changes: 6 additions & 7 deletions Tests/test_gates_G_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
test_gates_G_unitary_001 ← {
test_gates_G_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.G 2

correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.G 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_P_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_P_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.P 2
test_gates_P_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.P 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_Rx_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_Rx_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.Rx 2
test_gates_Rx_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.Rx 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_Ry_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_Ry_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.Ry 2
test_gates_Ry_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.Ry 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
13 changes: 6 additions & 7 deletions Tests/test_gates_Rz_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
test_gates_Rz_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.Rz 2
test_gates_Rz_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.Rz 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''

}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_XX_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_XX_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.XX 2
test_gates_XX_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.XX 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_XY_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test_gates_XY_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.XY 2
test_gates_XY_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.XY 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}

12 changes: 6 additions & 6 deletions Tests/test_gates_YY_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test_gates_YY_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.YY 2
test_gates_YY_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.YY 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}

12 changes: 6 additions & 6 deletions Tests/test_gates_ZZ_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_ZZ_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.ZZ 2
test_gates_ZZ_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.ZZ 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_aSWAP_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_aSWAP_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.aSWAP 2
test_gates_aSWAP_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) #.quapl.gates.aSWAP 2

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_gCTR_unitary_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_gCTR_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) (1 #.quapl.gates.gCTR (2 2 ⍴ 0 1 1 0))
test_gates_gCTR_unitary_001 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) (1 #.quapl.gates.gCTR (2 2 ⍴ 0 1 1 0))

'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary'⊢ correct_result Assert result:
''
}
12 changes: 6 additions & 6 deletions Tests/test_gates_gCTR_unitary_002.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_gates_gCTR_unitary_002 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) (5 #.quapl.gates.gCTR (2 2 ⍴ 0 1 1 0))
test_gates_gCTR_unitary_002 ← {
correct_result ← 1
result ← (⌹≡⍉∘+) (5 #.quapl.gates.gCTR (2 2 ⍴ 0 1 1 0))

'If 0, it means the generated matrix is not unitary. Testing with multiple qubits'⊢ correct_result Assert result:
''
}
'If 0, it means the generated matrix is not unitary. Testing with multiple qubits'⊢ correct_result Assert result:
''
}
1 change: 0 additions & 1 deletion Tests/test_kpr_basic_001.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ test_kpr_basic_001 ← {

'Basic arbitrary values matrices to test kpr'⊢ correct_result Assert result:
''

}
3 changes: 1 addition & 2 deletions Tests/test_kpr_basic_002.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
test_kpr_basic_002 ← {
correct_result ← 4 1 ⍴ 1 0 0 0
a ← #.quapl.sng.q0
b ← #.quapl.sng.q0
result ← a #.quapl.mlt.kpr b
result ← a #.quapl.mlt.kpr a

'Testing 2 separate |0> qubits'⊢ correct_result Assert result:
''
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_kpr_basic_003.aplf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
test_kpr_basic_003 ← {
correct_result ← 4 1 ⍴ (1÷(2*0.5)) 0 (1÷(2*0.5)) 0
a ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
sqrt ← 0.5*0.5
correct_result ← 4 1 ⍴ sqrt 0 sqrt 0
a ← 2 1 ⍴ sqrt sqrt
b ← #.quapl.sng.q0
result ← a #.quapl.mlt.kpr b

'Testing 2 separate |0> qubits'⊢ correct_result Assert result:
''

}
7 changes: 3 additions & 4 deletions Tests/test_kpr_basic_004.aplf
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
test_kpr_basic_004 ← {
sqrt ← 0.5*0.5
correct_result ← 4 1 ⍴ 0.5 0.5 0.5 0.5
a ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
b ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
result ← a #.quapl.mlt.kpr b
a ← 2 1 ⍴ sqrt sqrt
result ← a #.quapl.mlt.kpr a

'Testing 2 separate |0> qubits'⊢ correct_result Assert result:
''

}
1 change: 0 additions & 1 deletion Tests/test_measure_001.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ test_measure_001 ← {

'Testing an equal superposition with 3 qubits' ⊢ 0 Assert result:
''

}
1 change: 0 additions & 1 deletion Tests/test_measure_002.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ test_measure_002 ← {

'Testing an imbalanced superposition with 3 qubits' ⊢ 0 Assert result:
''

}
6 changes: 3 additions & 3 deletions Tests/test_measure_003.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ test_measure_003 ← {
⍝ Start with qubits 0 and 2 in an equal superposition
initial_vs ← 8 1 ⍴ 0.5 0.5 0 0 0.5 0.5 0 0

state0 ← 8 1 ⍴ (0.5*0.5) 0 0 0 (0.5*0.5) 0 0 0
state1 ← 8 1 ⍴ 0 (0.5*0.5) 0 0 0 (0.5*0.5) 0 0
sqrt ← 0.5*0.5
state0 ← 8 1 ⍴ sqrt 0 0 0 sqrt 0 0 0
state1 ← 8 1 ⍴ 0 sqrt 0 0 0 sqrt 0 0

measured_ret ← 2 #.quapl.measurement.measure initial_vs
qubit_result ← ⊃ 2 ⌷ (⊃⊃(1 ⌷ measured_ret))
Expand All @@ -14,5 +15,4 @@ test_measure_003 ← {

'Test measuring a specific qubit does not brake a superposition' ⊢ correct_result Assert measured_state:
''

}
3 changes: 2 additions & 1 deletion Tests/test_normalize_001.aplf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_normalize_001 ← {
correct_vector ← (1÷2*0.5)(1÷2*0.5)
sqrt ← 0.5*0.5
correct_vector ← sqrt sqrt
result←#.quapl.mlt.normalize 1 1

'result should be correct_vector' ⊢ correct_vector Assert result:
Expand Down
3 changes: 2 additions & 1 deletion Tests/test_normalize_002.aplf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_normalize_002 ← {
correct_vector ← (1÷17*0.5)(4÷17*0.5)
sqrt ← 17*0.5
correct_vector ← (1÷sqrt)(4÷sqrt)
result←#.quapl.mlt.normalize 2 8

'result should be correct_vector' ⊢ correct_vector Assert result:
Expand Down
12 changes: 6 additions & 6 deletions Tests/test_qx_orthogonality_001.aplf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_qx_orthogonality_001 ← {
correct_answer ← 0
result ← ((⍉#.quapl.sng.qx 0 1)+.×(#.quapl.sng.qx 1 0))
test_qx_orthogonality_001 ← {
correct_answer ← 0
result ← ((⍉#.quapl.sng.qx 0 1)+.×(#.quapl.sng.qx 1 0))

'If the basis is orthogonal, the result should be 0'⊢ ⊃correct_answer Assert ⊃result:
''
}
'If the basis is orthogonal, the result should be 0'⊢ ⊃correct_answer Assert ⊃result:
''
}
13 changes: 7 additions & 6 deletions Tests/test_qx_value_001.aplf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
test_qx_value_001 ← {
correct_value ← 2 1 ⍴ ((1÷(2*0.5)) (1÷(2*0.5)))
result ← #.quapl.sng.qx 5 5
test_qx_value_001 ← {
sqrt ← 0.5*0.5
correct_value ← 2 1 ⍴ sqrt sqrt
result ← #.quapl.sng.qx 5 5

'A vector state with equal numbers should give you the state 1/sqrt(2) 1/sqrt(2)'⊢ correct_value Assert result:
''
}
'A vector state with equal numbers should give you the state 1/sqrt(2) 1/sqrt(2)'⊢ correct_value Assert result:
''
}

4 changes: 2 additions & 2 deletions Tests/test_stage_003.aplf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
test_stage_003 ← {
correct_result ← 8 1 ⍴ (0.5 0 0.5 0 0 0 0 0)*0.5
sqrt ← 0.5*0.5
correct_result ← 8 1 ⍴ sqrt 0 sqrt 0 0 0 0 0
vs ← 8 1 ⍴ 1 0 0 0 0 0 0 0
result ← ((1)(⊂#.quapl.gates.H)) #.quapl.circuit.stage vs

'The end vector state is not an equal superposition' ⊢ correct_result Assert result:
''

}
1 change: 0 additions & 1 deletion Tests/test_stage_004.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ test_stage_004 ← {

'starts with qubit 3 & 1 in 1 and apply CNOT from 3 to 1' ⊢ correct_result Assert result:
''

}
1 change: 0 additions & 1 deletion Tests/test_subregister_001.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ test_subregister_001 ← {

'Getting the correct subregister'⊢correct_result Assert result:
''

}
1 change: 0 additions & 1 deletion Tests/test_subregister_002.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ test_subregister_002 ← {

'Getting the correct subregister'⊢correct_result Assert result:
''

}
6 changes: 1 addition & 5 deletions Tests/test_thread_001.aplf
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
test_thread_001 ← {
correct_result ← 8 1 ⍴ 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
a ← 2 1 ⍴ 1 0
b ← 2 1 ⍴ 1 0
c ← 2 1 ⍴ 1 0
result ← #.quapl.circuit.thread (a b c)
result ← #.quapl.circuit.thread (a a a)

'Threading different vector states should give you the combined one on top'⊢correct_result Assert result:
''


}
5 changes: 3 additions & 2 deletions Tests/test_thread_002.aplf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
test_thread_002 ← {
correct_result ← 8 1 ⍴ 0 0 (1÷(2*0.5)) 0 0 0 (1÷(2*0.5)) 0
a ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
sqrt ← 0.5*0.5
correct_result ← 8 1 ⍴ 0 0 sqrt 0 0 0 sqrt 0
a ← 2 1 ⍴ sqrt sqrt
b ← 2 1 ⍴ 0 1
c ← 2 1 ⍴ 1 0
result ← #.quapl.circuit.thread (a b c)
Expand Down
8 changes: 3 additions & 5 deletions Tests/test_thread_003.aplf
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
test_thread_003 ← {
sqrt ← 0.5*0.5
correct_result ← 16 1 ⍴ (16/0.25)
a ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
b ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
c ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
d ← 2 1 ⍴ (1÷(2*0.5)) (1÷(2*0.5))
result ← #.quapl.circuit.thread (a b c d)
a ← 2 1 ⍴ sqrt sqrt
result ← #.quapl.circuit.thread (a a a a)

'Threading different vector states should give you the combined one on top'⊢correct_result Assert result:
''
Expand Down
Loading

0 comments on commit 07d17ad

Please sign in to comment.