int gen_proc(gen_workspace *w) { int s; s = gsl_eigen_gen_QZ(w->A, w->B, w->alpha, w->beta, w->Q, w->Z, w->gen_p); w->n_evals = w->gen_p->n_evals; return s; } /* gen_proc() */
/** * C++ version of gsl_eigen_gen_QZ(). * Computes the eigenvalues of A and stores them (unordered) in eval. * The diagonal and lower triangle of A are altered. The workspace should have size * @c n, where @c A has @c n rows and columns. * @param A A matrix (should be square) * @param B A matrix (should be square) * @param alpha This is where the eigenvalues are stored * @param beta This is where the eigenvalues are stored * @param Q A matrix (should be square) * @param Z A matrix (should be square) * @param w A workspace * @return Error code on failure */ inline int gen_QZ( gsl::matrix& A, gsl::matrix& B, gsl::vector_complex& alpha, gsl::vector& beta, gsl::matrix& Q, gsl::matrix& Z, gen_workspace& w ){ return gsl_eigen_gen_QZ( A.get(), B.get(), alpha.get(), beta.get(), Q.get(), Z.get(), w.get() ); }
void test_eigen_gen_pencil(const gsl_matrix * A, const gsl_matrix * B, size_t count, const char * desc, int test_schur, test_eigen_gen_workspace *w) { const size_t N = A->size1; size_t i; gsl_matrix_memcpy(w->A, A); gsl_matrix_memcpy(w->B, B); if (test_schur) { gsl_eigen_genv_QZ(w->A, w->B, w->alphav, w->betav, w->evec, w->Q, w->Z, w->genv_p); test_eigen_schur(A, w->A, w->Q, w->Z, count, "genv/A", desc); test_eigen_schur(B, w->B, w->Q, w->Z, count, "genv/B", desc); } else gsl_eigen_genv(w->A, w->B, w->alphav, w->betav, w->evec, w->genv_p); test_eigen_gen_results(A, B, w->alphav, w->betav, w->evec, count, desc, "unsorted"); gsl_matrix_memcpy(w->A, A); gsl_matrix_memcpy(w->B, B); if (test_schur) { gsl_eigen_gen_params(1, 1, 0, w->gen_p); gsl_eigen_gen_QZ(w->A, w->B, w->alpha, w->beta, w->Q, w->Z, w->gen_p); test_eigen_schur(A, w->A, w->Q, w->Z, count, "gen/A", desc); test_eigen_schur(B, w->B, w->Q, w->Z, count, "gen/B", desc); } else { gsl_eigen_gen_params(0, 0, 0, w->gen_p); gsl_eigen_gen(w->A, w->B, w->alpha, w->beta, w->gen_p); } /* compute eval = alpha / beta values */ for (i = 0; i < N; ++i) { gsl_complex z, ai; double bi; ai = gsl_vector_complex_get(w->alpha, i); bi = gsl_vector_get(w->beta, i); GSL_SET_COMPLEX(&z, GSL_REAL(ai) / bi, GSL_IMAG(ai) / bi); gsl_vector_complex_set(w->eval, i, z); ai = gsl_vector_complex_get(w->alphav, i); bi = gsl_vector_get(w->betav, i); GSL_SET_COMPLEX(&z, GSL_REAL(ai) / bi, GSL_IMAG(ai) / bi); gsl_vector_complex_set(w->evalv, i, z); } /* sort eval and evalv and test them */ gsl_eigen_nonsymmv_sort(w->eval, NULL, GSL_EIGEN_SORT_ABS_ASC); gsl_eigen_nonsymmv_sort(w->evalv, NULL, GSL_EIGEN_SORT_ABS_ASC); test_eigenvalues_complex(w->evalv, w->eval, "gen", desc); gsl_eigen_genv_sort(w->alphav, w->betav, w->evec, GSL_EIGEN_SORT_ABS_ASC); test_eigen_gen_results(A, B, w->alphav, w->betav, w->evec, count, desc, "abs/asc"); gsl_eigen_genv_sort(w->alphav, w->betav, w->evec, GSL_EIGEN_SORT_ABS_DESC); test_eigen_gen_results(A, B, w->alphav, w->betav, w->evec, count, desc, "abs/desc"); } /* test_eigen_gen_pencil() */