@@ -247,17 +247,22 @@ class Measurements final
247
247
auto expval (const Observable<StateVectorT> &ob) -> PrecisionT {
248
248
PrecisionT result{};
249
249
250
- if constexpr (std::is_same_v<StateVectorLQubitManaged<PrecisionT> ,
251
- StateVectorT >) {
250
+ if constexpr (std::is_same_v<typename StateVectorT::MemoryStorageT ,
251
+ MemoryStorageLocation::Internal >) {
252
252
StateVectorT sv (this ->_statevector );
253
253
result = calculateObsExpval (sv, ob, this ->_statevector );
254
- } else if constexpr (std::is_same_v<StateVectorLQubitRaw<PrecisionT>,
255
- StateVectorT>) {
254
+ } else if constexpr (std::is_same_v<
255
+ typename StateVectorT::MemoryStorageT,
256
+ MemoryStorageLocation::External>) {
256
257
std::vector<ComplexT> data_storage (
257
258
this ->_statevector .getData (),
258
259
this ->_statevector .getData () + this ->_statevector .getLength ());
259
260
StateVectorT sv (data_storage.data (), data_storage.size ());
260
261
result = calculateObsExpval (sv, ob, this ->_statevector );
262
+ } else {
263
+ // / LCOV_EXCL_START
264
+ PL_ABORT (" Undefined memory storage location for StateVectorT." );
265
+ // / LCOV_EXCL_STOP
261
266
}
262
267
263
268
return result;
@@ -271,18 +276,23 @@ class Measurements final
271
276
*/
272
277
auto var (const Observable<StateVectorT> &ob) -> PrecisionT {
273
278
PrecisionT result{};
274
- if constexpr (std::is_same_v<StateVectorLQubitManaged<PrecisionT> ,
275
- StateVectorT >) {
279
+ if constexpr (std::is_same_v<typename StateVectorT::MemoryStorageT ,
280
+ MemoryStorageLocation::Internal >) {
276
281
StateVectorT sv (this ->_statevector );
277
282
result = calculateObsVar (sv, ob, this ->_statevector );
278
283
279
- } else if constexpr (std::is_same_v<StateVectorLQubitRaw<PrecisionT>,
280
- StateVectorT>) {
284
+ } else if constexpr (std::is_same_v<
285
+ typename StateVectorT::MemoryStorageT,
286
+ MemoryStorageLocation::External>) {
281
287
std::vector<ComplexT> data_storage (
282
288
this ->_statevector .getData (),
283
289
this ->_statevector .getData () + this ->_statevector .getLength ());
284
290
StateVectorT sv (data_storage.data (), data_storage.size ());
285
291
result = calculateObsVar (sv, ob, this ->_statevector );
292
+ } else {
293
+ // / LCOV_EXCL_START
294
+ PL_ABORT (" Undefined memory storage location for StateVectorT." );
295
+ // / LCOV_EXCL_STOP
286
296
}
287
297
return result;
288
298
}
0 commit comments