57 #ifndef AMESOS2_SUPERLUDIST_TYPEMAP_HPP
58 #define AMESOS2_SUPERLUDIST_TYPEMAP_HPP
63 #include <Teuchos_as.hpp>
64 #ifdef HAVE_TEUCHOS_COMPLEX
65 #include <Teuchos_SerializationTraits.hpp>
68 #include "Amesos2_TypeMap.hpp"
75 #include "superlu_dist_config.h"
78 #define USER_FREE(addr) SLUD::superlu_free_dist(addr)
82 #undef __SUPERLU_SUPERMATRIX
83 #include "superlu_defs.h"
86 #if SUPERLU_DIST_MAJOR_VERSION > 4
87 typedef superlu_dist_options_t amesos2_superlu_dist_options_t;
88 typedef superlu_dist_mem_usage_t amesos2_superlu_dist_mem_usage_t;
89 #define AMESOS2_ENABLES_SUPERLUDIST_VERSION5_AND_HIGHER 1
91 typedef superlu_options_t amesos2_superlu_dist_options_t;
92 typedef mem_usage_t amesos2_superlu_dist_mem_usage_t;
97 #include "superlu_ddefs.h"
100 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
102 #include "superlu_zdefs.h"
104 #endif // HAVE_TEUCHOS_COMPLEX
110 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
114 template <
typename slu_scalar_t,
typename slu_mag_t>
115 struct slu_mt_mult {};
119 template <
typename T>
120 struct slu_mt_mult<T,T> : std::multiplies<T> {};
124 struct slu_mt_mult<Z::doublecomplex,double>
125 : std::binary_function<Z::doublecomplex,double,Z::doublecomplex> {
126 Z::doublecomplex operator()(Z::doublecomplex amesos_z,
double amesos_d) {
127 Z::doublecomplex amesos_zr;
128 zd_mult(&amesos_zr, &amesos_z, amesos_d);
134 struct slu_mt_mult<Z::doublecomplex,Z::doublecomplex>
135 : std::binary_function<Z::doublecomplex,Z::doublecomplex,Z::doublecomplex> {
136 Z::doublecomplex operator()(Z::doublecomplex amesos_z1, Z::doublecomplex amesos_z2) {
137 Z::doublecomplex amesos_zr;
138 zz_mult(&amesos_zr, &amesos_z1, &amesos_z2);
142 #endif // HAVE_TEUCHOS_COMPLEX
144 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
160 template <
typename TypeFrom>
161 class ValueTypeConversionTraits<SLUD::Z::doublecomplex, TypeFrom>
164 static SLUD::Z::doublecomplex convert(
const TypeFrom t )
166 SLUD::Z::doublecomplex ret;
167 ret.r = Teuchos::as<double>(t.real());
168 ret.i = Teuchos::as<double>(t.imag());
172 static SLUD::Z::doublecomplex safeConvert(
const TypeFrom t )
174 SLUD::Z::doublecomplex ret;
175 ret.r = Teuchos::as<double>(t.real());
176 ret.i = Teuchos::as<double>(t.imag());
183 template <
typename TypeTo>
184 class ValueTypeConversionTraits<TypeTo, SLUD::Z::doublecomplex>
187 static TypeTo convert(
const SLUD::Z::doublecomplex t )
189 typedef typename TypeTo::value_type value_type;
190 value_type ret_r = Teuchos::as<value_type>( t.r );
191 value_type ret_i = Teuchos::as<value_type>( t.i );
192 return ( TypeTo( ret_r, ret_i ) );
196 static TypeTo safeConvert(
const SLUD::Z::doublecomplex t )
198 typedef typename TypeTo::value_type value_type;
199 value_type ret_r = Teuchos::as<value_type>( t.r );
200 value_type ret_i = Teuchos::as<value_type>( t.i );
201 return ( TypeTo( ret_r, ret_i ) );
205 template <
typename Ordinal>
206 class SerializationTraits<Ordinal,SLUD::Z::doublecomplex>
207 :
public DirectSerializationTraits<Ordinal,SLUD::Z::doublecomplex>
223 ostream& operator<<(ostream& out,
const SLUD::Z::doublecomplex z);
227 #endif // HAVE_TEUCHOS_COMPLEX
233 template <
class,
class>
class Superludist;
240 struct TypeMap<Superludist,double>
242 static const SLUD::Dtype_t dtype = SLUD::SLU_D;
244 typedef double magnitude_type;
245 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
246 typedef SLUD::D::dLUstruct_t LUstruct_t;
247 typedef SLUD::D::dSOLVEstruct_t SOLVEstruct_t;
248 typedef SLUD::D::dScalePermstruct_t ScalePermstruct_t;
250 typedef SLUD::D::LUstruct_t LUstruct_t;
251 typedef SLUD::D::SOLVEstruct_t SOLVEstruct_t;
252 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
256 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
258 struct TypeMap<Superludist,std::complex<double> >
260 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
261 typedef SLUD::Z::doublecomplex type;
262 typedef double magnitude_type;
263 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
264 typedef SLUD::Z::zLUstruct_t LUstruct_t;
265 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
266 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
268 typedef SLUD::Z::LUstruct_t LUstruct_t;
269 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
270 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
278 struct TypeMap<Superludist,SLUD::Z::doublecomplex>
280 static const SLUD::Dtype_t dtype = SLUD::SLU_Z;
281 typedef SLUD::Z::doublecomplex type;
282 typedef double magnitude_type;
283 #if SUPERLU_DIST_MAJOR_VERSION > 6 || (SUPERLU_DIST_MAJOR_VERSION == 6 && SUPERLU_DIST_MINOR_VERSION > 2)
284 typedef SLUD::Z::zLUstruct_t LUstruct_t;
285 typedef SLUD::Z::zSOLVEstruct_t SOLVEstruct_t;
286 typedef SLUD::Z::zScalePermstruct_t ScalePermstruct_t;
288 typedef SLUD::Z::LUstruct_t LUstruct_t;
289 typedef SLUD::Z::SOLVEstruct_t SOLVEstruct_t;
290 typedef SLUD::ScalePermstruct_t ScalePermstruct_t;
294 #endif // HAVE_TEUCHOS_COMPLEX
301 #endif // AMESOS2_SUPERLUDIST_TYPEMAP_HPP