美文网首页
c++求极值

c++求极值

作者: 送分童子笑嘻嘻 | 来源:发表于2020-03-27 16:18 被阅读0次

https://blog.csdn.net/fengbingchun/article/details/77922558

#include "numeric_limits.hpp"
#include <limits>
#include <iostream>
 
//////////////////////////////////////////////////////////////////////
/* reference:
    http://www.cplusplus.com/reference/limits/numeric_limits/
    https://msdn.microsoft.com/en-us/library/c707ct0t.aspx
*/
int test_numeric_limits_1()
{
    std::cout << std::boolalpha;
    std::cout << "Minimum value for int: " << std::numeric_limits<int>::min() << std::endl;
    std::cout << "Maximum value for int: " << std::numeric_limits<int>::max() << std::endl;
    std::cout << "int is signed: " << std::numeric_limits<int>::is_signed << std::endl;
    std::cout << "Non-sign bits in int: " << std::numeric_limits<int>::digits << std::endl;
    std::cout << "int has infinity: " << std::numeric_limits<int>::has_infinity << std::endl;
 
    std::cout << "Minimum value for float: " << std::numeric_limits<float>::min() << std::endl; // min returns the smallest positive value the type can encode, not the lowest
    std::cout << "Lowest value for float: " << std::numeric_limits<float>::lowest() << std::endl; // the lowest value
    std::cout << "Maximum value for float: " << std::numeric_limits<float>::max() << std::endl;
    std::cout << "float is signed: " << std::numeric_limits<float>::is_signed << std::endl;
    std::cout << "Non-sign bits in float: " << std::numeric_limits<float>::digits << std::endl;
    std::cout << "float has infinity: " << std::numeric_limits<float>::has_infinity << std::endl;
 
    std::cout << "Minimum value for unsigned short: " << std::numeric_limits<unsigned short>::min() << std::endl;
    std::cout << "Maximum value for unsigned short: " << std::numeric_limits<unsigned short>::max() << std::endl;
 
    std::cout << "is_specialized(float): " << std::numeric_limits<float>::is_specialized << std::endl;
    std::cout << "is_integer(float): " << std::numeric_limits<float>::is_integer << std::endl;
    std::cout << "is_exact(float): " << std::numeric_limits<float>::is_exact << std::endl;
    std::cout << "is_bounded(float): " << std::numeric_limits<float>::is_bounded << std::endl;
    std::cout << "is_modulo(float): " << std::numeric_limits<float>::is_modulo << std::endl;
    std::cout << "is_iec559(float): " << std::numeric_limits<float>::is_iec559 << std::endl;
    std::cout << "digits10(float): " << std::numeric_limits<float>::digits10 << std::endl;
    std::cout << "radix(float): " << std::numeric_limits<float>::radix << std::endl;
    std::cout << "min_exponent(float): " << std::numeric_limits<float>::min_exponent << std::endl;
    std::cout << "max_exponent(float): " << std::numeric_limits<float>::max_exponent << std::endl;
    std::cout << "min_exponent10(float): " << std::numeric_limits<float>::min_exponent10 << std::endl;
    std::cout << "max_exponent10(float): " << std::numeric_limits<float>::max_exponent10 << std::endl;
    std::cout << "epsilon(float): " << std::numeric_limits<float>::epsilon() << std::endl;
    std::cout << "round_style(float): " << std::numeric_limits<float>::round_style << std::endl;
 
    std::cout << "The smallest nonzero denormalized value for float: "
        << std::numeric_limits<float>::denorm_min()<< std::endl;
    std::cout << "The difference between 1 and the smallest value greater than 1 for float: "
        << std::numeric_limits<float>::epsilon()<< std::endl;
    std::cout << "Whether float objects allow denormalized values: "
        << std::numeric_limits<float>::has_denorm << std::endl;
    std::cout << "Whether float objects can detect denormalized loss: "
        << std::numeric_limits<float>::has_denorm_loss << std::endl;
    std::cout << "Whether float objects have quiet_NaN: "
        << std::numeric_limits<float>::has_quiet_NaN << std::endl;
    std::cout << "Whether float objects have a signaling_NaN: "
        << std::numeric_limits<float>::has_signaling_NaN << std::endl;
    std::cout << "The base for type float is:  "
        << std::numeric_limits<float>::radix << std::endl;
    std::cout << "The maximum rounding error for type float is:  "
        << std::numeric_limits<float>::round_error() << std::endl;
    std::cout << "The rounding style for a double type is: "
        << std::numeric_limits<double>::round_style << std::endl;
    std::cout << "The signaling NaN for type float is:  "
        << std::numeric_limits<float>::signaling_NaN() << std::endl;
    std::cout << "Whether float types can detect tinyness before rounding: "
        << std::numeric_limits<float>::tinyness_before << std::endl;
    std::cout << "Whether float types have implemented trapping: "
        << std::numeric_limits<float>::traps << std::endl;
 
    return 0;
}
图片.png

相关文章

  • c++求极值

    https://blog.csdn.net/fengbingchun/article/details/77922558

  • 极值

    类型一求极值

  • MATLAB|求极值

    极大值matlab里面的findpeaks函数可以求出数据的极大值。 极小值fminbnd可以找到一个有约束边界的...

  • 1 参悟深度学习-梯度下降法

    数学知识 导函数 本质上梯度下降法是在解决极值的问题 而在数学上求极值,需要知道导函数 就很容易求的 比如 函数 ...

  • 牛顿法求极值

    摘要 最近在做两幅图像间单应性矩阵估计的研究,遇到LM(Levenberg-Marquardt)算法求极值,在查找...

  • \GeoGebra{求函数极值}

    指令 extremum(f)extrem(极端,末端)um 例子

  • 推导svm

    梯度垂直于等高线,指向函数变化最快的方向,指向极大值点方向 约束条件为等式求极值 先来看个简单求极值例子 先看下图...

  • 二元微分

    1.大题一般会遇到求极值:条件极值和无条件极值 出现的问题: 1.讨论“来木他”是否为0,从而得到不同的驻点,代入...

  • 拉格朗日乘子法

    问题:求函数 在条件 下可能的极值点,其中 . 利用 Lagrange 乘子法,可将带约束的极值问题转化为无约束...

  • 2017年高考数学(全国Ⅱ卷)理科第11题导数与函数极值/微信公

    本题考查导数的应用——求函数的极值,属于中档题目,也是热点题。首先根据函数的极值点,求出a的值,然后运用导数判断函...

网友评论

      本文标题:c++求极值

      本文链接:https://www.haomeiwen.com/subject/rnzluhtx.html