Skip to content

Commit 0f3ab13

Browse files
Merge aefc33d into fbc415f
2 parents fbc415f + aefc33d commit 0f3ab13

File tree

31 files changed

+107
-145
lines changed

31 files changed

+107
-145
lines changed

compiler/qsc_partial_eval/src/tests/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,5 +606,5 @@ fn evaluation_error_within_stdlib_yield_correct_package_span() {
606606
}
607607
"#,
608608
});
609-
assert_error(&error, &expect!["UnexpectedDynamicValue(PackageSpan { package: PackageId(1), span: Span { lo: 13910, hi: 13925 } })"]);
609+
assert_error(&error, &expect!["UnexpectedDynamicValue(PackageSpan { package: PackageId(1), span: Span { lo: 13902, hi: 13917 } })"]);
610610
}

compiler/qsc_partial_eval/src/tests/qubits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,6 @@ fn qubit_relabel_in_dynamic_block_triggers_capability_error() {
377377

378378
assert_error(
379379
&error,
380-
&expect!["CapabilityError(UseOfDynamicQubit(Span { lo: 60173, hi: 60186 }))"],
380+
&expect!["CapabilityError(UseOfDynamicQubit(Span { lo: 60168, hi: 60181 }))"],
381381
);
382382
}

katas/content/KatasLibrary.qs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ namespace KatasUtils {
210210
// get the solution's answer and verify if NOT a match, then differentiate what kind of mismatch
211211
let ans = testImpl(q);
212212
if ans != (state == 1) {
213-
set misclassifications w/= state <- misclassifications[state] + 1;
213+
misclassifications[state] += 1;
214214
}
215215

216216
// If the final state is to be preserved, check if it was not modified
@@ -271,11 +271,11 @@ namespace KatasUtils {
271271
if ans >= 0 and ans < nStates {
272272
// classification result is a valid state index - check if is it correct
273273
if ans != state {
274-
set misclassifications w/= ((state * nStates) + ans) <- (misclassifications[(state * nStates) + ans] + 1);
274+
misclassifications[(state * nStates) + ans] += 1;
275275
}
276276
} else {
277277
// classification result is an invalid state index - file it separately
278-
set unknownClassifications w/= state <- (unknownClassifications[state] + 1);
278+
unknownClassifications[state] += 1;
279279
}
280280

281281
if preserveState {

katas/content/distinguishing_unitaries/Common.qs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ namespace Kata.Verification {
2828

2929
if returnedIndex != actualIndex {
3030
if returnedIndex < 0 or returnedIndex >= nUnitaries {
31-
set unknownClassifications w/= actualIndex <- unknownClassifications[actualIndex] + 1;
31+
unknownClassifications[actualIndex] += 1;
3232
} else {
3333
let index = actualIndex * nUnitaries + returnedIndex;
34-
set wrongClassifications w/= index <- wrongClassifications[index] + 1;
34+
wrongClassifications[index] += 1;
3535
}
3636
}
3737
}

katas/content/key_distribution/examples/BB84Demo.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Kata {
3434
operation RandomArray(N : Int) : Bool[] {
3535
mutable array = [false, size = N];
3636
for i in 0..N - 1 {
37-
set array w/= i <- DrawRandomInt(0, 1) == 0;
37+
array[i] = DrawRandomInt(0, 1) == 0;
3838
}
3939
return array;
4040
}

katas/content/key_distribution/random_array/Solution.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Kata {
44
operation RandomArray(N : Int) : Bool[] {
55
mutable array = [false, size = N];
66
for i in 0..N - 1 {
7-
set array w/= i <- DrawRandomInt(0, 1) == 0;
7+
array[i] = DrawRandomInt(0, 1) == 0;
88
}
99
return array;
1010
}

katas/content/multi_qubit_measurements/examples/MeasuringOne.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Kata {
2525
// and convert the result to an integer, interpreting it as big endian binary notation.
2626
let result = (MResetZ(qs[0]) == One ? 1 | 0) * 2 + (MResetZ(qs[1]) == One ? 1 | 0);
2727

28-
set countArray w/= result <- countArray[result] + 1;
28+
countArray[result] += 1;
2929
}
3030

3131
// Obtain simulated probability of measurement for each outcome.

katas/content/multi_qubit_measurements/examples/PartialMeasurementsDemo.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Kata {
2323

2424
// Measure the first qubit.
2525
let outcome = M(qs[0]) == Zero ? 0 | 1;
26-
set countArray w/= outcome <- countArray[outcome] + 1;
26+
countArray[outcome] += 1;
2727

2828
if countArray[outcome] == 1 {
2929
// The first time the outcome is 0/1, print the system state afterwards.

katas/content/phase_estimation/examples/QuantumPhaseEstimationDemo.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Kata {
1919
mutable counts = [0, size = 2^n];
2020
for _ in 1..100 {
2121
let res = PhaseEstimation(U, P, n);
22-
set counts w/= res <- counts[res] + 1;
22+
counts[res] += 1;
2323
}
2424
for i in 0..2^n - 1 {
2525
if counts[i] > 0 {

katas/content/random_numbers/Common.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace Kata.Verification {
5353
return 0x1;
5454
}
5555
set average += IntAsDouble(val);
56-
set counts w/= val <- counts[val] + 1;
56+
counts[val] += 1;
5757
}
5858

5959
set average = average / IntAsDouble(nRuns);

katas/content/solving_sat/Common.qs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ namespace Kata.Verification {
4040
set nextInd = DrawRandomInt(0, nVar - 1);
4141
} until (not usedVariables[nextInd])
4242
fixup {}
43-
set clause w/= k <- (nextInd, DrawRandomBool(0.5));
44-
set usedVariables w/= nextInd <- true;
43+
clause[k] = (nextInd, DrawRandomBool(0.5));
44+
usedVariables[nextInd] = true;
4545
}
4646
return clause;
4747
}
@@ -50,7 +50,7 @@ namespace Kata.Verification {
5050
mutable problem = [[(0, false), size = 0], size = nClause];
5151

5252
for j in 0..nClause - 1 {
53-
set problem w/= j <- Generate_SAT_Clause(nVar, nTerms);
53+
problem[j] = Generate_SAT_Clause(nVar, nTerms);
5454
}
5555
return problem;
5656
}

library/chemistry/src/JordanWigner/BlockEncoding.qs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ function JWBlockEncodingGeneratorSystem(data : JWOptimizedHTerms) : GeneratorSys
5050

5151
for idx in IndexRange(ZData) {
5252
// Array of Arrays of Length 1
53-
genIdxes w/= idx <- (ZTermToPauliGenIdx(HTermToGenIdx(ZData[idx], [0])))[0];
53+
genIdxes[idx] = (ZTermToPauliGenIdx(HTermToGenIdx(ZData[idx], [0])))[0];
5454
}
5555

5656
startIdx = Length(ZData);
5757

5858
for idx in IndexRange(ZZData) {
5959
// Array of Arrays of Length 1
60-
genIdxes w/= startIdx + idx <- (ZZTermToPauliGenIdx(HTermToGenIdx(ZZData[idx], [1])))[0];
60+
genIdxes[startIdx + idx] = (ZZTermToPauliGenIdx(HTermToGenIdx(ZZData[idx], [1])))[0];
6161
}
6262

6363
startIdx = startIdx + Length(ZZData);
@@ -66,8 +66,8 @@ function JWBlockEncodingGeneratorSystem(data : JWOptimizedHTerms) : GeneratorSys
6666

6767
// Array of Arrays of Length 2
6868
let genArr = PQandPQQRTermToPauliGenIdx(HTermToGenIdx(PQandPQQRData[idx], [2]));
69-
genIdxes w/= startIdx + 2 * idx <- genArr[0];
70-
genIdxes w/= (startIdx + 2 * idx) + 1 <- genArr[1];
69+
genIdxes[startIdx + 2 * idx] = genArr[0];
70+
genIdxes[(startIdx + 2 * idx) + 1] = genArr[1];
7171
}
7272

7373
startIdx = startIdx + 2 * Length(PQandPQQRData);
@@ -78,7 +78,7 @@ function JWBlockEncodingGeneratorSystem(data : JWOptimizedHTerms) : GeneratorSys
7878
let genArr = V0123TermToPauliGenIdx(HTermToGenIdx(h0123Data[idx], [3]));
7979

8080
for idx0123 in IndexRange(genArr) {
81-
genIdxes w/= finalIdx <- genArr[idx0123];
81+
genIdxes[finalIdx] = genArr[idx0123];
8282
finalIdx += 1;
8383
}
8484
}
@@ -203,11 +203,11 @@ function V0123TermToPauliGenIdx(term : GeneratorIndex) : GeneratorIndex[] {
203203
for idxOp in IndexRange(ops) {
204204
if (IsNotZero(v0123[idxOp % 4])) {
205205
let newCoeff = [v0123[idxOp % 4]];
206-
genIdxes w/= nonZero <- new GeneratorIndex {
206+
genIdxes[nonZero] = new GeneratorIndex {
207207
Term = (ops[idxOp] + Repeated(3, Length(qubitsPQJW) + Length(qubitsRSJW)), newCoeff),
208208
Subsystem = ((qubitsPQ + qubitsRS) + qubitsPQJW) + qubitsRSJW
209209
};
210-
nonZero = nonZero + 1;
210+
nonZero += 1;
211211
}
212212
}
213213

library/chemistry/src/JordanWigner/ClusterOperatorEvolutionSet.qs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ function ComputeJWBitString(nFermions : Int, idxFermions : Int[]) : Bool[] {
4343
}
4444
// NOTE: This could be optimized
4545
for idx in 0..fermionIdx {
46-
zString w/= idx <- not zString[idx];
46+
zString[idx] = not zString[idx];
4747
}
4848
}
4949

5050
for fermionIdx in idxFermions {
51-
zString w/= fermionIdx <- false;
51+
zString[fermionIdx] = false;
5252
}
5353
return zString;
5454
}
@@ -60,7 +60,7 @@ function ComputeJWPauliZString(nFermions : Int, idxFermions : Int[]) : Pauli[] {
6060
mutable pauliString = Repeated(PauliI, Length(bitString));
6161
for idx in IndexRange(bitString) {
6262
if bitString[idx] {
63-
pauliString w/= idx <- PauliZ;
63+
pauliString[idx] = PauliZ;
6464
}
6565
}
6666
return pauliString;
@@ -79,7 +79,7 @@ function ComputeJWPauliString(
7979
for idx in IndexRange(idxFermions) {
8080
let idxFermion = idxFermions[idx];
8181
let op = pauliReplacements[idx];
82-
pauliString w/= idxFermion <- op;
82+
pauliString[idxFermion] = op;
8383
}
8484

8585
return pauliString;

library/chemistry/src/JordanWigner/OptimizedBlockEncoding.qs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ function V0123TermToPauliMajIdx(term : GeneratorIndex) : OptimizedBETermIndex[]
275275
for idxOp in 0..3 {
276276
if IsNotZero(v0123[idxOp]) {
277277
let newCoeff = (2.0 * 0.25) * v0123[idxOp];
278-
majIdxes w/= nonZero <- new OptimizedBETermIndex {
278+
majIdxes[nonZero] = new OptimizedBETermIndex {
279279
Coefficient = newCoeff,
280280
UseSignQubit = v0123[idxOp] < 0.0,
281281
ZControlRegisterMask = selectZControlRegisters,
282282
OptimizedControlRegisterMask = optimizedBEControlRegisters,
283283
PauliBases = ops[idxOp],
284284
RegisterIndices = indexRegisters
285285
};
286-
nonZero = nonZero + 1;
286+
nonZero += 1;
287287
}
288288
}
289289

@@ -322,25 +322,25 @@ function OptimizedBlockEncodingGeneratorSystem(data : JWOptimizedHTerms) : Optim
322322

323323
for idx in IndexRange(ZData) {
324324
// Array of Arrays of Length 1
325-
majIdxes w/= idx <- ZTermToPauliMajIdx(HTermToGenIdx(ZData[idx], [0]));
325+
majIdxes[idx] = ZTermToPauliMajIdx(HTermToGenIdx(ZData[idx], [0]));
326326
}
327327

328328
startIdx = Length(ZData);
329329

330330
for idx in IndexRange(ZZData) {
331331
// Array of Arrays of Length 1
332-
majIdxes w/= startIdx + idx <- ZZTermToPauliMajIdx(HTermToGenIdx(ZZData[idx], [1]));
332+
majIdxes[startIdx + idx] = ZZTermToPauliMajIdx(HTermToGenIdx(ZZData[idx], [1]));
333333
}
334334

335-
startIdx = startIdx + Length(ZZData);
335+
startIdx += Length(ZZData);
336336

337337
for idx in IndexRange(PQandPQQRData) {
338338

339339
// Array of Arrays of Length 1
340-
majIdxes w/= startIdx + idx <- PQandPQQRTermToPauliMajIdx(HTermToGenIdx(PQandPQQRData[idx], [2]));
340+
majIdxes[startIdx + idx] = PQandPQQRTermToPauliMajIdx(HTermToGenIdx(PQandPQQRData[idx], [2]));
341341
}
342342

343-
startIdx = startIdx + Length(PQandPQQRData);
343+
startIdx += Length(PQandPQQRData);
344344
mutable finalIdx = startIdx;
345345

346346
for idx in 0..Length(h0123Data) - 1 {
@@ -349,8 +349,8 @@ function OptimizedBlockEncodingGeneratorSystem(data : JWOptimizedHTerms) : Optim
349349
let genArr = V0123TermToPauliMajIdx(HTermToGenIdx(h0123Data[idx], [3]));
350350

351351
for idx0123 in IndexRange(genArr) {
352-
majIdxes w/= finalIdx <- genArr[idx0123];
353-
finalIdx = finalIdx + 1;
352+
majIdxes[finalIdx] = genArr[idx0123];
353+
finalIdx += 1;
354354
}
355355
}
356356

library/chemistry/src/JordanWigner/VQE.qs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ function MeasurementOperators(
244244
if termType == 0 or termType == 1 {
245245
mutable op = Repeated(PauliI, nQubits);
246246
for idx in indices {
247-
op w/= idx <- PauliZ;
247+
op[idx] = PauliZ;
248248
}
249-
ops w/= 0 <- op;
249+
ops[0] = op;
250250
}
251251

252252
// PQRS terms set operators between indices P and Q (resp R and S) to PauliZ
@@ -267,15 +267,15 @@ function MeasurementOperators(
267267

268268
mutable op = Repeated(PauliI, nQubits);
269269
for idx in IndexRange(indices) {
270-
op w/= indices[idx] <- compactOp[idx];
270+
op[indices[idx]] = compactOp[idx];
271271
}
272272
for i in indices[0] + 1..indices[1] - 1 {
273-
op w/= i <- PauliZ;
273+
op[i] = PauliZ;
274274
}
275275
for i in indices[2] + 1..indices[3] - 1 {
276-
op w/= i <- PauliZ;
276+
op[i] = PauliZ;
277277
}
278-
ops w/= iOp <- op;
278+
ops[iOp] = op;
279279
}
280280
}
281281

@@ -289,17 +289,17 @@ function MeasurementOperators(
289289
mutable op = Repeated(PauliI, nQubits);
290290

291291
let nIndices = Length(indices);
292-
op w/= indices[0] <- compactOp[0];
293-
op w/= indices[nIndices-1] <- compactOp[1];
292+
op[indices[0]] = compactOp[0];
293+
op[indices[nIndices-1]] = compactOp[1];
294294
for i in indices[0] + 1..indices[nIndices - 1] - 1 {
295-
op w/= i <- PauliZ;
295+
op[i] = PauliZ;
296296
}
297297

298298
// Case of PQQR term
299299
if nIndices == 4 {
300-
op w/= indices[1] <- (indices[0] < indices[1] and indices[1] < indices[3]) ? PauliI | PauliZ;
300+
op[indices[1]] = (indices[0] < indices[1] and indices[1] < indices[3]) ? PauliI | PauliZ;
301301
}
302-
ops w/= iOp <- op;
302+
ops[iOp] = op;
303303
}
304304
}
305305

@@ -333,10 +333,10 @@ function ExpandedCoefficients(coeff : Double[], termType : Int) : Double[] {
333333

334334
// Return the expanded array of coefficients
335335
if termType == 0 or termType == 1 {
336-
coeffs w/= 0 <- coeff[0];
336+
coeffs[0] = coeff[0];
337337
} elif termType == 2 or termType == 3 {
338338
for i in 0..nCoeffs - 1 {
339-
coeffs w/= i <- coeff[i / 2];
339+
coeffs[i] = coeff[i / 2];
340340
}
341341
}
342342

library/chemistry/src/MixedStatePreparation.qs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function QuantumROMDiscretization(bitsPrecision : Int, coefficients : Double[])
220220

221221
// Uniformly distribute excess bars across coefficients.
222222
for idx in 0..AbsI(bars) - 1 {
223-
keepCoeff w/= idx <- keepCoeff[idx] + (bars > 0 ? -1 | + 1);
223+
keepCoeff[idx] += (bars > 0 ? -1 | + 1);
224224
}
225225

226226
mutable barSink = [];
@@ -241,8 +241,8 @@ function QuantumROMDiscretization(bitsPrecision : Int, coefficients : Double[])
241241
barSink = Most(barSink);
242242
barSource = Most(barSource);
243243

244-
keepCoeff w/= idxSource <- keepCoeff[idxSource] - barHeight + keepCoeff[idxSink];
245-
altIndex w/= idxSink <- idxSource;
244+
keepCoeff[idxSource] += keepCoeff[idxSink] - barHeight;
245+
altIndex[idxSink] = idxSource;
246246

247247
if keepCoeff[idxSource] < barHeight {
248248
barSink += [idxSource];
@@ -252,7 +252,7 @@ function QuantumROMDiscretization(bitsPrecision : Int, coefficients : Double[])
252252
} elif Length(barSource) > 0 {
253253
let idxSource = Tail(barSource);
254254
barSource = Most(barSource);
255-
keepCoeff w/= idxSource <- barHeight;
255+
keepCoeff[idxSource] = barHeight;
256256
} else {
257257
return (oneNorm, keepCoeff, altIndex);
258258
}

library/fixed_point/src/Convert.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function FixedPointAsBoolArray(integerBits : Int, fractionalBits : Int, value :
4040
set currentBit = not currentBit;
4141
}
4242
if currentBit {
43-
set result w/= idx <- true;
43+
result[idx] = true;
4444
}
4545
}
4646

library/src/tests/resources/src/state_preparation.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace Test {
9999
let bitsize = 2^n;
100100
for i in 0..bitsize - 1 {
101101
mutable c = Repeated(0.0, bitsize);
102-
set c w/= i <- 1.0;
102+
c[i] = 1.0;
103103
PreparePureStateD(c, qs);
104104
DumpMachine();
105105
ResetAll(qs);

0 commit comments

Comments
 (0)