Skip to content

Commit 1f7a2ed

Browse files
authored
Fix #938 by adding type casts (#939)
This adds a few type cases to address the compiler warnings about comparing signed with unsigned integers.
1 parent b2658b0 commit 1f7a2ed

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/mps_statespace.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class MPSStateSpace {
241241
const auto num_qubits = state.num_qubits();
242242
const auto bond_dim = state.bond_dim();
243243
const auto end = Size(state);
244-
const bool last_index = (index == num_qubits - 1);
244+
const bool last_index = (static_cast<unsigned>(index) == num_qubits - 1);
245245
const auto right_dim = (last_index ? 1 : bond_dim);
246246
auto offset = 0;
247247
fp_type* state_raw = state.get();
@@ -266,10 +266,11 @@ class MPSStateSpace {
266266
}
267267

268268
// Contract all internal blocks together.
269-
for (unsigned i = 1; i < index; ++i) {
269+
for (unsigned i = 1; i < static_cast<unsigned>(index); ++i) {
270270
offset = GetBlockOffset(state, i);
271271

272272
// reshape:
273+
273274
new (&partial_contract2)
274275
MatrixMap((Complex*)(state_raw_workspace), bond_dim, 2 * bond_dim);
275276

@@ -301,11 +302,11 @@ class MPSStateSpace {
301302

302303
partial_contract.setZero();
303304
partial_contract(0, 0) = 1;
304-
if (index < num_qubits - 1) {
305+
if (static_cast<unsigned>(index) < num_qubits - 1) {
305306
partial_contract.noalias() = top * bot.adjoint();
306307
}
307308

308-
for (unsigned i = num_qubits - 2; i > index; --i) {
309+
for (unsigned i = num_qubits - 2; i > static_cast<unsigned>(index); --i) {
309310
offset = GetBlockOffset(state, i);
310311

311312
// reshape:

0 commit comments

Comments
 (0)