303{
304 int size =
static_cast<int>(A->
numRows());
305 if (size !=
static_cast<int>(A->
numColumns()))
306 {
307 ERROR(
"expected a square matrix");
308 return false;
309 }
310
311 if (size == 0)
312 {
313 eigvals->resize(0, 1);
314 return true;
315 }
316
317 bool ret = true;
318 char dont = 'N';
319 int wsize = 3 * size;
320 double* workspace = new double[2 * wsize];
321 int info;
322
324 double *real = new double[size];
325 double *imag = new double[size];
326
328 &dont,
329 &size,
330 copyA.data(),
331 &size,
332 real,
333 imag,
334 static_cast<double *>(nullptr),
335 &size,
336 static_cast<double *>(nullptr),
337 &size,
338 workspace,
339 &wsize,
340 &info);
341
342 if (info < 0)
343 {
344 ERROR(
"argument passed to dgeev had an illegal value");
345 ret = false;
346 }
347 else if (info > 0)
348 {
349 ERROR(
"the QR algorithm in dgeev failed to compute all eigvals");
350 ret = false;
351 }
352 else
353 {
354 eigvals->resize(size, 1);
355 for (int i = 0; i < size; i++)
356 eigvals->ring().set_from_doubles(eigvals->entry(i, 0), real[i], imag[i]);
357 }
358
359 delete [] real;
360 delete [] imag;
361
362 return ret;
363}
size_t numColumns() const
std::vector< double > make_lapack_array(const DMatRR &mat)
int dgeev_(char *n, char *n2, int *size, double *M, int *size1, double *E, double *E2, double *, int *, double *, int *, double *, int *, int *)