Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ArrayView.cpp
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#include <Teuchos_ArrayView.hpp>
11
12namespace Teuchos {
13
14template<>
15TEUCHOSCORE_LIB_DLL_EXPORT std::string
17{
18 using Teuchos::as;
19 std::ostringstream ss;
20
22
23 ss.setf (std::ios::scientific);
24 // 8 = round(23 * log10(2)) + 1. That's one decimal digit more
25 // than the binary precision justifies, which should be plenty.
26 // Guy Steele et al. have a better algorithm for floating-point
27 // I/O, but using a lot of digits is the lazy approach.
28 ss.precision (8);
29 ss << "{";
30 for (size_type i = 0; i < size (); ++i) {
31 ss << operator[] (i);
32 if (i + 1 < size ()) {
33 ss << ", ";
34 }
35 }
36 ss << "}";
37 return ss.str ();
38}
39
40template<>
41TEUCHOSCORE_LIB_DLL_EXPORT std::string
43{
44 using Teuchos::as;
45 std::ostringstream ss;
46
48
49 ss.setf (std::ios::scientific);
50 // 8 = round(23 * log10(2)) + 1. That's one decimal digit more
51 // than the binary precision justifies, which should be plenty.
52 // Guy Steele et al. have a better algorithm for floating-point
53 // I/O, but using a lot of digits is the lazy approach.
54 ss.precision (8);
55 ss << "{";
56 for (size_type i = 0; i < size (); ++i) {
57 ss << operator[] (i);
58 if (i + 1 < size ()) {
59 ss << ", ";
60 }
61 }
62 ss << "}";
63 return ss.str ();
64}
65
66template<>
67TEUCHOSCORE_LIB_DLL_EXPORT std::string
69{
70 using Teuchos::as;
71 std::ostringstream ss;
72
74
75 ss.setf (std::ios::scientific);
76 // 17 = round(52 * log10(2)) + 1. That's one decimal digit more
77 // than the binary precision justifies, which should be plenty. Guy
78 // Steele et al. have a better algorithm for floating-point I/O, but
79 // using a lot of digits is the lazy approach.
80 ss.precision (17);
81 ss << "{";
82 for (size_type i = 0; i < size (); ++i) {
83 ss << operator[] (i);
84 if (i + 1 < size ()) {
85 ss << ", ";
86 }
87 }
88 ss << "}";
89 return ss.str ();
90}
91
92template<>
93TEUCHOSCORE_LIB_DLL_EXPORT std::string
95{
96 using Teuchos::as;
97 std::ostringstream ss;
98
100
101 ss.setf (std::ios::scientific);
102 // 17 = round(52 * log10(2)) + 1. That's one decimal digit more
103 // than the binary precision justifies, which should be plenty. Guy
104 // Steele et al. have a better algorithm for floating-point I/O, but
105 // using a lot of digits is the lazy approach.
106 ss.precision (17);
107 ss << "{";
108 for (size_type i = 0; i < size (); ++i) {
109 ss << operator[] (i);
110 if (i + 1 < size ()) {
111 ss << ", ";
112 }
113 }
114 ss << "}";
115 return ss.str ();
116}
117
118} // namespace Teuchos
std::string toString() const
Convert an ArrayView<T> to an std::string
const RCP< T > & debug_assert_valid_ptr() const
Calls assert_valid_ptr() in a debug build.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...