Skip to content

Commit

Permalink
Add minor comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thilinarmtb committed Feb 8, 2019
1 parent 0eea829 commit 182a2eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
20 changes: 8 additions & 12 deletions src/genmap-algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ 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 @@ -122,7 +121,6 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal,
GenmapVector d, e;
GenmapCreateVector(&d, n);
GenmapCopyVector(d, diagonal);
//printf("n is: %d\n", n);
GenmapCreateVector(&e, n);
GenmapCopyVector(e, upper);
e->data[n - 1] = 0.0;
Expand All @@ -134,7 +132,6 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal,
for(GenmapInt i = 0; i < n; i++) {
GenmapCreateZerosVector(&(*eVectors)[i], n);
(*eVectors)[i]->data[i] = 1.0;
//GenmapPrintVector((*eVectors)[i]);
}

GenmapInt l, iter, m, i;
Expand All @@ -154,15 +151,13 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal,
return 1;
}

//printf("l=%d, l+1=%d\n", l, l+1);
GenmapScalar g = (d->data[l + 1] - d->data[l]) / (2.0 * e->data[l]);
GenmapScalar r = sqrt(g * g + 1.0);

g = d->data[m] - d->data[l] + e->data[l] / (g + GenmapSign(r, g));
GenmapScalar s = 1.0, c = 1.0, p = 0.0;

for(i = m - 1; i >= l; i--) {
//printf("i=%d, i+1=%d\n", i, i+1);
GenmapScalar f = s * e->data[i];
GenmapScalar b = c * e->data[i];
#if defined(GENMAP_PAUL)
Expand Down Expand Up @@ -223,10 +218,6 @@ int GenmapTQLI(GenmapHandle h, GenmapVector diagonal,
}

for(GenmapInt ko = 0; ko < n; ko++) {
//for(GenmapInt ki = 0; ki < n; ki++) {
// e->data[ki] = GenmapDotVector((*eVectors)[ki], (*eVectors)[ko]);
// if(e->data[ki] > 0.0) e->data[ki] = sqrt(fabs(e->data[ki]));
//}
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];
Expand Down Expand Up @@ -276,6 +267,7 @@ int GenmapSymTriDiagSolve(GenmapVector x, GenmapVector b,
return 0;
}
//
// Orthogonalize by 1-vector (vector of all 1's)
//
int GenmapOrthogonalizebyOneVector(GenmapHandle h, GenmapComm c,
GenmapVector q1, GenmapLong n) {
Expand All @@ -293,7 +285,9 @@ int GenmapOrthogonalizebyOneVector(GenmapHandle h, GenmapComm c,

return 0;
}

//
// Lanczos version used in Paul's original genmap code.
//
int GenmapLanczosLegendary(GenmapHandle h, GenmapComm c, GenmapVector f,
GenmapInt niter, GenmapVector **rr, GenmapVector diag,
GenmapVector upper) {
Expand Down Expand Up @@ -402,7 +396,9 @@ int GenmapLanczosLegendary(GenmapHandle h, GenmapComm c, GenmapVector f,

return iter;
}

//
// Lanczos version in Introduction to Sci. Comp by Prof. Heath.
//
int GenmapLanczos(GenmapHandle h, GenmapComm c, GenmapVector init,
GenmapInt iter, GenmapVector **q, GenmapVector alpha,
GenmapVector beta) {
Expand Down
8 changes: 3 additions & 5 deletions src/genmap.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define _POSIX_C_SOURCE 200112
#include <genmap-impl.h>
#include <genmap-io.h>
#include "genmap-impl.h"
#include "genmap-io.h"

#include <stdlib.h>
#include <stdarg.h>
Expand All @@ -19,8 +19,7 @@ static int GenmapReadersRegistered = 0;
// Register readers -- each reader should call this
//
int GenmapRegisterReader(char *name, int (*Create)(GenmapHandle h)) {
if(GenmapNumReaders >= sizeof(GenmapReaders) / sizeof(
GenmapReaders[0])) {
if(GenmapNumReaders >= sizeof(GenmapReaders) / sizeof(GenmapReaders[0])) {
//TODO: GenmapError
printf("Error: Too many readers.\n");
}
Expand Down Expand Up @@ -125,7 +124,6 @@ int GenmapDestroyHandle(GenmapHandle h) {
//
int GenmapCreateHeader(GenmapHeader *h) {
GenmapMalloc(1, h);

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion src/parRSB.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ int parRSB_partMesh(long long *egl, long long *vl, int *negl,

GenmapLong out[2][1], buf[2][1];
GenmapLong lelt_ = h->header->lelt;
comm_scan(out, &(GenmapGetGlobalComm(h)->gsComm), genmap_gs_long, gs_add, &lelt_, 1,
comm_scan(out, &(GenmapGetGlobalComm(h)->gsComm), genmap_gs_long, gs_add,
&lelt_, 1,
buf);
h->header->start = out[0][0];
h->header->nel = out[1][0];
Expand Down

0 comments on commit 182a2eb

Please sign in to comment.