/[escript]/trunk/paso/src/PasoUtil.h
ViewVC logotype

Contents of /trunk/paso/src/PasoUtil.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (5 weeks, 3 days ago) by uqaeller
File MIME type: text/plain
File size: 3502 byte(s)
Updated the copyright header.


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17
18
19 #ifndef __PASO_UTIL_H__
20 #define __PASO_UTIL_H__
21
22 /****************************************************************************/
23
24 /* Some utility routines: */
25
26 /****************************************************************************/
27
28 /* Copyrights by ACcESS Australia, 2003,2004,2005 */
29 /* author: l.gross@uq.edu.au */
30
31 /****************************************************************************/
32
33 #include "Paso.h"
34
35 namespace paso {
36
37 namespace util {
38
39 /// Applies a sequence of N-1 Givens rotations (c,s) to v of length N which is
40 /// assumed to be small.
41 void applyGivensRotations(dim_t N, double* v, const double* c, const double* s);
42
43 /// returns the index to the largest entry in lambda
44 index_t arg_max(dim_t N, dim_t* lambda);
45
46 /// this int-comparison function is used by qsort/bsearch in various places
47 int comparIndex(const void* index1, const void* index2);
48
49 /// calculates the cumulative sum in array and returns the total sum
50 index_t cumsum(dim_t N, index_t* array);
51
52 index_t cumsum_maskedTrue(dim_t N, index_t* array, int* mask);
53
54 index_t cumsum_maskedFalse(dim_t N, index_t* array, int* mask);
55
56 /// returns the maximum value in integer array
57 index_t iMax(dim_t N, const index_t* array);
58
59 /// returns the inner product of global arrays x and y
60 double innerProduct(dim_t N, const double* x, const double* y,
61 escript::JMPI mpiInfo);
62
63 /// returns true if array contains value
64 bool isAny(dim_t N, const index_t* array, index_t value);
65
66 /// returns the global L2 norm of x
67 double l2(dim_t N, const double* x, escript::JMPI mpiInfo);
68
69 /// Performs an update of the form z = a*x+b*y where y and x are long vectors.
70 /// If a=0, x is not used; if b=0, y is not used.
71 void linearCombination(dim_t N, double* z, double a, const double* x, double b,
72 const double* y);
73
74 /// returns the global Lsup of x
75 double lsup(dim_t N, const double* x, escript::JMPI mpiInfo);
76
77 /// returns the number of positive values in x
78 dim_t numPositives(dim_t N, const double* x, escript::JMPI mpiInfo);
79
80 /// Performs an update of the form x = a*x+b*y where y and x are long vectors.
81 /// If b=0, y is not used.
82 void update(dim_t N, double a, double* x, double b, const double* y);
83
84 /// fills array x with zeroes
85 void zeroes(dim_t N, double* x);
86
87 /// out = in
88 inline void copy(dim_t N, double* out, const double* in)
89 {
90 linearCombination(N, out, 1., in, 0., in);
91 }
92
93 /// x = a*x
94 inline void scale(dim_t N, double* x, double a)
95 {
96 update(N, a, x, 0, x);
97 }
98
99 /// x = x+a*y
100 inline void AXPY(dim_t N, double* x, double a, const double* y)
101 {
102 update(N, 1., x, a, y);
103 }
104
105 /// returns true if both arguments have the same sign, false otherwise
106 inline bool samesign(double a, double b)
107 {
108 return (a>=0 && b>=0) || (a<=0 && b<=0);
109 }
110
111 } // namespace util
112 } // namespace paso
113
114 #endif // __PASO_UTIL_H__
115

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26