forked from hypre-space/hypre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsstruct_scale.c
62 lines (50 loc) · 1.81 KB
/
sstruct_scale.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/******************************************************************************
* Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
* HYPRE Project Developers. See the top-level COPYRIGHT file for details.
*
* SPDX-License-Identifier: (Apache-2.0 OR MIT)
******************************************************************************/
/******************************************************************************
*
* SStruct scale routine
*
*****************************************************************************/
#include "_hypre_sstruct_mv.h"
/*--------------------------------------------------------------------------
*--------------------------------------------------------------------------*/
HYPRE_Int
hypre_SStructPScale( HYPRE_Complex alpha,
hypre_SStructPVector *py )
{
HYPRE_Int nvars = hypre_SStructPVectorNVars(py);
HYPRE_Int var;
for (var = 0; var < nvars; var++)
{
hypre_StructScale(alpha, hypre_SStructPVectorSVector(py, var));
}
return hypre_error_flag;
}
/*--------------------------------------------------------------------------
*--------------------------------------------------------------------------*/
HYPRE_Int
hypre_SStructScale( HYPRE_Complex alpha,
hypre_SStructVector *y )
{
HYPRE_Int nparts = hypre_SStructVectorNParts(y);
HYPRE_Int part;
HYPRE_Int y_object_type = hypre_SStructVectorObjectType(y);
if (y_object_type == HYPRE_SSTRUCT)
{
for (part = 0; part < nparts; part++)
{
hypre_SStructPScale(alpha, hypre_SStructVectorPVector(y, part));
}
}
else if (y_object_type == HYPRE_PARCSR)
{
hypre_ParVector *y_par;
hypre_SStructVectorConvert(y, &y_par);
hypre_ParVectorScale(alpha, y_par);
}
return hypre_error_flag;
}