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

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

Parent Directory Parent Directory | Revision Log Revision Log


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


1 ksteube 1312
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 uqaeller 6939 * Copyright (c) 2003-2020 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13 uqaeller 6939 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14     * Development from 2019 by School of Earth and Environmental Sciences
15     **
16 jfenwick 3981 *****************************************************************************/
17 dhawcroft 631
18 ksteube 1811
19 caltinay 4852 #ifndef __PASO_UTIL_H__
20     #define __PASO_UTIL_H__
21 jgs 150
22 caltinay 4852 /****************************************************************************/
23 jgs 150
24     /* Some utility routines: */
25    
26 caltinay 4852 /****************************************************************************/
27 jgs 150
28     /* Copyrights by ACcESS Australia, 2003,2004,2005 */
29 jfenwick 2625 /* author: l.gross@uq.edu.au */
30 jgs 150
31 caltinay 4852 /****************************************************************************/
32 jgs 150
33 caltinay 4869 #include "Paso.h"
34 jgs 150
35 caltinay 4819 namespace paso {
36 jfenwick 4934
37     namespace util {
38 caltinay 4819
39 caltinay 4852 /// 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 caltinay 4819 int comparIndex(const void* index1, const void* index2);
48    
49 caltinay 4852 /// calculates the cumulative sum in array and returns the total sum
50     index_t cumsum(dim_t N, index_t* array);
51 caltinay 4819
52 caltinay 4869 index_t cumsum_maskedTrue(dim_t N, index_t* array, int* mask);
53 gross 3283
54 caltinay 4869 index_t cumsum_maskedFalse(dim_t N, index_t* array, int* mask);
55 gross 1639
56 caltinay 4852 /// returns the maximum value in integer array
57     index_t iMax(dim_t N, const index_t* array);
58 gross 3140
59 caltinay 4852 /// returns the inner product of global arrays x and y
60     double innerProduct(dim_t N, const double* x, const double* y,
61 caltinay 6190 escript::JMPI mpiInfo);
62 caltinay 4852
63     /// returns true if array contains value
64 caltinay 6192 bool isAny(dim_t N, const index_t* array, index_t value);
65 caltinay 4852
66     /// returns the global L2 norm of x
67 caltinay 6190 double l2(dim_t N, const double* x, escript::JMPI mpiInfo);
68 caltinay 4852
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 caltinay 6190 double lsup(dim_t N, const double* x, escript::JMPI mpiInfo);
76 caltinay 4852
77     /// returns the number of positive values in x
78 caltinay 6190 dim_t numPositives(dim_t N, const double* x, escript::JMPI mpiInfo);
79 caltinay 4852
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 caltinay 4869 /// returns true if both arguments have the same sign, false otherwise
106     inline bool samesign(double a, double b)
107 caltinay 4852 {
108 caltinay 4869 return (a>=0 && b>=0) || (a<=0 && b<=0);
109 caltinay 4852 }
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