Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Zoltan2_MatchingSolution.hpp
Go to the documentation of this file.
1 #if 0
2 // @HEADER
3 //
4 // ***********************************************************************
5 //
6 // Zoltan2: A package of combinatorial algorithms for scientific computing
7 // Copyright 2012 Sandia Corporation
8 //
9 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Karen Devine (kddevin@sandia.gov)
40 // Erik Boman (egboman@sandia.gov)
41 // Siva Rajamanickam (srajama@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 
51 #ifndef _ZOLTAN2_MATCHINGSOLUTION_HPP_
52 #define _ZOLTAN2_MATCHINGSOLUTION_HPP_
53 
54 #include <Zoltan2_Standards.hpp>
55 #include <Zoltan2_Solution.hpp>
56 
57 namespace Zoltan2 {
58 
70 template <typename Adapter>
71  class MatchingSolution : public Solution
72 {
73 private:
74  typedef typename Adapter::gno_t gno_t;
75  typedef typename Adapter::scalar_t scalar_t;
76  typedef typename Adapter::lno_t lno_t;
77 
78 public:
79 
82  MatchingSolution(
83  size_t length // This should be equal to nlids. TODO: Optional?
84  )
85  {
86  HELLO;
87  length_ = length;
88  colors_ = ArrayRCP<int>(length_);
89  }
90 
92  // Accessor functions, allowing algorithms to get ptrs to solution memory.
93  // Algorithms can then load the memory.
94  // Non-RCP versions are provided for applications to use.
95 
98  inline size_t getMatchsSize() {return length_;}
99 
102  inline ArrayRCP<int> &getMatchsRCP() {return colors_;}
103 
106  inline int * getMatchs() {return &(*colors_);}
107 
111  int getNumColors()
112  {
113  int maxColor = 0;
114  for (size_t i=0; i<length_; i++){
115  if (colors_[i] > maxColor)
116  maxColor = colors_[i];
117  }
118  return maxColor;
119  }
120 
123  //int getGlobalNumColors(); // TODO
124 
125 protected:
126  // Matching solution consists of permutation vector(s).
127  size_t length_;
128  ArrayRCP<int> colors_; // zero-based local color array
129  //int numMatchs_; // Number of colors (local on this proc)
130  //int numMatchsGlobal_; // For future distributed coloring
131 };
132 
133 }
134 
135 #endif
136 #endif
#define HELLO
Defines the Solution base class.
map_t::global_ordinal_type gno_t
Definition: mapRemotes.cpp:18
map_t::local_ordinal_type lno_t
Definition: mapRemotes.cpp:17
Gathering definitions used in software development.