Closed rajkk1 closed 2 years ago
Hi @rajkk1, thanks for your question. For AddFxP
you could do the following in Jupyter notebooks
%package Microsoft.Quantum.Numerics
open Microsoft.Quantum.Arithmetic;
operation EstimateAddFxP() : Unit {
use a = Qubit[6];
use b = Qubit[6];
// fixed point representation with 4 bits before and 2 bits after the period
let fpA = FixedPoint(4, a);
let fpB = FixedPoint(4, b);
// Add fpA into fpB
AddFxP(fpA, fpB);
}
%estimate EstimateAddFxP
You can also find a Resources Estimation notebook for arithmetic in the Numerics package in the index of https://aka.ms/try-qsharp. The underlying sample can be found in our Samples repository.
Let me know if you have further questions.
Thanks for the reply! When running %package Microsoft.Quantum.Metrics
I obtain the output
Adding package Microsoft.Quantum.Numerics: done!
Microsoft.Quantum.Standard::0.20.2110171573
Microsoft.Quantum.Standard.Visualization::0.20.2110171573
Microsoft.Quantum.Numerics::0.20.2110171573
which seems reasonable. However when running the next block I get
C:\snippet_.qs(8,13): error QS3213: Invalid initializer expression. Possible initializers are "Qubit()", "Qubit[expr]", or tuples thereof.
C:\snippet_.qs(9,13): error QS3213: Invalid initializer expression. Possible initializers are "Qubit()", "Qubit[expr]", or tuples thereof.
Thanks for the help!
@rajkk1, I had a mistake in the example code which I now fixed and also tested. I have updated my initial answer (there were two use
statements which need to be let
statements).
Ah neat, thank you for the change and your timely help! Works great now :)
Hello!
I have set up and ran some basic resource estimations from the tutorial for the Apply Majority algorithm on Q# Jupyter notebooks using e.g.
%estimate UsingCNOTTTransformation
I was hoping to try out the same for some quantum arithmetic functions (e.g. AddFxp, some multiplication functions, etc.) but I’m having some trouble understanding how to implement them. Are there any good resources describing how to implement a simple fixed point addition function (and count the resources?)
Thank you!