Yes, it is possible to obtain this information, but only for troubleshooting purposes, not for using it in the code.
Dump functions dump the status of the target machine into a file or to the console output. If the program is executed on the full-state simulator, this status will include the wave function of the whole system (for DumpMachine) or of the register (for DumpRegister).
So you could do the following:
using (register = Qubit[2]) {
H(register[0]);
CNOT(register[0], register[1]);
DumpMachine("");
// to avoid ReleasedQubitsAreNotInZeroState exception
ResetAll(register);
}
and get the following amplitudes (each one is a complex number):
Ids: [1;0;]
Wavefunction:
0: 0.707107 0
1: 0 0
2: 0 0
3: 0.707107 0
Note that this does not allow you to implement the GetProbabilityAmplitude()
function which you requested. If you are running a Q# program on a simulator, it will let you see the wave function but it will not let you make any decisions in the program based on that information. The intent is twofold: to facilitate debugging on a simulator while not allowing to implement any logic which would be impossible to execute on a quantum computer. Since the execution on a quantum computer won't give the program direct access to the quantum state, it's better not to rely on this feature in the code.