-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can enorm be replaced with norm2? #36
Comments
The CMinpack version of
following the MPFIT library. They also offer the option of using the BLAS norm with a preprocessor statement: #ifdef USE_CBLAS
return __cminpack_cblas__(nrm2)(n, x, 1);
#else /* !USE_CBLAS */
// ... Honestly, all of these feel like magic numbers to me. The Fortran intrinsic |
I agree with using the standard norm2. I experimented a bit to mimic the
situation where the intrinsic function is not available and would have to
be replaced by an external function. That is a trifle subtle, but with a
bit of manipulation that is quite doable.
Op za 12 feb. 2022 om 17:00 schreef Ivan Pribec ***@***.***>:
… The CMinpack <https://github.com/devernay/cminpack/blob/master/enorm.c>
version of enorm also decided to redefine the rdwarf and rgiant constants
so that:
rdwarf = sqrt(dpmpar(2)*1.5) * 10
rgiant = sqrt(dpmpar(3)) * 0.1
following the MPFIT <http://cow.physics.wisc.edu/~craigm/idl/fitting.html>
library.
They also offer the option of using the BLAS norm with a preprocessor
statement:
#ifdef USE_CBLAS
return __cminpack_cblas__(nrm2)(n, x, 1);
#else /* !USE_CBLAS */
// ...
—
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR5S55E2X52H2OK63Q3U2Z72XANCNFSM5OFWTWOQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
In the case #if NO_F2008_NORM2
external :: norm2
#else
intrinsic :: norm2
#endif One downside is in case you need the optional Edit: Since we are now using a module, it might make more sense to play with importing or over-writing the intrinsic procedure, or even some other preprocessor trickery. In any case it is not worth pursuing unless users ask for it kindly. |
A quick grep shows there are 43 occurrences where
In most cases the number of elements matches the array size so no problem there. Probably only four occurrences reference rank-2 arrays:
Here's the wider context of line 2813: sing = .false.
do j = 1, n
if (Fjac(j, j) == zero) sing = .true.
Ipvt(j) = j
Wa2(j) = enorm(j, Fjac(1, j))
end do The norm is taken over columns in the upper triangular part of the matrix ! check if Jacobian is singular
sing = any(diag(fjac) == zero)
! initialize pivot array
Ipvt = [(j, j = 1, n)]
! calculate norm of upper triangular columns
do j = 1, n
Wa2(j) = norm2(fjac(1:j,j))
end do While it communicates the intent better, I can't decide whether it's a modification worth pursuing. Here's the context of line 3235: ! compute the initial column norms and initialize several arrays.
do j = 1, n
Acnorm(j) = enorm(m, a(1, j))
Rdiag(j) = Acnorm(j)
Wa(j) = Rdiag(j)
if (Pivot) Ipvt(j) = j
end do In this case we could use the ! compute the initial column norms and initialize several arrays
acnorm = norm2(a, dim=2)
rdiag = acnorm
wa = rdiag
if (pivot) Ipvt = [(j, j = 1, n)] What do you guys think:
|
Before I forget, the two instances:
can be rewritten as
In both cases, the norm is taken over a section of an array column, so no need for the |
The function
enorm
provides the Euclidean norm of a vector. From the MINPACK user guide:The function
enorm
is obsolescent as far as I'm concerned. The Fortran 2008 standard and later provide anorm2
intrinsic function. The standard recommends that processors compute the result without undue overflow or underflow.Other notable norm implementations include:
enorm
: https://www.netlib.org/minpack/enorm.fdnrm2
: https://www.netlib.org/slatec/lin/dnrm2.fdnrm2
: http://www.netlib.org/lapack/explore-3.1.1-html/dnrm2.f.htmlnorm2
: gfortran docs, ifort docsHere's a quick demonstration program:
An example run:
A potential issue of removing
enorm
in favor ofnorm2
are the workarounds needed to support older compilers. One approach could be to use a preprocessor block:Personally, I'd just replace
enorm
withnorm2
everywhere it occurs. If deemed necessary, the original implementation can be preserved as an external subroutine in a "compatibility" folder for older compilers.I'd also be interested in learning what type of tests can we come up with to prove the "worthiness" of the intrinsic
norm2
over the MINPACK-1 algorithm.Literature
The text was updated successfully, but these errors were encountered: