]> https://gitweb.dealii.org/ - dealii.git/commitdiff
scalapack: query lwork from ppocon 5915/head
authorDenis Davydov <davydden@gmail.com>
Fri, 16 Feb 2018 20:20:03 +0000 (21:20 +0100)
committerDenis Davydov <davydden@gmail.com>
Fri, 16 Feb 2018 20:20:03 +0000 (21:20 +0100)
source/lac/scalapack.cc

index 1fbe23f489f27cfbe00d7413a6fedf0ba832a3b2..74e3ce3a2db9d5bae02b1d49672527bc971d825e 100644 (file)
@@ -831,12 +831,22 @@ NumberType ScaLAPACKMatrix<NumberType>::reciprocal_condition_number(const Number
 
   if (grid->mpi_process_is_active)
     {
-      int lwork = 2 * n_local_rows + 3 * n_local_columns + column_block_size;
       int liwork = n_local_rows;
-      work.resize(lwork);
       iwork.resize(liwork);
+
       int info = 0;
       const NumberType *A_loc = &this->values[0];
+
+      // by setting lwork to -1 a workspace query for optimal length of work is performed
+      int lwork = -1;
+      work.resize(1);
+      ppocon(&uplo, &n_columns, A_loc, &submatrix_row, &submatrix_column, descriptor,
+             &a_norm, &rcond, &work[0], &lwork, &iwork[0], &liwork, &info);
+      AssertThrow (info==0, LAPACKSupport::ExcErrorCode("pdpocon", info));
+      lwork = std::ceil(work[0]);
+      work.resize(lwork);
+
+      // now the actual run:
       ppocon(&uplo, &n_columns, A_loc, &submatrix_row, &submatrix_column, descriptor,
              &a_norm, &rcond, &work[0], &lwork, &iwork[0], &liwork, &info);
       AssertThrow (info==0, LAPACKSupport::ExcErrorCode("pdpocon", info));

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.