rpzero.f 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. *DECK RPZERO
  2. SUBROUTINE RPZERO (N, A, R, T, IFLG, S)
  3. C***BEGIN PROLOGUE RPZERO
  4. C***PURPOSE Find the zeros of a polynomial with real coefficients.
  5. C***LIBRARY SLATEC
  6. C***CATEGORY F1A1A
  7. C***TYPE SINGLE PRECISION (RPZERO-S, CPZERO-C)
  8. C***KEYWORDS POLYNOMIAL ROOTS, POLYNOMIAL ZEROS, REAL ROOTS
  9. C***AUTHOR Kahaner, D. K., (NBS)
  10. C***DESCRIPTION
  11. C
  12. C Find the zeros of the real polynomial
  13. C P(X)= A(1)*X**N + A(2)*X**(N-1) +...+ A(N+1)
  14. C
  15. C Input...
  16. C N = degree of P(X)
  17. C A = real vector containing coefficients of P(X),
  18. C A(I) = coefficient of X**(N+1-I)
  19. C R = N word complex vector containing initial estimates for zeros
  20. C if these are known.
  21. C T = 6(N+1) word array used for temporary storage
  22. C IFLG = flag to indicate if initial estimates of
  23. C zeros are input.
  24. C If IFLG .EQ. 0, no estimates are input.
  25. C If IFLG .NE. 0, the vector R contains estimates of
  26. C the zeros
  27. C ** Warning ****** If estimates are input, they must
  28. C be separated; that is, distinct or
  29. C not repeated.
  30. C S = an N word array
  31. C
  32. C Output...
  33. C R(I) = ith zero,
  34. C S(I) = bound for R(I) .
  35. C IFLG = error diagnostic
  36. C Error Diagnostics...
  37. C If IFLG .EQ. 0 on return, all is well.
  38. C If IFLG .EQ. 1 on return, A(1)=0.0 or N=0 on input.
  39. C If IFLG .EQ. 2 on return, the program failed to converge
  40. C after 25*N iterations. Best current estimates of the
  41. C zeros are in R(I). Error bounds are not calculated.
  42. C
  43. C***REFERENCES (NONE)
  44. C***ROUTINES CALLED CPZERO
  45. C***REVISION HISTORY (YYMMDD)
  46. C 810223 DATE WRITTEN
  47. C 890206 REVISION DATE from Version 3.2
  48. C 891214 Prologue converted to Version 4.0 format. (BAB)
  49. C***END PROLOGUE RPZERO
  50. C
  51. COMPLEX R(*), T(*)
  52. REAL A(*), S(*)
  53. C***FIRST EXECUTABLE STATEMENT RPZERO
  54. N1=N+1
  55. DO 1 I=1,N1
  56. T(I)= CMPLX(A(I),0.0)
  57. 1 CONTINUE
  58. CALL CPZERO(N,T,R,T(N+2),IFLG,S)
  59. RETURN
  60. END