Polynomial Roots with Modern Fortran
Note
The default real kind (wp
) can be
changed using optional preprocessor flags.
This library was built with real kind:
real(kind=real64)
[8 bytes]
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | polyroots_module_rk | = | real64 |
real kind used by this module [8 bytes] |
integer, | private, | parameter | :: | wp | = | polyroots_module_rk |
local copy of |
real(kind=wp), | private, | parameter | :: | eps | = | epsilon(1.0_wp) |
machine epsilon |
real(kind=wp), | private, | parameter | :: | pi | = | acos(-1.0_wp) | |
real(kind=wp), | private, | parameter | :: | deg2rad | = | pi/180.0_wp |
"Polish" a root using Newton Raphson. This routine will perform a Newton iteration and update the roots only if they improve, otherwise, they are left as is.
"Polish" a root using a complex Newton Raphson method. This routine will perform a Newton iteration and update the roots only if they improve, otherwise, they are left as is.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of polynomial |
||
real(kind=wp), | intent(in), | dimension(n+1) | :: | p |
vector of coefficients in order of decreasing powers |
|
real(kind=wp), | intent(inout) | :: | zr |
real part of the zero |
||
real(kind=wp), | intent(inout) | :: | zi |
imaginary part of the zero |
||
real(kind=wp), | intent(in) | :: | ftol |
convergence tolerance for the root |
||
real(kind=wp), | intent(in) | :: | ztol |
convergence tolerance for |
||
integer, | intent(in) | :: | maxiter |
maximum number of iterations |
||
integer, | intent(out) | :: | istat |
status flag: |
"Polish" a root using a complex Newton Raphson method. This routine will perform a Newton iteration and update the roots only if they improve, otherwise, they are left as is.
Note
Same as newton_root_polish_real except that p
is complex(wp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of polynomial |
||
complex(kind=wp), | intent(in), | dimension(n+1) | :: | p |
vector of coefficients in order of decreasing powers |
|
real(kind=wp), | intent(inout) | :: | zr |
real part of the zero |
||
real(kind=wp), | intent(inout) | :: | zi |
imaginary part of the zero |
||
real(kind=wp), | intent(in) | :: | ftol |
convergence tolerance for the root |
||
real(kind=wp), | intent(in) | :: | ztol |
convergence tolerance for |
||
integer, | intent(in) | :: | maxiter |
maximum number of iterations |
||
integer, | intent(out) | :: | istat |
status flag: |
Cube root of a real number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
evaluation of sqrt(x*x + y*y)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y |
Compute the complex square root of a complex number without destructive overflow or underflow.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | a | |||
real(kind=wp), | intent(in) | :: | b |
test the convexity of the angle formed by (il,a(il)), (i,a(i)), (ir,a(ir)) at the vertex (i,a(i)), up to within the tolerance toler. if convexity holds then the function is set to .true., otherwise ctest=.false. the parameter toler is set to 0.4 by default.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
length of the vector a |
||
real(kind=wp), | intent(in) | :: | a(n) |
vector of double |
||
integer, | intent(in) | :: | il |
integers such that il<i<ir |
||
integer, | intent(in) | :: | i |
integers such that il<i<ir |
||
integer, | intent(in) | :: | ir |
integers such that il<i<ir |
Finds the zeros of a general real polynomial using the Jenkins & Traub algorithm.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(degree+1) | :: | op |
vector of coefficients in order of decreasing powers |
|
integer, | intent(in) | :: | degree |
degree of polynomial |
||
real(kind=wp), | intent(out), | dimension(degree) | :: | zeror |
output vector of real parts of the zeros |
|
real(kind=wp), | intent(out), | dimension(degree) | :: | zeroi |
output vector of imaginary parts of the zeros |
|
integer, | intent(out) | :: | istat |
status output: |
Computes the roots of a cubic polynomial of the form
a(1) + a(2)*z + a(3)*z**2 + a(4)*z**3 = 0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(4) | :: | a |
coefficients |
|
real(kind=wp), | intent(out), | dimension(3) | :: | zr |
real components of roots |
|
real(kind=wp), | intent(out), | dimension(3) | :: | zi |
imaginary components of roots |
Computes the roots of a quadratic polynomial of the form
a(1) + a(2)*z + a(3)*z**2 = 0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(3) | :: | a |
coefficients |
|
real(kind=wp), | intent(out), | dimension(2) | :: | zr |
real components of roots |
|
real(kind=wp), | intent(out), | dimension(2) | :: | zi |
imaginary components of roots |
Calculate the zeros of the quadratic a*z**2 + b*z + c
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | a |
coefficients |
||
real(kind=wp), | intent(in) | :: | b |
coefficients |
||
real(kind=wp), | intent(in) | :: | c |
coefficients |
||
real(kind=wp), | intent(out) | :: | sr |
real part of first root |
||
real(kind=wp), | intent(out) | :: | si |
imaginary part of first root |
||
real(kind=wp), | intent(out) | :: | lr |
real part of second root |
||
real(kind=wp), | intent(out) | :: | li |
imaginary part of second root |
dqtcrt computes the roots of the real polynomial
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp) | :: | a(5) | ||||
real(kind=wp) | :: | zr(4) | ||||
real(kind=wp) | :: | zi(4) |
Used to reorder the elements of the double precision array a so that abs(a(i)) <= abs(a(i+1)) for i = 1,...,n-1. it is assumed that n >= 1.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout) | :: | a(n) | |||
integer, | intent(in) | :: | n |
w = sqrt(z)
for the double precision complex number z
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | z(2) | |||
real(kind=wp), | intent(out) | :: | w(2) |
Solve the real coefficient algebraic equation by the qr-method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of the monic polynomial. |
||
real(kind=wp), | intent(in) | :: | c(n+1) |
coefficients of the polynomial. in order of decreasing powers. |
||
real(kind=wp), | intent(out) | :: | zr(n) |
real part of output roots |
||
real(kind=wp), | intent(out) | :: | zi(n) |
imaginary part of output roots |
||
integer, | intent(out) | :: | istatus |
return code: |
||
real(kind=wp), | intent(out), | optional | :: | detil |
accuracy hint. |
Evaluate a complex polynomial and its derivatives. Optionally compute error bounds for these values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
Degree of the polynomial |
||
integer, | intent(in) | :: | m |
Number of derivatives to be calculated: |
||
complex(kind=wp), | intent(in) | :: | a(*) |
vector containing the |
||
complex(kind=wp), | intent(in) | :: | z |
point at which the evaluation is to take place |
||
complex(kind=wp), | intent(out) | :: | c(*) |
Array of |
||
complex(kind=wp), | intent(out) | :: | b(*) |
Array of |
||
logical, | intent(in) | :: | kbd |
A logical variable, e.g. .TRUE. or .FALSE. which is to be set .TRUE. if bounds are to be computed. |
Find the zeros of a polynomial with complex coefficients:
P(Z)= A(1)*Z**N + A(2)*Z**(N-1) +...+ A(N+1)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | in |
|
||
complex(kind=wp), | intent(in), | dimension(in+1) | :: | a |
complex vector containing coefficients of |
|
complex(kind=wp), | intent(inout), | dimension(in) | :: | r |
|
|
integer, | intent(inout) | :: | iflg |
flag to indicate if initial estimates of zeros are input: |
||
real(kind=wp), | intent(out) | :: | s(in) |
an |
Find the zeros of a polynomial with real coefficients:
P(X)= A(1)*X**N + A(2)*X**(N-1) +...+ A(N+1)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of |
||
real(kind=wp), | intent(in), | dimension(n+1) | :: | a |
real vector containing coefficients of |
|
complex(kind=wp), | intent(inout), | dimension(n) | :: | r |
|
|
integer, | intent(inout) | :: | iflg |
flag to indicate if initial estimates of zeros are input: |
||
real(kind=wp), | intent(out), | dimension(n) | :: | s |
an |
This routine computes all zeros of a polynomial of degree NDEG with real coefficients by computing the eigenvalues of the companion matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ndeg |
degree of polynomial |
||
real(kind=wp), | intent(in), | dimension(ndeg+1) | :: | coeff |
|
|
complex(kind=wp), | intent(out), | dimension(ndeg) | :: | root |
|
|
integer, | intent(out) | :: | ierr |
Output Error Code |
This subroutine finds the eigenvalues of a real upper hessenberg matrix by the qr method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nm |
must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. |
||
integer, | intent(in) | :: | n |
order of the matrix |
||
integer, | intent(in) | :: | low |
low and igh are integers determined by the balancing subroutine balanc. if balanc has not been used, set low=1, igh=n. |
||
integer, | intent(in) | :: | igh |
low and igh are integers determined by the balancing subroutine balanc. if balanc has not been used, set low=1, igh=n. |
||
real(kind=wp), | intent(inout) | :: | h(nm,n) |
On input: contains the upper hessenberg matrix. information about the transformations used in the reduction to hessenberg form by elmhes or orthes, if performed, is stored in the remaining triangle under the hessenberg matrix. |
||
real(kind=wp), | intent(out) | :: | wr(n) |
the real parts of the eigenvalues. the eigenvalues are unordered except that complex conjugate pairs of values appear consecutively with the eigenvalue having the positive imaginary part first. if an error exit is made, the eigenvalues should be correct for indices ierr+1,...,n. |
||
real(kind=wp), | intent(out) | :: | wi(n) |
the imaginary parts of the eigenvalues. the eigenvalues are unordered except that complex conjugate pairs of values appear consecutively with the eigenvalue having the positive imaginary part first. if an error exit is made, the eigenvalues should be correct for indices ierr+1,...,n. |
||
integer, | intent(out) | :: | ierr |
is set to: |
Solve for the roots of a real polynomial equation by computing the eigenvalues of the companion matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
polynomial degree |
||
real(kind=wp), | intent(in), | dimension(n+1) | :: | p |
polynomial coefficients array, in order of decreasing powers |
|
real(kind=wp), | intent(out), | dimension(n) | :: | wr |
real parts of roots |
|
real(kind=wp), | intent(out), | dimension(n) | :: | wi |
imaginary parts of roots |
|
integer, | intent(out) | :: | info |
output from the lapack solver. |
Solve for the roots of a complex polynomial equation by computing the eigenvalues of the companion matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
polynomial degree |
||
complex(kind=wp), | intent(in), | dimension(n+1) | :: | p |
polynomial coefficients array, in order of decreasing powers |
|
complex(kind=wp), | intent(out), | dimension(n) | :: | w |
roots |
|
integer, | intent(out) | :: | info |
output from the lapack solver. |
This routine computes all zeros of a polynomial of degree NDEG with complex coefficients by computing the eigenvalues of the companion matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ndeg |
degree of polynomial |
||
complex(kind=wp), | intent(in), | dimension(ndeg+1) | :: | coeff |
|
|
complex(kind=wp), | intent(out), | dimension(ndeg) | :: | root |
|
|
integer, | intent(out) | :: | ierr |
Output Error Code. |
this subroutine finds the eigenvalues of a complex upper hessenberg matrix by the qr method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nm |
row dimension of two-dimensional array parameters |
||
integer, | intent(in) | :: | n |
the order of the matrix |
||
integer, | intent(in) | :: | low |
integer determined by the balancing subroutine cbal. if cbal has not been used, set low=1 |
||
integer, | intent(in) | :: | igh |
integer determined by the balancing subroutine cbal. if cbal has not been used, igh=n. |
||
real(kind=wp), | intent(inout) | :: | hr(nm,n) |
On input: hr and hi contain the real and imaginary parts, respectively, of the complex upper hessenberg matrix. their lower triangles below the subdiagonal contain information about the unitary transformations used in the reduction by corth, if performed. |
||
real(kind=wp), | intent(inout) | :: | hi(nm,n) |
See |
||
real(kind=wp), | intent(out) | :: | wr(n) |
the real parts of the eigenvalues. if an error
exit is made, the eigenvalues should be correct
for indices |
||
real(kind=wp), | intent(out) | :: | wi(n) |
the imaginary parts of the eigenvalues. if an error
exit is made, the eigenvalues should be correct
for indices |
||
integer, | intent(out) | :: | ierr |
is set to: |
Compute the complex square root of a complex number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | xr | |||
real(kind=wp), | intent(in) | :: | xi | |||
real(kind=wp), | intent(out) | :: | yr | |||
real(kind=wp), | intent(out) | :: | yi |
Compute the complex quotient of two complex numbers.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | ar | |||
real(kind=wp), | intent(in) | :: | ai | |||
real(kind=wp), | intent(in) | :: | br | |||
real(kind=wp), | intent(in) | :: | bi | |||
real(kind=wp), | intent(out) | :: | cr | |||
real(kind=wp), | intent(out) | :: | ci |
"Polish" a root using a complex Newton Raphson method. This routine will perform a Newton iteration and update the roots only if they improve, otherwise, they are left as is.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of polynomial |
||
real(kind=wp), | intent(in), | dimension(n+1) | :: | p |
vector of coefficients in order of decreasing powers |
|
real(kind=wp), | intent(inout) | :: | zr |
real part of the zero |
||
real(kind=wp), | intent(inout) | :: | zi |
imaginary part of the zero |
||
real(kind=wp), | intent(in) | :: | ftol |
convergence tolerance for the root |
||
real(kind=wp), | intent(in) | :: | ztol |
convergence tolerance for |
||
integer, | intent(in) | :: | maxiter |
maximum number of iterations |
||
integer, | intent(out) | :: | istat |
status flag: |
"Polish" a root using a complex Newton Raphson method. This routine will perform a Newton iteration and update the roots only if they improve, otherwise, they are left as is.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of polynomial |
||
complex(kind=wp), | intent(in), | dimension(n+1) | :: | p |
vector of coefficients in order of decreasing powers |
|
real(kind=wp), | intent(inout) | :: | zr |
real part of the zero |
||
real(kind=wp), | intent(inout) | :: | zi |
imaginary part of the zero |
||
real(kind=wp), | intent(in) | :: | ftol |
convergence tolerance for the root |
||
real(kind=wp), | intent(in) | :: | ztol |
convergence tolerance for |
||
integer, | intent(in) | :: | maxiter |
maximum number of iterations |
||
integer, | intent(out) | :: | istat |
status flag: |
This subroutine finds roots of a complex polynomial. It uses a new dynamic root finding algorithm (see the Paper).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | degree |
degree of the polynomial and size of 'roots' array |
||
complex(kind=wp), | intent(in), | dimension(degree+1) | :: | poly |
coeffs of the polynomial, in order of increasing powers. |
|
complex(kind=wp), | intent(inout), | dimension(degree) | :: | roots |
array which will hold all roots that had been found. If the flag 'use_roots_as_starting_points' is set to .true., then instead of point (0,0) we use value from this array as starting point for cmplx_laguerre |
|
logical, | intent(in), | optional | :: | polish_roots_after |
after all roots have been found by dividing original polynomial by each root found, you can opt in to polish all roots using full polynomial. [default is false] |
|
logical, | intent(in), | optional | :: | use_roots_as_starting_points |
usually we start Laguerre's method from point (0,0), but you can decide to use the values of 'roots' array as starting point for each new root that is searched for. This is useful if you have very rough idea where some of the roots can be. [default is false] |
Finds the zeros of a complex polynomial.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(degree+1) | :: | opr |
vectors of real parts of the coefficients in order of decreasing powers. |
|
real(kind=wp), | intent(in), | dimension(degree+1) | :: | opi |
vectors of imaginary parts of the coefficients in order of decreasing powers. |
|
integer, | intent(in) | :: | degree |
degree of polynomial |
||
real(kind=wp), | intent(out), | dimension(degree) | :: | zeror |
real parts of the zeros |
|
real(kind=wp), | intent(out), | dimension(degree) | :: | zeroi |
imaginary parts of the zeros |
|
logical, | intent(out) | :: | fail |
true only if leading coefficient is zero or if cpoly
has found fewer than |
Numerical computation of the roots of a polynomial having complex coefficients, based on aberth's method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of the polynomial. |
||
complex(kind=wp), | intent(in) | :: | poly(n+1) |
complex vector of n+1 components, |
||
integer, | intent(in) | :: | nitmax |
the max number of allowed iterations. |
||
complex(kind=wp), | intent(out) | :: | root(n) |
complex vector of |
||
real(kind=wp), | intent(out) | :: | radius(n) |
real vector of |
||
logical, | intent(out) | :: | err(n) |
vector of |
compute the newton's correction, the inclusion radius (4) and checks the stop condition (3)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of the polynomial p(x) |
||
complex(kind=wp), | intent(in) | :: | poly(n+1) |
coefficients of the polynomial p(x) |
||
real(kind=wp), | intent(in) | :: | apoly(n+1) |
upper bounds on the backward perturbations on the coefficients of p(x) when applying ruffini-horner's rule |
||
real(kind=wp), | intent(in) | :: | apolyr(n+1) |
upper bounds on the backward perturbations on the coefficients of p(x) when applying (2), (2') |
||
complex(kind=wp), | intent(in) | :: | z |
value at which the newton correction is computed |
||
real(kind=wp), | intent(in) | :: | small |
the min positive real(wp), small=2**(-1074) for the ieee. |
||
real(kind=wp), | intent(out) | :: | radius |
upper bound to the distance of z from the closest root of the polynomial computed according to (4). |
||
complex(kind=wp), | intent(out) | :: | corr |
newton's correction |
||
logical, | intent(out) | :: | again |
this variable is .true. if the computed value p(z) is reliable, i.e., (3) is not satisfied in z. again is .false., otherwise. |
compute the aberth correction. to save time, the reciprocation of root(j)-root(i) could be performed in single precision (complex*8) in principle this might cause overflow if both root(j) and root(i) have too small moduli.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
degree of the polynomial |
||
integer, | intent(in) | :: | j |
index of the component of root with respect to which the aberth correction is computed |
||
complex(kind=wp), | intent(in) | :: | root(n) |
vector containing the current approximations to the roots |
||
complex(kind=wp), | intent(out) | :: | abcorr |
aberth's correction (compare (1)) |
compute the starting approximations of the roots
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
number of the coefficients of the polynomial |
||
real(kind=wp), | intent(inout) | :: | a(n+1) |
moduli of the coefficients of the polynomial |
||
complex(kind=wp), | intent(out) | :: | y(n) |
starting approximations |
||
real(kind=wp), | intent(out) | :: | radius(n) |
if a component is -1 then the corresponding root has a too big or too small modulus in order to be represented as double float with no overflow/underflow |
||
integer, | intent(out) | :: | nz |
number of roots which cannot be represented without overflow/underflow |
||
real(kind=wp), | intent(in) | :: | small |
the min positive real(wp), small=2**(-1074) for the ieee. |
||
real(kind=wp), | intent(in) | :: | big |
the max real(wp), big=2**1023 for the ieee standard. |
compute the upper convex hull of the set (i,a(i)), i.e., the set of vertices (i_k,a(i_k)), k=1,2,...,m, such that the points (i,a(i)) lie below the straight lines passing through two consecutive vertices. the abscissae of the vertices of the convex hull equal the indices of the true components of the logical output vector h. the used method requires o(nlog n) comparisons and is based on a divide-and-conquer technique. once the upper convex hull of two contiguous sets (say, {(1,a(1)),(2,a(2)),...,(k,a(k))} and {(k,a(k)), (k+1,a(k+1)),...,(q,a(q))}) have been computed, then the upper convex hull of their union is provided by the subroutine cmerge. the program starts with sets made up by two consecutive points, which trivially constitute a convex hull, then obtains sets of 3,5,9... points, up to arrive at the entire set. the program uses the subroutine cmerge; the subroutine cmerge uses the subroutines left, right and ctest. the latter tests the convexity of the angle formed by the points (i,a(i)), (j,a(j)), (k,a(k)) in the vertex (j,a(j)) up to within a given tolerance toler, where i<j<k.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
real(kind=wp) | :: | a(n) | ||||
logical, | intent(out) | :: | h(n) |
given as input the integer i and the vector h of logical, compute the the maximum integer il such that il<i and h(il) is true.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
length of the vector h |
||
logical, | intent(in) | :: | h(n) |
vector of logical |
||
integer, | intent(in) | :: | i |
integer |
||
integer, | intent(out) | :: | il |
maximum integer such that il<i, h(il)=.true. |
given as input the integer i and the vector h of logical, compute the the minimum integer ir such that ir>i and h(il) is true.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
length of the vector h |
||
logical, | intent(in) | :: | h(n) |
vector of logical |
||
integer, | intent(in) | :: | i |
integer |
||
integer, | intent(out) | :: | ir |
minimum integer such that ir>i, h(ir)=.true. |
given the upper convex hulls of two consecutive sets of pairs (j,a(j)), compute the upper convex hull of their union
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
length of the vector a |
||
real(kind=wp), | intent(in) | :: | a(n) |
vector defining the points (j,a(j)) |
||
integer, | intent(in) | :: | i |
abscissa of the common vertex of the two sets |
||
integer, | intent(in) | :: | m |
the number of elements of each set is m+1 |
||
logical, | intent(out) | :: | h(n) |
vector defining the vertices of the convex hull, i.e., h(j) is .true. if (j,a(j)) is a vertex of the convex hull this vector is used also as output. |
FPML: Fourth order Parallelizable Modification of Laguerre's method
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=wp), | intent(in) | :: | poly(deg+1) |
coefficients |
||
integer, | intent(in) | :: | deg |
polynomial degree |
||
complex(kind=wp), | intent(out) | :: | roots(:) |
the root approximations |
||
real(kind=wp), | intent(out) | :: | berr(:) |
the backward error in each approximation |
||
real(kind=wp), | intent(out) | :: | cond(:) |
the condition number of each root approximation |
||
integer, | intent(out) | :: | conv(:) | |||
integer, | intent(in) | :: | itmax |
Compute the roots of a cubic equation with real coefficients.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(4) | :: | coeffs |
vector of coefficients in order of decreasing powers |
|
real(kind=wp), | intent(out), | dimension(3) | :: | zr |
output vector of real parts of the zeros |
|
real(kind=wp), | intent(out), | dimension(3) | :: | zi |
output vector of imaginary parts of the zeros |
Sorts a set of complex numbers (with real and imag parts in different vectors) in increasing order.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x |
the real parts to be sorted.
on exit, |
|
real(kind=wp), | intent(inout), | dimension(:) | :: | y |
the imaginary parts to be sorted |
Given coefficients A(1),...,A(NDEG+1)
this subroutine computes the
NDEG
roots of the polynomial A(1)*X**NDEG + ... + A(NDEG+1)
storing the roots as complex numbers in the array Z
.
Require NDEG >= 1
and A(1) /= 0
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ndeg |
Degree of the polynomial |
||
real(kind=wp), | intent(in) | :: | a(ndeg+1) |
Contains the coefficients of a polynomial, high
order coefficient first with |
||
real(kind=wp), | intent(out) | :: | zr(ndeg) |
Contains the real parts of the roots |
||
real(kind=wp), | intent(out) | :: | zi(ndeg) |
Contains the imaginary parts of the roots |
||
integer, | intent(out) | :: | ierr |
Error flag: |
In the discussion below, the notation A([*,],k} should be interpreted as the complex number A(k) if A is declared complex, and should be interpreted as the complex number A(1,k) + i * A(2,k) if A is not declared to be of type complex. Similar statements apply for Z(k).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=wp), | intent(in) | :: | a(ndeg+1) |
contains the complex coefficients of a polynomial high order coefficient first, with a([,]1)/=0. the real and imaginary parts of the jth coefficient must be provided in a([],j). the contents of this array will not be modified by the subroutine. |
||
integer, | intent(in) | :: | ndeg |
degree of the polynomial |
||
complex(kind=wp), | intent(out) | :: | z(ndeg) |
contains the polynomial roots stored as complex numbers. the real and imaginary parts of the jth root will be stored in z([*,]j). |
||
integer, | intent(out) | :: | ierr |
error flag. set by the subroutine to 0 on normal termination. set to -1 if a([*,]1)=0. set to -2 if ndeg <= 0. set to j > 0 if the iteration count limit has been exceeded and roots 1 through j have not been determined. |
This subroutine finds the eigenvalues of a complex upper hessenberg matrix by the qr method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nm |
the row dimension of two-dimensional array parameters as declared in the calling program dimension statement |
||
integer, | intent(in) | :: | n |
the order of the matrix |
||
integer, | intent(in) | :: | low |
low and igh are integers determined by the balancing subroutine cbal. if cbal has not been used, set low=1, igh=n |
||
integer, | intent(in) | :: | igh |
low and igh are integers determined by the balancing subroutine cbal. if cbal has not been used, set low=1, igh=n |
||
real(kind=wp), | intent(inout) | :: | hr(nm,n) |
see |
||
real(kind=wp), | intent(inout) | :: | hi(nm,n) |
Input: hr and hi contain the real and imaginary parts, respectively, of the complex upper hessenberg matrix. their lower triangles below the subdiagonal contain information about the unitary transformations used in the reduction by corth, if performed. |
||
complex(kind=wp), | intent(out) | :: | z(n) |
the real and imaginary parts, respectively, of the eigenvalues. if an error exit is made, the eigenvalues should be correct for indices ierr+1,...,n, |
||
integer, | intent(out) | :: | ierr |
is set to: |