General functions: Fast element Progression Group functions
A general function is a function that performs element-level operations on data in Ndarry, and can be thought of as a vectorization wrapper for simple functions that accept one or more scalar values and produce one or more scalar values.
Unary Func:abs, Fabs calculates the absolute value of an integer, floating point, or complex number. For non-complex values, a faster fabs can be used.
in [ +]: Np.abs (12.0) out[ +]:12.0In [ -]: Np.abs ( A) out[ -]: AIn [ +]: Np.abs ( A+5j) #其中12 +5j is a complex number, where 12 is the real part and 5 is the imaginary part out[ +]:13.0In [ A]: Np.abs ( A-5j) out[ A]:13.0
SQRT: Calculates the square root of each element.
In [approx]: np.sqrt (4) out[2.0in[Notoginseng]: np.sqrt (5 ) out[notoginseng2.23606797749979
Square: Calculates the square of each element.
In [the]: Np.square (4) out[[+]: Np.square ( 2.6 ) out[6.760000000000001
Exp: Calculating the exponent of each element (E^X)
in [Max]: Np.exp (2) out[7.38905609893065#python3还有个函数为exp2, Calculates the exponent in [2]: Np.exp2 (5) out[32.0
Log, log10, log2, log1p are natural logarithm (base e), log of base 10, log of base 2, log (1+x)
In [all]: Np.log (2) out[0.6931471805599453in[]: NP.LOG10 (0.1) out[]:-1.0
Sign: Calculate the positive and negative numbers of each element: 1 (positive), 0 (0), 1 (negative)
In [the]: np.sign (out[)1in[The]: np.sign (-12 ) out[]:-1in[[]: np.sign (0) out[ $ 0
Ceil: Computes the ceiling value of each element, which is the smallest integer greater than or equal to the value
In [£ º]: Np.ceil (15.971) out[16.0
Floor: Calculates the floor value of each element, which is the largest integer less than or equal to the value
In [to]: Np.floor (-1.564) out[]:-2.0in[+]: Np.floor (1.564) out[1.0
Rint: Rounds each element to the nearest integer, preserving Dtype
in [[]: Np.rint (1.485) out[1.0
MODF: Returns the fractional and integral parts of an array as two independent arrays
In [NP.MODF]: The out[([1.5,2.9]): (Array ([0.50.9 ]), Array ([12.]))
isNaN: Returns a Boolean array that represents "which values are Nan (this is not a number)"
In []: Np.isnan (NaN) out[:truein []: Np.isnan out[]: False
Isfinite, Isinf: Returns a Boolean array that represents "which elements are poor (non-INF, non-Nan)" or "which elements are infinite"
in [ A]: Np.isfinite (1/3) out[ A]: Truein [ +]: Np.isinf (1/3) out[ +]: Falsein [ the]: Np.isinf (1/2) out[ the]: Falsein [ -]: Np.isfinite (1/2) out[ -]: True
Cos, cosh, sin, sinh: normal and hyperbolic trigonometric functions
in [ $]: Np.sin ( -) out[ $]: -0.9880316240928618In [ the]: Np.sin (1/2) out[ the]:0.479425538604203In [ the]: Np.sin (1/6) out[ the]:0.16589613269341502In [ the]: Np.cos (1/3) out[ the]:0.9449569463147377
Tan, Tanh, Arccos, Arccosh, Arcsin, Arcsinh, arctan, Arctanh: Inverse trigonometric function Logical_not: Calculates the true value of not x for each element. Equivalent to-arr
In []: Np.logical_not (out[):falsein []: Np.logical_ Not (-out[): Falsein []: Np.logical_not (-1) out[[Falsein]: Np.logical_not (0) out[74 ]: True
#以上传入的参数都可以是数组, just passing in a value for testing convenience
Binary funcadd: Adds the corresponding elements of the array subtract: subtracts the elements from the second array in the first array multiply: Multiply the array elements divide, floor_ Divide: Division or downward circle divide (discard remainder) power: for element A in the first array, calculate A^bmaximum, Fmax: The maximum value of the element level, based on the corresponding element B in the second array. Fmax ignores Nanminimum, fmin: The minimum value calculation for the element level. Fmax ignores Nanmod: element-level evaluation (remainder of division) Copysign: Copies the symbols of the values in the second array to the values in the first array. Greater, greater_equal, less, less_equal, equal, not_equal: Performs an element-level comparison operation, resulting in a Boolean array. Equivalent to Operators >, >=, <, <=, = =,!=logical_and, Logical_or, Logical_xor: Perform the element-level truth logic operations. Equivalent to Operators &, |, ^ (and/or XOR)
General functions of NumPy