/[escript]/trunk/ripley/src/domainhelpers.h
ViewVC logotype

Diff of /trunk/ripley/src/domainhelpers.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4760 by sshaw, Mon Mar 17 23:48:37 2014 UTC revision 5114 by caltinay, Thu Aug 14 05:15:31 2014 UTC
# Line 1  Line 1 
 #ifndef _DOMAINHELPERS_H_  
 #define _DOMAINHELPERS_H_  
1    
2  #include <vector>  /*****************************************************************************
3    *
4    * Copyright (c) 2003-2014 by University of Queensland
5    * http://www.uq.edu.au
6    *
7    * Primary Business: Queensland, Australia
8    * Licensed under the Open Software License version 3.0
9    * http://www.opensource.org/licenses/osl-3.0.php
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 by Centre for Geoscience Computing (GeoComp)
14    *
15    *****************************************************************************/
16    #ifndef _RIPLEY_DOMAINHELPERS_H_
17    #define _RIPLEY_DOMAINHELPERS_H_
18    
19  #include <ripley/Ripley.h>  #include <ripley/Ripley.h>
20  #include <escript/Data.h>  #include <escript/Data.h>
21    
22    namespace ripley {
23    
24    typedef std::map<std::string, escript::Data> DataMap;
25    
26    /// returns the data associated with the string key or an empty data object
27    /// if the map does not contain the given key
28    inline const escript::Data unpackData(const std::string target,
29                                          const DataMap& mapping)
30    {
31        DataMap::const_iterator i = mapping.find(target);
32        return (i == mapping.end() ? escript::Data() : i->second);
33    }
34    
35  /**  /**
36      factorises 'product' and inserts the factors into the vector 'factors'      returns true if the given string is in the mapping AND the resulting
37      in order of smallest to largest      coefficient is not empty
38  */  */
39  void factorise(std::vector<int>& factors, int product);  inline bool isNotEmpty(const std::string target, const DataMap& mapping)
40    {
41        DataMap::const_iterator i = mapping.find(target);
42        return i != mapping.end() && !i->second.isEmpty();
43    }
44    
45  /**  /**
46      sets va[a] = b and vb[b] = a, used in constructing CSC and CSR matrix      sets va[a] = b and vb[b] = a, used in constructing CSC and CSR matrix
47      formats simultaneously      formats simultaneously
48  */  */
49  void doublyLink(std::vector<ripley::IndexVector>& va,  inline void doublyLink(std::vector<ripley::IndexVector>& va,
50          std::vector<ripley::IndexVector>& vb, int a, int b);                         std::vector<ripley::IndexVector>& vb, int a, int b)
51    {
52        va[a].push_back(b);
53        vb[b].push_back(a);
54    }
55    
56  /**  /**
57      returns true if the given string is in the mapping AND the resulting      factorises 'product' and inserts the factors into the vector 'factors'
58      coefficient is not empty      in order of smallest to largest
59  */  */
60  bool isNotEmpty(std::string target, std::map<std::string, escript::Data> mapping);  void factorise(std::vector<int>& factors, int product);
61    
62    
63  #ifdef USE_BOOSTIO  #ifdef USE_BOOSTIO
64  /**  /**
65      converts the given gzip compressed char vector unto an uncompressed form      converts the given gzip compressed char vector into an uncompressed form
66  */  */
67  std::vector<char> unzip(const std::vector<char> compressed);  std::vector<char> unzip(const std::vector<char>& compressed);
68  #endif  #endif // USE_BOOSTIO
69  #endif  
70    } // namespace ripley
71    
72    #endif // _RIPLEY_DOMAINHELPERS_H_
73    

Legend:
Removed from v.4760  
changed lines
  Added in v.5114

  ViewVC Help
Powered by ViewVC 1.1.26