MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseLinAlgPack_assert_print_nan_inf.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef ASSERT_PRINT_NAN_INF_H
43 #define ASSERT_PRINT_NAN_INF_H
44 
45 #include <stdexcept>
46 #include <string>
47 
49 
50 namespace DenseLinAlgPack {
51 
53 class NaNInfException : public std::runtime_error
54 {public: NaNInfException(const std::string& what_arg) : std::runtime_error(what_arg) {}};
55 
57 /* * This function asserts if a value_type scalare is a NaN or Inf and optionally
58  * prints out these entires.
59  *
60  * @param val [I] Value the check
61  * @param name [I] Name of the scale variable for output purposes
62  * @param throw_excpt [I] If true and is found to be a NaN or Inf
63  * then a NaNInfException excetion is thrown after
64  * any output.
65  * @param out [I/O] If out==NULL then not output is produced.
66  * If out!=NULL and val is not
67  * NaN or Inf, then no output is produced.
68  * If out!=NULL and val is
69  * NaN or Inf then this will be printed before any
70  * execption is thrown.
71  *
72  * @return Returns true if val is not NaN or Inf. If val
73  * is NaN or Inf then false will be returned unless a
74  * excetion NaNInfException was thrown (throw_except==true).
75  */
76 bool assert_print_nan_inf( const value_type& val, const std::string & name
77  , bool throw_excpt, std::ostream* out );
78 
80 /* * This function asserts if a vector has any NaN or inf entries and optionally
81  * prints out these entires.
82  *
83  * @param v [I] DVector slice to check
84  * @param name [I] Name of the vector for output purposes
85  * @param throw_excpt [I] If true and an entry is found to be a NaN or Inf
86  * then a NaNInfException excetion is thrown after
87  * any output.
88  * @param out [I/O] If out==NULL then not output is produced.
89  * If out!=NULL and none of the entries is
90  * NaN or Inf, then no output is produced.
91  * If out!=NULL then any entries that are
92  * NaN or Inf will be printed before any
93  * execption is thrown.
94  *
95  * @return Returns true none of the entries are NaN or Inf. If one of the
96  * entries is NaN or Inf then false will be returned unless an
97  * excetion was thrown (throw_except==true).
98  */
99 bool assert_print_nan_inf( const DVectorSlice& v, const std::string & name
100  , bool throw_excpt, std::ostream* out );
101 
103 /* * This function asserts if a matrix has any NaN or inf entries and optionally
104  * prints out these entires.
105  *
106  * @param m [I] Matrix slice to check
107  * @param name [I] Name of the matrix for output purposes
108  * @param throw_excpt [I] If true and an entry is found to be a NaN or Inf
109  * then a NaNInfException excetion is thrown after
110  * any output.
111  * @param out [I/O] If out==NULL then not output is produced.
112  * If out!=NULL and none of the entries is
113  * NaN or Inf, then no output is produced.
114  * If out!=NULL then any entries that are
115  * NaN or Inf will be printed before any
116  * execption is thrown.
117  *
118  * @return Returns true none of the entries are NaN or Inf. If one of the
119  * entries is NaN or Inf then false will be returned unless an
120  * excetion was thrown (throw_except==true).
121  */
122 bool assert_print_nan_inf( const DMatrixSlice& m, const std::string & name
123  , bool throw_excpt, std::ostream* out );
124 
125 } // end namespace DenseLinAlgPack
126 
127 #endif // ASSERT_PRINT_NAN_INF_H
bool assert_print_nan_inf(const value_type &val, const std::string &name, bool throw_excpt, std::ostream *out)
std::ostream * out
FortranTypes::f_dbl_prec value_type
Typedef for the value type of elements that is used for the library.