Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions mpb/bott.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/matrices/sqmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down