Skip to content

Commit

Permalink
Update *nrm2.c for negative incx following the new lapack release.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyeli committed Jun 19, 2024
1 parent 4cc2cdb commit 098f95e
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 1,402 deletions.
22 changes: 11 additions & 11 deletions CBLAS/dnrm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

doublereal dnrm2_(integer *n, doublereal *x, integer *incx)
{


/* System generated locals */

doublereal ret_val, d__1;
Expand All @@ -22,37 +20,39 @@ doublereal dnrm2_(integer *n, doublereal *x, integer *incx)
integer ix;
doublereal ssq;


/* DNRM2 returns the euclidean norm of a vector via the function
name, so that
DNRM2 := sqrt( x'*x )
-- This version written on 25-October-1982.
Modified on 14-October-1993 to inline the call to DLASSQ.
Sven Hammarling, Nag Ltd.
Parameter adjustments
Function Body */
#define X(I) x[(I)-1]


if (*n < 1 || *incx < 1) {
//if (*n < 1 || *incx < 1) {
if (*n < 1) {
norm = 0.;
} else if (*n == 1) {
norm = abs(X(1));
} else {
scale = 0.;
ssq = 1.;
/* The following loop is equivalent to this call to the LAPACK
auxiliary routine:
CALL DLASSQ( N, X, INCX, SCALE, SSQ ) */
for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {

int ixinitial = 1;
if (*incx < 0) {
ixinitial = 1 - (*n-1)* (*incx);
}

int i;
for (i = 1,ix = ixinitial; i <= *n; i++, ix += *incx) {
//for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {
if (X(ix) != 0.) {
absxi = (d__1 = X(ix), abs(d__1));
if (scale < absxi) {
Expand Down
18 changes: 12 additions & 6 deletions CBLAS/dznrm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ doublereal dznrm2_(integer *n, doublecomplex *x, integer *incx)
DZNRM2 := sqrt( conjg( x' )*x )
-- This version written on 25-October-1982.
Modified on 14-October-1993 to inline the call to ZLASSQ.
Sven Hammarling, Nag Ltd.
Parameter adjustments
Function Body */
#define X(I) x[(I)-1]


if (*n < 1 || *incx < 1) {
// if (*n < 1 || *incx < 1) {
if (*n < 1) {
norm = 0.;
} else {
scale = 0.;
Expand All @@ -50,7 +47,16 @@ doublereal dznrm2_(integer *n, doublecomplex *x, integer *incx)
auxiliary routine:
CALL ZLASSQ( N, X, INCX, SCALE, SSQ ) */
for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {

int ixinitial = 1;
if (*incx < 0) {
ixinitial = 1 - (*n-1)* (*incx);
}

int i;
for (i = 1,ix = ixinitial; i <= *n; i++, ix += *incx) {
//for (ix = 1; *incx < 0 ? ix >= (*n-1)*(*incx)+1 : ix <= (*n-1)*(*incx)+1; ix += *incx) {

if (X(ix).r != 0.) {
temp = (d__1 = X(ix).r, abs(d__1));
if (scale < temp) {
Expand Down
17 changes: 11 additions & 6 deletions CBLAS/scnrm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@ real scnrm2_(integer *n, singlecomplex *x, integer *incx)
SCNRM2 := sqrt( conjg( x' )*x )
-- This version written on 25-October-1982.
Modified on 14-October-1993 to inline the call to CLASSQ.
Sven Hammarling, Nag Ltd.
Parameter adjustments
Function Body */
#define X(I) x[(I)-1]


if (*n < 1 || *incx < 1) {
//if (*n < 1 || *incx < 1) {
if (*n < 1) {
norm = 0.f;
} else {
scale = 0.f;
Expand All @@ -50,7 +47,15 @@ real scnrm2_(integer *n, singlecomplex *x, integer *incx)
auxiliary routine:
CALL CLASSQ( N, X, INCX, SCALE, SSQ ) */
for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {

int ixinitial = 1;
if (*incx < 0) {
ixinitial = 1 - (*n-1)* (*incx);
}

int i;
for (i = 1,ix = ixinitial; i <= *n; i++, ix += *incx) {
//for (ix = 1; *incx < 0 ? ix >= (*n-1)*(*incx)+1 : ix <= (*n-1)*(*incx)+1; ix += *incx) {
if (X(ix).r != 0.f) {
temp = (r__1 = X(ix).r, dabs(r__1));
if (scale < temp) {
Expand Down
16 changes: 11 additions & 5 deletions CBLAS/snrm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
real snrm2_(integer *n, real *x, integer *incx)
{


/* System generated locals */

real ret_val, r__1;
Expand All @@ -29,19 +28,18 @@ real snrm2_(integer *n, real *x, integer *incx)
SNRM2 := sqrt( x'*x )
-- This version written on 25-October-1982.
Modified on 14-October-1993 to inline the call to SLASSQ.
Sven Hammarling, Nag Ltd.
Parameter adjustments
Function Body */
#define X(I) x[(I)-1]


if (*n < 1 || *incx < 1) {
//if (*n < 1 || *incx < 1) {
if (*n < 1) {
norm = 0.f;
} else if (*n == 1) {
norm = dabs(X(1));
Expand All @@ -52,7 +50,15 @@ real snrm2_(integer *n, real *x, integer *incx)
auxiliary routine:
CALL SLASSQ( N, X, INCX, SCALE, SSQ ) */
for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {

int ixinitial = 1;
if (*incx < 0) {
ixinitial = 1 - (*n-1)* (*incx);
}

int i;
for (i = 1,ix = ixinitial; i <= *n; i++, ix += *incx) {
//for (ix = 1; *incx < 0 ? ix >= (*n-1)**incx+1 : ix <= (*n-1)**incx+1; ix += *incx) {
if (X(ix) != 0.f) {
absxi = (r__1 = X(ix), dabs(r__1));
if (scale < absxi) {
Expand Down
2 changes: 1 addition & 1 deletion DOC/html/cgscon_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions DOC/html/cgssvx_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DOC/html/dgscon_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DOC/html/dgssvx_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DOC/html/sgscon_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DOC/html/sgssvx_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions DOC/html/slu__cdefs_8h.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions DOC/html/slu__ddefs_8h.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions DOC/html/slu__sdefs_8h.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions DOC/html/slu__zdefs_8h.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DOC/html/zgscon_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DOC/html/zgssvx_8c.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 098f95e

Please sign in to comment.