Skip to content

Commit 65cbbd2

Browse files
committed
more tests
1 parent 6cbd9ba commit 65cbbd2

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

test/bspline_defc_test.f90

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ program bspline_defc_test
5050
real(wp),dimension(nconst) :: xconst
5151
real(wp),dimension(nconst) :: yconst
5252
integer ,dimension(nconst) :: nderiv
53-
integer :: itype, mode, iw1, l, neqcon, nincon
53+
integer :: itype, mode, iw1, l, neqcon, nincon, imode
5454

5555
call random_seed(size=isize)
5656
allocate(iseed(isize)); iseed = 42_ip
@@ -162,23 +162,28 @@ program bspline_defc_test
162162
neqcon = 2 ! num equality constraints
163163
nincon = 2 ! num inequality constraints
164164

165-
mode = 1 ! a new problem
166-
l = nbkpt-nord+1
167-
iw1 = nincon+2*l
168-
lw = (nbkpt-nord+3)*(nord+1)+2*max(ndata,nbkpt)+nbkpt+nord**2 + &
169-
(l+nconst)*l+2*(neqcon+l)+(nincon+l)+(nincon+2)*(l+6)
170-
if (allocated(w)) deallocate(w)
171-
if (allocated(iw)) deallocate(iw)
172-
allocate(w(lw)) ; w = 0.0_wp
173-
allocate(iw(iw1)); iw = 0
174-
iw(1) = lw
175-
iw(2) = iw1
176-
call dfc (ndata, xdata, ydata, sddata, nord, nbkpt, bkpt, &
177-
nconst, xconst, yconst, nderiv, mode, coeff, w, iw)
178-
if (mode /= 0) then
179-
write(*,*) 'error calling dfc. mode = ',mode
180-
error stop
181-
end if
165+
do imode = 1, 2
166+
! run it twice just for testing, one with cov, one without
167+
! mode = 1 ! a new problem - no cov
168+
! mode = 2 ! a new problem - with cov
169+
mode = imode
170+
l = nbkpt-nord+1
171+
iw1 = nincon+2*l
172+
lw = (nbkpt-nord+3)*(nord+1)+2*max(ndata,nbkpt)+nbkpt+nord**2 + &
173+
(l+nconst)*l+2*(neqcon+l)+(nincon+l)+(nincon+2)*(l+6)
174+
if (allocated(w)) deallocate(w)
175+
if (allocated(iw)) deallocate(iw)
176+
allocate(w(lw)) ; w = 0.0_wp
177+
allocate(iw(iw1)); iw = 0
178+
iw(1) = lw
179+
iw(2) = iw1
180+
call dfc (ndata, xdata, ydata, sddata, nord, nbkpt, bkpt, &
181+
nconst, xconst, yconst, nderiv, mode, coeff, w, iw)
182+
if (mode /= 0) then
183+
write(*,*) 'error calling dfc. mode = ',mode
184+
error stop
185+
end if
186+
end do
182187
! use the splines to interpolate the data:
183188
inbvx = 1
184189
w0 = 0.0_wp
@@ -213,7 +218,7 @@ program bspline_defc_test
213218
label='Least squares bspline',&
214219
linestyle='r-',markersize=2,linewidth=2,istat=istat)
215220
call plt%add_plot(xdata,ydata_est_constr,&
216-
label='Least squares bspline with constraint',&
221+
label='Least squares bspline with constraints',&
217222
linestyle='g.-',markersize=4,linewidth=2,istat=istat)
218223
call plt%savefig(pyfile='bspline_defc_test.py', figfile='bspline_defc_test.png',istat=istat)
219224

0 commit comments

Comments
 (0)