From e1b3cdfcb8ac1a5d64646142bbd2f28eafd389a7 Mon Sep 17 00:00:00 2001 From: Cassandra Granade Date: Fri, 1 Apr 2022 09:00:25 -0700 Subject: [PATCH] More test cases for inv. --- src/Simulation/qdk_sim_rs/src/linalg/inv.rs | 714 +++++++++++++++++++- src/Simulation/qdk_sim_rs/src/utils.rs | 3 + 2 files changed, 707 insertions(+), 10 deletions(-) diff --git a/src/Simulation/qdk_sim_rs/src/linalg/inv.rs b/src/Simulation/qdk_sim_rs/src/linalg/inv.rs index 4b42ed80679..d6c89a4beb4 100644 --- a/src/Simulation/qdk_sim_rs/src/linalg/inv.rs +++ b/src/Simulation/qdk_sim_rs/src/linalg/inv.rs @@ -45,7 +45,7 @@ mod tests { use ndarray::array; use num_traits::Zero; - use crate::{error::QdkSimError, linalg::Inv}; + use crate::{c64, error::QdkSimError, linalg::Inv}; #[test] fn inv_works_f64() -> Result<(), QdkSimError> { @@ -65,20 +65,714 @@ mod tests { ]; let inv = mtx.inv()?; let expected_inv = array![ + [c64!(-0.69791667), c64!(-0.0625 i), c64!(0.13541667),], + [c64!(-0.0625 i), c64!(0.125), c64!(-0.0625 i)], + [c64!(0.46875), c64!(-0.0625 i), c64!(-0.03125)], + ]; + + for (actual, expected) in inv.iter().zip(expected_inv.iter()) { + assert_abs_diff_eq!(actual, expected, epsilon = 1e-6); + } + Ok(()) + } + + #[test] + fn inv_works_c64_5x5() -> Result<(), QdkSimError> { + // Python code to generate test case: + // import numpy as np + // import scipy.linalg as la + // X = np.random.random((5, 5)) + np.random.random((5, 5)) * 1j + // def print_arr_as_rs(arr): + // print("array![") + // for row in arr: + // print(" [", end="") + // print(", ".join( + // f"c64::new({element.real}, {element.imag})" + // for element in row + // ), end="") + // print("],") + // print("]") + // print_arr_as_rs(X) + // print_arr_as_rs(la.inv(X)) + let mtx = array![ + [ + c64::new(0.25759564633928533, 0.9499197824003289), + c64::new(0.36288815045785816, 0.7542794140806953), + c64::new(0.3575366182927219, 0.15718447037949934), + c64::new(0.6258618223229145, 0.606098740015765), + c64::new(0.4262277886124155, 0.952615526372946) + ], + [ + c64::new(0.7574275030894558, 0.5980955544457704), + c64::new(0.8519089404515027, 0.37274304468840325), + c64::new(0.6484719497482538, 0.29885541821603523), + c64::new(0.047156400699850165, 0.7003281373877304), + c64::new(0.7573593614243241, 0.02022619925054081) + ], + [ + c64::new(0.06565657022052329, 0.8964247633381773), + c64::new(0.43971180912111907, 0.0936752171206513), + c64::new(0.8565111965854413, 0.716416438691636), + c64::new(0.4620853548253515, 0.08859493859607226), + c64::new(0.6761502941167822, 0.7629177012545356) + ], + [ + c64::new(0.28592498922650456, 0.11505276541596976), + c64::new(0.8638866172586472, 0.3860930727399199), + c64::new(0.06899006463605606, 0.8630942739465155), + c64::new(0.07967078190474364, 0.6271701884478902), + c64::new(0.9889623172686699, 0.6831913961093329) + ], + [ + c64::new(0.9198323331490859, 0.9418968234232035), + c64::new(0.7956810140209064, 0.7897894731423162), + c64::new(0.9390139934709593, 0.9133215782294428), + c64::new(0.4983734769859526, 0.0994474246120769), + c64::new(0.2619209371310002, 0.004972757766929403) + ], + ]; + let inv = mtx.inv()?; + let expected_inv = array![ + [ + c64::new(-0.7909619701222462, 0.4675463791528054), + c64::new(-0.09950302744992989, -1.5959803664920833), + c64::new(0.681218090153333, -1.0192017365612318), + c64::new(0.4942583087733383, 1.4655410303969532), + c64::new(0.3918368731842419, 0.555047115830301) + ], + [ + c64::new(0.14432483967352205, -1.2656338362747568), + c64::new(1.3951911164644337, 1.1214902968878036), + c64::new(-0.21697568748595358, 1.7970639543704376), + c64::new(-1.0823513631779629, -0.5997321814949002), + c64::new(-0.4824879562743729, -0.7262272675611384) + ], + [ + c64::new(0.4217193550149313, 0.8408538401399359), + c64::new(-0.7486966253548832, 0.4967589619972676), + c64::new(-0.31853978279704065, -0.535332891638263), + c64::new(0.4293214150441409, -0.680836516539264), + c64::new(0.4312617193077752, -0.528250661249761) + ], + [ + c64::new(0.7120409190490832, -0.057771642957427746), + c64::new(-0.8431484241081729, -0.4785306364974677), + c64::new(-0.23128119608361064, 0.041150277748116), + c64::new(0.17415737286549077, -0.3041063301615835), + c64::new(0.30229406523570523, 0.20878202324721712) + ], + [ + c64::new(0.24696145093874475, -0.038144733375202966), + c64::new(-0.3996802757158412, 0.41676978509463203), + c64::new(-0.26054584996722907, -0.6309725521979278), + c64::new(0.6465176542968839, -0.39453347662338617), + c64::new(-0.16680206233005246, 0.18386759857791737) + ], + ]; + + for (actual, expected) in inv.iter().zip(expected_inv.iter()) { + assert_abs_diff_eq!(actual, expected, epsilon = 1e-6); + } + Ok(()) + } + + #[test] + fn inv_works_c64_16x16() -> Result<(), QdkSimError> { + // Python code to generate test case: + // import numpy as np + // import scipy.linalg as la + // X = np.random.random((16, 16)) + np.random.random((16, 16)) * 1j + // def print_arr_as_rs(arr): + // print("array![") + // for row in arr: + // print(" [", end="") + // print(", ".join( + // f"c64::new({element.real}, {element.imag})" + // for element in row + // ), end="") + // print("],") + // print("]") + // print_arr_as_rs(X) + // print_arr_as_rs(la.inv(X)) + let mtx = array![ + [ + c64::new(0.24343550539460002, 0.7096397032845722), + c64::new(0.629546686432831, 0.5301006031714603), + c64::new(0.4199349954349497, 0.358375134500281), + c64::new(0.400595688139045, 0.9645759115525548), + c64::new(0.08639871723999515, 0.7655041461418464), + c64::new(0.5272421501371002, 0.49548242232242845), + c64::new(0.201862871149052, 0.691752157021674), + c64::new(0.566606570806358, 0.9090447061650156), + c64::new(0.5224821650372808, 0.5254829260378098), + c64::new(0.5264656718847738, 0.37651456343277556), + c64::new(0.5561885182402057, 0.9143124378366423), + c64::new(0.49710125441166253, 0.030484298760797723), + c64::new(0.1631863300384664, 0.8113573847147066), + c64::new(0.8400531600269201, 0.43703798604805766), + c64::new(0.1730150235896153, 0.4988400829932095), + c64::new(0.07911501549474143, 0.4510850896893345) + ], + [ + c64::new(0.4182284703927561, 0.17768533289509136), + c64::new(0.5436803677118057, 0.28670911836907875), + c64::new(0.8660479956675148, 0.6718934426880514), + c64::new(0.8224549142195182, 0.09964377556322512), + c64::new(0.34496329518768976, 0.9801731197806263), + c64::new(0.5849863010766326, 0.4490005338446601), + c64::new(0.07836771055042646, 0.5420110965117988), + c64::new(0.4669545625108412, 0.1407565997515524), + c64::new(0.42484012971040686, 0.8759094071016321), + c64::new(0.5205341023964746, 0.9923357553551803), + c64::new(0.7014879416155709, 0.37485464528319457), + c64::new(0.5471165052558605, 0.20796849150802799), + c64::new(0.6199629816663412, 0.7519415024152558), + c64::new(0.9037790360470818, 0.666480231673042), + c64::new(0.2086744777910019, 0.07827526780188987), + c64::new(0.4670844989586508, 0.9537412452187163) + ], + [ + c64::new(0.4140469741259334, 0.4560336908973007), + c64::new(0.2546277825179136, 0.08143353851401769), + c64::new(0.6537603463090524, 0.6570297683362842), + c64::new(0.4009562738772193, 0.8805488266979159), + c64::new(0.02207598382742204, 0.5920605348013798), + c64::new(0.05517423266462318, 0.793992529375867), + c64::new(0.5632193027908459, 0.5977005530132938), + c64::new(0.9017864875558482, 0.5339011375670782), + c64::new(0.3828142959921751, 0.339242061558683), + c64::new(0.3385209625213713, 0.8324049401182788), + c64::new(0.30970070432395513, 0.005197774068218308), + c64::new(0.20695380217097692, 0.472246800325997), + c64::new(0.20221796644122614, 0.6857628071658661), + c64::new(0.17174699519185188, 0.6929524277609821), + c64::new(0.8041808362434856, 0.3371802625347794), + c64::new(0.9362896880145364, 0.38138437444507334) + ], + [ + c64::new(0.4696066202823814, 0.03198447459798637), + c64::new(0.6323638366681098, 0.9258645924825338), + c64::new(0.48515708183133144, 0.11024424103997121), + c64::new(0.609317530558061, 0.2972302001516389), + c64::new(0.30060843150464833, 0.8100153459051707), + c64::new(0.7986668256449622, 0.3922734957863946), + c64::new(0.2729653457634389, 0.4953984142309359), + c64::new(0.06098942703216337, 0.2004705039464001), + c64::new(0.4106442591731715, 0.47107371888912153), + c64::new(0.8932416419338051, 0.35348623017807734), + c64::new(0.9437579522965495, 0.3028603115275772), + c64::new(0.8997707657703546, 0.7534540438416928), + c64::new(0.8732369875427841, 0.6374743043364531), + c64::new(0.381827893689629, 0.3927530492921386), + c64::new(0.16011119980494248, 0.1146828362583655), + c64::new(0.4209728872731916, 0.9462487108084525) + ], + [ + c64::new(0.9179230088359127, 0.5038538240712301), + c64::new(0.2889594017105449, 0.787940771523522), + c64::new(0.4598053875867901, 0.41623746452910215), + c64::new(0.8095036581534074, 0.21551533218788865), + c64::new(0.4268228153778082, 0.9889060962179577), + c64::new(0.4304494380785887, 0.8040452167212958), + c64::new(0.223311800504025, 0.4970151956113278), + c64::new(0.007997571773524781, 0.6317969612629845), + c64::new(0.7469084890757939, 0.3363308133241615), + c64::new(0.7207259005808849, 0.6053258370249136), + c64::new(0.22517978068201328, 0.76379017292531), + c64::new(0.012292832735091963, 0.35381918017361436), + c64::new(0.8538576693766322, 0.464070671170861), + c64::new(0.429655967580578, 0.19559316787868042), + c64::new(0.935606881298734, 0.7033910463384877), + c64::new(0.4549095375495651, 0.2058092116780722) + ], + [ + c64::new(0.3865520894048742, 0.002013314615649353), + c64::new(0.22015446091828872, 0.38043374130648455), + c64::new(0.5048931185357252, 0.4194081288354866), + c64::new(0.6158067241441327, 0.7767694835770059), + c64::new(0.7584962310602148, 0.9546886708614651), + c64::new(0.5822353268156216, 0.537889230679487), + c64::new(0.8662438490163971, 0.7545107340070697), + c64::new(0.9083377609146424, 0.6927881140843738), + c64::new(0.9898651658147615, 0.11855995178629275), + c64::new(0.5420545051674228, 0.7449456850548131), + c64::new(0.6300620336271961, 0.3901867594702042), + c64::new(0.34711633901876726, 0.018969229982951585), + c64::new(0.2583485690095335, 0.3627546968287746), + c64::new(0.6679984633215221, 0.8079392177620631), + c64::new(0.456269593518148, 0.672929467478175), + c64::new(0.7703161905109068, 0.5312644373073533) + ], + [ + c64::new(0.19545257016136797, 0.7486267918001699), + c64::new(0.45956607922957327, 0.02495271845680236), + c64::new(0.23801167172055393, 0.5234015133852364), + c64::new(0.8151487989582498, 0.9925066835945822), + c64::new(0.4173531176676154, 0.9983961026357865), + c64::new(0.08850701855742737, 0.6651580674279115), + c64::new(0.14664093713712056, 0.9616446116985102), + c64::new(0.06556846579674958, 0.4332711601853556), + c64::new(0.00999669313077256, 0.9503289570965522), + c64::new(0.8492820744902253, 0.19441515542717458), + c64::new(0.1196791277954703, 0.3135973114594467), + c64::new(0.8974320738101824, 0.5088961076620361), + c64::new(0.3077492417211729, 0.0587507288460859), + c64::new(0.6718542468314663, 0.8784564572108206), + c64::new(0.8058709416507477, 0.5693768630795327), + c64::new(0.5608670604971727, 0.5311021334681032) + ], + [ + c64::new(0.34560208388480096, 0.16739020607281618), + c64::new(0.23331826916254472, 0.6130815663685395), + c64::new(0.9397427753841658, 0.6655565440854049), + c64::new(0.8821156688165074, 0.7944792018803679), + c64::new(0.42739938631087837, 0.2878194026469886), + c64::new(0.9233635811530989, 0.09216121753894313), + c64::new(0.885269983678575, 0.10561646132268732), + c64::new(0.7306049360915047, 0.28794390992481966), + c64::new(0.7180647224566964, 0.38575181855530294), + c64::new(0.6028287170510034, 0.1452395558557621), + c64::new(0.5858041396491549, 0.3765295350341745), + c64::new(0.5234838270893098, 0.9291711699124525), + c64::new(0.7220257096923388, 0.681906888190176), + c64::new(0.44671808608453434, 0.25263171502629855), + c64::new(0.15387870406855686, 0.01859599479014662), + c64::new(0.7108714026423096, 0.9921637786908944) + ], + [ + c64::new(0.5522540902713062, 0.5289418043806777), + c64::new(0.17955033836453782, 0.6641512242937374), + c64::new(0.2870982224237145, 0.8253475828830054), + c64::new(0.6953135064981454, 0.5389399858548773), + c64::new(0.9044154166667651, 0.7291375690536017), + c64::new(0.014969049881469187, 0.5823645756346624), + c64::new(0.4106110274919824, 0.9772441717239208), + c64::new(0.7899475513249096, 0.33718757706048264), + c64::new(0.12564982302572625, 0.08164867163164302), + c64::new(0.8277448644423485, 0.6684800005333317), + c64::new(0.8063722001578879, 0.293139957786377), + c64::new(0.7616443403756338, 0.41248468565508944), + c64::new(0.48370112983282043, 0.5237165655219297), + c64::new(0.9852738590227202, 0.7814762792425599), + c64::new(0.3150523000233134, 0.25232529923596003), + c64::new(0.7055164700072192, 0.4364210816486238) + ], + [ + c64::new(0.47480263870579453, 0.5668225452197742), + c64::new(0.8861112169309894, 0.7839593615514723), + c64::new(0.47984998067122964, 0.6940783683811662), + c64::new(0.6365911151977862, 0.8508530098815925), + c64::new(0.9221748970317584, 0.37814148012826587), + c64::new(0.41247888626124285, 0.6036385621285446), + c64::new(0.2077081234948941, 0.6237160782342986), + c64::new(0.3014578023119979, 0.4601857335517109), + c64::new(0.2594737250836574, 0.6075684486769833), + c64::new(0.8128732699081882, 0.41023156765679436), + c64::new(0.36232588883648964, 0.7338270593218202), + c64::new(0.5175615608791986, 0.04730733357986405), + c64::new(0.16569218047093304, 0.20214314530371735), + c64::new(0.4906398311215432, 0.6566575126029983), + c64::new(0.6122744130095827, 0.5855960128693636), + c64::new(0.8069280585173866, 0.6446311686762304) + ], + [ + c64::new(0.8873728806853252, 0.5005611313637354), + c64::new(0.9770223512150816, 0.6343132757665193), + c64::new(0.4061148961549872, 0.6729021869161408), + c64::new(0.457189125698762, 0.06439923211784304), + c64::new(0.8080764133185422, 0.8427563110745654), + c64::new(0.14742320294056432, 0.7461451243453329), + c64::new(0.6621587725591924, 0.07592063914586178), + c64::new(0.9119688176628091, 0.5791055651876627), + c64::new(0.05277334761942254, 0.7149032903155043), + c64::new(0.9617330181619003, 0.3459175480617631), + c64::new(0.8273379741828939, 0.10046702842390531), + c64::new(0.0053714122905957895, 0.46193759316661875), + c64::new(0.38494207909599165, 0.9376983173170867), + c64::new(0.7355626689153292, 0.744918797249697), + c64::new(0.3565603523759998, 0.6328091577590916), + c64::new(0.48732908110439943, 0.9961922465946875) + ], + [ + c64::new(0.8535294237098889, 0.4555765978417987), + c64::new(0.7986881125668084, 0.51780181927999), + c64::new(0.7401082539212396, 0.4260186037296265), + c64::new(0.5005532719840523, 0.8663437529938097), + c64::new(0.7666829073963346, 0.053633375518612136), + c64::new(0.09618596396671064, 0.14132877650296938), + c64::new(0.41325974785966146, 0.5188530456833758), + c64::new(0.4951335463859594, 0.7681452338571635), + c64::new(0.13337087025353667, 0.4534550761637307), + c64::new(0.264802459443372, 0.6960503802635601), + c64::new(0.10620477984934751, 0.16952615428155038), + c64::new(0.41326087740330664, 0.11093454026305205), + c64::new(0.11885855965831427, 0.8643900810326837), + c64::new(0.9531576858961567, 0.6405661730490178), + c64::new(0.2256965951584058, 0.6929381202000422), + c64::new(0.8775026501055405, 0.06819532335632383) + ], + [ + c64::new(0.05366306018663092, 0.6786935353784738), + c64::new(0.7049618674230367, 0.5343466515014068), + c64::new(0.1971345668641724, 0.9945961106878076), + c64::new(0.21850330503480253, 0.9315673412181285), + c64::new(0.46085694564476165, 0.41750086472796577), + c64::new(0.7797969253742099, 0.37698595587188244), + c64::new(0.22352377642177046, 0.6202647253113842), + c64::new(0.3947773505412384, 0.30392363084842966), + c64::new(0.79796785522656, 0.3573353874612716), + c64::new(0.23931143583970305, 0.712883482793276), + c64::new(0.14995225507944243, 0.6591874658307774), + c64::new(0.15535778984760662, 0.6646611213320233), + c64::new(0.7203947478912175, 0.2850133023325271), + c64::new(0.6466176117241828, 0.7808674648656392), + c64::new(0.5041129975238132, 0.36145725474426016), + c64::new(0.5302947663343138, 0.7083319689929208) + ], + [ + c64::new(0.7320943239049572, 0.908797021842243), + c64::new(0.7427211309634909, 0.3356960467687501), + c64::new(0.22286966092460725, 0.27543792599706995), + c64::new(0.05098355106161934, 0.12880818021612772), + c64::new(0.42913896501867776, 0.48225626640930075), + c64::new(0.7247114618619713, 0.6201582971419118), + c64::new(0.2990209549883077, 0.6065353578264744), + c64::new(0.8803034486159311, 0.46632710634376084), + c64::new(0.3900337102002004, 0.8603415217544679), + c64::new(0.03161503771138252, 0.2020000054053933), + c64::new(0.03285549876078819, 0.7197691844048204), + c64::new(0.8861914311445265, 0.4524597317254516), + c64::new(0.919139071989545, 0.9903753036352839), + c64::new(0.26413815520887607, 0.6125517285372406), + c64::new(0.9557958183246573, 0.5678539269316171), + c64::new(0.40410119324680294, 0.27980193142477106) + ], + [ + c64::new(0.27285675504845885, 0.14225223021480682), + c64::new(0.15871896780671346, 0.30806072726128164), + c64::new(0.28647798096884347, 0.37659944477098006), + c64::new(0.9539651068234646, 0.42730784410934874), + c64::new(0.9918958737388014, 0.5885319671531076), + c64::new(0.13253799282053358, 0.6799795473579588), + c64::new(0.5697443682755279, 0.9692621115480067), + c64::new(0.9408520393874307, 0.635189510953812), + c64::new(0.6378103987865228, 0.94962613572105), + c64::new(0.8980087424095724, 0.2840861303932122), + c64::new(0.5177631962541133, 0.5298970606217572), + c64::new(0.9173844985722672, 0.5722269153975366), + c64::new(0.10624346021142306, 0.6437026744926997), + c64::new(0.8234387192061203, 0.6901214486979598), + c64::new(0.6394729661348116, 0.6883637984832083), + c64::new(0.7781863797181444, 0.9197816550850407) + ], + [ + c64::new(0.8221647342763111, 0.3724858860937563), + c64::new(0.8384533817923859, 0.12061755516837247), + c64::new(0.14283137274059887, 0.2633143962286675), + c64::new(0.8479111175389686, 0.4143606483497789), + c64::new(0.8586200226659483, 0.04144888283592396), + c64::new(0.5924050968149841, 0.2936642057302724), + c64::new(0.26548598304261006, 0.5566420247616555), + c64::new(0.8270951953157784, 0.43319207911455204), + c64::new(0.6449007431399179, 0.16135807058447116), + c64::new(0.8489376152853729, 0.2423209662369905), + c64::new(0.9080821967375533, 0.1456211521082592), + c64::new(0.6165589096032493, 0.33794567982637114), + c64::new(0.39510580490087865, 0.4541868882549819), + c64::new(0.6767219080169666, 0.015218396907329734), + c64::new(0.5013860268093684, 0.21134538382323254), + c64::new(0.8745499679879252, 0.553499342738368) + ], + ]; + let inv = mtx.inv()?; + let expected_inv = array![ + [ + c64::new(-0.33341646484875576, 1.1052853101713702), + c64::new(-0.9524670156810291, -1.4260083616552919), + c64::new(-0.28008723834080096, 2.370239467388982), + c64::new(1.9975641630467906, 2.807918119574881), + c64::new(-2.145372013203242, 0.372298143790908), + c64::new(1.9668787833875745, -1.4178060687148868), + c64::new(1.628648632004574, -3.7986548511472975), + c64::new(-0.3841234618774047, -1.6266964977599572), + c64::new(0.5422313413841024, 1.2455849319689138), + c64::new(0.903361443678693, 1.0898735025274768), + c64::new(1.1133856248111635, -0.4701055609971547), + c64::new(-0.24962622846943747, -1.7771615655750181), + c64::new(0.5505173511853978, 1.158698308900222), + c64::new(0.5203113052796122, 0.2383987562681391), + c64::new(-3.692746889492212, 2.0725054682902377), + c64::new(0.3038728322291176, -2.214101409455073) + ], + [ + c64::new(0.6983382732954325, -1.5158076344322589), + c64::new(-0.20357552550341684, 1.5929538750963994), + c64::new(1.2274983134845052, -2.3218771130111637), + c64::new(0.10693506334445249, -2.6282640973556752), + c64::new(1.4343432776702896, 0.24146199302301508), + c64::new(-2.4976548307366, 1.3294740940569563), + c64::new(-2.802338558934232, 2.1485292671458254), + c64::new(-1.2647768773084678, 1.4373996801440505), + c64::new(-0.7052630223190702, -0.9023615614347303), + c64::new(-0.09089496809290643, -0.6402466613665145), + c64::new(-0.40136582493590267, 0.062206713362174204), + c64::new(0.22716356730332987, 1.4219236621098785), + c64::new(0.9769380171392674, -1.7439870854541086), + c64::new(-0.6518850947761342, -0.09063262579860987), + c64::new(3.8490253998520467, -0.6602384272549691), + c64::new(-1.266366905888641, 1.2948650691721733) + ], + [ + c64::new(-2.1150334917169067, -0.7524716105762088), + c64::new(2.865705855106625, -1.7919232385720578), + c64::new(-4.6372368665191495, 0.17211604185024365), + c64::new(-4.2548274092020835, 4.405149160028291), + c64::new(-1.273424038031718, -4.607022884361642), + c64::new(3.538122864770967, 3.7768700142222427), + c64::new(7.1939705238336025, 2.432924405835742), + c64::new(2.9121489577395616, -0.6869034106342744), + c64::new(-2.2868064317950814, 1.7817946421397064), + c64::new(-1.1327618966999562, 2.1697296568784603), + c64::new(0.8446373052778617, 1.2833732909034243), + c64::new(3.9395250724162416, -1.3807357928110635), + c64::new(-2.3853552783633574, 1.0480719154218856), + c64::new(-0.8893681746460103, 1.466190836254347), + c64::new(-4.414495537980002, -6.84540935784314), + c64::new(2.6889373223511144, -0.2690773578058888) + ], + [ + c64::new(-0.9411498074258554, -0.21883261987691854), + c64::new(0.734218533330576, -0.25138850289824616), + c64::new(-1.413778097867341, 0.13946356232182566), + c64::new(-0.9230913277697869, 1.1939182811997437), + c64::new(-0.500623877942419, -0.9632715774539262), + c64::new(1.2147048376728817, 0.7973868770253624), + c64::new(2.124908888672486, 0.0620633188311287), + c64::new(0.8530892013630627, -0.47480774043129137), + c64::new(-0.41954658192217403, 0.6143444446321021), + c64::new(-0.16212043344560645, 0.455921823842463), + c64::new(0.1452607123772317, 0.5140894248791609), + c64::new(0.879848490746153, -0.835664894813614), + c64::new(-0.40773386118785726, 0.595894534716184), + c64::new(-0.3107685669271478, 0.632628292161437), + c64::new(-1.6066598484534516, -1.4202036674117309), + c64::new(1.0679617005904698, -0.21927353401787894) + ], + [ + c64::new(-1.2006792624267157, -3.0785366301386503), + c64::new(2.9998484902996343, 2.0506177173361895), + c64::new(-2.786643678486076, -5.270377319461184), + c64::new(-6.332372870212514, -2.7133499614347927), + c64::new(3.7738891982330425, -3.402493113787302), + c64::new(-1.7781003206660229, 5.718899556657502), + c64::new(0.8339112283930712, 8.762743527504561), + c64::new(2.0569636038790033, 3.146955624252856), + c64::new(-2.7031084237762477, -1.200977331949071), + c64::new(-2.4430054443688007, -0.4059754102625929), + c64::new(-1.185157131906472, 1.4890565683775576), + c64::new(3.590908753088401, 3.0941791756116297), + c64::new(-2.641272411857855, -2.0351254037035407), + c64::new(-1.5648879937245017, -0.011039956994125966), + c64::new(4.899209965296281, -8.154920908424456), + c64::new(1.7041853352045995, 3.986228161505659) + ], + [ + c64::new(0.7098321944918885, 1.8899960715632942), + c64::new(-1.2876995397035196, -0.4974779624183936), + c64::new(1.5979867371106224, 2.18302312402332), + c64::new(2.9317303907773473, 0.1464447495528882), + c64::new(-1.1309352560779358, 2.3978248444784915), + c64::new(0.833438793503704, -3.7067752030654693), + c64::new(-1.6585616430787469, -3.8407526888470445), + c64::new(-0.8982175686022119, -1.0025945939580605), + c64::new(1.5575446743219135, -0.38889435787413484), + c64::new(1.1772769305079582, -0.6778245090880448), + c64::new(-0.15792138663043898, -0.9309931883669093), + c64::new(-2.66343386833843, -0.5715520673153744), + c64::new(0.9557077119414871, 0.8656183410600455), + c64::new(1.441553858828804, -0.3040776192978809), + c64::new(-1.7175922339016105, 5.159005168251366), + c64::new(-0.43154772399617425, -1.4184624078914763) + ], + [ + c64::new(0.7067369639484306, -0.11677774934896479), + c64::new(-1.683473630140353, 1.3019416191833875), + c64::new(2.6652317489455895, -0.7333921335041848), + c64::new(2.355056156923994, -3.1632176945121766), + c64::new(0.8497205963164971, 2.5732497308004616), + c64::new(-2.0154697095526872, -1.3128840122359084), + c64::new(-4.4422946390839915, -0.5506581875054117), + c64::new(-1.479170402306385, 1.173540079477825), + c64::new(1.0644798429183335, -1.3106697173813893), + c64::new(0.5830433337637937, -1.4688418402948535), + c64::new(-0.45785525478165967, -0.4195897948227327), + c64::new(-1.8983086728039444, 0.8913322959702731), + c64::new(1.2560059050813184, -1.6095836772765104), + c64::new(0.6008114921264225, -0.6653443016353698), + c64::new(3.2493010280194836, 2.997293768718692), + c64::new(-2.4054246583174637, 0.9739433780581721) + ], + [ + c64::new(1.4239159811426512, 0.8492138766545766), + c64::new(-1.3991192281292535, -0.43373158118485333), + c64::new(2.174929687527398, 1.3879134381263984), + c64::new(2.0535605031600834, 0.30290545784992706), + c64::new(-0.9507775086955514, 1.5330343629000758), + c64::new(-0.5995075478759522, -2.5158922223417863), + c64::new(-1.961409868797519, -3.0719263946349766), + c64::new(-1.1532845082224947, -1.3535437102253036), + c64::new(1.2536363004520334, -0.39574740266623964), + c64::new(0.878499113182353, -0.015575249533619606), + c64::new(0.14506197677793486, -0.6095788748412565), + c64::new(-2.0006000760113993, -0.36270160074571994), + c64::new(1.5014401345887063, 0.9124332027445035), + c64::new(0.6224797643970621, -0.41935426116973706), + c64::new(-0.08903298168132473, 4.263757880031095), + c64::new(-0.9093231367777892, -1.4242001367849448) + ], + [ + c64::new(-1.252615813160683, -3.0046048352701398), + c64::new(3.6937074952945474, 0.8629851151639598), + c64::new(-4.424158892742261, -4.819197382549424), + c64::new(-7.548435879349295, 0.4123445749516162), + c64::new(2.989181436478559, -5.518161108503455), + c64::new(-0.3971571217791885, 7.354687327960869), + c64::new(4.5312026486551575, 8.878293476735566), + c64::new(2.5972543971580055, 1.7949272103216405), + c64::new(-4.724266957695443, -0.17086789993622736), + c64::new(-3.7587317704878878, 1.225753184207096), + c64::new(-0.1388339158026093, 2.338843606827039), + c64::new(5.43195196867949, 2.4055348833010304), + c64::new(-2.3261483013555857, -0.9883963113909155), + c64::new(-2.709252611717642, 0.34074394535010155), + c64::new(3.0393053848361538, -11.037706160752986), + c64::new(3.3744887199210103, 2.3998987532495195) + ], + [ + c64::new(-0.6653756801965123, -0.1036593934409793), + c64::new(1.5205374386230774, -0.8841741070156326), + c64::new(-2.394043208594155, -0.8045471482882556), + c64::new(-2.814975456215832, 1.5932935660927487), + c64::new(0.11248961579460955, -2.369649518617432), + c64::new(0.993651193365689, 2.0349442465753826), + c64::new(3.4164791453229926, 2.358359283330307), + c64::new(1.5385342334885286, 0.1632682172084824), + c64::new(-1.7279134524806181, 0.7690062252967498), + c64::new(-0.8684676203130114, 1.1327657637345285), + c64::new(0.587069210347443, 1.0816539677189212), + c64::new(1.953176918767738, -0.17502354955401722), + c64::new(-1.4319425641758028, 0.39723015900232195), + c64::new(-0.7953530169702814, 0.3018693314086077), + c64::new(-1.1095546459915613, -3.91769613866538), + c64::new(2.0871995699347408, -0.34994087477466085) + ], + [ + c64::new(1.0428659661743744, -1.627000038293237), + c64::new(0.8935286888615769, 2.9905846717173947), + c64::new(1.0755083030676815, -4.0177728554390955), + c64::new(-3.0359003674327036, -5.027961108809421), + c64::new(4.673494661011926, 0.21701930072847653), + c64::new(-3.927807792882151, 2.0369036075192652), + c64::new(-4.030989423360226, 6.59990309935656), + c64::new(0.26335030205361054, 2.5483491799122), + c64::new(-0.49435775657652165, -3.1792386277930893), + c64::new(-2.0204286938145746, -2.9045120248583745), + c64::new(-1.8049059670607743, 0.49938863667012034), + c64::new(-0.22188049558232192, 4.281258983711006), + c64::new(-1.2928614778042757, -2.1001096045646483), + c64::new(-0.693613251969597, -1.5908493889838762), + c64::new(7.277239343072571, -2.0979995176164756), + c64::new(-0.12787942570107225, 3.8509947575701413) + ], + [ + c64::new(-0.9030035567896482, -1.285148731288444), + c64::new(2.226551915191729, 0.9198169968078413), + c64::new(-2.570296540921288, -2.542050486376615), + c64::new(-4.000007296285765, -0.3495888233487804), + c64::new(1.5322785903488643, -2.8364745006616494), + c64::new(0.05457640225206961, 3.8086232939559075), + c64::new(2.4132022722967004, 5.021382620580456), + c64::new(1.575482666377672, 1.2949366880751572), + c64::new(-2.2798286177934255, -0.23202522027280154), + c64::new(-1.9453429360673578, 0.9086022093574165), + c64::new(-0.36782592552388826, 1.1282298110284499), + c64::new(2.7909851000471724, 1.1901581765442475), + c64::new(-2.0449147956434595, -1.1027820508657102), + c64::new(-0.957402145821622, 0.2219440862791633), + c64::new(1.5311134129121113, -6.106774871371683), + c64::new(1.9750485314567656, 1.6036470887259389) + ], + [ + c64::new(-1.647229157806129, 0.788861290474623), + c64::new(0.6148722774868443, -1.7793373228544274), + c64::new(-2.3174465361956824, 2.1040057464401194), + c64::new(-0.4420474653129551, 2.7791610362888512), + c64::new(-2.069639274156649, -1.155550866182406), + c64::new(3.1026708695195566, 0.207718180381943), + c64::new(4.081353810713267, -1.5985484153287735), + c64::new(1.7387648401193387, -1.1811673575712405), + c64::new(0.7078217807594732, 1.7697384542515109), + c64::new(0.3896853684770497, 1.072939257271109), + c64::new(0.7616221623406603, 0.18279301165029538), + c64::new(0.7572481411523853, -2.699298614275696), + c64::new(-0.9170378278185156, 1.6906134084938873), + c64::new(0.5337827371636874, 0.8724411387783653), + c64::new(-5.276156593076657, -1.156578578366272), + c64::new(1.1874546730575855, -0.8966724612603467) + ], [ - c64::new(-0.69791667, 0.), - c64::new(0., -0.0625), - c64::new(0.13541667, 0.) + c64::new(0.9313726674656437, 3.0718691038815065), + c64::new(-3.0215888657993535, -2.0907788661535767), + c64::new(2.3356696345973313, 5.596976766853978), + c64::new(6.609499575230608, 2.6858335287924033), + c64::new(-4.114103323857318, 3.5840334133467096), + c64::new(2.1436259729553644, -6.129539492479053), + c64::new(-0.7790731721951514, -9.373889045466344), + c64::new(-2.2086446458204954, -2.9265263723081896), + c64::new(3.37294887937093, 1.4327653829016842), + c64::new(2.4774112974245375, 0.4697634315107313), + c64::new(1.204678119876694, -1.9976531671605633), + c64::new(-3.4061059135734686, -3.4243155383617183), + c64::new(2.724539266310142, 1.9301312701773405), + c64::new(1.6583588462898349, 0.20482421031998577), + c64::new(-5.3022656451878865, 8.359424149418086), + c64::new(-2.0536748485066942, -3.4518838281996613) ], [ - c64::new(0., -0.0625), - c64::new(0.125, 0.), - c64::new(0., -0.0625) + c64::new(-0.3400038949681029, 0.45128888584303883), + c64::new(0.302834399057287, -0.9502246062639901), + c64::new(-0.6068476034774675, 1.6660485163780343), + c64::new(0.19115500499373536, 2.173061763191289), + c64::new(-0.9538667784471226, -0.9977729990492099), + c64::new(1.2388604002033339, -0.8371530287267638), + c64::new(2.553109099137643, -1.2809339536966684), + c64::new(0.23292377813052328, -0.8646085600315921), + c64::new(-0.5896410383024675, 1.033670974129205), + c64::new(-0.022540559446400155, 1.0698412350894706), + c64::new(0.4127485917223416, 0.11538759781118935), + c64::new(0.697367920179159, -0.952172194056835), + c64::new(-0.27389037619737855, 1.0604722509205344), + c64::new(0.02919900182455054, 0.13786814316808738), + c64::new(-2.259132868623872, -0.5163004615257191), + c64::new(0.5043165094609598, -1.1438622215101546) ], [ - c64::new(0.46875, 0.), - c64::new(0., -0.0625), - c64::new(-0.03125, 0.) + c64::new(3.212745888447596, 2.913982534731071), + c64::new(-5.707956217016549, 0.561560814070595), + c64::new(8.47650395832462, 3.578564034019665), + c64::new(10.124896409465327, -4.184969047203229), + c64::new(-1.170061311708083, 8.686707346447756), + c64::new(-3.313821036277578, -8.896990083424384), + c64::new(-10.7526969515756, -9.519756126873094), + c64::new(-4.9127993200515085, -1.1059785971618572), + c64::new(5.749895822184144, -1.1833266940320586), + c64::new(4.508761401024904, -3.0900236338081783), + c64::new(-0.6673814135567939, -3.3461695674261254), + c64::new(-7.889103766073837, -0.4075117015034545), + c64::new(4.399990035115406, -0.34774164990939216), + c64::new(2.6333247662163712, -1.4466247972859447), + c64::new(2.014420530325137, 15.024581881327247), + c64::new(-5.8578217429440445, -1.7952789388416184) ], ]; diff --git a/src/Simulation/qdk_sim_rs/src/utils.rs b/src/Simulation/qdk_sim_rs/src/utils.rs index 5ed14a7f412..ea4ddaf7b31 100644 --- a/src/Simulation/qdk_sim_rs/src/utils.rs +++ b/src/Simulation/qdk_sim_rs/src/utils.rs @@ -147,6 +147,9 @@ macro_rules! c64 { ($re:literal + $im:literal i) => { c64::new($re, $im) }; + ($re:literal - $im:literal i) => { + c64::new($re, -$im) + }; ($im:literal i) => { c64::new(0.0, $im) };