source: CIVL/examples/mpi-omp/AMG2013/sstruct_mv/sstruct_axpy.c@ 7d77e64

main test-branch
Last change on this file since 7d77e64 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13
14
15/******************************************************************************
16 *
17 * SStruct axpy routine
18 *
19 *****************************************************************************/
20
21#include "headers.h"
22
23/*--------------------------------------------------------------------------
24 * hypre_SStructPAxpy
25 *--------------------------------------------------------------------------*/
26
27int
28hypre_SStructPAxpy( double alpha,
29 hypre_SStructPVector *px,
30 hypre_SStructPVector *py )
31{
32 int ierr = 0;
33 int nvars = hypre_SStructPVectorNVars(px);
34 int var;
35
36 for (var = 0; var < nvars; var++)
37 {
38 hypre_StructAxpy(alpha,
39 hypre_SStructPVectorSVector(px, var),
40 hypre_SStructPVectorSVector(py, var));
41 }
42
43 return ierr;
44}
45
46/*--------------------------------------------------------------------------
47 * hypre_SStructAxpy
48 *--------------------------------------------------------------------------*/
49
50int
51hypre_SStructAxpy( double alpha,
52 hypre_SStructVector *x,
53 hypre_SStructVector *y )
54{
55 int ierr = 0;
56 int nparts = hypre_SStructVectorNParts(x);
57 int part;
58
59 int x_object_type= hypre_SStructVectorObjectType(x);
60 int y_object_type= hypre_SStructVectorObjectType(y);
61
62 if (x_object_type != y_object_type)
63 {
64 printf("vector object types different- cannot compute Axpy\n");
65 return ierr;
66 }
67
68 if (x_object_type == HYPRE_SSTRUCT)
69 {
70 for (part = 0; part < nparts; part++)
71 {
72 hypre_SStructPAxpy(alpha,
73 hypre_SStructVectorPVector(x, part),
74 hypre_SStructVectorPVector(y, part));
75 }
76 }
77
78 else if (x_object_type == HYPRE_PARCSR)
79 {
80 hypre_ParVector *x_par;
81 hypre_ParVector *y_par;
82
83 hypre_SStructVectorConvert(x, &x_par);
84 hypre_SStructVectorConvert(y, &y_par);
85
86 hypre_ParVectorAxpy(alpha, x_par, y_par);
87 }
88
89 return ierr;
90}
Note: See TracBrowser for help on using the repository browser.