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

Method CPUComplexTensor

Core/VirtualQuantumProcessor/SingleAmplitude/Tensor.cpp:229–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229CPUComplexTensor::CPUComplexTensor(const CPUComplexTensor &old)
230 :m_max_rank(old.m_max_rank), m_rank(old.m_rank)
231{
232 auto size = 1ull << old.m_rank;
233 m_tensor = (qcomplex_data_t *)calloc(size, sizeof(qcomplex_data_t));
234
235 if (nullptr == m_tensor)
236 {
237 QCERR("calloc_fail");
238 throw calloc_fail();
239 }
240 int threads = get_num_threads(m_rank);
241#pragma omp parallel for num_threads(threads)
242 for (long long i = 0; i < size; i++)
243 {
244 m_tensor[i] = old.m_tensor[i];
245 }
246}
247
248CPUComplexTensor::CPUComplexTensor(size_t rank, qstate_t &tensor, size_t max_rank)
249 :m_max_rank(max_rank), m_rank(rank), m_backend(ComputeBackend::CPU)

Callers

nothing calls this directly

Calls 2

calloc_failClass · 0.85
get_num_threadsFunction · 0.85

Tested by

no test coverage detected