-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add alias "H" for Hadamard - Measure now won't terminate read - Code refactor
- Loading branch information
Showing
13 changed files
with
242 additions
and
141 deletions.
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
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import operator.Operator | ||
import util.read | ||
import util.reader | ||
import java.io.File | ||
|
||
/** | ||
|
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,61 @@ | ||
package matrix | ||
|
||
/** | ||
* Created by DEDZTBH on 2020/09/25. | ||
* Project KuantumCircuitSim | ||
*/ | ||
|
||
/** 2^(-1/2) */ | ||
const val HALF_AMPL = 0.70710678118654757273731092936941422522068023681640625 | ||
|
||
/** Don't change these constant matrices! */ | ||
val NOT = CMatrix( | ||
arrayOf( | ||
doubleArrayOf(0.0, 0.0, 1.0, 0.0), | ||
doubleArrayOf(1.0, 0.0, 0.0, 0.0) | ||
) | ||
) | ||
val H = CMatrix( | ||
arrayOf( | ||
doubleArrayOf(HALF_AMPL, 0.0, HALF_AMPL, 0.0), | ||
doubleArrayOf(HALF_AMPL, 0.0, -HALF_AMPL, 0.0) | ||
) | ||
) | ||
val I1 = COps.identity(1) | ||
val I2 = COps.identity(2) | ||
|
||
val KET0 = CMatrix(arrayOf(doubleArrayOf(1.0, 0.0), doubleArrayOf(0.0, 0.0))) | ||
val KET1 = CMatrix(arrayOf(doubleArrayOf(0.0, 0.0), doubleArrayOf(1.0, 0.0))) | ||
|
||
val KETBRA0 = COps.diag(1.0, 0.0, 0.0, 0.0) | ||
val KETBRA1 = COps.diag(0.0, 0.0, 1.0, 0.0) | ||
val SQRT_NOT = CMatrix( | ||
arrayOf( | ||
doubleArrayOf(0.5, 0.5, 0.5, -0.5), | ||
doubleArrayOf(0.5, -0.5, 0.5, 0.5), | ||
) | ||
) | ||
val SQRT_NOT_DAG = CMatrix(2, 2).also { | ||
COps.transposeConjugate(SQRT_NOT, it) | ||
} | ||
val Z = CMatrix( | ||
arrayOf( | ||
doubleArrayOf(1.0, 0.0, 0.0, 0.0), | ||
doubleArrayOf(0.0, 0.0, -1.0, 0.0), | ||
) | ||
) | ||
val S = CMatrix( | ||
arrayOf( | ||
doubleArrayOf(1.0, 0.0, 0.0, 0.0), | ||
doubleArrayOf(0.0, 0.0, 0.0, 1.0), | ||
) | ||
) | ||
val T = CMatrix( | ||
arrayOf( | ||
doubleArrayOf(1.0, 0.0, 0.0, 0.0), | ||
doubleArrayOf(0.0, 0.0, HALF_AMPL, HALF_AMPL), | ||
) | ||
) | ||
val TDag = CMatrix(2, 2).also { | ||
COps.transposeConjugate(T, it) | ||
} |
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,14 @@ | ||
package matrix | ||
|
||
import org.ejml.data.Complex_F64 | ||
import org.ejml.data.ZMatrixRMaj | ||
import org.ejml.dense.row.CommonOps_ZDRM | ||
|
||
/** | ||
* Created by DEDZTBH on 2020/09/25. | ||
* Project KuantumCircuitSim | ||
*/ | ||
|
||
typealias CMatrix = ZMatrixRMaj | ||
typealias COps = CommonOps_ZDRM | ||
typealias CNumber = Complex_F64 |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package operator | ||
|
||
import util.* | ||
import matrix.* | ||
|
||
|
||
/** | ||
|
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
Oops, something went wrong.