@@ -30,7 +30,7 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
30
30
! Maximum size of the subproblems at the bottom of the computation (~25)
31
31
smlsiz = stdlib_ilaenv(9,'${ri}$gelsd',' ',0,0,0,0)
32
32
33
- ! The exact minimum amount of workspace needed depends on M, N and NRHS. As long as LWORK is at least
33
+ ! The exact minimum amount of workspace needed depends on M, N and NRHS.
34
34
nlvl = max(0, ilog2(mnmin/(smlsiz+1))+1)
35
35
36
36
! Real space
@@ -47,7 +47,8 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
47
47
! Integer space
48
48
liwork = max(1, 3*mnmin*nlvl+11*mnmin)
49
49
50
- ! For good performance, the workspace should generally be larger.
50
+ ! For good performance, the workspace should generally be larger.
51
+ ! Allocate 25% more space than strictly needed.
51
52
lrwork = ceiling(1.25*lrwork,kind=ilp)
52
53
lcwork = ceiling(1.25*lcwork,kind=ilp)
53
54
liwork = ceiling(1.25*liwork,kind=ilp)
@@ -117,8 +118,8 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
117
118
err0 = linalg_state_type(this,LINALG_VALUE_ERROR,'invalid sizes: a=',[lda,n], &
118
119
'b=',[ldb,nrhs])
119
120
allocate(x${nde}$)
120
- arank = 0
121
- goto 1
121
+ call linalg_error_handling(err0,err)
122
+ if (present(rank)) rank = 0
122
123
end if
123
124
124
125
! Can A be overwritten? By default, do not overwrite
@@ -182,10 +183,10 @@ submodule (stdlib_linalg) stdlib_linalg_least_squares
182
183
err0 = linalg_state_type(this,LINALG_INTERNAL_ERROR,'catastrophic error')
183
184
end select
184
185
185
- if (.not. copy_a) deallocate(amat)
186
+ if (copy_a) deallocate(amat)
186
187
187
188
! Process output and return
188
- 1 call linalg_error_handling(err0,err)
189
+ call linalg_error_handling(err0,err)
189
190
if (present(rank)) rank = arank
190
191
191
192
end function stdlib_linalg_${ri}$_lstsq_${ndsuf}$
0 commit comments