grid_tools
1.3.0
|
Module for handy vector and matrix operations in Euclidean geometry. More...
Data Types | |
interface | absv |
interface | axial |
interface | axtoq |
interface | axtorot |
interface | corral |
interface | cross_product |
interface | ctoz |
interface | det |
interface | diag |
interface | dlltoxy |
interface | expmat |
interface | gram |
interface | hav |
interface | huarea |
interface | identity |
interface | mobius |
interface | mobiusi |
interface | mulqq |
interface | normalize |
interface | normalized |
interface | orthogonalized |
interface | outer_product |
interface | qtoax |
interface | qtorot |
interface | qtospin |
interface | rottoax |
interface | rottoq |
interface | rowops |
interface | sarea |
interface | setem |
interface | setmobius |
interface | spintoq |
interface | trace |
interface | triple_product |
interface | znfun |
interface | zntay |
interface | ztoc |
Public Member Functions | |
real(dp) function, dimension(3) | axial33_d (b) |
Return the 3-vector corresponding to the given antisymmetric "axial vector" matrix, assuming a right-handed correspondence. More... | |
real(sp) function, dimension(3) | axial33_s (b) |
Return the 3-vector corresponding to the given antisymmetric "axial vector" matrix, assuming a right-handed correspondence. More... | |
real(dp) function, dimension(3, 3) | axial3_d (a) |
Return the axial "vector", as an antisymmetric matrix, corresponding to the given 3-vector assuming a right-handed correspondence. More... | |
real(sp) function, dimension(3, 3) | axial3_s (a) |
Return the axial "vector", as an antisymmetric matrix, corresponding to the given 3-vector assuming a right-handed correspondence. More... | |
subroutine, public | axtoq (v, q) |
Go from an axial 3-vector to its equivalent quaternion. More... | |
subroutine, public | axtorot (ax3, orth33) |
Construct the 3*3 orthogonal matrix, orth33, that corresponds to the proper rotation encoded by the 3-vector, ax3. More... | |
subroutine, public | corral (m, n, mask, a, d, aa, e) |
Find positive diagonals D and E and a Lagrange multiplier F that minimize the row-sum +column-sum of masked terms, (D_i +log(|A_ij|) +E_j)^2 subject to the single constraint, sum_j E_j =0, where the mask permits only nonnegligible A_ij to participate in the quadratic quantities. More... | |
subroutine, public | ctoz (v, z, infz) |
Utility codes for various Mobius transformations. More... | |
real(dp) function | det_d (a) |
Return the determinant of a double precision matrix. More... | |
integer(spi) function | det_i (a) |
Return the determinant of a single precision integer matrix. More... | |
real(dp) function, dimension(size(a), size(a)) | diagn_d (a) |
Return the diagonal matrix whose elements are the given vector. More... | |
integer(spi) function, dimension(size(a), size(a)) | diagn_i (a) |
Return the diagonal matrix whose elements are the given vector. More... | |
real(sp) function, dimension(size(a), size(a)) | diagn_s (a) |
Return the diagonal matrix whose elements are the given vector. More... | |
subroutine | dlltoxy_d (rlat, drlat, drlon, x2) |
From a reference latitude, and increments of latitude and longitude, return the local cartesian 2-vector corresponding to the projection of the increment onto the tangent plane of the reference point. More... | |
real(sp) function | dqarea_s (rlat, drlata, drlona, drlatb, drlonb, drlatc, drlonc) |
Compute the area of the spherical quadrilateral with a vertex at latitude rlat, and three other vertices at A, B, and C in turn, whose incremented latitudes and longitudes are drlata,drlona (for A), drlatb,drlonb (for B), and drlatc,drlonc (for C). More... | |
real(dp) function | dtarea_d (rlat, drlata, drlona, drlatb, drlonb) |
Compute the area of the spherical triangle with a vertex at latitude rlat, and two other vertices, A and B, whose incremented latitudes and longitudes are drlata,drlona (for A) and drlatb,drlonb (for B). More... | |
subroutine, public | expmat (n, a, b, detb) |
Evaluate the exponential, B, of a matrix, A, of degree n. More... | |
subroutine | expmatd (n, a, b, bd, detb, detbd) |
Like expmat, but for the 1st derivatives also. More... | |
subroutine | expmatdd (n, a, b, bd, bdd, detb, detbd, detbdd) |
Like expmat, but for the 1st and 2nd derivatives also. More... | |
subroutine | gram_d (as, b, nrank, det) |
Apply a form of Gram-Schmidt orthogonalization process to return as many normalized orthogonal basis column vectors in matrix B as possible in the space spanned by the columns of matrix A. More... | |
subroutine | gram_s (as, b, nrank, det) |
Apply a form of Gram-Schmidt orthogonalization process to return as many normalized orthogonal basis column vectors in matrix B as possible in the space spanned by the columns of matrix A. More... | |
subroutine | graml_d (as, b, nrank, detsign, ldet) |
A version of gram_d where the determinant information is returned in logarithmic form (to avoid overflows for large matrices). More... | |
real(dp) function | hav_d (t) |
Haversine function in double precision. More... | |
real(sp) function | hav_s (t) |
Haversine function in single precision. More... | |
real(dp) function, dimension(0:3), public | mulqq (a, b) |
Multiply quaternions, a*b, assuming operation performed from right to left. More... | |
subroutine | normalize_d (v) |
Normalize the given double precision real vector. More... | |
subroutine | normalize_s (v) |
Normalize the given single precision real vector. More... | |
real(dp) function, dimension(size(a)) | normalized_d (a) |
Return the normalized version of a double precision real vector. More... | |
real(sp) function, dimension(size(u)) | orthogonalized_s (u, a) |
Return the part of vector a that is orthogonal to unit vector u. More... | |
subroutine | plaingram_d (b, nrank) |
A "plain" (unpivoted) version of Gram-Schmidt, for square matrices only. More... | |
subroutine | plaingram_s (b, nrank) |
A "plain" (unpivoted) version of Gram-Schmidt, for square matrices only. More... | |
subroutine, public | qtoax (q, v) |
Go from quaternion to axial 3-vector. More... | |
subroutine, public | qtorot (q, rot) |
Go from quaternion to rotation matrix representations. More... | |
subroutine, public | qtospin (q, cspin) |
Go from the unit quaternion to the complex spinor representation. More... | |
subroutine, public | rottoax (orth33, ax3) |
Assuming that given orth33 is a 3*3 proper rotation matrix, derive an axial 3-vector, ax3, such that orth33 is implied by ax3 when the latter is interpreted as encoding a rotation (as in subroutine axtorot). More... | |
subroutine, public | rottoq (rot, q) |
Go from rotation matrix to a corresponding unit quaternion representation. More... | |
subroutine | rowgram (m, n, a, ipiv, tt, b, rank) |
Without changing (tall) rectangular input matrix a, perform pivoted gram- Schmidt operations to orthogonalize the rows, until rows that remain become negligible. More... | |
subroutine, public | rowops (m, n, ipiv, tt, v, vv) |
Apply the row-operations, implied by ipiv and tt returned by rowgram, to the single column vector, v, to produce the transformed vector vv. More... | |
subroutine, public | setmobius (xc0, xc1, xc2, aa, bb, cc, dd) |
Find the Mobius transformation complex coefficients, aa,bb,cc,dd, with aa*dd-bb*cc=1, for a standard (north-)polar stereographic transformation that takes cartesian point, xc0 to the north pole, xc1 to (lat=0,lon=0), xc2 to the south pole (=complex infinity). More... | |
subroutine, public | spintoq (cspin, q) |
Go from the complex spinor matrix to the unit quaternion representation. More... | |
subroutine, public | znfun (n, z, zn, znd, zndd, znddd) |
For a given nonnegative integer n and real argument z, evaluate the nth,...,(n+3)th derivatives, wrt z, of the function C(z) = cosh(sqrt(2z)) or, equivalently, of C(z) = cos(sqrt(-2z)), according to the sign of z. More... | |
subroutine, public | zntay (n, z, zn) |
Evaluate, by Taylor-Maclaurin expansion, the nth-derivative of the function, C(z)=cosh(sqrt(2z)), or equiavlently, of C(z)=cos(sqrt(-2z)). More... | |
subroutine, public | ztoc (z, infz, v) |
Given a complex z, return the equivalent cartesian unit 3-vector associated by the polar stereographic projection. More... | |
Private Member Functions | |
real(dp) function | absv_d (a) |
Return the absolute magnitude of a double precision real vector. More... | |
real(sp) function | absv_s (a) |
Return the absolute magnitude of a single precision real vector. More... | |
subroutine | cmobius (aa, bb, cc, dd, vz, vw) |
Perform a complex Mobius transformation from cartesian vz to cartesian vw where the transformation coefficients are the standard aa,bb,cc,dd. More... | |
real(dp) function, dimension(3) | cross_product_d (a, b) |
Return the cross product of two double precision real 3-vectors. More... | |
real(sp) function, dimension(3) | cross_product_s (a, b) |
Return the cross product of two single precision real 3-vectors. More... | |
integer(dpi) function | det_id (a) |
Return the determinant of a double precision integer matrix. More... | |
real(sp) function | det_s (a) |
Return the determinant of a single precision matrix. More... | |
real(dp) function, dimension(size(b, 1)) | diagnn_d (b) |
Return the vector whose elements are the diagonal ones of a given matrix. More... | |
integer(spi) function, dimension(size(b, 1)) | diagnn_i (b) |
Return the vector whose elements are the diagonal ones of a given matrix. More... | |
real(sp) function, dimension(size(b, 1)) | diagnn_s (b) |
Return the vector whose elements are the diagonal ones of a given matrix. More... | |
subroutine | dlltoxy_s (rlat, drlat, drlon, x2) |
From a reference latitude, and increments of latitude and longitude, return the local cartesian 2-vector corresponding to the projection of the increment onto the tangent plane of the reference point. More... | |
real(dp) function | dqarea_d (rlat, drlata, drlona, drlatb, drlonb, drlatc, drlonc) |
Compute the area of the spherical quadrilateral with a vertex at latitude rlat, and three other vertices at A, B, and C in turn, whose incremented latitudes and longitudes are drlata,drlona (for A), drlatb,drlonb (for B), and drlatc,drlonc (for C). More... | |
real(sp) function | dtarea_s (rlat, drlata, drlona, drlatb, drlonb) |
Compute the area of the spherical triangle with a vertex at latitude rlat, and two other vertices, A and B, whose incremented latitudes and longitudes are drlata,drlona (for A) and drlatb,drlonb (for B). More... | |
real(dp) function | huarea_d (sa, sb) |
Spherical area of right-angle triangle whose orthogonal sides have orthographic projection dimensions, sa and sb, sphere of unit radius. More... | |
real(sp) function | huarea_s (sa, sb) |
Spherical area of right-angle triangle whose orthogonal sides have orthographic projection dimensions, sa and sb, sphere of unit radius. More... | |
integer(spi) function, dimension(3, 3) | identity3_i () |
Return the 3-dimensional integer identity matrix. More... | |
integer(spi) function, dimension(n, n) | identity_i (n) |
Return the integer identity matrix for a given dimensionality. More... | |
real(sp) function, dimension(size(a)) | normalized_s (a) |
Return the normalized version of a single precision real vector. More... | |
real(dp) function, dimension(size(u)) | orthogonalized_d (u, a) |
Return the part of vector a that is orthogonal to unit vector u. More... | |
real(dp) function, dimension(size(a), size(b)) | outer_product_d (a, b) |
Return the outer product matrix of two double precision real vectors. More... | |
integer(spi) function, dimension(size(a), size(b)) | outer_product_i (a, b) |
Return the outer product matrix of two integer vectors. More... | |
real(sp) function, dimension(size(a), size(b)) | outer_product_s (a, b) |
Return the outer product matrix of two single precision real vectors. More... | |
real(dp) function | sarea_d (v1, v2, v3) |
Compute the area of the spherical triangle, {v1,v2,v3}. More... | |
real(sp) function | sarea_s (v1, v2, v3) |
Compute the area of the spherical triangle, {v1,v2,v3}, measured in the right-handed sense, by dropping a perpendicular to u0 on the longest side so that the area becomes the sum of areas of the two simpler right-angled triangles. More... | |
subroutine | setem (c, d, e, g, r) |
Given the 4 components of a unit quaternion, return the associated 3*3 rotation matrix. More... | |
real(dp) function | trace_d (b) |
Return the trace of a given double precision real matrix. More... | |
integer(spi) function | trace_i (b) |
Return the trace of a given integer matrix. More... | |
real(sp) function | trace_s (b) |
Return the trace of a given single precision real matrix. More... | |
real(dp) function, dimension(4) | triple_cross_product_d (u, v, w) |
Return the triple_cross_product for 4-vectors. More... | |
real(sp) function, dimension(4) | triple_cross_product_s (u, v, w) |
Deliver the triple-cross-product, x, of the three 4-vectors, u, v, w, with the sign convention that ordered, {u,v,w,x} form a right-handed quartet in the generic case (determinant >= 0). More... | |
real(dp) function | triple_product_d (a, b, c) |
Return the triple product of three double precision real 3-vectors. More... | |
real(sp) function | triple_product_s (a, b, c) |
Return the triple product of three single precision real 3-vectors. More... | |
subroutine | zmobius (aa, bb, cc, dd, z, infz, w, infw) |
Perform a complex Mobius transformation from (z,infz) to (w,infw) where the transformation coefficients are the standard aa,bb,cc,dd. More... | |
subroutine | zmobiusi (aa, bb, cc, dd, zz, infz, zw, infw) |
Perform the inverse of the mobius transformation with coefficients, {aa,bb,cc,dd}. More... | |
subroutine | zsetmobius (z0, infz0, z1, infz1, z2, infz2, aa, bb, cc, dd) |
Find the Mobius transformation complex coefficients, aa,bb,cc,dd, with aa*dd-bb*cc=1, that takes polar stereographic point, z0 to the north pole, z1 to (lat=0,lon=0), z2 to the south pole (=complex infinity). More... | |
subroutine | ztocd (z, infz, v, vd) |
The convention adopted for the complex derivative is that, for a complex infinitesimal map displacement, delta_z, the corresponding infinitesimal change of cartesian vector position is delta_v given by: delta_v = Real(vd*delta_z). More... | |
Module for handy vector and matrix operations in Euclidean geometry.
This package is primarily intended for 3D operations and three of the functions (Cross_product, Triple_product and Axial) do not possess simple generalizations to a generic number N of dimensions. The others, while admitting such N-dimensional generalizations, have not all been provided with such generic forms here at the time of writing, though some of these may be added at a future date.
May 2017: Added routines to facilitate manipulation of 3D rotations, their representations by axial vectors, and routines to compute the exponentials of matrices (without resort to eigen methods). Also added Quaternion and spinor representations of 3D rotations, and their conversion routines. FUNCTION:
Gram: Right-handed orthogonal basis and rank, nrank. The first nrank basis vectors span the column range of matrix given, OR ("plain" version) simple unpivoted Gram-Schmidt of a square matrix.
In addition, we include routines that relate to stereographic projections and some associated mobius transformation utilities, since these complex operations have a strong geometrical flavor.
|
private |
|
private |
real(dp) function, dimension(3) pmat4::axial33_d | ( | real(dp), dimension(3,3), intent(in) | b | ) |
real(sp) function, dimension(3) pmat4::axial33_s | ( | real(sp), dimension(3,3), intent(in) | b | ) |
real(dp) function, dimension(3,3) pmat4::axial3_d | ( | real(dp), dimension(3), intent(in) | a | ) |
real(sp) function, dimension(3,3) pmat4::axial3_s | ( | real(sp), dimension(3), intent(in) | a | ) |
subroutine, public pmat4::axtoq | ( | real(dp), dimension(3), intent(in) | v, |
real(dp), dimension(0:3), intent(out) | q | ||
) |
subroutine, public pmat4::axtorot | ( | real(dp), dimension(3), intent(in) | ax3, |
real(dp), dimension(3,3), intent(out) | orth33 | ||
) |
Construct the 3*3 orthogonal matrix, orth33, that corresponds to the proper rotation encoded by the 3-vector, ax3.
The antisymmetric matrix ax33 equivalent to the axial vector ax3 is exponentiated to obtain orth33.
[in] | ax3 | axial 3-vector |
[out] | orth33 | 3*3 orthogonal matrix |
|
private |
Perform a complex Mobius transformation from cartesian vz to cartesian vw where the transformation coefficients are the standard aa,bb,cc,dd.
[in] | aa | Mobius transformation coefficient |
[in] | bb | Mobius transformation coefficient |
[in] | cc | Mobius transformation coefficient |
[in] | dd | Mobius transformation coefficient |
[in] | vz | Cartesian unit 3-vector representation of input argument |
[out] | vw | Cartesian unit 3-vector representation of output |
Definition at line 2311 of file pmat4.f90.
References pmat4::mobius::zmobius().
subroutine, public pmat4::corral | ( | integer(spi), intent(in) | m, |
integer(spi), intent(in) | n, | ||
logical, dimension(m,n), intent(in) | mask, | ||
real(dp), dimension(m,n), intent(in) | a, | ||
real(dp), dimension(m ), intent(out) | d, | ||
real(dp), dimension(m,n), intent(out) | aa, | ||
real(dp), dimension( n), intent(out) | e | ||
) |
Find positive diagonals D and E and a Lagrange multiplier F that minimize the row-sum +column-sum of masked terms, (D_i +log(|A_ij|) +E_j)^2 subject to the single constraint, sum_j E_j =0, where the mask permits only nonnegligible A_ij to participate in the quadratic quantities.
Once a solution for D and E is found, return their exponentials, d and e, together with the rescaled matrix aa such that a = d.aa.e when d and e are interpreted as diagonal matrices.
[in] | m | number of rows of A |
[in] | n | number of columns of A |
[in] | mask | logical mask |
[in] | a | real rectangular matrix A |
[out] | d | positive diagonal matrix of dimension m |
[in] | aa | rescaled version of A |
[out] | e | positive diagonal matrix of dimension n |
|
private |
|
private |
subroutine, public pmat4::ctoz | ( | real(dp), dimension(3), intent(in) | v, |
complex(dpc), intent(out) | z, | ||
logical, intent(out) | infz | ||
) |
Utility codes for various Mobius transformations.
If aa1,bb1,cc1,dd1 are the coefficients for one transformation, and aa2,bb2,cc2,dd2 are the coefficients for a second one, then the coefficients for the mapping of a test point, zz, by aa1 etc to zw, followed by a mapping of zw, by aa2 etc to zv, is equivalent to a single mapping zz–>zv by the transformatn with coefficients aa3,bb3,cc3,dd3, such that, as 2*2 complex matrices:
[ aa3, bb3 ] [ aa2, bb2 ] [ aa1, bb1 ] [ ] = [ ] * [ ] [ cc3, dd3 ] [ cc2, dd2 ] [ cc1, dd1 ] .
Note that the determinant of these matrices is always +1. Given a cartesian 3-vector representation of a point on the Riemann unit sphere, return the stereographically equivalent complex number.
[in] | v | cartesian 3-vector representation of point on Riemann sphere |
[out] | z | complex point stereographically equivalent to v |
[out] | infz | logical indicator for z being the point at infinity |
real(dp) function pmat4::det_d | ( | real(dp), dimension(:,:), intent(in) | a | ) |
integer(spi) function pmat4::det_i | ( | integer(spi), dimension(:,:), intent(in) | a | ) |
|
private |
|
private |
real(dp) function, dimension(size(a),size(a)) pmat4::diagn_d | ( | real(dp), dimension(:), intent(in) | a | ) |
integer(spi) function, dimension(size(a),size(a)) pmat4::diagn_i | ( | integer(spi), dimension(:), intent(in) | a | ) |
real(sp) function, dimension(size(a),size(a)) pmat4::diagn_s | ( | real(sp), dimension(:), intent(in) | a | ) |
|
private |
|
private |
|
private |
subroutine pmat4::dlltoxy_d | ( | real(dp), intent(in) | rlat, |
real(dp), intent(in) | drlat, | ||
real(dp), intent(in) | drlon, | ||
real(dp), dimension(2), intent(out) | x2 | ||
) |
From a reference latitude, and increments of latitude and longitude, return the local cartesian 2-vector corresponding to the projection of the increment onto the tangent plane of the reference point.
Double precision version.
[in] | rlat | latitude |
[in] | drlat | latitude |
[in] | drlon | longitudes |
[out] | x2 | output |
|
private |
From a reference latitude, and increments of latitude and longitude, return the local cartesian 2-vector corresponding to the projection of the increment onto the tangent plane of the reference point.
Single precision version.
[in] | rlat | latitude |
[in] | drlat | latitude |
[in] | drlon | longitudes |
[out] | x2 | output |
|
private |
Compute the area of the spherical quadrilateral with a vertex at latitude rlat, and three other vertices at A, B, and C in turn, whose incremented latitudes and longitudes are drlata,drlona (for A), drlatb,drlonb (for B), and drlatc,drlonc (for C).
The computations are designed to give a proportionately accurate area estimate even when the quadrilateral is very small, provided the diagonal making the B-increment is not disproportionately small compared to the characteristic size of the quadrilateral. Double precision version.
[in] | rlat | latitude of reference point |
[in] | drlata | incremental latitude of point A |
[in] | drlona | incremental longitude of point A |
[in] | drlatb | incremental latitude of point B |
[in] | drlonb | incremental longitude of point B |
[in] | drlatc | incremental latitude of point C |
[in] | drlonc | incremental longitude of point C |
real(sp) function pmat4::dqarea_s | ( | real(sp), intent(in) | rlat, |
real(sp), intent(in) | drlata, | ||
real(sp), intent(in) | drlona, | ||
real(sp), intent(in) | drlatb, | ||
real(sp), intent(in) | drlonb, | ||
real(sp), intent(in) | drlatc, | ||
real(sp), intent(in) | drlonc | ||
) |
Compute the area of the spherical quadrilateral with a vertex at latitude rlat, and three other vertices at A, B, and C in turn, whose incremented latitudes and longitudes are drlata,drlona (for A), drlatb,drlonb (for B), and drlatc,drlonc (for C).
The computations are designed to give a proportionately accurate area estimate even when the quadrilateral is very small, provided the diagonal making the B-increment is not disproportionately small compared to the characteristic size of the quadrilateral. Single precision version.
[in] | rlat | latitude of reference point |
[in] | drlata | incremental latitude of point A |
[in] | drlona | incremental longitude of point A |
[in] | drlatb | incremental latitude of point B |
[in] | drlonb | incremental longitude of point B |
[in] | drlatc | incremental latitude of point C |
[in] | drlonc | incremental longitude of point C |
real(dp) function pmat4::dtarea_d | ( | real(dp), intent(in) | rlat, |
real(dp), intent(in) | drlata, | ||
real(dp), intent(in) | drlona, | ||
real(dp), intent(in) | drlatb, | ||
real(dp), intent(in) | drlonb | ||
) |
Compute the area of the spherical triangle with a vertex at latitude rlat, and two other vertices, A and B, whose incremented latitudes and longitudes are drlata,drlona (for A) and drlatb,drlonb (for B).
The computations are designed to give a proportionately accurate area estimate even when the triangle is very small, provided the B-increment is not disproportionately small compared to the other two sides. Double precision version.
[in] | rlat | latitude of reference point |
[in] | drlata | incremental latitude of A |
[in] | drlona | incremental longitude of A |
[in] | drlatb | incremental latitude of B |
[in] | drlonb | incremental longitude of B |
|
private |
Compute the area of the spherical triangle with a vertex at latitude rlat, and two other vertices, A and B, whose incremented latitudes and longitudes are drlata,drlona (for A) and drlatb,drlonb (for B).
The computations are designed to give a proportionately accurate area estimate even when the triangle is very small, provided the B-increment is not disproportionately small compared to the other two sides. Single precision version.
[in] | rlat | latitude of reference point |
[in] | drlata | incremental latitude of A |
[in] | drlona | incremental longitude of A |
[in] | drlatb | incremental latitude of B |
[in] | drlonb | incremental longitude of B |
subroutine, public pmat4::expmat | ( | integer(spi), intent(in) | n, |
real(dp), dimension(n,n), intent(in) | a, | ||
real(dp), dimension(n,n), intent(out) | b, | ||
real(dp), intent(out) | detb | ||
) |
Evaluate the exponential, B, of a matrix, A, of degree n.
Apply the iterated squaring method, m times, to the approximation to exp(A/(2**m)) obtained as a Taylor expansion of degree L See Fung, T. C., 2004, Int. J. Numer. Meth. Engng, 59, 1273–1286.
[in] | n | order of square matrix A |
[in] | a | input matrix A |
[out] | b | matrix B, the exponential of matrix A |
[out] | detb | determinant of matrix B |
subroutine pmat4::expmatd | ( | integer(spi), intent(in) | n, |
real(dp), dimension(n,n), intent(in) | a, | ||
real(dp), dimension(n,n), intent(out) | b, | ||
real(dp), dimension(n,n,(n*(n+1))/2), intent(out) | bd, | ||
real(dp), intent(out) | detb, | ||
real(dp), dimension((n*(n+1))/2), intent(out) | detbd | ||
) |
Like expmat, but for the 1st derivatives also.
[in] | n | order of square matrix A |
[in] | a | input matrix A |
[out] | b | matrix B, the exponential of matrix A |
[out] | bd | derivative of B wrt elements of A |
[out] | detb | determinant of matrix B |
[out] | detbd | derivative of detb wrt elements of A |
subroutine pmat4::expmatdd | ( | integer(spi), intent(in) | n, |
real(dp), dimension(n,n), intent(in) | a, | ||
real(dp), dimension(n,n), intent(out) | b, | ||
real(dp), dimension(n,n,(n*(n+1))/2), intent(out) | bd, | ||
real(dp), dimension(n,n,(n*(n+1))/2,(n*(n+1))/2), intent(out) | bdd, | ||
real(dp), intent(out) | detb, | ||
real(dp), dimension((n*(n+1))/2), intent(out) | detbd, | ||
real(dp), dimension((n*(n+1))/2,(n*(n+1))/2), intent(out) | detbdd | ||
) |
Like expmat, but for the 1st and 2nd derivatives also.
[in] | n | order of the matrix A |
[in] | a | input matrix A |
[out] | b | matrix B, exponential of matrix A |
[out] | bd | derivative of B wrt elements of A |
[out] | bdd | 2nd derivative of B wrt elements of A |
[out] | detb | determinant of matrix B |
[out] | detbd | derivative of detb wrt elements of A |
[out] | detbdd | 2nd derivative of detb wrt elements of A |
subroutine pmat4::gram_d | ( | real(dp), dimension(:,:), intent(in) | as, |
real(dp), dimension(:,:), intent(out) | b, | ||
integer(spi), intent(out) | nrank, | ||
real(dp), intent(out) | det | ||
) |
Apply a form of Gram-Schmidt orthogonalization process to return as many normalized orthogonal basis column vectors in matrix B as possible in the space spanned by the columns of matrix A.
The number of columns returned is the rank, nrank, of A, and the determinant of the projection of A into the subspace of B is returned as det.
[in] | as | given matrix A |
[out] | b | matrix B containing nrank orthonormal column vectors |
[out] | nrank | rank of A |
[out] | det | determinant of projection of A into subspace of B |
subroutine pmat4::gram_s | ( | real(sp), dimension(:,:), intent(in) | as, |
real(sp), dimension(:,:), intent(out) | b, | ||
integer(spi), intent(out) | nrank, | ||
real(sp), intent(out) | det | ||
) |
Apply a form of Gram-Schmidt orthogonalization process to return as many normalized orthogonal basis column vectors in matrix B as possible in the space spanned by the columns of matrix A.
The number of columns returned is the rank, nrank, of A, and the determinant of the projection of A into the subspace of B is returned as det.
[in] | as | given matrix A |
[out] | b | matrix B containing nrank orthonormal column vectors |
[out] | nrank | rank of A |
[out] | det | determinant of projection of A into subspace of B |
subroutine pmat4::graml_d | ( | real(dp), dimension(:,:), intent(in) | as, |
real(dp), dimension(:,:), intent(out) | b, | ||
integer(spi), intent(out) | nrank, | ||
integer(spi), intent(out) | detsign, | ||
real(dp), intent(out) | ldet | ||
) |
A version of gram_d where the determinant information is returned in logarithmic form (to avoid overflows for large matrices).
When the matrix is singular, the "sign" of the determinant, detsign, is returned as zero (instead of either +1 or -1) and ldet is then just the log of the nonzero factors found by the process.
[in] | as | given matrix A |
[out] | b | matrix B of orthonormal columns |
[out] | nrank | rank of A |
[out] | detsign | sign of determinant |
[out] | ldet | logarithm of absolute value of determinant |
real(dp) function pmat4::hav_d | ( | real(dp), intent(in) | t | ) |
real(sp) function pmat4::hav_s | ( | real(sp), intent(in) | t | ) |
|
private |
Spherical area of right-angle triangle whose orthogonal sides have orthographic projection dimensions, sa and sb, sphere of unit radius.
Double precision version.
[in] | sa | orthographic projection of triangle's side A |
[in] | sb | orthographic projection of triangle's side B |
|
private |
Spherical area of right-angle triangle whose orthogonal sides have orthographic projection dimensions, sa and sb, sphere of unit radius.
Single precision version.
[in] | sa | orthographic projection of triangle's side A |
[in] | sb | orthographic projection of triangle's side B |
|
private |
|
private |
real(dp) function, dimension(0:3), public pmat4::mulqq | ( | real(dp), dimension(0:3), intent(in) | a, |
real(dp), dimension(0:3), intent(in) | b | ||
) |
subroutine pmat4::normalize_d | ( | real(dp), dimension(:), intent(inout) | v | ) |
subroutine pmat4::normalize_s | ( | real(sp), dimension(:), intent(inout) | v | ) |
real(dp) function, dimension(size(a)) pmat4::normalized_d | ( | real(dp), dimension(:), intent(in) | a | ) |
Return the normalized version of a double precision real vector.
[in] | a | real type input vector |
Definition at line 156 of file pmat4.f90.
References pmat4::absv::absv_d().
|
private |
Return the normalized version of a single precision real vector.
[in] | a | real type input vector |
Definition at line 142 of file pmat4.f90.
References pmat4::absv::absv_s().
|
private |
real(sp) function, dimension(size(u)) pmat4::orthogonalized_s | ( | real(sp), dimension(:), intent(in) | u, |
real(sp), dimension(:), intent(in) | a | ||
) |
|
private |
|
private |
|
private |
subroutine pmat4::plaingram_d | ( | real(dp), dimension(:,:), intent(inout) | b, |
integer(spi), intent(out) | nrank | ||
) |
subroutine pmat4::plaingram_s | ( | real(sp), dimension(:,:), intent(inout) | b, |
integer(spi), intent(out) | nrank | ||
) |
subroutine, public pmat4::qtoax | ( | real(dp), dimension(0:3), intent(in) | q, |
real(dp), dimension(3), intent(out) | v | ||
) |
subroutine, public pmat4::qtorot | ( | real(dp), dimension(0:3), intent(in) | q, |
real(dp), dimension(3,3), intent(out) | rot | ||
) |
subroutine, public pmat4::qtospin | ( | real(dp), dimension(0:3), intent(in) | q, |
complex(dpc), dimension(2,2), intent(out) | cspin | ||
) |
subroutine, public pmat4::rottoax | ( | real(dp), dimension(3,3), intent(in) | orth33, |
real(dp), dimension(3), intent(out) | ax3 | ||
) |
Assuming that given orth33 is a 3*3 proper rotation matrix, derive an axial 3-vector, ax3, such that orth33 is implied by ax3 when the latter is interpreted as encoding a rotation (as in subroutine axtorot).
Note that such ax3 are not unique – adding any multiple of 2*pi times the parallel unit vector leads to the same orth33.
[in] | orth33 | 3*3 proper rotation matrix |
[out] | ax3 | axial 3-vector |
subroutine, public pmat4::rottoq | ( | real(dp), dimension(3,3), intent(in) | rot, |
real(dp), dimension(0:3), intent(out) | q | ||
) |
subroutine pmat4::rowgram | ( | integer(spi), intent(in) | m, |
integer(spi), intent(in) | n, | ||
real(dp), dimension(m,n), intent(in) | a, | ||
integer(spi), dimension(n), intent(out) | ipiv, | ||
real(dp), dimension(m,n), intent(out) | tt, | ||
real(dp), dimension(n,n), intent(out) | b, | ||
integer(spi), intent(out) | rank | ||
) |
Without changing (tall) rectangular input matrix a, perform pivoted gram- Schmidt operations to orthogonalize the rows, until rows that remain become negligible.
Record the pivoting sequence in ipiv, and the row-normalization in tt(j,j) and the row-orthogonalization in tt(i,j), for i>j. Note that tt(i,j)=0 for i<j (tt is truncated lower triangular). The orthonormalized rows are returned in square array b, which is complete even when the effective rank < n. The recorded row operations can be repeated on independent column vectors through the use of subroutine ROWOPS (in this module). It is recommended to rescale the original matrix A via a call to CORRAL (in this module) because the negligibility criterion depends upon an "epsilon" value that is fixed (10**(-13)) and assumes elements of a are never too different in magnitude from unity, unless they are actually zero.
[in] | m | number of rows of A |
[in] | n | number of columns of A |
[in] | a | rectangular input matrix A |
[out] | ipiv | pivoting sequence |
[out] | tt | row-normalization |
[out] | b | orthonormalized rows |
[in] | rank | effective rank of A |
subroutine, public pmat4::rowops | ( | integer(spi), intent(in) | m, |
integer(spi), intent(in) | n, | ||
integer(spi), dimension(n), intent(in) | ipiv, | ||
real(dp), dimension(m,n), intent(in) | tt, | ||
real(dp), dimension(m), intent(in) | v, | ||
real(dp), dimension(m), intent(out) | vv | ||
) |
Apply the row-operations, implied by ipiv and tt returned by rowgram, to the single column vector, v, to produce the transformed vector vv.
[in] | m | number of rows of matrix tt, dimension of vectors V and VV |
[in] | n | number of columns of matrix tt |
[in] | ipiv | integer vector encoding the pivoting sequence |
[in] | tt | row-normalized matrix provided by subroutine rowgram |
[in] | v | input single column vector |
[out] | vv | output column vector vector |
|
private |
Compute the area of the spherical triangle, {v1,v2,v3}.
[in] | v1 | unit-3-vector vertex of the spherical triangle |
[in] | v2 | unit-3-vector vertex of the spherical triangle |
[in] | v3 | unit-3-vector vertex of the spherical triangle |
Definition at line 722 of file pmat4.f90.
References cyclic().
|
private |
Compute the area of the spherical triangle, {v1,v2,v3}, measured in the right-handed sense, by dropping a perpendicular to u0 on the longest side so that the area becomes the sum of areas of the two simpler right-angled triangles.
[in] | v1 | area of the spherical triangle |
[in] | v2 | area of the spherical triangle |
[in] | v3 | area of the spherical triangle |
Definition at line 667 of file pmat4.f90.
References cyclic().
|
private |
Given the 4 components of a unit quaternion, return the associated 3*3 rotation matrix.
[in] | c | 0th component of given quaternion |
[in] | d | 1st component of given quaternion |
[in] | e | 2nd component of given quaternion |
[in] | g | 3rd component of given quaternion |
[in] | r | output 3*3 real rotation matrix |
subroutine, public pmat4::setmobius | ( | real(dp), dimension(3), intent(in) | xc0, |
real(dp), dimension(3), intent(in) | xc1, | ||
real(dp), dimension(3), intent(in) | xc2, | ||
complex(dpc), intent(out) | aa, | ||
complex(dpc), intent(out) | bb, | ||
complex(dpc), intent(out) | cc, | ||
complex(dpc), intent(out) | dd | ||
) |
Find the Mobius transformation complex coefficients, aa,bb,cc,dd, with aa*dd-bb*cc=1, for a standard (north-)polar stereographic transformation that takes cartesian point, xc0 to the north pole, xc1 to (lat=0,lon=0), xc2 to the south pole (=complex infinity).
[in] | xc0 | cartesian point that will map to (0,0,1) |
[in] | xc1 | cartesian point that will map to (1,0,0) |
[in] | xc2 | cartesian point that will map to (0,0,-1) |
[out] | aa | Mobius transformation complex coefficient |
[out] | bb | Mobius transformation complex coefficient |
[out] | cc | Mobius transformation complex coefficient |
[out] | dd | Mobius transformation complex coefficient |
subroutine, public pmat4::spintoq | ( | complex(dpc), dimension(2,2), intent(in) | cspin, |
real(dp), dimension(0:3), intent(out) | q | ||
) |
|
private |
|
private |
|
private |
|
private |
|
private |
Deliver the triple-cross-product, x, of the three 4-vectors, u, v, w, with the sign convention that ordered, {u,v,w,x} form a right-handed quartet in the generic case (determinant >= 0).
[in] | u | real type input 4-vector |
[in] | v | real type input 4-vector |
[in] | w | real type input 4-vector |
|
private |
|
private |
|
private |
Perform a complex Mobius transformation from (z,infz) to (w,infw) where the transformation coefficients are the standard aa,bb,cc,dd.
Infz is .TRUE. only when z is at complex infinity; likewise infw and w. For these infinite cases, it is important that numerical z==(0,0).
[in] | aa | Mobius transformation complex coefficient |
[in] | bb | Mobius transformation complex coefficient |
[in] | cc | Mobius transformation complex coefficient |
[in] | dd | Mobius transformation complex coefficient |
[in] | z | complex input argument of the Mobius transformation |
[in] | infz | logical indicator for z being a point at infinity |
[out] | w | complex output of the Mobius transformation |
[out] | infw | logical indicator for w being a point at infinity |
|
private |
Perform the inverse of the mobius transformation with coefficients, {aa,bb,cc,dd}.
[in] | aa | inverse Mobius transformation coefficient |
[in] | bb | inverse Mobius transformation coefficient |
[in] | cc | inverse Mobius transformation coefficient |
[in] | dd | inverse Mobius transformation coefficient |
[in] | zz | complex input argument |
[in] | infz | logical indicator for zz the point at infinity |
[out] | zw | complex output argument |
[out] | infw | logical indicator for zw the point at infinity |
Definition at line 2335 of file pmat4.f90.
References pmat4::mobius::zmobius().
subroutine, public pmat4::znfun | ( | integer(spi), intent(in) | n, |
real(dp), intent(in) | z, | ||
real(dp), intent(out) | zn, | ||
real(dp), intent(out) | znd, | ||
real(dp), intent(out) | zndd, | ||
real(dp), intent(out) | znddd | ||
) |
For a given nonnegative integer n and real argument z, evaluate the nth,...,(n+3)th derivatives, wrt z, of the function C(z) = cosh(sqrt(2z)) or, equivalently, of C(z) = cos(sqrt(-2z)), according to the sign of z.
[in] | n | integer order of the first of the returned derivatives of C. |
[in] | z | real input argument in the function C(z) |
[out] | zn | nth-derivative of C(z) |
[out] | znd | (n+1)th-derivative of C(z) |
[out] | zndd | (n+2)th-derivative of C(z) |
[out] | znddd | (n+3)th-derivative of C(z) |
subroutine, public pmat4::zntay | ( | integer(spi), intent(in) | n, |
real(dp), intent(in) | z, | ||
real(dp), intent(out) | zn | ||
) |
|
private |
Find the Mobius transformation complex coefficients, aa,bb,cc,dd, with aa*dd-bb*cc=1, that takes polar stereographic point, z0 to the north pole, z1 to (lat=0,lon=0), z2 to the south pole (=complex infinity).
Should any one of z0,z1,z2 be itself the "point at infinity" its corresponding infz will be set "true" (and the z value itself not used). This routine is like setmobius, except the three fixed points defining the mapping are given in standard complex stereographic form, together with the logical codes "infzn" that are TRUE if that point is itself the projection pole (i.e., the South Pole for a north polar stereographic).
[in] | z0 | complex input point that will map to (0,0) |
[in] | infz0 | logical indicator that z0 is the point at infinity |
[in] | z1 | complex input point that will map to (1,0) |
[in] | infz1 | logical indicator that z1 is the point at infinity |
[in] | z2 | complex input point that will map to infinity |
[in] | infz2 | logical indicator that z2 is the point at infinity |
[out] | aa | Mobius transformation complex coefficient |
[out] | bb | Mobius transformation complex coefficient |
[out] | cc | Mobius transformation complex coefficient |
[out] | dd | Mobius transformation complex coefficient |
subroutine, public pmat4::ztoc | ( | complex(dpc), intent(in) | z, |
logical, intent(in) | infz, | ||
real(dp), dimension(3), intent(out) | v | ||
) |
Given a complex z, return the equivalent cartesian unit 3-vector associated by the polar stereographic projection.
[in] | z | complex input argument |
[in] | infz | logical indicator for z being the point at infinity |
[out] | v | cartesian unit 3-vector position equivalent to z |
|
private |
The convention adopted for the complex derivative is that, for a complex infinitesimal map displacement, delta_z, the corresponding infinitesimal change of cartesian vector position is delta_v given by: delta_v = Real(vd*delta_z).
Thus, by a kind of Cauchy-Riemann relation, Imag(vd)=v CROSS Real(vd).
[in] | z | complex input argument |
[in] | infz | logical indicator for z being the point at infinity |
[out] | v | cartesian unit 3-vector position equivalent to z |
[out] | vd | derivative of cartesian v wrt z |