00001 /* Ergo, version 3.7, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 00004 * and Anastasia Kruchinina. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * Primary academic reference: 00020 * Ergo: An open-source program for linear-scaling electronic structure 00021 * calculations, 00022 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 00023 * Kruchinina, 00024 * SoftwareX 7, 107 (2018), 00025 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 00026 * 00027 * For further information about Ergo, see <http://www.ergoscf.org>. 00028 */ 00029 00030 /* This file belongs to the template_lapack part of the Ergo source 00031 * code. The source files in the template_lapack directory are modified 00032 * versions of files originally distributed as CLAPACK, see the 00033 * Copyright/license notice in the file template_lapack/COPYING. 00034 */ 00035 00036 00037 #ifndef TEMPLATE_BLAS_NUM_LIMITS_HEADER 00038 #define TEMPLATE_BLAS_NUM_LIMITS_HEADER 00039 00040 #include <limits> 00041 00042 /* We need to include config.h to get macro PRECISION_QUAD_FLT128 */ 00043 #include "config.h" 00044 00045 #ifdef PRECISION_QUAD_FLT128 00046 #include <quadmath.h> 00047 #endif 00048 00049 00050 /* template_blas_get_machine_epsilon(): function for getting the 00051 machine epsilon (the difference between 1 and the least value 00052 greater than 1 that is representable) for the given 00053 floating-point type. */ 00054 template<typename Treal> 00055 inline static Treal template_blas_get_machine_epsilon() { 00056 return std::numeric_limits<Treal>::epsilon(); 00057 } 00058 00059 #ifdef PRECISION_QUAD_FLT128 00060 template<> 00061 inline __float128 template_blas_get_machine_epsilon<__float128>() { 00062 return FLT128_EPSILON; 00063 } 00064 #endif 00065 00066 00067 /* template_blas_get_num_limit_min(): function for getting the minimum 00068 positive normalized value for the given floating-point type. */ 00069 template<typename Treal> 00070 inline static Treal template_blas_get_num_limit_min() { 00071 return std::numeric_limits<Treal>::min(); 00072 } 00073 00074 #ifdef PRECISION_QUAD_FLT128 00075 template<> 00076 inline __float128 template_blas_get_num_limit_min<__float128>() { 00077 return FLT128_MIN; // FLT128_MIN: smallest positive number with full precision 00078 } 00079 #endif 00080 00081 00082 /* template_blas_get_num_limit_max(): function for getting the maximum 00083 finite value for the given floating-point type. */ 00084 template<typename Treal> 00085 inline static Treal template_blas_get_num_limit_max() { 00086 return std::numeric_limits<Treal>::max(); 00087 } 00088 00089 #ifdef PRECISION_QUAD_FLT128 00090 template<> 00091 inline __float128 template_blas_get_num_limit_max<__float128>() { 00092 return FLT128_MAX; // FLT128_MAX: largest finite number 00093 } 00094 #endif 00095 00096 00097 #endif