Belos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_lsqr_complex.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Belos: Block Linear Solvers Package
4 //
5 // Copyright 2004-2016 NTESS and the Belos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include <BelosConfigDefs.hpp>
13 #include <BelosLinearProblem.hpp>
14 #include <BelosLSQRSolMgr.hpp>
15 #include <complex>
16 
17 #include "MyMultiVec.hpp"
18 #include "MyBetterOperator.hpp"
19 #include "MyOperator.hpp"
20 
21 //
22 // mfh 20 Jan 2014: This test ensures the following:
23 //
24 // 1. Belos::LSQRSolMgr can compile whether its ScalarType (first)
25 // template parameter is real or complex.
26 // 2. Belos::LSQRSolMgr's constructor throws std::logic_error if and
27 // only if its ScalarType (first) template parameter is complex.
28 //
29 // At some point, if LSQRSolMgr gets fixed so that it works with
30 // complex ScalarType, the second test will no longer pass. This will
31 // be a good thing! The test should still be built in that case, in
32 // order to demonstrate that LSQRSolMgr compiles for complex
33 // ScalarType. However, in that case, the TEST_THROW macro should be
34 // changed to TEST_NOTHROW, and the macro's second argument should be
35 // removed.
36 //
37 // This test requires that Trilinos was compiled with complex
38 // arithmetic support enabled.
39 //
40 
41 TEUCHOS_UNIT_TEST( LSQR, RealDoesNotThrow )
42 {
43  using Teuchos::RCP;
44  using Teuchos::rcp;
45  typedef double ST;
46  typedef Belos::MultiVec<ST> MV;
47  typedef Belos::Operator<ST> OP;
48  // typedef Belos::MultiVecTraits<ST, MV> MVT;
49  // typedef Belos::OperatorTraits<ST, MV, OP> OPT;
50  typedef Belos::LSQRSolMgr<ST, MV, OP> sol_mgr_type;
51 
52  RCP<sol_mgr_type> solver;
53  TEST_NOTHROW( solver = rcp (new sol_mgr_type ()) );
54 }
55 
56 TEUCHOS_UNIT_TEST( LSQR, ComplexThrows )
57 {
58  using Teuchos::RCP;
59  using Teuchos::rcp;
60  typedef std::complex<double> ST;
61  typedef Belos::MultiVec<ST> MV;
62  typedef Belos::Operator<ST> OP;
63  // typedef Belos::MultiVecTraits<ST, MV> MVT;
64  // typedef Belos::OperatorTraits<ST, MV, OP> OPT;
65  typedef Belos::LSQRSolMgr<ST, MV, OP> sol_mgr_type;
66 
67  // no longer throws due to DII system needing to make dummy constructor
68  RCP<sol_mgr_type> solver = rcp (new sol_mgr_type ());
69  TEST_THROW( solver->getNumIters() , std::logic_error ); // throws!
70 }
#define TEST_NOTHROW(code)
TEUCHOS_UNIT_TEST(Factory, Bug6383)
Definition: Factory.cpp:201
Alternative run-time polymorphic interface for operators.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class which describes the linear problem to be solved by the iterative solver.
LSQRSolMgr: interface to the LSQR method.
#define TEST_THROW(code, ExceptType)
Interface for multivectors used by Belos&#39; linear solvers.
LSQR method (for linear systems and linear least-squares problems).
Belos header file which uses auto-configuration information to include necessary C++ headers...