Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_ShyLUBasker_TypeMap.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// Amesos2: Templated Direct Sparse Solver Package
6// Copyright 2011 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//
42// @HEADER
43
55#ifndef AMESOS2_SHYLUBASKER_TYPEMAP_HPP
56#define AMESOS2_SHYLUBASKER_TYPEMAP_HPP
57
58#include <functional>
59#ifdef HAVE_TEUCHOS_COMPLEX
60#include <complex>
61#endif
62
63#include <Teuchos_as.hpp>
64#ifdef HAVE_TEUCHOS_COMPLEX
65#include <Teuchos_SerializationTraits.hpp>
66#endif
67
68#include "Amesos2_TypeMap.hpp"
69
70
71#ifdef HAVE_TEUCHOS_COMPLEX
72
73/* ==================== Conversion ==================== */
74namespace Teuchos {
75
87#ifndef HAVE_AMESOS2_KLU2
88
89template <>
90class ValueTypeConversionTraits<std::complex<double>, std::complex<float> >
91{
92public:
93 static std::complex<double> convert( const std::complex<float> t )
94 {
95 std::complex<double> ret(Teuchos::as<double>(t.real()),
96 Teuchos::as<double>(t.imag()));
97 return( ret );
98 }
99
100 static std::complex<double> safeConvert( const std::complex<float> t )
101 {
102 std::complex<double> ret(Teuchos::as<double>(t.real()),
103 Teuchos::as<double>(t.imag()));
104 return( ret );
105 }
106};
107
108
109template <>
110class ValueTypeConversionTraits<std::complex<float> , std::complex<double> >
111{
112public:
113 static std::complex<float> convert( const std::complex<double> t )
114 {
115 float ret_r = Teuchos::as<float>( t.real() );
116 float ret_i = Teuchos::as<float>( t.imag() );
117 std::complex<float> ret (ret_r, ret_i);
118 return (ret);
119 }
120
121 // No special checks for safe Convert
122 static std::complex<float> safeConvert( const std::complex<double> t )
123 {
124 float ret_r = Teuchos::as<float>( t.real() );
125 float ret_i = Teuchos::as<float>( t.imag() );
126 std::complex<float> ret (ret_r, ret_i);
127 return (ret);
128 }
129};
130
131
132#endif
134
135
136} // end namespace Teuchos
137
138#endif // HAVE_TEUCHOS_COMPLEX
139
140
141namespace Amesos2 {
142
143template <class, class> class ShyLUBasker;
144
145/* Specialize the Amesos2::TypeMap struct for ShyLUBasker types
146 * TODO: Mostly dummy assignments as ShyLUBasker is templated. Remove if possible.
147 *
148 * \cond ShyLUBasker_type_specializations
149 */
150
151template <>
152struct TypeMap<ShyLUBasker,float>
153{
154 static float dtype;
155 typedef float type;
156 typedef float magnitude_type;
157};
158
159
160template <>
161struct TypeMap<ShyLUBasker,double>
162{
163 static double dtype;
164 typedef double type;
165 typedef double magnitude_type;
166};
167
168
169#ifdef HAVE_TEUCHOS_COMPLEX
170
171template <>
172struct TypeMap<ShyLUBasker,std::complex<float> >
173{
174 static std::complex<double> dtype;
175 typedef std::complex<double> type;
176 typedef double magnitude_type;
177};
178
179
180template <>
181struct TypeMap<ShyLUBasker,std::complex<double> >
182{
183 static std::complex<double> dtype;
184 typedef std::complex<double> type;
185 typedef double magnitude_type;
186};
187
188
189#endif // HAVE_TEUCHOS_COMPLEX
190
191/* \endcond ShyLUBasker_type_specializations */
192
193
194} // end namespace Amesos2
195
196#endif // AMESOS2_SHYLUBASKER_TYPEMAP_HPP