| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <stdio.h> // for NULL |
| 10 |
|
| 11 |
void y2x(double **xvecs, /* pointer to list of x-vectors */ |
| 12 |
int ndims, /* number of divisions to make (# xvecs) */ |
| 13 |
int nmyvtxs, /* number of vertices I own (length xvecs) */ |
| 14 |
double *wsqrt /* sqrt of vertex weights */ |
| 15 |
) |
| 16 |
|
| 17 |
/* Convert from y to x by dividing by wsqrt. */ |
| 18 |
{ |
| 19 |
double *wptr; /* loops through wsqrt */ |
| 20 |
double *xptr; /* loops through elements of a xvec */ |
| 21 |
int i, j; /* loop counters */ |
| 22 |
|
| 23 |
if (wsqrt == NULL) { |
| 24 |
return; |
| 25 |
} |
| 26 |
|
| 27 |
for (i = 1; i <= ndims; i++) { |
| 28 |
xptr = xvecs[i]; |
| 29 |
wptr = wsqrt; |
| 30 |
for (j = nmyvtxs; j; j--) { |
| 31 |
*(++xptr) /= *(++wptr); |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
void x2y(double **yvecs, /* pointer to list of y-vectors */ |
| 37 |
int ndims, /* number of divisions to make (# yvecs) */ |
| 38 |
int nmyvtxs, /* number of vertices I own (length yvecs) */ |
| 39 |
double *wsqrt /* sqrt of vertex weights */ |
| 40 |
) |
| 41 |
|
| 42 |
/* Convert from x to y by multiplying by wsqrt. */ |
| 43 |
{ |
| 44 |
double *wptr; /* loops through wsqrt */ |
| 45 |
double *yptr; /* loops through elements of a yvec */ |
| 46 |
int i, j; /* loop counters */ |
| 47 |
|
| 48 |
if (wsqrt == NULL) { |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
for (i = 1; i <= ndims; i++) { |
| 53 |
yptr = yvecs[i]; |
| 54 |
wptr = wsqrt; |
| 55 |
for (j = nmyvtxs; j; j--) { |
| 56 |
*(++yptr) *= *(++wptr); |
| 57 |
} |
| 58 |
} |
| 59 |
} |