https://qiita.com/piyo7 ScalaMatsuri & me • 2014: wireless simulation engineer (C++) • 2016: looking for a new job... • 2017: adtech data & ML engineer (Scala) 鳥越貴智です。ScalaMatsuri に感化されて転職しました。 サイバーエージェントは今年も\将軍スポンサー/
0.i)) java.lang.OutOfMemoryError: GC overhead limit exceeded at com.github.piyo7.qlione.Complex.$plus(Complex.scala:8) at .$anonfun$res31$2(<console>:15) at $$Lambda$2011/487012190.apply(Unknown Source) at scala.collection.generic.GenTraversableFactory.fill(GenTrave at .$anonfun$res31$1(<console>:15) at $$Lambda$2010/565550535.apply(Unknown Source) at scala.collection.generic.GenTraversableFactory.fill(GenTrave ... 25 elided
a-th row and b-th column element is an only 1. |a> is a column vector called “ket”. <b| is a row vector called “bra”. 量子計算では、しばしばブラケット記法を使います。 |a> <b| は、 a 行 b 列の要素のみが 1 の疎行列です。
2^B matrix // N quantum bits: A = N, B = _0 // N quantum gate: A = N, B = N case class QuMatrix[A <: _Nat, B <: _Nat] (map: Map[(Int, Int), Complex]) { // (2^A x 2^B matrix) + (2^A x 2^B matrix) = 2^A x 2^B matrix def +(that: QuMatrix[A, B]): QuMatrix[A, B] = … // (2^A x 2^B matrix) * (2^B x 2^C matrix) = 2^A x 2^C matrix def *[C <: _Nat](that: QuMatrix[B, C]): QuMatrix[A, C] = …
to calculate type-level sized qubits on classical memory? これで冗長な型パラメータを書かずにすみますね。 OK余裕? the cake is a lie. the cake is a lie. the cake is a lie. the cake is a lie.
<: _OptNat] (map: Map[(Int, Int), Complex]) { def |>[C <: _OptNat](that: QuMatrix[C, A]): QuMatrix[C, B] = that * this // flip horizontal ... } val out = |(0).> |> X |> Y |> Z
type parameters to calculate type-level sized qubits on classical memory? これで直感的にデータフローを書けますね。 もうOKしてもいいよね? cake is a lie. the cake is a lie. the cake is a lie. the cake is a lie. the cake is