@@ -389,21 +389,23 @@ void PopulateHessianPhasedXPhasedExponent(const std::string& symbol,
389389 float gs, GradientOfGate* grad) {
390390 grad->params .push_back (symbol);
391391 grad->index = location;
392- auto left = qsim::Cirq::PhasedXPowGate<float >::Create (
393- 0 , qid, (pexp + _HESS_EPS) * pexp_s, exp * exp_s, gs);
394- auto center = qsim::Cirq::PhasedXPowGate<float >::Create (0 , qid, pexp * pexp_s,
395- exp * exp_s, gs);
396- auto right = qsim::Cirq::PhasedXPowGate<float >::Create (
397- 0 , qid, (pexp - _HESS_EPS) * pexp_s, exp * exp_s, gs);
398- // Due to precision issue, multiply weights first.
399- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, left.matrix );
400- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, right.matrix );
401- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, center.matrix );
402- Matrix2Add (right.matrix ,
403- left.matrix ); // left's entries have right added.
404- qsim::MatrixScalarMultiply (2.0 , center.matrix );
405- Matrix2Diff (center.matrix ,
406- left.matrix ); // left's entries have center subtracted.
392+ // auto left = qsim::Cirq::PhasedXPowGate<float>::Create(
393+ // 0, qid, (pexp + _HESS_EPS) * pexp_s, exp * exp_s, gs);
394+ // auto center = qsim::Cirq::PhasedXPowGate<float>::Create(0, qid, pexp * pexp_s,
395+ // exp * exp_s, gs);
396+ // auto right = qsim::Cirq::PhasedXPowGate<float>::Create(
397+ // 0, qid, (pexp - _HESS_EPS) * pexp_s, exp * exp_s, gs);
398+ // // Due to precision issue, multiply weights first.
399+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, left.matrix);
400+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, right.matrix);
401+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, center.matrix);
402+ // Matrix2Add(right.matrix,
403+ // left.matrix); // left's entries have right added.
404+ // qsim::MatrixScalarMultiply(2.0, center.matrix);
405+ // Matrix2Diff(center.matrix,
406+ // left.matrix); // left's entries have center subtracted.
407+ auto left = D2PhasedExponentPhasedXPowGate<float >::Create (
408+ 0 , qid, pexp, pexp_s, exp*exp_s, gs);
407409 grad->grad_gates .push_back (left);
408410}
409411
@@ -414,21 +416,23 @@ void PopulateHessianPhasedXExponent(const std::string& symbol,
414416 GradientOfGate* grad) {
415417 grad->params .push_back (symbol);
416418 grad->index = location;
417- auto left = qsim::Cirq::PhasedXPowGate<float >::Create (
418- 0 , qid, pexp * pexp_s, (exp + _HESS_EPS) * exp_s, gs);
419- auto center = qsim::Cirq::PhasedXPowGate<float >::Create (0 , qid, pexp * pexp_s,
420- exp * exp_s, gs);
421- auto right = qsim::Cirq::PhasedXPowGate<float >::Create (
422- 0 , qid, pexp * pexp_s, (exp - _HESS_EPS) * exp_s, gs);
423- // Due to precision issue, multiply weights first.
424- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, left.matrix );
425- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, right.matrix );
426- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, center.matrix );
427- Matrix2Add (right.matrix ,
428- left.matrix ); // left's entries have right added.
429- qsim::MatrixScalarMultiply (2.0 , center.matrix );
430- Matrix2Diff (center.matrix ,
431- left.matrix ); // left's entries have center subtracted.
419+ // auto left = qsim::Cirq::PhasedXPowGate<float>::Create(
420+ // 0, qid, pexp * pexp_s, (exp + _HESS_EPS) * exp_s, gs);
421+ // auto center = qsim::Cirq::PhasedXPowGate<float>::Create(0, qid, pexp * pexp_s,
422+ // exp * exp_s, gs);
423+ // auto right = qsim::Cirq::PhasedXPowGate<float>::Create(
424+ // 0, qid, pexp * pexp_s, (exp - _HESS_EPS) * exp_s, gs);
425+ // // Due to precision issue, multiply weights first.
426+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, left.matrix);
427+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, right.matrix);
428+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, center.matrix);
429+ // Matrix2Add(right.matrix,
430+ // left.matrix); // left's entries have right added.
431+ // qsim::MatrixScalarMultiply(2.0, center.matrix);
432+ // Matrix2Diff(center.matrix,
433+ // left.matrix); // left's entries have center subtracted.
434+ auto left = D2ExponentPhasedXPowGate<float >::Create (
435+ 0 , qid, pexp * pexp_s, exp, exp_s, gs);
432436 grad->grad_gates .push_back (left);
433437}
434438
@@ -437,24 +441,26 @@ void PopulateCrossTermPhasedXPhasedExponentExponent(
437441 float exp, float exp_s, float gs, GradientOfGate* grad) {
438442 grad->params .push_back (kUsePrevTwoSymbols );
439443 grad->index = location;
440- auto left = qsim::Cirq::PhasedXPowGate<float >::Create (
441- 0 , qid, (pexp + _GRAD_EPS) * pexp_s, (exp + _GRAD_EPS) * exp_s, gs);
442- auto left_center = qsim::Cirq::PhasedXPowGate<float >::Create (
443- 0 , qid, (pexp + _GRAD_EPS) * pexp_s, (exp - _GRAD_EPS) * exp_s, gs);
444- auto right_center = qsim::Cirq::PhasedXPowGate<float >::Create (
445- 0 , qid, (pexp - _GRAD_EPS) * pexp_s, (exp + _GRAD_EPS) * exp_s, gs);
446- auto right = qsim::Cirq::PhasedXPowGate<float >::Create (
447- 0 , qid, (pexp - _GRAD_EPS) * pexp_s, (exp - _GRAD_EPS) * exp_s, gs);
448- // Due to precision issue, multiply weights first.
449- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, left.matrix );
450- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, right.matrix );
451- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, left_center.matrix );
452- qsim::MatrixScalarMultiply (_INVERSE_HESS_EPS_SQUARE, right_center.matrix );
453- Matrix2Add (right.matrix ,
454- left.matrix ); // left's entries have right added.
455- Matrix2Add (right_center.matrix , left_center.matrix );
456- Matrix2Diff (left_center.matrix ,
457- left.matrix ); // left's entries have left_center subtracted.
444+ // auto left = qsim::Cirq::PhasedXPowGate<float>::Create(
445+ // 0, qid, (pexp + _GRAD_EPS) * pexp_s, (exp + _GRAD_EPS) * exp_s, gs);
446+ // auto left_center = qsim::Cirq::PhasedXPowGate<float>::Create(
447+ // 0, qid, (pexp + _GRAD_EPS) * pexp_s, (exp - _GRAD_EPS) * exp_s, gs);
448+ // auto right_center = qsim::Cirq::PhasedXPowGate<float>::Create(
449+ // 0, qid, (pexp - _GRAD_EPS) * pexp_s, (exp + _GRAD_EPS) * exp_s, gs);
450+ // auto right = qsim::Cirq::PhasedXPowGate<float>::Create(
451+ // 0, qid, (pexp - _GRAD_EPS) * pexp_s, (exp - _GRAD_EPS) * exp_s, gs);
452+ // // Due to precision issue, multiply weights first.
453+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, left.matrix);
454+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, right.matrix);
455+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, left_center.matrix);
456+ // qsim::MatrixScalarMultiply(_INVERSE_HESS_EPS_SQUARE, right_center.matrix);
457+ // Matrix2Add(right.matrix,
458+ // left.matrix); // left's entries have right added.
459+ // Matrix2Add(right_center.matrix, left_center.matrix);
460+ // Matrix2Diff(left_center.matrix,
461+ // left.matrix); // left's entries have left_center subtracted.
462+ auto left = DPhasedExponentDExponentPhasedXPowGate<float >::Create (
463+ 0 , qid, pexp, pexp_s, exp, exp_s, gs);
458464 grad->grad_gates .push_back (left);
459465}
460466
0 commit comments