io.cpp
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2019 Joel Holdsworth <joel.holdsworth@vcatechnology.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #include <sstream>
11 
12 #include "main.h"
13 
14 template<typename Scalar>
16 {
17  static void run()
18  {
19  const Array<Scalar,1,1> array(123);
20  std::ostringstream ss;
21  ss << array;
22  VERIFY(ss.str() == "123");
23 
25  };
26 };
27 
28 template<>
29 struct check_ostream_impl<bool>
30 {
31  static void run()
32  {
33  const Array<bool,1,2> array(1, 0);
34  std::ostringstream ss;
35  ss << array;
36  VERIFY(ss.str() == "1 0");
37  };
38 };
39 
40 template<typename Scalar>
41 struct check_ostream_impl< std::complex<Scalar> >
42 {
43  static void run()
44  {
45  const Array<std::complex<Scalar>,1,1> array(std::complex<Scalar>(12, 34));
46  std::ostringstream ss;
47  ss << array;
48  VERIFY(ss.str() == "(12,34)");
49  };
50 };
51 
52 template<typename Scalar>
53 static void check_ostream()
54 {
56 }
57 
59 {
60  CALL_SUBTEST(check_ostream<bool>());
61  CALL_SUBTEST(check_ostream<float>());
62  CALL_SUBTEST(check_ostream<double>());
63  CALL_SUBTEST(check_ostream<Eigen::numext::int8_t>());
64  CALL_SUBTEST(check_ostream<Eigen::numext::uint8_t>());
65  CALL_SUBTEST(check_ostream<Eigen::numext::int16_t>());
66  CALL_SUBTEST(check_ostream<Eigen::numext::uint16_t>());
67  CALL_SUBTEST(check_ostream<Eigen::numext::int32_t>());
68  CALL_SUBTEST(check_ostream<Eigen::numext::uint32_t>());
69  CALL_SUBTEST(check_ostream<Eigen::numext::int64_t>());
70  CALL_SUBTEST(check_ostream<Eigen::numext::uint64_t>());
71 }
check_ostream_impl::run
static void run()
Definition: io.cpp:17
array
int array[24]
Definition: Map_general_stride.cpp:1
check_ostream
static void check_ostream()
Definition: io.cpp:53
Eigen::Array
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:45
ss
static std::stringstream ss
Definition: testBTree.cpp:31
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(rand)
Definition: io.cpp:58
check_ostream_impl< std::complex< Scalar > >::run
static void run()
Definition: io.cpp:43
check_ostream_impl< bool >::run
static void run()
Definition: io.cpp:31
main.h
std
Definition: BFloat16.h:88
check_ostream_impl
Definition: io.cpp:15
complex
Definition: datatypes.h:12
CALL_SUBTEST
#define CALL_SUBTEST(FUNC)
Definition: main.h:399
VERIFY
#define VERIFY(a)
Definition: main.h:380


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:45