⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genmathfunc.cpp

📁 A C++ class library for scientific computing
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    ofs << "x,";    if (specialization != 0)        ofs << "(" << specialization << ")";    else if ((returnType) && (!noCastFlag))        ofs << "(" << returnType << ")";    ofs << "y); }" << std::endl;    ofs << std::endl << "    template<typename T1, typename T2>" << std::endl        << "    static void prettyPrint(BZ_STD_SCOPE(string) &str, prettyPrintFormat& format,"        << std::endl        << "        const T1& a, const T2& b)" << std::endl        << "    {" << std::endl        << "        str += \"" << funcName;      ofs  << "(\";" << std::endl        << "        a.prettyPrint(str,format);" << std::endl        << "        str += \",\";" << std::endl        << "        b.prettyPrint(str,format);" << std::endl        << "        str += \")\";" << std::endl        << "    }" << std::endl;    ofs << "};" << std::endl;    if ((flag != ldflag) && (flag != 0))        ofs << "#endif" << std::endl;    ofs << std::endl;}int main(){    std::cout << "Generating <mathfunc.h>" << std::endl;    ofs.open("../mathfunc.h");    ofs <<  "// Generated: " << __FILE__ << " " << __DATE__ << " " << __TIME__                  << std::endl << std::endl <<"#ifndef BZ_MATHFUNC_H\n""#define BZ_MATHFUNC_H\n""\n""#ifndef BZ_APPLICS_H\n"" #error <blitz/mathfunc.h> should be included via <blitz/applics.h>\n""#endif\n\n""\n""#ifndef BZ_PRETTYPRINT_H\n"" #include <blitz/prettyprint.h>\n""#endif\n\n""BZ_NAMESPACE(blitz)\n\n";    one("abs", 0, "abs", 0, "Absolute value");    one("abs","long","labs","long", 0);    one("abs","float"       ,"fabs",    "float",       0);one("abs"    ,"double"      ,"fabs"    ,"double"       ,"");one("abs"    ,"long double" ,"fabs"   ,"long double"  ,"", ldflag);one("abs"    ,"complex<float> ", "abs","float", "", cflag);one("abs"    ,"complex<double> ", "abs", "double", "", cflag);one("abs"    ,"complex<long double> ", "abs", "long double", "", cflag);one("acos"   ,""            ,"acos"    ,"double"       ,"Inverse cosine");one("acos"   ,"float"       ,"acos"  ,"float"         ,"");one("acos"   ,"long double" ,"acos"   ,"long double"  ,"", ldflag);one("acos"   ,"complex<float> ", "acos", "complex<float>", "", cflag2);one("acos"   ,"complex<double> ", "acos", "complex<double>", "", cflag2);one("acos", "complex<long double> ", "acos", "complex<long double>", "", cflag2);one("acosh"  ,""            ,"acosh"   ,"double"       ,"Inverse hyperbolic cosine", ieeeflag);one("asin"   ,""            ,"asin"    ,"double"       ,"Inverse sine");one("asin",   "float",       "asin",    "float", "");one("asin"   ,"long double" ,"asin"   ,"long double"  ,"", ldflag);one("asin"   ,"complex<float> ", "asin", "complex<float>", "", cflag2);one("asin"   ,"complex<double> ", "asin", "complex<double>", "", cflag2);one("asin", "complex<long double> ", "asin", "complex<long double>", "", cflag2);one("asinh"  ,""            ,"asinh"   ,"double"       ,"Inverse hyperbolic sine", ieeeflag);one("arg",   ""            ,"0"    ,0             ,"", cflag, nofuncflag);one("arg",   "complex<float> ", "arg", "float", "", cflag, 0);one("arg",   "complex<double> ", "arg", "double", "", cflag, 0);one("arg",   "complex<long double> ", "arg", "long double", "", cflag, 0);one("atan"   ,""            ,"atan"    ,"double"       ,"Inverse tangent");one("atan",   "float",       "atan",    "float",        "");one("atan"   ,"long double" ,"atan"   ,"long double"  ,"", ldflag);one("atan"   ,"complex<float> ", "atan", "complex<float>", "", cflag2);one("atan"   ,"complex<double> ", "atan", "complex<double>", "", cflag2);one("atan", "complex<long double> ", "atan", "complex<long double>", "", cflag2);one("atanh"  ,""            ,"atanh"   ,"double"       ,"Inverse hyperbolic tangent", ieeeflag);two("atan2"  ,""            ,"atan2"   ,"double"       ,"Inverse tangent");two("atan2"  ,"float"       ,"atan2"   ,"float"        ,"");two("atan2"  ,"long double" ,"atan2"   ,"long double"  ,"");one("_class" ,""            ,"_class"  ,"int"          ,"Classification of float-point value (FP_xxx)", bsdflag,1);one("cbrt"   ,""            ,"cbrt"    ,"double"       ,"Cube root", ieeeflag);one("ceil"   ,""            ,"ceil"    ,"double"       ,"Ceiling");one("ceil",   "float",       "ceil",    "float",       "");one("ceil"   ,"long double" ,"ceil"   ,"long double"  ,"", ldflag);one("conj",   ""            ,"conj"    ,0             ,"", cflag);one("cos"    ,""            ,"cos"     ,"double"       ,"Cosine");one("cos",    "float",       "cos",     "float",       "");one("cos"    ,"long double" ,"cos"    ,"long double"  ,"", ldflag);one("cos"   ,"complex<float> ", "cos", "complex<float>", "", cflag1);one("cos"   ,"complex<double> ", "cos", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("cos", "complex<long double> ", "cos", "complex<long double>", "", cflag1); ofs << "#endif\n";two("copysign", ""          ,"copysign","double"       ,"", bsdflag);one("cosh"   ,""            ,"cosh"    ,"double"       ,"Hyperbolic cosine");one("cosh",   "float",       "cosh",    "float", "");one("cosh"   ,"long double" ,"cosh"   ,"long double"  ,"", ldflag);one("cosh"   ,"complex<float> ", "cosh", "complex<float>", "", cflag1);one("cosh"   ,"complex<double> ", "cosh", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("cosh", "complex<long double> ", "cosh", "complex<long double>", "", cflag1); ofs << "#endif\n";two("drem"   ,""            ,"drem"    ,"double"       ,"Remainder", bsdflag);one("exp"    ,""            ,"exp"     ,"double"       ,"Exponential");one("exp",    "float",       "exp",     "float",       "");one("exp"    ,"long double" ,"exp"    ,"long double"  ,"", ldflag      );one("exp"   ,"complex<float> ", "exp", "complex<float>", "", cflag1);one("exp"   ,"complex<double> ", "exp", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("exp", "complex<long double> ", "exp", "complex<long double>", "", cflag1); ofs << "#endif\n";one("expm1"  ,""            ,"expm1"   ,"double"       ,"Exp(x)-1", ieeeflag);one("erf"    ,""            ,"erf"     ,"double"       ,"Error function", ieeeflag);one("erfc"   ,""            ,"erfc"    ,"double"       ,"Complementary error function", ieeeflag);// blitz-bugs/archive/0189.html// one("finite" ,""            ,"finite"  ,"int"          ,"Nonzero if finite", ieeeflag,1);one("floor"  ,""            ,"floor"   ,"double"       ,"Floor function");one("floor",  "float",       "floor",   "float",        "");one("floor"  ,"long double" ,"floor"   ,"long double"  ,"");two("fmod"   ,""            ,"fmod"    ,"double"       ,"Modulo remainder");two("hypot"  ,""            ,"hypot"   ,"double"       ,"sqrt(x*x+y*y)",bsdflag);one("ilogb"  ,""            ,"ilogb"   ,"int"          ,"Integer unbiased exponent", ieeeflag,1);one("blitz_isnan"  ,""            ,"blitz_isnan"   ,"int"          ,"Nonzero if NaNS or NaNQ", ieeeflag,nofuncflag);one("itrunc" ,""            ,"itrunc"  ,"int"          ,"Truncate and convert to integer", bsdflag,1);one("j0"     ,""            ,"j0"      ,"double"       ,"Bessel function first kind, order 0", ieeeflag);one("j1"     ,""            ,"j1"      ,"double"       ,"Bessel function first kind, order 1", ieeeflag);one("lgamma" ,""            ,"lgamma"  ,"double"       ,"Log absolute gamma", ieeeflag);one("log"    ,""            ,"log"     ,"double"       ,"Natural logarithm");one("log",    "float",       "log",     "float",        "");one("log"    ,"long double" ,"log"     ,"long double"  ,"", ldflag);one("log"   ,"complex<float> ", "log", "complex<float>", "", cflag1);one("log"   ,"complex<double> ", "log", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("log", "complex<long double> ", "log", "complex<long double>", "", cflag1); ofs << "#endif\n";one("logb"   ,""            ,"logb"    ,"double"       ,"Unbiased exponent (IEEE)", ieeeflag);one("log1p"  ,""            ,"log1p"   ,"double"       ,"Compute log(1 + x)", ieeeflag);one("log10"  ,""            ,"log10"   ,"double"       ,"Logarithm base 10");one("log10",  "float",       "log10",   "float",        "");one("log10"  ,"long double" ,"log10"  ,"long double"  ,"", ldflag);one("log10"   ,"complex<float> ", "log10", "complex<float>", "", cflag2);one("log10"   ,"complex<double> ", "log10", "complex<double>", "", cflag2);one("log10", "complex<long double> ", "log10", "complex<long double>", "", cflag2);one("nearest", ""           ,"nearest" ,"double"       ,"Nearest floating point integer", bsdflag);two("nextafter", "",         "nextafter", "double",     "Next representable number after x towards y", bsdflag);ofs <<"template<typename P_numtype>\n""class _bz_negate : public OneOperandApplicativeTemplatesBase {\n""public:\n""    typedef BZ_SIGNEDTYPE(P_numtype) T_numtype;\n\n""    static inline T_numtype apply(T_numtype x)\n""    { return -x; }\n\n""        template<typename T1>\n""        ""static void prettyPrint(BZ_STD_SCOPE(string) &str, prettyPrintFormat& format, const T1& a)\n""        {\n""                str += \"-(\";\n""                       a.prettyPrint(str,format);\n""                       str += \")\";\n""        }\n""};\n\n";one("norm",   ""            ,"norm"    ,0             ,"", cflag);two("polar"  ,""            ,"polar"   ,"complex<T_numtype1>", "", cflag, 1);two("pow"    ,""            ,"pow"     ,"double"       ,"Power"); ofs << "#ifndef __PGI\n";two("pow"    ,"float"       ,"pow"     ,"float"        ,""); ofs << "#endif\n";two("pow"    ,"long double" ,"pow"     ,"long double"  ,"");two("pow"    ,"complex<float>","pow"   ,"complex<float>" ,"",cflag1);two("pow"    ,"complex<double>","pow"  ,"complex<double>","",cflag1); ofs << "#ifndef __PGI\n";two("pow"    ,"complex<long double>","pow","complex<long double>","",cflag1); ofs << "#endif\n";two("remainder", "",         "remainder", "double",     "Remainder", bsdflag);one("rint"   ,""            ,"rint"    ,"double"       ,"Round to floating point integer", ieeeflag);one("rsqrt"  ,""            ,"rsqrt"   ,"double"       ,"Reciprocal square root", bsdflag);two("scalb"  ,""            ,"scalb"   ,"double"       ,"x * (2**y)", bsdflag);one("sin"    ,""            ,"sin"     ,"double"       ,"Sine");one("sin",    "float",       "sin",     "float",       "");one("sin"    ,"long double" ,"sin"    ,"long double"  ,"", ldflag);one("sin"   ,"complex<float> ", "sin", "complex<float>", "", cflag1);one("sin"   ,"complex<double> ", "sin", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("sin", "complex<long double> ", "sin", "complex<long double>", "", cflag1); ofs << "#endif\n";one("sinh"   ,""            ,"sinh"    ,"double"       ,"Hyperbolic sine");one("sinh",   "float",       "sinh",    "float",        "");one("sinh"   ,"long double" ,"sinh"   ,"long double"  ,"", ldflag);one("sinh"   ,"complex<float> ", "sinh", "complex<float>", "", cflag1);one("sinh"   ,"complex<double> ", "sinh", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("sinh", "complex<long double> ", "sinh", "complex<long double>", "", cflag1); ofs << "#endif\n";ofs << "template<typename P_numtype>\n""class _bz_sqr : public OneOperandApplicativeTemplatesBase {\n""public:\n""    typedef P_numtype T_numtype;\n\n""    static inline T_numtype apply(T_numtype x)\n""    { return x*x; }\n""    template<typename T1>\n""    static void prettyPrint(BZ_STD_SCOPE(string) &str, prettyPrintFormat& format,\n""        const T1& a)\n""    {\n""        str += \"sqr(\";\n""        a.prettyPrint(str,format);\n""        str += \")\";\n""    }\n""};\n\n""#ifdef BZ_HAVE_COMPLEX\n""// Specialization of _bz_sqr for complex<T>\n""template<typename T>\n""class _bz_sqr<complex<T> > : public OneOperandApplicativeTemplatesBase {\n""public:\n""    typedef complex<T> T_numtype;\n\n""    static inline T_numtype apply(T_numtype x)\n""    {\n""        T r = x.real();  T i = x.imag();\n""        return T_numtype(r*r-i*i, 2*r*i);\n""    }\n""    template<typename T1>\n""    static void prettyPrint(BZ_STD_SCOPE(string) &str, prettyPrintFormat& format,\n""        const T1& a)\n""    {\n""        str += \"sqr(\";\n""        a.prettyPrint(str,format);\n""        str += \")\";\n""    }\n""};\n""#endif\n\n";one("sqrt"   ,""            ,"sqrt"    ,"double"       ,"Square root");one("sqrt",   "float",       "sqrt",    "float",        "");one("sqrt"   ,"long double" ,"sqrt"   ,"long double"  ,"", ldflag);one("sqrt"   ,"complex<float> ", "sqrt", "complex<float>", "", cflag1);one("sqrt"   ,"complex<double> ", "sqrt", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("sqrt", "complex<long double> ", "sqrt", "complex<long double>", "", cflag1); ofs << "#endif\n";one("tan"    ,""            ,"tan"     ,"double"       ,"Tangent");one("tan",    "float",       "tan",    "float",         "");one("tan"    ,"long double" ,"tan"    ,"long double"  ,"");one("tan"   ,"complex<float> ", "tan", "complex<float>", "", cflag1);one("tan"   ,"complex<double> ", "tan", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("tan", "complex<long double> ", "tan", "complex<long double>", "", cflag1); ofs << "#endif\n";one("tanh"   ,""            ,"tanh"    ,"double"       ,"Hyperbolic tangent");one("tanh",   "float",       "tanh",    "float",        "");one("tanh"   ,"long double" ,"tanh"   ,"long double"  ,"", ldflag);one("tanh"   ,"complex<float> ", "tanh", "complex<float>", "", cflag1);one("tanh"   ,"complex<double> ", "tanh", "complex<double>", "", cflag1); ofs << "#ifndef __PGI\n";one("tanh", "complex<long double> ", "tanh", "complex<long double>", "", cflag1); ofs << "#endif\n";// blitz-bugs/archive/0189.html// one("trunc"  ,""            ,"trunc"   ,"double"       ,"Nearest floating integer in the direction of zero", ieeeflag);one("uitrunc", ""           ,"uitrunc" ,"unsigned"     ,"Truncate and convert to unsigned", bsdflag);two("unordered", "",         "unordered", "int",       "True if a comparison of x and y would be unordered", bsdflag,1);one("y0"     ,""            ,"y0"      ,"double"       ,"Bessel function of the second kind, order zero", ieeeflag);one("y1"     ,""            ,"y1"      ,"double"       ,"Bessel function of the second kind, order one", ieeeflag);    ofs << std::endl << std::endl <<"BZ_NAMESPACE_END\n\n""#endif // BZ_MATHFUNC_H\n";    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -