Skip to content

Commit 094d55e

Browse files
committed
readme and test updates
1 parent d562e9c commit 094d55e

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Polyroots-Fortran: Root solvers for modern Fortran
22
<https://github.com/jacobwilliams/polyroots-fortran>
33

4-
Copyright (c) 2022, Jacob Williams
4+
Copyright (c) 2022-2024, Jacob Williams
55
All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without modification,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
**polyroots-fortran**: Polynomial Roots with Modern Fortran
55

6+
[![Language](https://img.shields.io/badge/-Fortran-734f96?logo=fortran&logoColor=white)](https://github.com/topics/fortran)
67
[![GitHub release](https://img.shields.io/github/release/jacobwilliams/polyroots-fortran.svg)](https://github.com/jacobwilliams/polyroots-fortran/releases/latest)
78
[![CI Status](https://github.com/jacobwilliams/polyroots-fortran/actions/workflows/CI.yml/badge.svg)](https://github.com/jacobwilliams/polyroots-fortran/actions)
89
[![codecov](https://codecov.io/gh/jacobwilliams/polyroots-fortran/branch/master/graph/badge.svg)](https://codecov.io/gh/jacobwilliams/polyroots-fortran)

fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "polyroots-fortran"
22
author = "Jacob Williams"
3-
copyright = "Copyright (c) 2022, Jacob Williams"
3+
copyright = "Copyright (c) 2022-2024, Jacob Williams"
44
license = "BSD-3"
55
description = "Polynomial Roots with Modern Fortran"
66
homepage = "https://github.com/jacobwilliams/polyroots-fortran"

test/polyroots_test_10.f90

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,40 @@
44

55
program polyroots_test_10
66

7-
use polyroots_module, only: dpolz, wp => polyroots_module_rk
7+
use polyroots_module, only: polyroots, dpolz, wp => polyroots_module_rk
88
use pyplot_module, only: pyplot
99

1010
implicit none
1111

12-
integer,parameter :: degree = 10 !! polynomial degree
13-
integer,dimension(*),parameter :: icoeffs = [-1,1] !! set of coefficients
14-
integer,dimension (degree+1) :: a !! coefficients of polynomial
15-
real(wp),dimension(degree) :: zr, zi !! roots
12+
integer :: degree = 5 !! polynomial degree
13+
integer,dimension(2) :: icoeffs = [-1,1] !! set of coefficients
1614
integer :: ierr !! error code from [[dpolz]]
1715
type(pyplot) :: plt !! for making the plot
18-
19-
call plt%initialize(grid=.true.,xlabel='$\Re(z)$',ylabel='$\Im(z)$',&
20-
title='Degree 10 Polynomial Roots',usetex=.true.,&
21-
figsize=[20,10])
22-
23-
call generate(1)
24-
call plt%savefig('roots.png')
16+
integer :: i ,j
17+
character(len=5) :: istr
18+
integer,dimension (:),allocatable :: a !! coefficients of polynomial
19+
real(wp),dimension(:),allocatable :: zr, zi !! roots
20+
21+
do i = 2, 10, 2
22+
23+
write(istr,'(I5)') i; istr = adjustl(istr)
24+
degree = i
25+
! resize
26+
a = [(0, j = 1, degree+1)]
27+
zr = [(0, j = 1, degree)]
28+
zi = [(0, j = 1, degree)]
29+
30+
!icoeffs = icoeffs + 1
31+
write(*,*) 'degree = ', degree
32+
call plt%initialize(grid=.true.,xlabel='$\Re(z)$',ylabel='$\Im(z)$',&
33+
title='Degree '//trim(istr)//' Polynomial Roots',usetex=.true.,&
34+
font_size=25, axes_labelsize=25, &
35+
xtick_labelsize=25, ytick_labelsize=25, &
36+
figsize=[20,10])
37+
call generate(1)
38+
call plt%savefig('roots_'//trim(istr)//'.png')
39+
40+
end do
2541

2642
contains
2743

@@ -30,10 +46,11 @@ recursive subroutine generate (i)
3046
integer :: ix
3147
if (i > degree+1) then
3248
!write (*, '(*(I2,","))') a
33-
call dpolz(degree,real(a,wp),zr,zi,ierr); if (ierr/=0) error stop ierr
34-
call plt%add_plot(zr,zi,label='',linestyle='bo',markersize=1)
49+
call polyroots(degree,real(a,wp),zr,zi,ierr) !polyroots !! dpolz
50+
if (ierr/=0) return !error stop ierr
51+
call plt%add_plot(zr,zi,label='',linestyle='bo',markersize=2)
3552
else
36-
do ix = 1,size(icoeffs)
53+
do ix = 1,size(icoeffs)
3754
a(i) = icoeffs(ix)
3855
call generate(i+1)
3956
end do

0 commit comments

Comments
 (0)