Skip to content

Commit

Permalink
v0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
TysonRayJones committed Jan 8, 2024
2 parents 9d06a7a + 2587c39 commit d1438ef
Show file tree
Hide file tree
Showing 12 changed files with 153,128 additions and 98 deletions.
769 changes: 745 additions & 24 deletions Link/QuESTlink.m

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Link/circuits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void local_updateCircuitProgress(qreal progress) {
// echo the message
WSPutFunction(stdlink, "Set", 2);
WSPutSymbol(stdlink, CALC_PROGRESS_VAR);
WSPutReal64(stdlink, progress);
WSPutQreal(stdlink, progress);

WSEndPacket(stdlink);
WSNextPacket(stdlink);
Expand Down Expand Up @@ -1803,7 +1803,7 @@ void internal_sampleExpecPauliString(int showProgress, int initQuregId, int work

// output average energy (if random), else determined energy
qreal expecVal = expecValSum / ((useAllDecomps)? 1 : numSamples);
WSPutReal64(stdlink, expecVal);
WSPutQreal(stdlink, expecVal);

} catch (QuESTException& err) {
local_sendErrorAndFailOrAbortFromExcep(apiFuncName, err.thrower, err.message);
Expand Down
20 changes: 10 additions & 10 deletions Link/decoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void local_sendMatrixToMMA(qmatrix matrix) {

// send each to Mathematica
WSPutFunction(stdlink, "List", 2);
WSPutReal64List(stdlink, matrRe, len);
WSPutReal64List(stdlink, matrIm, len);
WSPutQrealList(stdlink, matrRe, len);
WSPutQrealList(stdlink, matrIm, len);

// clean-up
free(matrRe);
Expand All @@ -159,7 +159,7 @@ void Circuit::loadFromMMA() {
WSGetInteger32List(stdlink, &numCtrlsPerOp, &numGates);
WSGetInteger32List(stdlink, &targs, &totalNumTargs);
WSGetInteger32List(stdlink, &numTargsPerOp, &numGates);
WSGetReal64List(stdlink, &params, &totalNumParams);
WSGetQrealList(stdlink, &params, &totalNumParams);
WSGetInteger32List(stdlink, &numParamsPerOp, &numGates);

// allocate gates array attribute (creates all Gate instances)
Expand Down Expand Up @@ -200,7 +200,7 @@ void Circuit::freeMMA() {
Gate gate = gates[0];
WSReleaseInteger32List(stdlink, gate.getCtrlsAddr(), totalNumCtrls);
WSReleaseInteger32List(stdlink, gate.getTargsAddr(), totalNumTargs);
WSReleaseReal64List( stdlink, gate.getParamsAddr(), totalNumParams);
WSReleaseQrealList( stdlink, gate.getParamsAddr(), totalNumParams);
}

void Circuit::sendOutputsToMMA(qreal* outputs) {
Expand All @@ -217,7 +217,7 @@ void Circuit::sendOutputsToMMA(qreal* outputs) {

// P gate outputs are top-level qreals (probabilities of projector)
if (gate.getOpcode() == OPCODE_P)
WSPutReal64(stdlink, outputs[outInd++]);
WSPutQreal(stdlink, outputs[outInd++]);

// M gate outputs are integer sublists (measurement outcomes grouped by targets)
if (gate.getOpcode() == OPCODE_M) {
Expand Down Expand Up @@ -246,7 +246,7 @@ void DerivCircuit::loadFromMMA() {

WSGetInteger32List(stdlink, &derivGateInds, &numTerms);
WSGetInteger32List(stdlink, &derivVarInds, &numTerms);
WSGetReal64List(stdlink, &derivParams, &totalNumDerivParams);
WSGetQrealList(stdlink, &derivParams, &totalNumDerivParams);
WSGetInteger32List(stdlink, &numDerivParamsPerDerivGate, &numTerms);

/*
Expand Down Expand Up @@ -282,7 +282,7 @@ void DerivCircuit::loadFromMMA() {
void DerivCircuit::freeMMA() {

// first term holds (i.e. has array beginning pointer) all term's derivParams
WSReleaseReal64List(stdlink, terms[0].getDerivParamsAddr(), totalNumDerivParams);
WSReleaseQrealList(stdlink, terms[0].getDerivParamsAddr(), totalNumDerivParams);
}


Expand All @@ -293,7 +293,7 @@ void DerivCircuit::freeMMA() {

void local_loadEncodedPauliStringFromMMA(int* numPaulis, int* numTerms, qreal** termCoeffs, int** allPauliCodes, int** allPauliTargets, int** numPaulisPerTerm) {

WSGetReal64List(stdlink, termCoeffs, numTerms);
WSGetQrealList(stdlink, termCoeffs, numTerms);
WSGetInteger32List(stdlink, allPauliCodes, numPaulis);
WSGetInteger32List(stdlink, allPauliTargets, numPaulis);
WSGetInteger32List(stdlink, numPaulisPerTerm, numTerms);
Expand Down Expand Up @@ -336,7 +336,7 @@ pauliOpType* local_decodePauliString(int numQb, int numTerms, int* allPauliCodes
}

void local_freePauliString(int numPaulis, int numTerms, qreal* termCoeffs, int* allPauliCodes, int* allPauliTargets, int* numPaulisPerTerm, pauliOpType* arrPaulis) {
WSReleaseReal64List(stdlink, termCoeffs, numTerms);
WSReleaseQrealList(stdlink, termCoeffs, numTerms);
WSReleaseInteger32List(stdlink, allPauliCodes, numPaulis);
WSReleaseInteger32List(stdlink, allPauliTargets, numPaulis);
WSReleaseInteger32List(stdlink, numPaulisPerTerm, numTerms);
Expand Down Expand Up @@ -375,6 +375,6 @@ PauliHamil local_loadPauliHamilForQuregFromMMA(int quregId) {

void local_freePauliHamil(PauliHamil hamil) {

WSReleaseReal64List(stdlink, hamil.termCoeffs, hamil.numSumTerms);
WSReleaseQrealList(stdlink, hamil.termCoeffs, hamil.numSumTerms);
free(hamil.pauliCodes);
}
4 changes: 2 additions & 2 deletions Link/derivatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ void internal_calcExpecPauliStringDerivs(int initQuregId) {
// attempt to compute and return energy grad
try {
derivCirc.calcDerivEnergies(energyGrad, hamil, initQureg, workQuregs, numNeededWorkQuregs); // throws
WSPutReal64List(stdlink, energyGrad, numDerivs);
WSPutQrealList(stdlink, energyGrad, numDerivs);

} catch (QuESTException& err) {
local_sendErrorAndFailOrAbortFromExcep(apiFuncName, err.thrower, err.message);
Expand Down Expand Up @@ -1067,7 +1067,7 @@ void internal_calcExpecPauliStringDerivsDenseHamil(int initQuregId, int hamilQur
try {
derivCirc.calcDerivEnergiesDenseHamil(energyGrad, hamilQureg, initQureg, workQuregs, numNeededWorkQuregs); // throws

WSPutReal64List(stdlink, energyGrad, numDerivs);
WSPutQrealList(stdlink, energyGrad, numDerivs);

} catch (QuESTException& err) {
local_sendErrorAndFailOrAbortFromExcep(apiFuncName, err.thrower, err.message);
Expand Down

1 comment on commit d1438ef

@TysonRayJones
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The continuous-deployment for rebuilding the binary of the release failed (due to some godforsaken Github issue), but that's no problem; this release modified no backend code, so the binary is unchanged from v0.15.

Please sign in to comment.