Skip to content

Commit

Permalink
Remove updated struct syntax in library and sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
sezna committed Aug 16, 2024
1 parent 82e7271 commit 007afc6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 43 deletions.
16 changes: 1 addition & 15 deletions library/std/qsharp.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
{
"author": "Microsoft",
"license": "MIT",
"lints": [
{
"lint": "deprecatedFunctionConstructor",
"level": "error"
},
{
"lint": "deprecatedWithOperator",
"level": "error"
},
{
"lint": "deprecatedDoubleColonOperator",
"level": "error"
}
],
"files": [
"src/arrays.qs",
"src/canon.qs",
Expand All @@ -35,4 +21,4 @@
"src/unstable_state_preparation.qs",
"src/unstable_table_lookup.qs"
]
}
}
14 changes: 0 additions & 14 deletions library/unstable/qsharp.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
{
"author": "Microsoft",
"license": "MIT",
"lints": [
{
"lint": "deprecatedFunctionConstructor",
"level": "error"
},
{
"lint": "deprecatedWithOperator",
"level": "error"
},
{
"lint": "deprecatedDoubleColonOperator",
"level": "error"
}
],
"files": [
"src/Arithmetic.qs",
"src/ArithmeticUtils.qs",
Expand Down
6 changes: 3 additions & 3 deletions library/unstable/src/StatePreparation.qs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import
/// # See Also
/// - Unstable.StatePreparation.ApproximatelyPreparePureStateCP
operation PreparePureStateD(coefficients : Double[], qubits : Qubit[]) : Unit is Adj + Ctl {
let coefficientsAsComplexPolar = Mapped(a -> ComplexAsComplexPolar(new Complex { Real = a, Imag = 0.0 }), coefficients);
let coefficientsAsComplexPolar = Mapped(a -> ComplexAsComplexPolar(Complex(a, 0.0)), coefficients);
ApproximatelyPreparePureStateCP(0.0, coefficientsAsComplexPolar, qubits);
}

Expand Down Expand Up @@ -113,7 +113,7 @@ operation ApproximatelyPreparePureStateCP(

let nQubits = Length(qubits);
// pad coefficients at tail length to a power of 2.
let coefficientsPadded = Padded(-2^nQubits, new ComplexPolar { Magnitude = 0.0, Argument = 0.0 }, coefficients);
let coefficientsPadded = Padded(-2^nQubits, ComplexPolar(0.0, 0.0), coefficients);
let idxTarget = 0;
// Determine what controls to apply
let rngControl = nQubits > 1 ? (1..(nQubits - 1)) | (1..0);
Expand Down Expand Up @@ -276,7 +276,7 @@ function BlochSphereCoordinates(
let t = 0.5 * (arg0 + arg1);
let phi = arg1 - arg0;
let theta = 2.0 * ArcTan2(abs1, abs0);
return (new ComplexPolar { Magnitude = r, Argument = t }, phi, theta);
return (ComplexPolar(r, t), phi, theta);
}

/// # Summary
Expand Down
9 changes: 6 additions & 3 deletions library/unstable/src/TableLookup.qs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ operation Select(
} else {
use andChainTarget = Qubit();
let andChain = MakeAndChain(ctls, andChainTarget);
use helper = Qubit[andChain.NGarbageQubits];
use helper = Qubit[andChain::NGarbageQubits];

within {
andChain.Apply(helper);
andChain::Apply(helper);
} apply {
SinglyControlledSelect(andChainTarget, data, address, target);
}
Expand Down Expand Up @@ -254,7 +254,10 @@ newtype AndChain = (
);

function MakeAndChain(ctls : Qubit[], target : Qubit) : AndChain {
new AndChain { NGarbageQubits = MaxI(Length(ctls) - 2, 0), Apply = helper => AndChainOperation(ctls, helper, target) }
AndChain(
MaxI(Length(ctls) - 2, 0),
helper => AndChainOperation(ctls, helper, target)
)
}

operation AndChainOperation(ctls : Qubit[], helper : Qubit[], target : Qubit) : Unit is Adj {
Expand Down
9 changes: 1 addition & 8 deletions samples/estimation/df-chemistry/qsharp.json
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{
"lints":
[
{"lint": "deprecatedFunctionConstructor", "level": "error"},
{"lint": "deprecatedWithOperator", "level": "error"},
{"lint": "deprecatedDoubleColonOperator", "level": "error"}
]
}
{}

0 comments on commit 007afc6

Please sign in to comment.