|
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 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef ASSERT_PRINT_NAN_INF_H 00030 #define ASSERT_PRINT_NAN_INF_H 00031 00032 #include <stdexcept> 00033 00034 #include "DenseLinAlgPack_Types.hpp" 00035 00036 namespace DenseLinAlgPack { 00037 00039 class NaNInfException : public std::runtime_error 00040 {public: NaNInfException(const std::string& what_arg) : std::runtime_error(what_arg) {}}; 00041 00043 /* * This function asserts if a value_type scalare is a NaN or Inf and optionally 00044 * prints out these entires. 00045 * 00046 * @param val [I] Value the check 00047 * @param name [I] Name of the scale variable for output purposes 00048 * @param throw_excpt [I] If true and is found to be a NaN or Inf 00049 * then a NaNInfException excetion is thrown after 00050 * any output. 00051 * @param out [I/O] If out==NULL then not output is produced. 00052 * If out!=NULL and val is not 00053 * NaN or Inf, then no output is produced. 00054 * If out!=NULL and val is 00055 * NaN or Inf then this will be printed before any 00056 * execption is thrown. 00057 * 00058 * @return Returns true if val is not NaN or Inf. If val 00059 * is NaN or Inf then false will be returned unless a 00060 * excetion NaNInfException was thrown (throw_except==true). 00061 */ 00062 bool assert_print_nan_inf( const value_type& val, char name[] 00063 , bool throw_excpt, std::ostream* out ); 00064 00066 /* * This function asserts if a vector has any NaN or inf entries and optionally 00067 * prints out these entires. 00068 * 00069 * @param v [I] DVector slice to check 00070 * @param name [I] Name of the vector for output purposes 00071 * @param throw_excpt [I] If true and an entry is found to be a NaN or Inf 00072 * then a NaNInfException excetion is thrown after 00073 * any output. 00074 * @param out [I/O] If out==NULL then not output is produced. 00075 * If out!=NULL and none of the entries is 00076 * NaN or Inf, then no output is produced. 00077 * If out!=NULL then any entries that are 00078 * NaN or Inf will be printed before any 00079 * execption is thrown. 00080 * 00081 * @return Returns true none of the entries are NaN or Inf. If one of the 00082 * entries is NaN or Inf then false will be returned unless an 00083 * excetion was thrown (throw_except==true). 00084 */ 00085 bool assert_print_nan_inf( const DVectorSlice& v, char name[] 00086 , bool throw_excpt, std::ostream* out ); 00087 00089 /* * This function asserts if a matrix has any NaN or inf entries and optionally 00090 * prints out these entires. 00091 * 00092 * @param m [I] Matrix slice to check 00093 * @param name [I] Name of the matrix for output purposes 00094 * @param throw_excpt [I] If true and an entry is found to be a NaN or Inf 00095 * then a NaNInfException excetion is thrown after 00096 * any output. 00097 * @param out [I/O] If out==NULL then not output is produced. 00098 * If out!=NULL and none of the entries is 00099 * NaN or Inf, then no output is produced. 00100 * If out!=NULL then any entries that are 00101 * NaN or Inf will be printed before any 00102 * execption is thrown. 00103 * 00104 * @return Returns true none of the entries are NaN or Inf. If one of the 00105 * entries is NaN or Inf then false will be returned unless an 00106 * excetion was thrown (throw_except==true). 00107 */ 00108 bool assert_print_nan_inf( const DMatrixSlice& m, char name[] 00109 , bool throw_excpt, std::ostream* out ); 00110 00111 } // end namespace DenseLinAlgPack 00112 00113 #endif // ASSERT_PRINT_NAN_INF_H
1.7.4