diff --git a/mpb/bott.c b/mpb/bott.c index 3996fe1d..90619cf3 100644 --- a/mpb/bott.c +++ b/mpb/bott.c @@ -95,20 +95,28 @@ number_list bott_indices(integer band_start, integer n_bands) bott.num_items = n_bands; CHK_MALLOC(bott.items, number, n_bands); for (n = 1; n <= n_bands; ++n) { /* compute n-th bott index */ + Un.p = Wn.p = n_bands; /* we change the .p field at every iteration (cf. resizing), but sqmatrix expects */ + /* the .p field to match the size of the matrix being copied; fix that here */ sqmatrix_copy(Un, U); sqmatrix_copy(Wn, W); + sqmatrix_resize(&Un, n, 1); sqmatrix_resize(&Wn, n, 1); - sqmatrix_resize(&S1, n, 0); - sqmatrix_resize(&S2, n, 0); - sqmatrix_AeBC(S1, Wn, 0, Un, 0); + sqmatrix_resize(&S1, n, 0); /*the .p-field-issue has no impact on the scratch */ + sqmatrix_resize(&S2, n, 0); /*matrices, as their initial value is unimportant */ + + sqmatrix_AeBC(S1, Wn, 0, Un, 0); /*do the matrix products*/ sqmatrix_AeBC(S2, Wn, 1, Un, 1); sqmatrix_AeBC(Un, S1, 0, S2, 0); + sqmatrix_eigenvalues(Un, eigvals); + + bott.items[n-1] = 0; /* initalize/zero (number_list gives random init) */ for (i = 0; i < n; ++i) bott.items[n-1] += scalar_carg(eigvals[i]); - bott.items[i] /= 6.28318530717958647692528676655900; /* twopi */ + bott.items[n-1] /= 6.28318530717958647692528676655900; /* twopi */ } + destroy_sqmatrix(Wn); destroy_sqmatrix(Un); destroy_sqmatrix(S2); diff --git a/src/matrices/sqmatrix.c b/src/matrices/sqmatrix.c index a256a7ec..e02cea63 100644 --- a/src/matrices/sqmatrix.c +++ b/src/matrices/sqmatrix.c @@ -60,7 +60,7 @@ void sqmatrix_assert_hermitian(sqmatrix A) /* A = B */ void sqmatrix_copy(sqmatrix A, sqmatrix B) { - sqmatrix_resize(&A, B.p, 0); + CHECK(A.p == B.p, "arrays not conformant"); blasglue_copy(A.p * A.p, B.data, 1, A.data, 1); }