Skip to content

Commit

Permalink
Merge pull request #156 from gruenich/feature/matgen-improve-c
Browse files Browse the repository at this point in the history
Matgen small C improvements
  • Loading branch information
xiaoyeli authored Sep 30, 2024
2 parents 7c80e81 + 7300719 commit cb8abfb
Show file tree
Hide file tree
Showing 50 changed files with 140 additions and 229 deletions.
6 changes: 6 additions & 0 deletions DOC/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@

These tests start with the letter z.
*/

/*!
\defgroup TestingMatgen Matrix generation
\ingroup Testing
\brief Matrix generation for tests.
*/
12 changes: 4 additions & 8 deletions TESTING/MATGEN/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ if(enable_single)
slarot.c
slatm2.c
slatm3.c
r_sign.c
pow_ri.c
powi.c
)
endif()

Expand All @@ -49,8 +48,7 @@ if(enable_double)
dlarot.c
dlatm2.c
dlatm3.c
d_sign.c
pow_di.c
powi.c
)
endif()

Expand All @@ -74,8 +72,7 @@ if(enable_complex)
claghe.c
clarnd.c
# cdotc.c
r_sign.c
pow_ri.c
powi.c
)
endif()

Expand All @@ -99,8 +96,7 @@ if(enable_complex16)
zlaghe.c
zlarnd.c
# zdotc.c
d_sign.c
pow_di.c
powi.c
)
endif()

Expand Down
4 changes: 2 additions & 2 deletions TESTING/MATGEN/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ include ../../make.inc
SCATGEN = slatm1.o slaran.o slarnd.o slaruv.o slabad.o slarnv.o
SLASRC = slatb4.o slaset.o slartg.o
SMATGEN = slatms.o slagge.o slagsy.o slarge.o slaror.o slarot.o slatm2.o slatm3.o
SINTRINSIC = r_sign.o pow_ri.o
SINTRINSIC = powi.o

DZATGEN = dlatm1.o dlaran.o dlarnd.o dlaruv.o dlabad.o dlarnv.o
DLASRC = dlatb4.o dlaset.o dlartg.o
DMATGEN = dlatms.o dlagge.o dlagsy.o dlarge.o dlaror.o dlarot.o dlatm2.o dlatm3.o
DINTRINSIC = d_sign.o pow_di.o
DINTRINSIC = powi.o

CLASRC = clatb4.o claset.o clartg.o clarnv.o clacgv.o csymv.o
CMATGEN = clatms.o clagge.o clagsy.o clarge.o claror.o clarot.o clatm2.o clatm3.o \
Expand Down
5 changes: 2 additions & 3 deletions TESTING/MATGEN/cdotc.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/* -- translated by f2c (version 19940927).
*/

#include "../../SRC/slu_scomplex.h"

