source: CIVL/examples/mpi-omp/AMG2013/struct_mv/struct_axpy.c@ 397ae5f

main test-branch
Last change on this file since 397ae5f 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.4 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 * Structured axpy routine
17 *
18 *****************************************************************************/
19
20#include "headers.h"
21
22/*--------------------------------------------------------------------------
23 * hypre_StructAxpy
24 *--------------------------------------------------------------------------*/
25
26int
27hypre_StructAxpy( double alpha,
28 hypre_StructVector *x,
29 hypre_StructVector *y )
30{
31 int ierr = 0;
32
33 hypre_Box *x_data_box;
34 hypre_Box *y_data_box;
35
36 int xi;
37 int yi;
38
39 double *xp;
40 double *yp;
41
42 hypre_BoxArray *boxes;
43 hypre_Box *box;
44 hypre_Index loop_size;
45 hypre_IndexRef start;
46 hypre_Index unit_stride;
47
48 int i;
49 int loopi, loopj, loopk;
50
51 hypre_SetIndex(unit_stride, 1, 1, 1);
52
53 boxes = hypre_StructGridBoxes(hypre_StructVectorGrid(y));
54 hypre_ForBoxI(i, boxes)
55 {
56 box = hypre_BoxArrayBox(boxes, i);
57 start = hypre_BoxIMin(box);
58
59 x_data_box = hypre_BoxArrayBox(hypre_StructVectorDataSpace(x), i);
60 y_data_box = hypre_BoxArrayBox(hypre_StructVectorDataSpace(y), i);
61
62 xp = hypre_StructVectorBoxData(x, i);
63 yp = hypre_StructVectorBoxData(y, i);
64
65 hypre_BoxGetSize(box, loop_size);
66
67 hypre_BoxLoop2Begin(loop_size,
68 x_data_box, start, unit_stride, xi,
69 y_data_box, start, unit_stride, yi);
70
71 hypre_BoxLoop2For(loopi, loopj, loopk, xi, yi)
72 {
73 yp[yi] += alpha * xp[xi];
74 }
75 hypre_BoxLoop2End(xi, yi);
76 }
77
78 return ierr;
79}
Note: See TracBrowser for help on using the repository browser.