Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_MatrixMarket_assignScalar.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef __Teuchos_MatrixMarket_assignScalar_hpp
11#define __Teuchos_MatrixMarket_assignScalar_hpp
12
13#include <Teuchos_as.hpp>
15#include <string>
16
17
18namespace Teuchos {
19 namespace MatrixMarket {
20 namespace details {
21
27 template<class Scalar, bool isComplex=Teuchos::ScalarTraits<Scalar>::isComplex>
29 public:
30 static void
31 assign (Scalar& val,
34 };
35
36 // Partial specialization for real Scalar types.
37 template<class RealType>
38 class ScalarAssigner<RealType, false> {
39 public:
40 static void
41 assign (RealType& val,
44 {
45 // imag had better be zero. We're ignoring it regardless.
46 (void) imag;
47 val = real;
48 }
49 };
50
51#ifdef HAVE_TEUCHOS_COMPLEX
52 // Partial specialization for complex Scalar types.
53 // MagType is the template parameter for std::complex.
54 template<class MagType>
55 class ScalarAssigner<std::complex<MagType>, true> {
56 public:
57 static void
58 assign (std::complex<MagType>& val,
59 const typename Teuchos::ScalarTraits<std::complex<MagType> >::magnitudeType& real,
60 const typename Teuchos::ScalarTraits<std::complex<MagType> >::magnitudeType& imag)
61 {
62 val = std::complex<MagType> (real, imag);
63 }
64 };
65#endif // HAVE_TEUCHOS_COMPLEX
66
73 template<class Scalar>
74 void
75 assignScalar (Scalar& val,
78 {
79 ScalarAssigner<Scalar>::assign (val, real, imag);
80 }
81
82 } // namespace details
83 } // namespace MatrixMarket
84} // namespace Teuchos
85
86#endif // __Teuchos_MatrixMarket_assignScalar_hpp
Defines basic traits for the scalar field type.
Definition of Teuchos::as, for conversions between types.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
This structure defines some basic traits for a scalar field type.
T magnitudeType
Mandatory typedef for result of magnitude.