/* Complex */ void cdotc_(singlecomplex * ret_val, int *n, singlecomplex *cx, int
*incx, singlecomplex *cy, int *incy)
{
/* System generated locals */
int i__1, i__2;
singlecomplex q__1, q__2, q__3;

/* Builtin functions */
void r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static int i;
static singlecomplex ctemp;
Expand Down
3 changes: 1 addition & 2 deletions TESTING/MATGEN/clacgv.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
Function Body */
/* System generated locals */
singlecomplex q__1;
/* Builtin functions */
void r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static int ioff, i;

Expand Down
4 changes: 0 additions & 4 deletions TESTING/MATGEN/clagge.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ static int c__1 = 1;
double d__1;
singlecomplex q__1;

/* Builtin functions */
double c_abs(singlecomplex *);
void c_div(singlecomplex *, singlecomplex *, singlecomplex *);

/* Local variables */
static int i, j;
extern /* Subroutine */ int cgerc_(int *, int *, singlecomplex *,
Expand Down
4 changes: 0 additions & 4 deletions TESTING/MATGEN/claghe.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ static int c__1 = 1;
double d__1;
singlecomplex q__1, q__2, q__3, q__4;

/* Builtin functions */
double c_abs(singlecomplex *);
void c_div(singlecomplex *, singlecomplex *, singlecomplex *), r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
extern /* Subroutine */ int cher2_(char *, int *, singlecomplex *, singlecomplex *
, int *, singlecomplex *, int *, singlecomplex *, int *);
Expand Down
4 changes: 0 additions & 4 deletions TESTING/MATGEN/clagsy.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ static int c__1 = 1;
double d__1;
singlecomplex q__1, q__2, q__3, q__4;

/* Builtin functions */
double c_abs(singlecomplex *);
void c_div(singlecomplex *, singlecomplex *, singlecomplex *);

/* Local variables */
static int i, j;
extern /* Subroutine */ int cgerc_(int *, int *, singlecomplex *,
Expand Down
4 changes: 0 additions & 4 deletions TESTING/MATGEN/clarge.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ static int c__1 = 1;
double d__1;
singlecomplex q__1;

/* Builtin functions */
double c_abs(singlecomplex *);
void c_div(singlecomplex *, singlecomplex *, singlecomplex *);

/* Local variables */
static int i;
extern /* Subroutine */ int cgerc_(int *, int *, singlecomplex *,
Expand Down
3 changes: 0 additions & 3 deletions TESTING/MATGEN/clarnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
double d__1, d__2;
singlecomplex q__1, q__2, q__3;

/* Builtin functions */
void c_exp(singlecomplex *, singlecomplex *);

/* Local variables */
static float t1, t2;
extern double dlaran_sluslu(int *);
Expand Down
3 changes: 1 addition & 2 deletions TESTING/MATGEN/clarnv.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
int i__2, i__3;
double d__1, d__2;
singlecomplex q__1, q__2, q__3;
/* Builtin functions */
void c_exp(singlecomplex *, singlecomplex *);

/* Local variables */
static int i;
static float u[128];
Expand Down
4 changes: 0 additions & 4 deletions TESTING/MATGEN/claror.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ static int c__1 = 1;
int a_dim1, a_offset, i__1, i__2, i__3;
singlecomplex q__1, q__2;

/* Builtin functions */
double c_abs(singlecomplex *);
void r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static int kbeg, jcol;
static float xabs;
Expand Down
3 changes: 0 additions & 3 deletions TESTING/MATGEN/clarot.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ int clarot_slu(bool *lrows, bool *lleft, bool *lright,
int i__1, i__2, i__3, i__4;
singlecomplex q__1, q__2, q__3, q__4, q__5, q__6;

/* Builtin functions */
void r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static int iinc, j, inext;
static singlecomplex tempx;
Expand Down
4 changes: 1 addition & 3 deletions TESTING/MATGEN/clartg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
float r__1, r__2;
double d__1;
singlecomplex q__1, q__2, q__3;
/* Builtin functions */
void r_cnjg(singlecomplex *, singlecomplex *);
double c_abs(singlecomplex *), r_imag(singlecomplex *);

/* Local variables */
static float d, f1, f2, g1, g2, fa, ga, di;
static singlecomplex fs, gs, ss;
Expand Down
3 changes: 0 additions & 3 deletions TESTING/MATGEN/clatm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
int i__1, i__2;
singlecomplex q__1, q__2, q__3;

/* Builtin functions */
void c_div(singlecomplex *, singlecomplex *, singlecomplex *), r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static int isub, jsub;
static singlecomplex ctemp;
Expand Down
3 changes: 0 additions & 3 deletions TESTING/MATGEN/clatm3.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
int i__1, i__2;
singlecomplex q__1, q__2, q__3;

/* Builtin functions */
void c_div(singlecomplex *, singlecomplex *, singlecomplex *), r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static singlecomplex ctemp;
extern /* Complex */ void clarnd_slu(singlecomplex *, int *, int *);
Expand Down
4 changes: 0 additions & 4 deletions TESTING/MATGEN/clatme.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ static int c__5 = 5;
float r__1, r__2;
singlecomplex q__1, q__2;

/* Builtin functions */
double c_abs(singlecomplex *);
void r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static bool bads;
static int isim;
Expand Down
3 changes: 0 additions & 3 deletions TESTING/MATGEN/clatms.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ static bool c_false = false;
singlecomplex q__1, q__2, q__3;
bool L__1;

/* Builtin functions */
void r_cnjg(singlecomplex *, singlecomplex *);

/* Local variables */
static int ilda, icol;
static float temp;
Expand Down
6 changes: 0 additions & 6 deletions TESTING/MATGEN/d_sign.c

This file was deleted.

17 changes: 8 additions & 9 deletions TESTING/MATGEN/dlagge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "../../SRC/slu_ddefs.h"

#include <math.h>

/* Table of constant values */

static int c__3 = 3;
Expand All @@ -18,9 +20,6 @@ static double c_b13 = 0.;
int a_dim1, a_offset, i__1, i__2, i__3;
double d__1;

/* Builtin functions */
double d_sign(double *, double *);

/* Local variables */
extern /* Subroutine */ int dger_(int *, int *, double *,
double *, int *, double *, int *, double *,
Expand Down Expand Up @@ -152,7 +151,7 @@ static double c_b13 = 0.;
dlarnv_slu(&c__3, &iseed[1], &i__1, &work[1]);
i__1 = *m - i + 1;
wn = dnrm2_(&i__1, &work[1], &c__1);
wa = d_sign(&wn, &work[1]);
wa = copysign(wn, work[1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down Expand Up @@ -185,7 +184,7 @@ t */
dlarnv_slu(&c__3, &iseed[1], &i__1, &work[1]);
i__1 = *n - i + 1;
wn = dnrm2_(&i__1, &work[1], &c__1);
wa = d_sign(&wn, &work[1]);
wa = copysign(wn, work[1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down Expand Up @@ -234,7 +233,7 @@ L = 0)

i__2 = *m - *kl - i + 1;
wn = dnrm2_(&i__2, &a[*kl + i + i * a_dim1], &c__1);
wa = d_sign(&wn, &a[*kl + i + i * a_dim1]);
wa = copysign(wn, a[*kl + i + i * a_dim1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down Expand Up @@ -271,7 +270,7 @@ eft */

i__2 = *n - *ku - i + 1;
wn = dnrm2_(&i__2, &a[i + (*ku + i) * a_dim1], lda);
wa = d_sign(&wn, &a[i + (*ku + i) * a_dim1]);
wa = copysign(wn, a[i + (*ku + i) * a_dim1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down Expand Up @@ -313,7 +312,7 @@ ight */

i__2 = *n - *ku - i + 1;
wn = dnrm2_(&i__2, &a[i + (*ku + i) * a_dim1], lda);
wa = d_sign(&wn, &a[i + (*ku + i) * a_dim1]);
wa = copysign(wn, a[i + (*ku + i) * a_dim1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down Expand Up @@ -350,7 +349,7 @@ ight */

i__2 = *m - *kl - i + 1;
wn = dnrm2_(&i__2, &a[*kl + i + i * a_dim1], &c__1);
wa = d_sign(&wn, &a[*kl + i + i * a_dim1]);
wa = copysign(wn, a[*kl + i + i * a_dim1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down
9 changes: 4 additions & 5 deletions TESTING/MATGEN/dlagsy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "../../SRC/slu_ddefs.h"

#include <math.h>

/* Table of constant values */

static int c__3 = 3;
Expand All @@ -19,9 +21,6 @@ static double c_b26 = 1.;
int a_dim1, a_offset, i__1, i__2, i__3;
double d__1;

/* Builtin functions */
double d_sign(double *, double *);

/* Local variables */
extern /* Subroutine */ int dger_(int *, int *, double *,
double *, int *, double *, int *, double *,
Expand Down Expand Up @@ -151,7 +150,7 @@ static double c_b26 = 1.;
dlarnv_slu(&c__3, &iseed[1], &i__1, &work[1]);
i__1 = *n - i + 1;
wn = dnrm2_(&i__1, &work[1], &c__1);
wa = d_sign(&wn, &work[1]);
wa = copysign(wn, work[1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down Expand Up @@ -197,7 +196,7 @@ static double c_b26 = 1.;

i__2 = *n - *k - i + 1;
wn = dnrm2_(&i__2, &a[*k + i + i * a_dim1], &c__1);
wa = d_sign(&wn, &a[*k + i + i * a_dim1]);
wa = copysign(wn, a[*k + i + i * a_dim1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down
5 changes: 1 addition & 4 deletions TESTING/MATGEN/dlarge.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ static double c_b10 = 0.;
int a_dim1, a_offset, i__1;
double d__1;

/* Builtin functions */
double d_sign(double *, double *);

/* Local variables */
extern /* Subroutine */ int dger_(int *, int *, double *,
double *, int *, double *, int *, double *,
Expand Down Expand Up @@ -111,7 +108,7 @@ static double c_b10 = 0.;
dlarnv_slu(&c__3, &iseed[1], &i__1, &work[1]);
i__1 = *n - i + 1;
wn = dnrm2_(&i__1, &work[1], &c__1);
wa = d_sign(&wn, &work[1]);
wa = copysign(wn, work[1]);
if (wn == 0.) {
tau = 0.;
} else {
Expand Down
9 changes: 3 additions & 6 deletions TESTING/MATGEN/dlaror.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ static int c__1 = 1;
int a_dim1, a_offset, i__1, i__2;
double d__1;

/* Builtin functions */
double d_sign(double *, double *);

/* Local variables */
static int kbeg;
extern /* Subroutine */ int dger_(int *, int *, double *,
Expand Down Expand Up @@ -219,9 +216,9 @@ static int c__1 = 1;
X */

xnorm = dnrm2_(&ixfrm, &x[kbeg], &c__1);
xnorms = d_sign(&xnorm, &x[kbeg]);
xnorms = copysign(xnorm, x[kbeg]);
d__1 = -x[kbeg];
x[kbeg + nxfrm] = d_sign(&c_b10, &d__1);
x[kbeg + nxfrm] = copysign(c_b10, d__1);
factor = xnorms * (xnorms + x[kbeg]);
if (fabs(factor) < 1e-20) {
*info = 1;
Expand Down Expand Up @@ -261,7 +258,7 @@ static int c__1 = 1;
}

d__1 = dlarnd_slu(&c__3, &iseed[1]);
x[nxfrm * 2] = d_sign(&c_b10, &d__1);
x[nxfrm * 2] = copysign(c_b10, d__1);

/* Scale the matrix A by D. */

Expand Down
Loading

0 comments on commit cb8abfb

Please sign in to comment.