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

Method trace

Core/VirtualQuantumProcessor/DensityMatrix/DensityMatrix.cpp:806–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

804
805template <typename data_t>
806std::complex<double> DensityMatrix<data_t>::trace()
807{
808 double val_real = 0.;
809 double val_imag = 0.;
810
811 for (size_t k = 0; k < m_rows; ++k)
812 {
813 val_real += std::real(VectorMatrix<data_t>::m_data[k * m_rows + k]);
814 val_imag += std::imag(VectorMatrix<data_t>::m_data[k * m_rows + k]);
815 }
816
817 return std::complex<double>(val_real, val_imag);
818}
819
820template class QPanda::DensityMatrix<double>;
821template class QPanda::DensityMatrix<float>;

Callers 7

validityFunction · 0.45

Calls 2

realFunction · 0.50
imagFunction · 0.50

Tested by

no test coverage detected