Inelastica.math package
Inelastica.math
|
Matrix class for spectral matrices. |
- Inelastica.math.GaussKronrod(n, tol=1e-10)[source]
Computes the (\(2n+1\))-point Gauss-Kronrod quadrature abscissa \(\{x_i\}\) and weights \(\{w_{1,i}\}\), \(\{w_{2,i}\}\). Kronrod adds \(n+1\) points to an \(n\)-point Gaussian rule.
Definition:
\(\int_{-1/2}^{1/2} f(x) dx \sim \sum_i w_{1,i} f(x_i)\).
The integration range corresponds to the first Brillouin zone in Inelastica.
The weights \(\{w_{2,i}\}\) are used for error estimation.
- Parameters:
- nint
Points for the Gaussian rule.
- tolfloat
The requested absolute accuracy of the abscissas.
- Returns:
- xndarray
Abscissa for which the function is to be evaluated.
- w1ndarray
Integration weights.
- w2ndarray
Weights for error estimation.
- Inelastica.math.Hilbert(f, ker=None)[source]
Hilbert transform \(\mathcal{H}[f](y)\) of a function \(f(x)\) with finite support, sampled on an equidistant grid \(\{x_1,x_2,x_{nh}\}\).
Definition:
\(\mathcal{H}[f](y)= \frac{1}{\pi} p.v.\int_{-\infty}^{\infty} dx \frac{f(x)}{x-y}\).
- Parameters:
- fndarray
List of function values \(f(x)\).
- kerndarray (optional)
- Returns:
- Hfndarray
Hilbert transform of \(f(x)\).
- kerndarray
Kernel function, can be reused for other transformations with the same number of grid points.
- class Inelastica.math.SpectralMatrix(A=None, cutoff=1e-08)[source]
Bases:
object
Matrix class for spectral matrices.
Idea: Split a spectral matrix \(\mathbf{A}^{(mxm)}\) into two smaller matrices \(\mathbf{A} = \mathbf{L}.\mathbf{R}\) where \(\mathbf{L}^{(mxn)} = [\lambda_1 \mathbf{v}_1, ..., \lambda_n \mathbf{v}_n]\) and \(\mathbf{R}^{(nxm)} = [\mathbf{v}_1, ..., \mathbf{v}_n]^\dagger\) are constructed from a call to
LA.eigh(A)
keeping only \(n\) eigensolutions with eigenvalues above the specified cutoff.The magic takes place in Matrix multiply function.
Todo: Adding two gives full matrix! Should be easy to fix.
- Parameters:
- Andarray
- Attributes:
- Lndarray
- Rndarray
- Inelastica.math.acos(x, /)
Return the arc cosine (measured in radians) of x.
The result is between 0 and pi.
- Inelastica.math.acosh(x, /)
Return the inverse hyperbolic cosine of x.
- Inelastica.math.asin(x, /)
Return the arc sine (measured in radians) of x.
The result is between -pi/2 and pi/2.
- Inelastica.math.asinh(x, /)
Return the inverse hyperbolic sine of x.
- Inelastica.math.atan(x, /)
Return the arc tangent (measured in radians) of x.
The result is between -pi/2 and pi/2.
- Inelastica.math.atan2(y, x, /)
Return the arc tangent (measured in radians) of y/x.
Unlike atan(y/x), the signs of both x and y are considered.
- Inelastica.math.atanh(x, /)
Return the inverse hyperbolic tangent of x.
- Inelastica.math.box(mu1, mu2, grid, kT)[source]
Window (box) function defined as \(n_F(\mu_2)-n_F(\mu_1)\)
- Inelastica.math.ceil(x, /)
Return the ceiling of x as an Integral.
This is the smallest integer >= x.
- Inelastica.math.comb(n, k, /)
Number of ways to choose k items from n items without repetition and without order.
Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates to zero when k > n.
Also called the binomial coefficient because it is equivalent to the coefficient of k-th term in polynomial expansion of the expression (1 + x)**n.
Raises TypeError if either of the arguments are not integers. Raises ValueError if either of the arguments are negative.
- Inelastica.math.copysign(x, y, /)
Return a float with the magnitude (absolute value) of x but the sign of y.
On platforms that support signed zeros, copysign(1.0, -0.0) returns -1.0.
- Inelastica.math.cos(x, /)
Return the cosine of x (measured in radians).
- Inelastica.math.cosh(x, /)
Return the hyperbolic cosine of x.
- Inelastica.math.dagger(x)[source]
Returns the hermitian conjugation of a normal or spectral matrix.
- Inelastica.math.degrees(x, /)
Convert angle x from radians to degrees.
- Inelastica.math.erf(x, /)
Error function at x.
- Inelastica.math.erfc(x, /)
Complementary error function at x.
- Inelastica.math.exp(x, /)
Return e raised to the power of x.
- Inelastica.math.expm1(x, /)
Return exp(x)-1.
This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
- Inelastica.math.fabs(x, /)
Return the absolute value of the float x.
- Inelastica.math.factorial(x, /)
Find x!.
Raise a ValueError if x is negative or non-integral.
- Inelastica.math.floor(x, /)
Return the floor of x as an Integral.
This is the largest integer <= x.
- Inelastica.math.fmod(x, y, /)
Return fmod(x, y), according to platform C.
x % y may differ.
- Inelastica.math.frexp(x, /)
Return the mantissa and exponent of x, as pair (m, e).
m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.
- Inelastica.math.fsum(seq, /)
Return an accurate floating point sum of values in the iterable seq.
Assumes IEEE-754 floating point arithmetic.
- Inelastica.math.gamma(x, /)
Gamma function at x.
- Inelastica.math.gcd(*integers)
Greatest Common Divisor.
- Inelastica.math.hypot(*coordinates) value
Multidimensional Euclidean distance from the origin to a point.
- Roughly equivalent to:
sqrt(sum(x**2 for x in coordinates))
For a two dimensional point (x, y), gives the hypotenuse using the Pythagorean theorem: sqrt(x*x + y*y).
For example, the hypotenuse of a 3/4/5 right triangle is:
>>> hypot(3.0, 4.0) 5.0
- Inelastica.math.interpolate(nx, x, y)[source]
Interpolate \(f(x)=y\) to find \(f(nx)\). Extrapolation allowed.
NB: Makes no checks for nx inside x region!!!
- Parameters:
- nxndarray
Abscissa values to interpolate the function.
- xndarray
Known abscissa values.
- yndarray
Known function values.
- Returns:
- nyndarray
Interpolated function values on nx.
- Inelastica.math.isclose(/, a, b, *, rel_tol=1e-09, abs_tol=0.0)
Determine whether two floating point numbers are close in value.
- rel_tol
maximum difference for being considered “close”, relative to the magnitude of the input values
- abs_tol
maximum difference for being considered “close”, regardless of the magnitude of the input values
Return True if a is close in value to b, and False otherwise.
For the values to be considered close, the difference between them must be smaller than at least one of the tolerances.
-inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is not close to anything, even itself. inf and -inf are only close to themselves.
- Inelastica.math.isfinite(x, /)
Return True if x is neither an infinity nor a NaN, and False otherwise.
- Inelastica.math.isinf(x, /)
Return True if x is a positive or negative infinity, and False otherwise.
- Inelastica.math.isnan(x, /)
Return True if x is a NaN (not a number), and False otherwise.
- Inelastica.math.isqrt(n, /)
Return the integer part of the square root of the input.
- Inelastica.math.lcm(*integers)
Least Common Multiple.
- Inelastica.math.ldexp(x, i, /)
Return x * (2**i).
This is essentially the inverse of frexp().
- Inelastica.math.lgamma(x, /)
Natural logarithm of absolute value of Gamma function at x.
- Inelastica.math.log(x[, base=math.e])
Return the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x.
- Inelastica.math.log10(x, /)
Return the base 10 logarithm of x.
- Inelastica.math.log1p(x, /)
Return the natural logarithm of 1+x (base e).
The result is computed in a way which is accurate for x near zero.
- Inelastica.math.log2(x, /)
Return the base 2 logarithm of x.
- Inelastica.math.mm(*args)[source]
Matrix multiplication with arbitrary number of arguments and the SpectralMatrix type.
- Inelastica.math.modf(x, /)
Return the fractional and integer parts of x.
Both results carry the sign of x and are floats.
- Inelastica.math.nextafter(x, y, /)
Return the next floating-point value after x towards y.
- Inelastica.math.perm(n, k=None, /)
Number of ways to choose k items from n items without repetition and with order.
Evaluates to n! / (n - k)! when k <= n and evaluates to zero when k > n.
If k is not specified or is None, then k defaults to n and the function returns n!.
Raises TypeError if either of the arguments are not integers. Raises ValueError if either of the arguments are negative.
- Inelastica.math.pow(x, y, /)
Return x**y (x to the power of y).
- Inelastica.math.prod(iterable, *, start=1)
Calculate the product of all the elements in the input iterable.
The default start value for the product is 1.
When the iterable is empty, return the start value. This function is intended specifically for use with numeric values and may reject non-numeric types.
- Inelastica.math.radians(x, /)
Convert angle x from degrees to radians.
- Inelastica.math.remainder(x, y, /)
Difference between x and the closest integer multiple of y.
Return x - n*y where n*y is the closest integer multiple of y. In the case where x is exactly halfway between two multiples of y, the nearest even value of n is used. The result is always exact.
- Inelastica.math.sin(x, /)
Return the sine of x (measured in radians).
- Inelastica.math.sinh(x, /)
Return the hyperbolic sine of x.
- Inelastica.math.sphericalHarmonics(l, m, costh, sinfi, cosfi)[source]
Spherical harmonics \(Y_\ell^m(\theta,\phi)\) derived from
scipy.special
.Note: This function has been checked up to d-orbitals with the Siesta overlap matrix.
- Parameters:
- lint
- mint
- costhfloat
- sinfifloat
- cosfifloat
- Returns:
- Ylmcomplex
- Inelastica.math.sqrt(x, /)
Return the square root of x.
- Inelastica.math.tan(x, /)
Return the tangent of x (measured in radians).
- Inelastica.math.tanh(x, /)
Return the hyperbolic tangent of x.
- Inelastica.math.trapez(x, f, equidistant=False)[source]
Integration of vector f on grid x using the 3rd degree polynomial. The grid x does not have to be equidistant.
- Parameters:
- xndarray
- fndarray
- equidistantbool
False = 3rd degree polynomial method. True = Linear trapez method.
- Returns:
- rescomplex number
Result of the integration.
- Inelastica.math.trunc(x, /)
Truncates the Real x to the nearest Integral toward 0.
Uses the __trunc__ magic method.
- Inelastica.math.ulp(x, /)
Return the value of the least significant bit of the float x.