| 1 |
/* |
| 2 |
* Copyright(C) 1999-2021 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> |
| 10 |
|
| 11 |
/* Scales vector by diagonal matrix (passed as vector) over range. */ |
| 12 |
void scale_diag(double *vec, /* the vector to scale */ |
| 13 |
int beg, int end, /* specify the range to norm over */ |
| 14 |
double *diag /* vector to scale by */ |
| 15 |
) |
| 16 |
{ |
| 17 |
if (diag != NULL) { |
| 18 |
vec = vec + beg; |
| 19 |
diag = diag + beg; |
| 20 |
for (int i = end - beg + 1; i; i--) { |
| 21 |
*vec++ *= *diag++; |
| 22 |
} |
| 23 |
} |
| 24 |
/* otherwise return vec unchanged */ |
| 25 |
} |
| 26 |
|
| 27 |
/* Scales vector by diagonal matrix (passed as vector) over range. */ |
| 28 |
void scale_diag_float(float *vec, /* the vector to scale */ |
| 29 |
int beg, int end, /* specify the range to norm over */ |
| 30 |
float *diag /* vector to scale by */ |
| 31 |
) |
| 32 |
{ |
| 33 |
if (diag != NULL) { |
| 34 |
vec = vec + beg; |
| 35 |
diag = diag + beg; |
| 36 |
for (int i = end - beg + 1; i; i--) { |
| 37 |
*vec++ *= *diag++; |
| 38 |
} |
| 39 |
} |
| 40 |
} |