MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / getAngles

Function getAngles

QAlg/ArithmeticUnit/ArithmeticUnit.cpp:586–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

584}
585
586void getAngles(size_t a, size_t n, std::vector<double> &angles)
587{
588 auto bin_string = integerToBinary(a, n);
589 for (int i = 0; i < n; i++)
590 {
591 for (int j = i; j < n; j++)
592 {
593 if (bin_string[j] == '1')
594 {
595 angles[n - i - 1] += pow(2, -(j - i));
596 }
597
598 }
599 angles[n - i - 1] *= PI;
600 }
601
602}
603
604double getAngle(size_t a, size_t n)
605{

Callers 1

FourierADDFunction · 0.70

Calls 2

integerToBinaryFunction · 0.85
powFunction · 0.50

Tested by

no test coverage detected