Re: help about ARPACK solver
- From: andy2O <andy2O@xxxxxxxxxxx>
- Date: 19 May 2007 16:31:21 -0700
[snip]On 16 May, 10:54, lorin <wwang...@xxxxxxxxx> wrote:
[snip]Hello,
I used the "parallel" vector to verify if the result satisfies A *
x=lamda * x. For the eigenvector from Matlab, (A * x - lamda * x)
could be as precise as (E-14), however, when I used the eigenvector
from my fortran program (yes, there is a constant factor between the
two eigenvectors), (A * x - lamda * x) can only be (E-04), sometimes
even (E-03), I think such precision can not be satisfied in our
application.
Thanks all the same,
With my best wishes,
lorin
Hi lorin,
[snip]
2) Matlab's eigs() function uses ARPACK, so logically your Fortran
code *should* be able to solve the problem as accurately as Matlab
*if* you get everything set up right... I don't know ARPACK well
enough to give detailed help to you, but:
- Matlab uses 'double precision' variables throughout by default.
Fortran uses single precision variables by default. If you want
accurate results from your Fortran code you *must* use double
precision. So:
(a) make sure you declare all your Fortran variables to be double
precision - note that if you rely of Fortran's implicit typing
mechanism this won't happen.
(b) remember that if you type a number such as 1.234 or 5.67e8 in a
Fortran program, that is *single* precision. If you want double
precision you need to use 1.234D0 or 5.67D8. This is a common cause of
loss of precision in Fortran, particularly in test case code.
If you identify any detailed Fortran problems, try asking in
comp.lang.fortran - they're very helpful.
andy
I've just remembered - you're using complex arithmetic.
Note that a 'COMPLEX' variable in Fortran is by default single
precision (In fact in FORTRAN77, there is no double precision complex
variable, but many compilers do support it as an extension). Fortran90
and later support double precision complex as standard, but it's still
easy to accidentally use single precision COMPLEX variables. For
example COMPLX(1.0D0,2.0D0) will return a single precision complex
number!! I certainly find it confusing....
If you're unsure about the precision of your complex Fortran
variables, read below (taken from
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/CMPLX_0028_0029-of-DOUBLE-PRECISION.html)
and do some more research.
Yours,
andy
In accordance with Fortran 90 and at least some (perhaps all) other
compilers, the GNU Fortran language defines CMPLX() as always
returning a result that is type COMPLEX(KIND=1).
This means `CMPLX(D1,D2)', where `D1' and `D2' are REAL(KIND=2)
(DOUBLE PRECISION), is treated as:
CMPLX(SNGL(D1), SNGL(D2))
(It was necessary for Fortran 90 to specify this behavior for DOUBLE
PRECISION arguments, since that is the behavior mandated by FORTRAN
77.)
The GNU Fortran language also provides the DCMPLX() intrinsic, which
is provided by some FORTRAN 77 compilers to construct a DOUBLE COMPLEX
entity from of DOUBLE PRECISION operands. However, this solution does
not scale well when more COMPLEX types (having various precisions and
ranges) are offered by Fortran implementations.
Fortran 90 extends the CMPLX() intrinsic by adding an extra argument
used to specify the desired kind of complex result.
.
- Follow-Ups:
- Re: help about ARPACK solver
- From: lorin
- Re: help about ARPACK solver
- From: lorin
- Re: help about ARPACK solver
- References:
- help about ARPACK solver
- From: lorin
- Re: help about ARPACK solver
- From: andy2O
- Re: help about ARPACK solver
- From: lorin
- Re: help about ARPACK solver
- From: andy2O
- help about ARPACK solver
- Prev by Date: Re: help about ARPACK solver
- Next by Date: ? analytic constraint optimization
- Previous by thread: Re: help about ARPACK solver
- Next by thread: Re: help about ARPACK solver
- Index(es):
Relevant Pages
|