|
DenseLinAlgPack: Concreate C++ Classes for Dense Blas-Compatible Linear Algebra
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization 00005 // Copyright (2003) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #ifndef ASSERT_PRINT_NAN_INF_H 00043 #define ASSERT_PRINT_NAN_INF_H 00044 00045 #include <stdexcept> 00046 #include <string> 00047 00048 #include "DenseLinAlgPack_Types.hpp" 00049 00050 namespace DenseLinAlgPack { 00051 00053 class NaNInfException : public std::runtime_error 00054 {public: NaNInfException(const std::string& what_arg) : std::runtime_error(what_arg) {}}; 00055 00057 /* * This function asserts if a value_type scalare is a NaN or Inf and optionally 00058 * prints out these entires. 00059 * 00060 * @param val [I] Value the check 00061 * @param name [I] Name of the scale variable for output purposes 00062 * @param throw_excpt [I] If true and is found to be a NaN or Inf 00063 * then a NaNInfException excetion is thrown after 00064 * any output. 00065 * @param out [I/O] If out==NULL then not output is produced. 00066 * If out!=NULL and val is not 00067 * NaN or Inf, then no output is produced. 00068 * If out!=NULL and val is 00069 * NaN or Inf then this will be printed before any 00070 * execption is thrown. 00071 * 00072 * @return Returns true if val is not NaN or Inf. If val 00073 * is NaN or Inf then false will be returned unless a 00074 * excetion NaNInfException was thrown (throw_except==true). 00075 */ 00076 bool assert_print_nan_inf( const value_type& val, const std::string & name 00077 , bool throw_excpt, std::ostream* out ); 00078 00080 /* * This function asserts if a vector has any NaN or inf entries and optionally 00081 * prints out these entires. 00082 * 00083 * @param v [I] DVector slice to check 00084 * @param name [I] Name of the vector for output purposes 00085 * @param throw_excpt [I] If true and an entry is found to be a NaN or Inf 00086 * then a NaNInfException excetion is thrown after 00087 * any output. 00088 * @param out [I/O] If out==NULL then not output is produced. 00089 * If out!=NULL and none of the entries is 00090 * NaN or Inf, then no output is produced. 00091 * If out!=NULL then any entries that are 00092 * NaN or Inf will be printed before any 00093 * execption is thrown. 00094 * 00095 * @return Returns true none of the entries are NaN or Inf. If one of the 00096 * entries is NaN or Inf then false will be returned unless an 00097 * excetion was thrown (throw_except==true). 00098 */ 00099 bool assert_print_nan_inf( const DVectorSlice& v, const std::string & name 00100 , bool throw_excpt, std::ostream* out ); 00101 00103 /* * This function asserts if a matrix has any NaN or inf entries and optionally 00104 * prints out these entires. 00105 * 00106 * @param m [I] Matrix slice to check 00107 * @param name [I] Name of the matrix for output purposes 00108 * @param throw_excpt [I] If true and an entry is found to be a NaN or Inf 00109 * then a NaNInfException excetion is thrown after 00110 * any output. 00111 * @param out [I/O] If out==NULL then not output is produced. 00112 * If out!=NULL and none of the entries is 00113 * NaN or Inf, then no output is produced. 00114 * If out!=NULL then any entries that are 00115 * NaN or Inf will be printed before any 00116 * execption is thrown. 00117 * 00118 * @return Returns true none of the entries are NaN or Inf. If one of the 00119 * entries is NaN or Inf then false will be returned unless an 00120 * excetion was thrown (throw_except==true). 00121 */ 00122 bool assert_print_nan_inf( const DMatrixSlice& m, const std::string & name 00123 , bool throw_excpt, std::ostream* out ); 00124 00125 } // end namespace DenseLinAlgPack 00126 00127 #endif // ASSERT_PRINT_NAN_INF_H
1.7.6.1