Skip to content

Commit

Permalink
make astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
thilinarmtb committed Feb 7, 2019
1 parent db59799 commit f38ced9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
43 changes: 22 additions & 21 deletions src/genmap-algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ GenmapScalar GenmapSign(GenmapScalar a, GenmapScalar b) {
//
// Routine to find eigenvectors and values of tri-diagonal matrix
//
int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
int GenmapTQLI(GenmapHandle h, GenmapVector diagonal,
GenmapVector upper,
GenmapVector **eVectors, GenmapVector *eValues) {
assert(diagonal->size == upper->size + 1);

Expand All @@ -124,7 +125,7 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
//printf("n is: %d\n", n);
GenmapCreateVector(&e, n);
GenmapCopyVector(e, upper);
e->data[n-1] = 0.0;
e->data[n - 1] = 0.0;

// Create the vector to store eigenvalues
GenmapCreateVector(eValues, n);
Expand All @@ -144,7 +145,7 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
for(m = l; m < n - 1; m++) {
GenmapScalar dd = fabs(d->data[m]) + fabs(d->data[m + 1]);
// Should use a tolerance for this check
if(fabs(e->data[m])/dd < GENMAP_DP_TOL) break;
if(fabs(e->data[m]) / dd < GENMAP_DP_TOL) break;
}

if(m != l) {
Expand All @@ -166,28 +167,28 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
GenmapScalar b = c * e->data[i];
#if defined(GENMAP_PAUL)
if(fabs(f) >= fabs(g)) {
c = g/f;
r = sqrt(c*c + 1.0);
e->data[i+1] = f*r;
s = 1.0/r;
c = c*s;
c = g / f;
r = sqrt(c * c + 1.0);
e->data[i + 1] = f * r;
s = 1.0 / r;
c = c * s;
} else {
s = f/g;
r = sqrt(s*s + 1.0);
e->data[i+1] = g*r;
c = 1.0/r;
s = s*c;
s = f / g;
r = sqrt(s * s + 1.0);
e->data[i + 1] = g * r;
c = 1.0 / r;
s = s * c;
}
#else
e->data[i+1] = r = sqrt(f*f + g*g);
e->data[i + 1] = r = sqrt(f * f + g * g);

if(r < GENMAP_DP_TOL) {
d->data[i+1] -= p;
d->data[i + 1] -= p;
e->data[m] = 0.0;
break;
}
s = f/r;
c = g/r;
s = f / r;
c = g / r;
#endif
g = d->data[i + 1] - p;
r = (d->data[i] - g) * s + 2.0 * c * b;
Expand All @@ -197,7 +198,7 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
// Find eigenvectors
for(GenmapInt k = 0; k < n; k++) {
f = (*eVectors)[k]->data[i + 1];
(*eVectors)[k]->data[i+1] = s * (*eVectors)[k]->data[i] + c * f;
(*eVectors)[k]->data[i + 1] = s * (*eVectors)[k]->data[i] + c * f;
(*eVectors)[k]->data[i] = c * (*eVectors)[k]->data[i] - s * f;
}
// Done with eigenvectors
Expand Down Expand Up @@ -228,7 +229,7 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
//}
e->data[ko] = GenmapDotVector((*eVectors)[ko], (*eVectors)[ko]);
if(e->data[ko] > 0.0) e->data[ko] = sqrt(fabs(e->data[ko]));
GenmapScalar scale = 1.0/e->data[ko];
GenmapScalar scale = 1.0 / e->data[ko];
GenmapScaleVector((*eVectors)[ko], (*eVectors)[ko], scale);
}

Expand Down Expand Up @@ -543,7 +544,7 @@ GenmapInt GenmapSetProcessorId(GenmapHandle h) {
}

void GenmapGlobalMinMax(GenmapHandle h, GenmapLong *min,
GenmapLong *max) {
GenmapLong *max) {
*min = LONG_MAX; *max = LONG_MIN;

GenmapElements e = GenmapGetElements(h);
Expand Down Expand Up @@ -613,7 +614,7 @@ int GenmapFiedler(GenmapHandle h, GenmapComm c, int maxIter,
}
#else
if(global > 0) {
initVec->data[i] = (GenmapScalar) elements[i].globalId;
initVec->data[i] = (GenmapScalar) elements[i].globalId;
} else {
for(i = 0; i < lelt; i++) {
initVec->data[i] = elements[i].fiedler;
Expand Down
3 changes: 2 additions & 1 deletion src/genmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ int GenmapPowerIterNew(GenmapVector eVector, void (*Ax)(GenmapVector ax,
int GenmapInvPowerIter(GenmapVector eVector, GenmapVector alpha,
GenmapVector beta, GenmapVector init, int iter);

int GenmapTQLI(GenmapHandle h, GenmapVector diagonal, GenmapVector upper,
int GenmapTQLI(GenmapHandle h, GenmapVector diagonal,
GenmapVector upper,
GenmapVector **eVectors, GenmapVector *eValues);
//
// Evaluate partition quality
Expand Down

0 comments on commit f38ced9

Please sign in to comment.