当前位置: 首页>>代码示例>>C++>>正文


C++ Quantity::print方法代码示例

本文整理汇总了C++中Quantity::print方法的典型用法代码示例。如果您正苦于以下问题:C++ Quantity::print方法的具体用法?C++ Quantity::print怎么用?C++ Quantity::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quantity的用法示例。


在下文中一共展示了Quantity::print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
    Quantity a = 2 * units::m;
    Quantity b = pow(a,10.0);
    Quantity c = pow(b,0.5);
    c = 1;
    c *= constant::sigma_SB<si>::value();
    c /= constant::sigma_SB<si>::value();

    Quantity d = 10*unit::radian;


    b.print(std::cout << "b:  ", Quantity::UGLY_PRINT) << '\n';
    c.print(std::cout << "c:  ", Quantity::UGLY_PRINT) << '\n';
    pow(b,0.1).print(std::cout << "pow(b,0.1):  ", Quantity::UGLY_PRINT) << '\n';
    std::cout << "b = " << b << "\n\n";

    d.print(std::cout << "d:  ") << '\n';
    if (d.units.find("radian") == d.units.end())
        std::cout << "d:  could not find radian\n";

    std::cout << "sigma_SB\t: " << constant::sigma_SB<si>::value() << '\n';
    std::cout << "h_bar\t\t: " << constant::h_bar<si>::value() << "\n\n";

    Quantity v = unit::m / unit::s;
    Quantity A = v + constant::c<si>::value();
    std::cout << v << v.units << constant::c<si>::value().units << std::endl;
    /* For quantity<T>::operator+(T), and T = std::complex<>,
     * this line does not work unless the 1.0 is wrapped inside something that
     * will convert it to std::complex.
     */
    Quantity v0 = v / constant::c<si>::value() + Quantity(1.0);

    std::cout << "c\t\t: " << constant::c<si>::value() << "\n"
                 "v\t\t: " << v << "\n"
                 "A = v + c\t: " << A << "\n"
                 "v0 = v / c\t: " << v0
              << std::endl;
    return 0;
}
开发者ID:hpcdev,项目名称:physical,代码行数:39,代码来源:testOutput.cpp


注:本文中的Quantity::print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。