📄 smath.h
字号:
SCYTHE_MATH_OP(expm1, ::expm1) /* calc the absval of each element of a Matrix */ /*! * \brief Calculate the absolute value of each element of a Matrix * * This function calculates the absolute value of each element in a Matrix * * \param A The matrix whose absolute values are to be taken. */ SCYTHE_MATH_OP(fabs, ::fabs) /* calc the floor of each element of a Matrix */ /*! * \brief Calculate the floor of each element of a Matrix * * This function calculates the floor of each element * in a Matrix * * \param A The matrix whose floors are of interest. * * \see ceil() */ SCYTHE_MATH_OP(floor, ::floor) /* calc the remainder of the division of each matrix element */ /*! * \brief Calculate the remainder of the division of each matrix element * * This function calculates the remainder when the elements of Matrix A are * divided by the elements of Matrix B. * * \param A The matrix to serve as dividend * \param B the matrix to serve as divisor */ SCYTHE_MATH_OP_2ARG(fmod, std::ptr_fun(::fmod)) /* calc the fractional val of input and return exponents in int * matrix reference */ /*! */ template <matrix_order RO, matrix_style RS, typename T, matrix_order PO1, matrix_style PS1, matrix_order PO2, matrix_style PS2> Matrix<T,RO,RS> frexp (const Matrix<T,PO1,PS1>& A, Matrix<int,PO2,PS2>& ex) { SCYTHE_CHECK_10(A.size() != ex.size(), scythe_conformation_error, "The input matrix sizes do not match"); Matrix<T,PO1,Concrete> res(A.rows(), A.cols()); typename Matrix<T,PO1,PS1>::const_forward_iterator it; typename Matrix<T,PO1,Concrete>::forward_iterator rit = res.begin_f(); typename Matrix<int,PO2,PS2>::const_forward_iterator it2 = ex.begin_f(); for (it = A.begin_f(); it != A.end_f(); ++it) { *rit = ::frexp(*it, &(*it2)); ++it2; ++rit; } return res; } template <typename T, matrix_order PO1, matrix_style PS1, matrix_order PO2, matrix_style PS2> Matrix<T,PO1,Concrete> frexp (Matrix<T,PO1,PS1>& A, Matrix<int,PO2,PS2>& ex) { return frexp<PO1,Concrete>(A,ex); } /* calc the euclidean distance between the two inputs */ /*! * \brief Calculate the euclidean distance between two inputs * * This function calculates the euclidean distance between the elements of Matrix * A and the elements of Matrix B. * * \param A Input matrix * \param B Input matrix */ SCYTHE_MATH_OP_2ARG(hypot, std::ptr_fun(::hypot)) /* return (int) logb */ SCYTHE_MATH_OP(ilogb, ::ilogb) /* compute the bessel func of the first kind of the order 0 */ /*! * \brief Compute the Bessel function of the first kind of the order 0 * * This function computes the Bessel function of the first kind of order 0 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j1() * \see jn() * \see y0() * \see y1() * \see yn() */ SCYTHE_MATH_OP(j0, ::j0) /* compute the bessel func of the first kind of the order 1 */ /*! * \brief Compute the Bessel function of the first kind of the order 1 * * This function computes the Bessel function of the first kind of order 1 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see jn() * \see y0() * \see y1() * \see yn() */ SCYTHE_MATH_OP(j1, ::j1) /* compute the bessel func of the first kind of the order n * TODO: This definition causes the compiler to issue some warnings. * Fix */ /*! * \brief Compute the Bessel function of the first kind of the order n * * This function computes the Bessel function of the first kind of order n * for each element in the input matrix, A. * * \param n Order of the Bessel function * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see y0() * \see y1() * \see yn() */ SCYTHE_MATH_OP_2ARG(jn, std::ptr_fun(::jn)) /* calc x * 2 ^ex */ /*! * \brief Compute x * 2^ex * * This function computes the value of x * 2^ex, where x is the ith element of * the input matrix A, and ex is the desired value of the exponent. * * \param A Matrix whose elements are to be multiplied * \param ex Matrix of powers to which 2 will be raised. */ SCYTHE_MATH_OP_2ARG(ldexp, std::ptr_fun(::ldexp)) /* compute the natural log of the absval of gamma function */ /*! * \brief Compute the natural log of the absolute value of the gamma function * * This function computes the absolute value of the Gamma Function, evaluated at * each element of the input matrix A. * * \param A Matrix whose elements will serve as inputs for the Gamma Function * * \see log() */ SCYTHE_MATH_OP(lgamma, ::lgamma) /* calc the natural log of each element of a Matrix */ /*! * \brief Compute the natural log of each element of a Matrix * * This function computes the natural log of each element in a matrix, A. * * \param A Matrix whose natural logs are of interest * * \see log10() * \see log1p() * \see logb() */ SCYTHE_MATH_OP(log, ::log) /* calc the base-10 log of each element of a Matrix */ /*! * \brief Compute the log base 10 of each element of a Matrix * * This function computes the log base 10 of each element in a matrix, A. * * \param A Matrix whose logs are of interest * * \see log() * \see log1p() * \see logb() */ SCYTHE_MATH_OP(log10, ::log10) /* calc the natural log of 1 + each element of a Matrix */ /*! * \brief Compute the natural log of 1 + each element of a Matrix * * This function computes the natural log of 1 + each element of a Matrix. * * \param A Matrix whose logs are of interest * * \see log() * \see log10() * \see logb() */ SCYTHE_MATH_OP(log1p, ::log1p) /* calc the logb of each element of a Matrix */ /*! * \brief Compute the logb each element of a Matrix * * This function computes the log base b of each element of a Matrix. * * \param A Matrix whose logs are of interest * * \see log() * \see log10() * \see log1p() */ SCYTHE_MATH_OP(logb, ::logb) /* x = frac + i, return matrix of frac and place i in 2nd matrix */ template <matrix_order RO, matrix_style RS, typename T, matrix_order PO1, matrix_style PS1, matrix_order PO2, matrix_style PS2> Matrix<T,RO,RS> modf (const Matrix<T,PO1,PS1>& A, Matrix<double,PO2,PS2>& ipart) { SCYTHE_CHECK_10(A.size() != ipart.size(), scythe_conformation_error, "The input matrix sizes do not match"); Matrix<T,PO1,Concrete> res(A.rows(), A.cols()); typename Matrix<T,PO1,PS1>::const_forward_iterator it; typename Matrix<T,PO1,Concrete>::forward_iterator rit = res.begin_f(); typename Matrix<double,PO2,PS2>::const_forward_iterator it2 = ipart.begin_f(); for (it = A.begin_f(); it != A.end_f(); ++it) { *rit = ::modf(*it, &(*it2)); ++it2; ++rit; } return res; } template <typename T, matrix_order PO1, matrix_style PS1, matrix_order PO2, matrix_style PS2> Matrix<T,PO1,Concrete> modf (Matrix<T,PO1,PS1>& A, Matrix<double,PO2,PS2>& ipart) { return modf<PO1,Concrete>(A,ipart); } /* calc x^ex of each element of a Matrix */ /*! * \brief Compute x^ex for each element of a matrix * * This function computes x^ex, where x is the ith element of the matrix A, * and ex is the desired exponent. * * \param A Matrix to be exponentiated * \param ex Desired exponent */ SCYTHE_MATH_OP_2ARG(pow, std::ptr_fun(::pow)) /* calc rem == x - n * y */ SCYTHE_MATH_OP_2ARG(remainder, std::ptr_fun(::remainder)) /* return x rounded to nearest int */ /*! * \brief Return x rounded to the nearest integer * * This function returns x, where x is the ith element of the Matrix A, * rounded to the nearest integer. * * \param A Matrix whose elements are to be rounded */ SCYTHE_MATH_OP(rint, ::rint) /* returns x * FLT_RADIX^ex */ SCYTHE_MATH_OP_2ARG(scalbn, std::ptr_fun(::scalbn)) /* calc the sine of x */ /*! * \brief Calculate the sine of each element of a Matrix * * This function calculates the sine of each element in a Matrix * * \param A The matrix whose sines are of interest. * * \see tan() * \see tanh() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(sin, ::sin) /* calc the hyperbolic sine of x */ /*! * \brief Calculate the hyperbolic sine of each element of a Matrix * * This function calculates the hyperbolic sine of each element in a Matrix * * \param A The matrix whose hyperbolic sines are of interest. * * \see tan() * \see tanh() * \see sin() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(sinh, ::sinh) /* calc the sqrt of x */ /*! * \brief Calculate the square root of each element in a matrix * * This function calculates the square root of each element in a Matrix * * \param A The matrix whose roots are of interest. * * \see cbrt() */ SCYTHE_MATH_OP(sqrt, ::sqrt) /* calc the tangent of x */ /*! * \brief Calculate the tangent of each element of a Matrix * * This function calculates the tangent of each element in a Matrix * * \param A The matrix whose tangents are of interest. * * \see sinh() * \see tanh() * \see sin() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(tan, ::tan) /* calc the hyperbolic tangent of x */ /*! * \brief Calculate the hyperbolic tangent of each element of a Matrix * * This function calculates the hyperbolic tangent of each element in a Matrix * * \param A The matrix whose hyperbolic tangents are of interest. * * \see sinh() * \see tan() * \see sin() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(tanh, ::tanh) /* bessel function of the second kind of order 0*/ /*! * \brief Compute the Bessel function of the second kind of order 0 * * This function computes the Bessel function of the second kind of order 0 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see jn() * \see y1() * \see yn() */ SCYTHE_MATH_OP(y0, ::y0) /* bessel function of the second kind of order 1*/ /*! * \brief Compute the Bessel function of the second kind of order 1 * * This function computes the Bessel function of the second kind of order 1 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see jn() * \see y0() * \see yn() */ SCYTHE_MATH_OP(y1, ::y1) /* bessel function of the second kind of order n * TODO: This definition causes the compiler to issue some warnings. * Fix */ /*! * \brief Compute the Bessel function of the second kind of order n * * This function computes the Bessel function of the second kind of order n * for each element in the input matrix, A. * * \param n Order of the Bessel function * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see jn() * \see y0() * \see y1() */ SCYTHE_MATH_OP_2ARG(yn, std::ptr_fun(::yn)) } // end namespace scythe#endif /* SCYTHE_MATH_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -