condition number of a matrix!

419 views
Skip to first unread message

Shiraz Farouq

unread,
Sep 29, 2014, 3:48:24 PM9/29/14
to dea...@googlegroups.com
Hi !

Well, just wondering to be sure if there is any function available in dealii to calculate condition number of a matrix?

thanks,

/S

Uwe Köcher

unread,
Sep 29, 2014, 5:43:25 PM9/29/14
to dea...@googlegroups.com
If you have a s.p.d. matrix and solving with the cg method, you can track the estimated condition number.
See the discussion on

For the third party libs involved:
If you are using the PETSc matricies, then you might look at the SLEPc project
and use the functions to compute your condition number.

If you are using the Trilinos matricies, then you might look at the Anasazi part to
and use the functions to compute your condition number.

Best,
  Uwe

Martin Kronbichler

unread,
Sep 30, 2014, 2:55:29 AM9/30/14
to dea...@googlegroups.com
Just one addition in case you have deal.II data structures and cannot
use CG: We recently added support to compute eigenvalue estimates for
GMRES. If you're interested, you could try to extend it to also compute
the condition number (largest estimated eigenvalue divided by smallest).
It would really only be a few lines around line 850 in
lac/solver_gmres.h

Best,
Martin
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to dealii+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Shiraz Farouq

unread,
Oct 2, 2014, 3:22:23 PM10/2/14
to dea...@googlegroups.com
Thanks Uwe !

Thanks Martin !

/S


Simon Sticko

unread,
Mar 2, 2015, 11:40:20 AM3/2/15
to dea...@googlegroups.com
I have a related question. I want to check how the condition number
of a spd-matrix changes upon refinement. So, I want to take the
condition number that the CG-solver have estimated and store that in a variable.
The solver does indeed output the condition number to deallog, but I cant figure
out how to extract that number once the solver is done (apart from copy-pasting from
terminal of course).

Timo Heister

unread,
Mar 5, 2015, 12:44:24 PM3/5/15
to dea...@googlegroups.com
Sadly, there is currently no easy way to capture this number *. I
wouldn't be difficult to add a boost signal/slot to the code that
would notify you of the condition estimate or provide a different way
to access this information. We are happy to help if you want to look
into that.

* You could attach another output stream to the deallog and use that
to capture the output but that is probably not worth the effort.
--
Timo Heister
http://www.math.clemson.edu/~heister/

Simon Sticko

unread,
Mar 6, 2015, 2:59:48 AM3/6/15
to dea...@googlegroups.com
Okey, thank you for the reply. I was thinking of the following solution:
Since SolverCG::AdditionalData is used to communicate to the solver that
I want to compute the condition number one might use it also to return
the result. Or is AdditionalData intended to be used only to transfer
information to the solver? (and not from the solver).
 
/Simon

Timo Heister

unread,
Mar 6, 2015, 8:03:44 AM3/6/15
to dea...@googlegroups.com
> Okey, thank you for the reply. I was thinking of the following solution:
> Since SolverCG::AdditionalData is used to communicate to the solver that
> I want to compute the condition number one might use it also to return
> the result. Or is AdditionalData intended to be used only to transfer
> information to the solver? (and not from the solver).

AdditionalData is not a good place to communicate data back to the
caller because the caller typical doesn't keep a reference of the
object around. The simplest way would be a function
double SolverCG::get_condition_estimate () const;
I guess.

There is other data like the CG coefficients and eigenvalues that
would be nice if there was a way to retrieve them. Here I would
probably implement a signal/slot similar to "Observing the progress of
linear solver iterations" in
https://www.dealii.org/developer/doxygen/deal.II/classSolver.html

Wolfgang Bangerth

unread,
Mar 6, 2015, 8:16:22 AM3/6/15
to dea...@googlegroups.com
On 03/06/2015 07:03 AM, Timo Heister wrote:
> AdditionalData is not a good place to communicate data back to the
> caller because the caller typical doesn't keep a reference of the
> object around. The simplest way would be a function
> double SolverCG::get_condition_estimate () const;
> I guess.

I would favor a signal/slot here as well. No point in having to store
information in a member variable for later in one function just to return it
from another.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

Simon Sticko

unread,
Mar 6, 2015, 10:02:53 AM3/6/15
to dea...@googlegroups.com
Thanks, then I at least know where to start.

/Simon
Reply all
Reply to author
Forward
0 new messages