-
Notifications
You must be signed in to change notification settings - Fork 2
/
dqed.f90
9259 lines (8459 loc) · 245 KB
/
dqed.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
subroutine difcen ( fj, func, fx, iopt, ldfj, mcon, mequa, nvars, &
ropt, x )
!***********************************************************************
!
!! DIFCEN estimates a jacobian using central differences.
!
! Modified:
!
! 18 February 2002
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Output, real ( kind = 8 ) FJ(LDFJ,NVARS), the estimated jacobian.
!
! Input, external FUNC, the name of the user written
! function evaluation routine. FUNC should have the form:
!
! subroutine func ( fx, iopt, mcon, mequa, nvars, ropt, x )
!
! and should accept X as input, and return in FX the value
! of the MEQUA+MCON functions.
!
! Workspace, real ( kind = 8 ) FX(MEQUA+MCON).
!
! Throughput, integer IOPT(*), parameters to be passed to FUNC.
!
! Input, integer LDFJ, the leading dimension of FJ, which must
! be at least MEQUA+MCON.
!
! Input, integer MCON, the number of constraints.
!
! Input, integer MEQUA, the number of nonlinear functions.
!
! Input, integer NVARS, the number of variables.
!
! Throughput, real ( kind = 8 ) ROPT(*), parameters to be passed to FUNC.
!
! Input, real ( kind = 8 ) X(NVARS), the point at which the
! jacobian should be evaluated.
!
implicit none
integer ldfj
integer mcon
integer mequa
integer nvars
real ( kind = 8 ) dxj
real ( kind = 8 ) eps
real ( kind = 8 ) fj(ldfj,nvars)
external func
real ( kind = 8 ) fx(mequa+mcon)
integer iopt(*)
integer j
real ( kind = 8 ) ropt(*)
real ( kind = 8 ) x(nvars)
real ( kind = 8 ) xsave
!
! Get the square root of the machine precision.
!
eps = sqrt ( epsilon ( eps ) )
!
! Consider each component X(J) of the set of variables.
!
do j = 1, nvars
!
! Set the appropriate increment DXJ to X(J).
!
dxj = eps * ( abs ( x(j) ) + 1.0D+00 )
!
! Make a copy XP of X, with X(J) incremented by DXJ.
!
xsave = x(j)
x(j) = xsave + dxj
!
! Evaluate F(XP).
!
call func ( fx, iopt, mcon, mequa, nvars, ropt, x )
!
! Save F(XP).
!
fj(1:mequa+mcon,j) = fx(1:mequa+mcon)
!
! Make a copy XM of X, with X(J) decremented by DXJ.
!
x(j) = xsave - dxj
!
! Evaluate F(XM).
!
call func ( fx, iopt, mcon, mequa, nvars, ropt, x )
!
! Estimate the partial derivative d F/d X(J) by (F(XP)-F(XM))/(2*DXJ)
!
fj(1:mequa+mcon,j) = ( fj(1:mequa+mcon,j) - fx(1:mequa+mcon) ) &
/ ( 2.0D+00 * dxj )
!
! Restore the value of X(J).
!
x(j) = xsave
end do
return
end
subroutine diffor ( fj, func, fx, iopt, ldfj, mcon, mequa, nvars, &
ropt, x )
!***********************************************************************
!
!! DIFFOR estimates a jacobian using forward differences.
!
! Modified:
!
! 18 February 2002
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Output, real ( kind = 8 ) FJ(LDFJ,NVARS), the estimated jacobian.
!
! Input, external FUNC, the name of the user written
! function evaluation routine. FUNC should have the form:
!
! subroutine func ( fx, iopt, mcon, mequa, nvars, ropt, x )
!
! and should accept X as input, and return in FX the value
! of the MEQUA+MCON functions.
!
! Workspace, real ( kind = 8 ) FX(MEQUA+MCON).
!
! Throughput, integer IOPT(*), parameters to be passed
! to FUNC.
!
! Input, integer LDFJ, the leading dimension of FJ, which must
! be at least MEQUA+MCON.
!
! Input, integer MCON, the number of constraints.
!
! Input, integer MEQUA, the number of nonlinear functions.
!
! Input, integer NVARS, the number of variables.
!
! Throughput, real ( kind = 8 ) ROPT(*), parameters to be passed to FUNC.
!
! Input, real ( kind = 8 ) X(NVARS), the point at which the
! jacobian should be evaluated.
!
implicit none
integer ldfj
integer mcon
integer mequa
integer nvars
real ( kind = 8 ) dxj
real ( kind = 8 ) eps
real ( kind = 8 ) fj(ldfj,nvars)
external func
real ( kind = 8 ) fx(mequa+mcon)
integer iopt(*)
integer j
real ( kind = 8 ) ropt(*)
real ( kind = 8 ) x(nvars)
real ( kind = 8 ) xsave
!
! Evaluate F(X) and save it in FX.
!
call func ( fx, iopt, mcon, mequa, nvars, ropt, x )
!
! Get the square root of the machine precision.
!
eps = sqrt ( epsilon ( eps ) )
!
! Consider each component X(J) of the set of variables.
!
do j = 1, nvars
!
! Set the appropriate increment DXJ to X(J).
!
dxj = eps * ( abs ( x(j) ) + 1.0D+00 )
!
! Make a copy XP of X, with X(J) incremented by DXJ.
!
xsave = x(j)
x(j) = xsave + dxj
!
! Evaluate F(XP) and store it in column J.
!
call func ( fj(1,j), iopt, mcon, mequa, nvars, ropt, x )
!
! Estimate the partial derivative d F/d X(J) by (F(XP)-F(X))/DXJ
!
fj(1:mequa+mcon,j) = ( fj(1:mequa+mcon,j) - fx(1:mequa+mcon) ) / dxj
!
! Restore the value of X(J).
!
x(j) = xsave
end do
return
end
function idamax ( n, x, incx )
!*******************************************************************************
!
!! IDAMAX finds the index of the vector element of maximum absolute value.
!
! Modified:
!
! 08 April 1999
!
! Reference:
!
! Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,
! Basic Linear Algebra Subprograms for Fortran Usage,
! Algorithm 539,
! ACM Transactions on Mathematical Software,
! Volume 5, Number 3, September 1979, pages 308-323.
!
! Parameters:
!
! Input, integer N, the number of entries in the vector.
!
! Input, real ( kind = 8 ) X(*), the vector to be examined.
!
! Input, integer INCX, the increment between successive entries of SX.
!
! Output, integer IDAMAX, the index of the element of SX of maximum
! absolute value.
!
implicit none
integer i
integer incx
integer idamax
integer ix
integer n
real ( kind = 8 ) damax
real ( kind = 8 ) x(*)
if ( n <= 0 ) then
idamax = 0
else if ( n == 1 ) then
idamax = 1
else if ( incx == 1 ) then
idamax = 1
damax = abs ( x(1) )
do i = 2, n
if ( abs ( x(i) ) > damax ) then
idamax = i
damax = abs ( x(i) )
end if
end do
else
if ( incx >= 0 ) then
ix = 1
else
ix = ( - n + 1 ) * incx + 1
end if
idamax = 1
damax = abs ( x(ix) )
ix = ix + incx
do i = 2, n
if ( abs ( x(ix) ) > damax ) then
idamax = i
damax = abs ( x(ix) )
end if
ix = ix + incx
end do
end if
return
end
subroutine ivout ( n, ix, title, idigit )
!***********************************************************************
!
!! IVOUT prints integer vectors.
!
! Author:
!
! John Wisniewski and Richard Hanson,
! SANDIA LABS ALBUQUERQUE.
!
! Parameters:
!
! Input, integer N, the size of the vector IX.
!
! Input, integer IX(N), the array to be printed.
!
! Input, character ( len = * ) TITLE, a title to be printed.
!
! Input, integer IDIGIT, indicates the number of digits to print.
! PRINT UP TO IABS(IDIGIT) DECIMAL DIGITS PER NUMBER.
! THE SUBPROGRAM WILL CHOOSE THAT integer 4,6,10 OR 14
! WHICH WILL PRINT AT LEAST IABS(IDIGIT) NUMBER OF
! PLACES. IF IDIGIT.LT.0, 72 PRINTING COLUMNS ARE UTILIZED
! TO WRITE EACH LINE OF OUTPUT OF THE ARRAY IX(*). (THIS
! CAN BE USED ON MOST TIME-SHARING TERMINALS). IF
! IDIGIT.GE.0, 133 PRINTING COLUMNS ARE UTILIZED. (THIS CAN
! BE USED ON MOST LINE PRINTERS).
!
implicit none
integer n
integer idigit
integer ix(n)
integer k1
integer k2
integer ndigit
character ( len = * ) title
write ( *, '(a)' ) trim ( title )
if ( n <= 0 ) then
return
end if
ndigit = idigit
if ( idigit == 0 ) then
ndigit = 4
end if
if ( idigit >= 0 ) go to 80
ndigit = -idigit
if ( ndigit <= 4 )then
do k1 = 1, n, 10
k2 = min ( n, k1+9 )
write(*,1000) k1, k2, ix(k1:k2)
end do
return
end if
if ( ndigit > 6) go to 40
do k1=1,n,7
k2 = min(n,k1+6)
write(*,1001) k1,k2, ix(k1:k2)
end do
return
40 continue
if ( ndigit > 10) go to 60
do k1=1,n,5
k2=min(n,k1+4)
write(*,1002) k1,k2, ix(k1:k2)
end do
return
60 continue
do k1=1,n,3
k2 = min(n,k1+2)
write(*,1003) k1,k2, ix(k1:k2)
end do
return
80 continue
if ( ndigit > 4) go to 100
do k1=1,n,20
k2 = min(n,k1+19)
write(*,1000) k1,k2, ix(k1:k2)
end do
return
100 continue
if ( ndigit > 6) go to 120
do k1=1,n,15
k2 = min(n,k1+14)
write(*,1001) k1,k2, ix(k1:k2)
end do
return
120 continue
if ( ndigit > 10) go to 140
do k1=1,n,10
k2 = min(n,k1+9)
write(*,1002) k1,k2, ix(k1:k2)
end do
return
140 continue
do k1=1,n,7
k2 = min(n,k1+6)
write(*,1003) k1,k2, ix(k1:k2)
end do
return
1000 format(1x,i4,' - ',i4,20(1x,i5))
1001 format(1x,i4,' - ',i4,15(1x,i7))
1002 format(1x,i4,' - ',i4,10(1x,i11))
1003 format(1x,i4,' - ',i4,7(1x,i15))
end
function damax ( n, x, incx )
!*******************************************************************************
!
!! DAMAX returns the maximum absolute value of the entries in a vector.
!
! Modified:
!
! 08 April 1999
!
! Parameters:
!
! Input, integer N, the number of entries in the vector.
!
! Input, real ( kind = 8 ) X(*), the vector to be examined.
!
! Input, integer INCX, the increment between successive entries of X.
!
! Output, real ( kind = 8 ) DAMAX, the maximum absolute value of an
! element of X.
!
implicit none
integer i
integer incx
integer ix
integer n
real ( kind = 8 ) damax
real ( kind = 8 ) x(*)
if ( n <= 0 ) then
damax = 0.0D+00
else if ( n == 1 ) then
damax = abs ( x(1) )
else if ( incx == 1 ) then
damax = abs ( x(1) )
do i = 2, n
if ( abs ( x(i) ) > damax ) then
damax = abs ( x(i) )
end if
end do
else
if ( incx >= 0 ) then
ix = 1
else
ix = ( - n + 1 ) * incx + 1
end if
damax = abs ( x(ix) )
ix = ix + incx
do i = 2, n
if ( abs ( x(ix) ) > damax ) then
damax = abs ( x(ix) )
end if
ix = ix + incx
end do
end if
return
end
function dasum ( n, x, incx )
!*******************************************************************************
!
!! DASUM sums the absolute values of the entries of a vector.
!
! Modified:
!
! 08 April 1999
!
! Reference:
!
! Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,
! Basic Linear Algebra Subprograms for Fortran Usage,
! Algorithm 539,
! ACM Transactions on Mathematical Software,
! Volume 5, Number 3, September 1979, pages 308-323.
!
! Parameters:
!
! Input, integer N, the number of entries in the vector.
!
! Input, real ( kind = 8 ) X(*), the vector to be examined.
!
! Input, integer INCX, the increment between successive entries of X.
!
! Output, real ( kind = 8 ) DASUM, the sum of the absolute values of
! the vector.
!
implicit none
integer i
integer incx
integer ix
integer m
integer n
real ( kind = 8 ) dasum
real ( kind = 8 ) stemp
real ( kind = 8 ) x(*)
stemp = 0.0D+00
if ( n <= 0 ) then
else if ( incx == 1 ) then
m = mod ( n, 6 )
do i = 1, m
stemp = stemp + abs ( x(i) )
end do
do i = m+1, n, 6
stemp = stemp + abs ( x(i) ) + abs ( x(i+1) ) + abs ( x(i+2) ) &
+ abs ( x(i+3) ) + abs ( x(i+4) ) + abs ( x(i+5) )
end do
else
if ( incx >= 0 ) then
ix = 1
else
ix = ( - n + 1 ) * incx + 1
end if
do i = 1, n
stemp = stemp + abs ( x(ix) )
ix = ix + incx
end do
end if
dasum = stemp
return
end
subroutine daxpy ( n, sa, x, incx, y, incy )
!*******************************************************************************
!
!! DAXPY adds a constant times one vector to another.
!
! Modified:
!
! 08 April 1999
!
! Reference:
!
! Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh,
! Basic Linear Algebra Subprograms for Fortran Usage,
! Algorithm 539,
! ACM Transactions on Mathematical Software,
! Volume 5, Number 3, September 1979, pages 308-323.
!
! Parameters:
!
! Input, integer N, the number of entries in the vector.
!
! Input, real ( kind = 8 ) SA, the multiplier.
!
! Input, real ( kind = 8 ) X(*), the vector to be scaled and added to Y.
!
! Input, integer INCX, the increment between successive entries of X.
!
! Input/output, real ( kind = 8 ) Y(*), the vector to which a multiple
! of X is to be added.
!
! Input, integer INCY, the increment between successive entries of Y.
!
implicit none
integer i
integer incx
integer incy
integer ix
integer iy
integer n
real ( kind = 8 ) sa
real ( kind = 8 ) x(*)
real ( kind = 8 ) y(*)
if ( n <= 0 ) then
else if ( sa == 0.0D+00 ) then
else if ( incx == 1 .and. incy == 1 ) then
y(1:n) = y(1:n) + sa * x(1:n)
else
if ( incx >= 0 ) then
ix = 1
else
ix = ( - n + 1 ) * incx + 1
end if
if ( incy >= 0 ) then
iy = 1
else
iy = ( - n + 1 ) * incy + 1
end if
do i = 1, n
y(iy) = y(iy) + sa * x(ix)
ix = ix + incx
iy = iy + incy
end do
end if
return
end
subroutine dbocls ( w, mdw, mcon, mrows, ncols, bl, bu, ind, iopt, x, &
rnormc, rnorm, mode, rw, iw )
!***********************************************************************
!
!! DBOCLS solves a bounded and constrained least squares problem.
!
! Discussion:
!
! DBOCLS solves the bounded and constrained least squares
! problem consisting of solving the equation
! E*X = F (in the least squares sense)
! subject to the linear constraints
! C*X = Y.
!
! This subprogram solves the bounded and constrained least squares
! problem. The problem statement is:
!
! Solve E*X = F (least squares sense), subject to constraints
! C*X=Y.
!
! In this formulation both X and Y are unknowns, and both may
! have bounds on any of their components. This formulation
! of the problem allows the user to have equality and inequality
! constraints as well as simple bounds on the solution components.
!
! This constrained linear least squares subprogram solves E*X=F
! subject to C*X=Y, where E is MROWS by NCOLS, C is MCON by NCOLS.
!
! The user must have dimension statements of the form
!
! DIMENSION W(MDW,NCOLS+MCON+1), BL(NCOLS+MCON), BU(NCOLS+MCON),
! * X(2*(NCOLS+MCON)+2+NX), RW(6*NCOLS+5*MCON)
! integer IND(NCOLS+MCON), IOPT(17+NI), IW(2*(NCOLS+MCON))
!
! (here NX=number of extra locations required for the options; NX=0
! if no options are in use. Also NI=number of extra locations
! for options 1-9.
!
! Author:
!
! Richard Hanson, Sandia National Laboratory
!
! Reference:
!
! Richard Hanson,
! Linear Least Squares with Bounds and Linear Constraints,
! SIAM Journal on Scientific and Statistical Computing,
! Volume 7, Number 3, July 1986.
!
! INPUT
! -----
!
! -------------------------
! W(MDW,*),MCON,MROWS,NCOLS
! -------------------------
! The array W contains the (possibly null) matrix [C:*] followed by
! [E:F]. This must be placed in W as follows:
! [C : *]
! W = [ ]
! [E : F]
! The (*) after C indicates that this data can be undefined. The
! matrix [E:F] has MROWS rows and NCOLS+1 columns. The matrix C is
! placed in the first MCON rows of W(*,*) while [E:F]
! follows in rows MCON+1 through MCON+MROWS of W(*,*). The vector F
! is placed in rows MCON+1 through MCON+MROWS, column NCOLS+1. The
! values of MDW and NCOLS must be positive; the value of MCON must
! be nonnegative. An exception to this occurs when using option 1
! for accumulation of blocks of equations. In that case MROWS is an
! OUTPUT variable only, and the matrix data for [E:F] is placed in
! W(*,*), one block of rows at a time. See IOPT(*) contents, option
! number 1, for further details. The row dimension, MDW, of the
! array W(*,*) must satisfy the inequality:
!
! If using option 1,
! MDW >= MCON + max(max. number of
! rows accumulated, NCOLS)
!
! If using option 8, MDW >= MCON + MROWS.
! Else, MDW >= MCON + max(MROWS, NCOLS).
!
! Other values are errors, but this is checked only when using
! option=2. The value of MROWS is an output parameter when
! using option number 1 for accumulating large blocks of least
! squares equations before solving the problem.
! See IOPT(*) contents for details about option 1.
!
! ------------------
! BL(*),BU(*),IND(*)
! ------------------
! These arrays contain the information about the bounds that the
! solution values are to satisfy. The value of IND(J) tells the
! type of bound and BL(J) and BU(J) give the explicit values for
! the respective upper and lower bounds on the unknowns X and Y.
! The first NVARS entries of IND(*), BL(*) and BU(*) specify
! bounds on X; the next MCON entries specify bounds on Y.
!
! 1. For IND(J)=1, require X(J) >= BL(J);
! IF J > NCOLS, Y(J-NCOLS) >= BL(J).
! (the value of BU(J) is not used.)
! 2. For IND(J)=2, require X(J) <= BU(J);
! IF J > NCOLS, Y(J-NCOLS) <= BU(J).
! (the value of BL(J) is not used.)
! 3. For IND(J)=3, require X(J) >= BL(J) and
! X(J) <= BU(J);
! IF J > NCOLS, Y(J-NCOLS) >= BL(J) and
! Y(J-NCOLS) <= BU(J).
! (to impose equality constraints have BL(J)=BU(J)=
! constraining value.)
! 4. For IND(J)=4, no bounds on X(J) or Y(J-NCOLS) are required.
! (the values of BL(J) and BU(J) are not used.)
!
! Values other than 1,2,3 or 4 for IND(J) are errors. In the case
! IND(J)=3 (upper and lower bounds) the condition BL(J) > BU(J)
! is an error. The values BL(J), BU(J), J > NCOLS, will be
! changed. Significant changes mean that the constraints are
! infeasible. (Users must make this decision themselves.)
! The new values for BL(J), BU(J), J > NCOLS, define a
! region such that the perturbed problem is feasible. If users
! know that their problem is feasible, this step can be skipped
! by using option number 8 described below.
!
! -------
! IOPT(*)
! -------
! This is the array where the user can specify nonstandard options
! for DBOCLS( ). Most of the time this feature can be ignored by
! setting the input value IOPT(1)=99. Occasionally users may have
! needs that require use of the following subprogram options. For
! details about how to use the options see below: IOPT(*) CONTENTS.
!
! Option Number Brief Statement of Purpose
! ------ ------ ----- --------- -- -------
! 1 Return to user for accumulation of blocks
! of least squares equations. The values
! of IOPT(*) are changed with this option.
! The changes are updates to pointers for
! placing the rows of equations into position
! for processing.
! 2 Check lengths of all arrays used in the
! subprogram.
! 3 Column scaling of the data matrix, [C].
! [E]
! 4 User provides column scaling for matrix [C].
! [E]
! 5 Provide option array to the low-level
! subprogram DBOLS( ).
! {Provide option array to the low-level
! subprogram DBOLSM( ) by imbedding an
! option array within the option array to
! DBOLS(). Option 6 is now disabled.}
! 7 Move the IOPT(*) processing pointer.
! 8 Do not preprocess the constraints to
! resolve infeasibilities.
! 9 Do not pretriangularize the least squares matrix.
! 99 No more options to change.
!
! ----
! X(*)
! ----
! This array is used to pass data associated with options 4,5 and
! 6. Ignore this parameter (on input) if no options are used.
! Otherwise see below: IOPT(*) CONTENTS.
!
!
! OUTPUT
! ------
!
! -----------------
! X(*),RNORMC,RNORM
! -----------------
! The array X(*) contains a solution (if MODE >=0 or == -22) for
! the constrained least squares problem. The value RNORMC is the
! minimum residual vector length for the constraints C*X - Y = 0.
! The value RNORM is the minimum residual vector length for the
! least squares equations. Normally RNORMC=0, but in the case of
! inconsistent constraints this value will be nonzero.
! The values of X are returned in the first NVARS entries of X(*).
! The values of Y are returned in the last MCON entries of X(*).
!
! ----
! MODE
! ----
! The sign of MODE determines whether the subprogram has completed
! normally, or encountered an error condition or abnormal status. A
! value of MODE >= 0 signifies that the subprogram has completed
! normally. The value of mode (>= 0) is the number of variables
! in an active status: not at a bound nor at the value zero, for
! the case of free variables. A negative value of MODE will be one
! of the cases (-57)-(-41), (-37)-(-22), (-19)-(-2). Values < -1
! correspond to an abnormal completion of the subprogram. These
! error messages are in groups for the subprograms DBOCLS(),
! DBOLSM(), and DBOLS(). An approximate solution will be returned
! to the user only when max. iterations is reached, MODE=-22.
!
! -----------
! RW(*),IW(*)
! -----------
! These are working arrays. (normally the user can ignore the
! contents of these arrays.)
!
! IOPT(*) CONTENTS
! ------- --------
! The option array allows a user to modify some internal variables
! in the subprogram without recompiling the source code. A central
! goal of the initial software design was to do a good job for most
! people. Thus the use of options will be restricted to a select
! group of users. The processing of the option array proceeds as
! follows: a pointer, here called LP, is initially set to the value
! 1. At the pointer position the option number is extracted and
! used for locating other information that allows for options to be
! changed. The portion of the array IOPT(*) that is used for each
! option is fixed; the user and the subprogram both know how many
! locations are needed for each option. The value of LP is updated
! for each option based on the amount of storage in IOPT(*) that is
! required. A great deal of error checking is done by the
! subprogram on the contents of the option array. Nevertheless it
! is still possible to give the subprogram optional input that is
! meaningless. For example option 4 uses the locations
! X(NCOLS+IOFF),...,X(NCOLS+IOFF+NCOLS-1) for passing scaling data.
! The user must manage the allocation of these locations.
!
! 1
! -
! This option allows the user to solve problems with a large number
! of rows compared to the number of variables. The idea is that the
! subprogram returns to the user (perhaps many times) and receives
! new least squares equations from the calling program unit.
! Eventually the user signals "that's all" and a solution is then
! computed. The value of MROWS is an output variable when this
! option is used. Its value is always in the range 0 <= MROWS
! <= NCOLS+1. It is the number of rows after the
! triangularization of the entire set of equations. If LP is the
! processing pointer for IOPT(*), the usage for the sequential
! processing of blocks of equations is
!
!
! IOPT(LP)=1
! Move block of equations to W(*,*) starting at
! the first row of W(*,*).
! IOPT(LP+3)=# of rows in the block; user defined
!
! The user now calls DBOCLS( ) in a loop. The value of IOPT(LP+1)
! directs the user's action. The value of IOPT(LP+2) points to
! where the subsequent rows are to be placed in W(*,*). Both of
! these values are first defined in the subprogram. The user
! changes the value of IOPT(LP+1) (to 2) as a signal that all of
! the rows have been processed.
!
!
! .<LOOP
! . CALL DBOCLS( )
! . IF(IOPT(LP+1) .EQ. 1) THEN
! . IOPT(LP+3)=# OF ROWS IN THE NEW BLOCK; USER DEFINED
! . PLACE NEW BLOCK OF IOPT(LP+3) ROWS IN
! . W(*,*) STARTING AT ROW MCON + IOPT(LP+2).
! .
! . IF( THIS IS THE LAST BLOCK OF EQUATIONS ) THEN
! . IOPT(LP+1)=2
! .<------CYCLE LOOP
! . ELSE IF (IOPT(LP+1) .EQ. 2) THEN
! <-------EXIT LOOP SOLUTION COMPUTED IF MODE .GE. 0
! . ELSE
! . ERROR CONDITION; SHOULD NOT HAPPEN.
! .<END LOOP
!
! Use of this option adds 4 to the required length of IOPT(*).
!
! 2
! -
! This option is useful for checking the lengths of all arrays used
! by DBOCLS( ) against their actual requirements for this problem.
! The idea is simple: the user's program unit passes the declared
! dimension information of the arrays. These values are compared
! against the problem-dependent needs within the subprogram. If any
! of the dimensions are too small an error message is printed and a
! negative value of MODE is returned, -41 to -47. The printed error
! message tells how long the dimension should be. If LP is the
! processing pointer for IOPT(*),
!
! IOPT(LP)=2
! IOPT(LP+1)=Row dimension of W(*,*)
! IOPT(LP+2)=Col. dimension of W(*,*)
! IOPT(LP+3)=Dimensions of BL(*),BU(*),IND(*)
! IOPT(LP+4)=Dimension of X(*)
! IOPT(LP+5)=Dimension of RW(*)
! IOPT(LP+6)=Dimension of IW(*)
! IOPT(LP+7)=Dimension of IOPT(*)
! .
! CALL DBOCLS( )
!
! Use of this option adds 8 to the required length of IOPT(*).
!
! 3
! -
! This option can change the type of scaling for the data matrix.
! Nominally each nonzero column of the matrix is scaled so that the
! magnitude of its largest entry is equal to the value ONE. If LP
! is the processing pointer for IOPT(*),
!
! IOPT(LP)=3
! IOPT(LP+1)=1,2 or 3
! 1= Nominal scaling as noted;
! 2= Each nonzero column scaled to have length ONE;
! 3= Identity scaling; scaling effectively suppressed.
! .
! CALL DBOCLS( )
!
! Use of this option adds 2 to the required length of IOPT(*).
!
! 4
! -
! This options allows the user to provide arbitrary (positive)
! column scaling for the matrix. If LP is the processing pointer
! for IOPT(*),
!
! IOPT(LP)=4
! IOPT(LP+1)=IOFF
! X(NCOLS+IOFF),...,X(NCOLS+IOFF+NCOLS-1)
! = Positive scale factors for cols. of E.
! .
! CALL DBOCLS( )
!
! Use of this option adds 2 to the required length of IOPT(*)
! and NCOLS to the required length of X(*).
!
! 5
! -
! This option allows the user to provide an option array to the
! low-level subprogram DBOLS( ). If LP is the processing pointer
! for IOPT(*),
!
! IOPT(LP)=5
! IOPT(LP+1)= Position in IOPT(*) where option array
! data for DBOLS( ) begins.
! .
! CALL DBOCLS( )
!