SCM dot_eigenvectors(SCM mo, integer b_start) { evectmatrix *m = assert_evectmatrix_smob(mo); sqmatrix U, S; SCM obj; CHECK(mdata, "init-params must be called before dot-eigenvectors"); U = create_sqmatrix(m->p); S = create_sqmatrix(m->p); evectmatrix_XtY_slice(U, *m, H, 0, b_start - 1, m->p, S); destroy_sqmatrix(S); obj = sqmatrix2scm(U); destroy_sqmatrix(U); return obj; }
static size_t free_sqmatrix(SCM obj) { sqmatrix *pm = SQMATRIX(obj); destroy_sqmatrix(*pm); free(pm); return 0; }
void eigensolver_get_eigenvals(evectmatrix Y, real *eigenvals, evectoperator A, void *Adata, evectmatrix Work1, evectmatrix Work2) { sqmatrix U, Usqrt, Uwork; U = create_sqmatrix(Y.p); Usqrt = create_sqmatrix(Y.p); Uwork = create_sqmatrix(Y.p); evectmatrix_XtX(U, Y, Uwork); sqmatrix_invert(U, 1, Uwork); eigensolver_get_eigenvals_aux(Y, eigenvals, A, Adata, Work1, Work2, U, Usqrt, Uwork); destroy_sqmatrix(U); destroy_sqmatrix(Usqrt); destroy_sqmatrix(Uwork); }
SCM sqmatrix_mult(SCM Ao, SCM Bo) { sqmatrix *A = assert_sqmatrix_smob(Ao); sqmatrix *B = assert_sqmatrix_smob(Bo); SCM obj; CHECK(A->p == B->p, "only equal-size matrices can be multiplied"); sqmatrix C = create_sqmatrix(A->p); sqmatrix_AeBC(C, *A, 0, *B, 0); obj = sqmatrix2scm(C); destroy_sqmatrix(C); return obj; }