Skip to content

vecfor ​

VecFor, Vector algebra class for Fortran poor people.

This derived type is useful for manipulating vectors in 3D space. The components of the vectors are reals with parametrized kind as defined by the library module. The components are defined in a three-dimensional cartesian frame of reference. All the vectorial math procedures (cross, dot products, parallel...) assume a three-dimensional cartesian frame of reference. The operators of assignment (=), multiplication (*), division (/), sum (+) and subtraction (-) have been overloaded. Furthermore the dot and cross products have been defined. Therefore this module provides a far-complete algebra based on Vector derived type.

Source: src/lib/vecfor.F90

Dependencies

Re-exports ​

NameKindModuleDescription
anglefunctionvecfor_RPPCalculate the angle (rad) between two vectors.
barycentric_tetrahedronfunctionvecfor_RPPBarycentric coordinates of p in the tetrahedron pt1, pt2, pt3, pt4: ratios of signed sub-volumes, so p = sum(l(i)*pt(i)), sum(l) = 1, all in [0, 1] inside (the point-in-cell test of donor search).
barycentric_trianglefunctionvecfor_RPPBarycentric coordinates of p (of its projection onto the plane) in the triangle pt1, pt2, pt3: p = l(1)*pt1 + l(2)*pt2 + l(3)*pt3 with sum(l) = 1; all in [0, 1] inside the triangle (Ericson's method, the 2x2 determinants by Kahan's algorithm).
closest_point_trianglesubroutinevecfor_RPPPoint q of the triangle a, b, c closest to p, and the feature it lies on: 1, 2, 3 the vertices a, b, c; 4, 5, 6 the edges ab, bc, ca; 7 the face (Ericson's Voronoi-region test, the region signs by Kahan's algorithm). For a signed distance to a mesh, sign |p - q| with the angle-weighted pseudo-normal of that feature (face normal on the face, an average over the faces sharing an edge or a vertex otherwise).
crossproduct_accuratefunctionvecfor_RPPCross product a .cross. b with each component as accurate as one rounding allows (up to 2 ulps): every component a_i * b_j - a_j * b_i by Kahan's algorithm with a fused multiply-add. The .cross. operator rounds both products first and can lose all digits when they nearly cancel (nearly parallel vectors, sliver faces).
distance_to_linefunctionvecfor_RPPCalculate the distance (scalar) to line defined by the 2 points.
distance_to_planefunctionvecfor_RPPCalculate the distance (signed, scalar) to plane defined by the 3 points.
distance_vectorial_to_planefunctionvecfor_RPPCalculate the distance (vectorial) to plane defined by the 3 points.
dotproduct_accuratefunctionvecfor_RPPDot product a .dot. b as if computed in twice the working precision, then rounded (Ogita, Rump, Oishi 2005, Dot2: products by TwoProduct with a fused multiply-add, sums by TwoSum). The .dot. operator can lose every digit when the products nearly cancel.
face_normal3functionvecfor_RPPCalculate the normal of the face defined by the 3 points.
face_normal4functionvecfor_RPPCalculate the normal of the face defined by 4 points.
iolenfunctionvecfor_RPPCompute IO length.
is_collinearfunctionvecfor_RPPReturn true if the point is collinear with other two given points.
is_concyclicfunctionvecfor_RPPReturn true if the point is concyclic with other three given points.
mirror_matrixfunctionvecfor_RPPReturn the mirror matrix (Householder's matrix) given normal of the mirroring plane.
normalizedfunctionvecfor_RPPReturn a normalized copy of vector.
normalized_checkedsubroutinevecfor_RPPNormalize a into c only when its norm is above min_norm (default smallRPP): ok tells which.
normL2functionvecfor_RPPReturn the norm L2 of vector.
polygon_vector_areafunctionvecfor_RPPVector area of the polygon pts(1), ..., pts(n) (vertices in order, closed implicitly): half the sum of (pts(i) - pts(1)) .cross. (pts(i+1) - pts(1)). Its norm is the area of a planar polygon, its direction the normal by the right-hand rule; it does not depend on the origin, and the outward vector areas of the faces of a closed polyhedron sum to zero (the discrete geometric conservation law of finite volumes).
projection_onto_planefunctionvecfor_RPPCalculate the projection of point onto plane defined by 3 points.
rotation_matrixfunctionvecfor_RPPReturn the rotation matrix given axis and angle of ratation.
sq_normfunctionvecfor_RPPReturn the square of the norm of vector.
tetrahedron_volumefunctionvecfor_RPPSigned volume of the tetrahedron pt1, pt2, pt3, pt4: (pt2 - pt1) .dot. ((pt3 - pt1) .cross. (pt4 - pt1)) / 6, positive when pt4 lies on the side where (pt2 - pt1) .cross. (pt3 - pt1) points (right-handed order).
triangle_areafunctionvecfor_RPPArea of the triangle pt1, pt2, pt3: half the norm of (pt2 - pt1) .cross. (pt3 - pt1).
exparametervecfor_RPPX direction versor.
eyparametervecfor_RPPY direction versor.
ezparametervecfor_RPPZ direction versor.
vectortypevecfor_RPPVector class.
angle_devfunctionvecfor_RPPDevice-callable angle (radians) between a and b: angle without its polymorphic array constructor ([self%normalized(), other%normalized()], a host-only runtime call on the device): both versors by normalized_dev, then atan2(normL2(v1.cross.v2), v1.dot.v2) as on the host.
assign_vector_devsubroutinevecfor_RPPDevice-callable vector = vector. Subroutine form is mandatory because Fortran assignment overloads must be subroutines, and the user-defined assign_vector TBP is unreachable from device code.
barycentric_tetrahedron_devsubroutinevecfor_RPPDevice-callable barycentric_tetrahedron, the coordinates as an intent(out) argument.
barycentric_triangle_devsubroutinevecfor_RPPDevice-callable barycentric_triangle, the coordinates as an intent(out) argument.
closest_point_triangle_devsubroutinevecfor_RPPDevice-callable closest_point_triangle.
crossproduct_accurate_devsubroutinevecfor_RPPDevice-callable crossproduct_accurate.
crossproduct_devsubroutinevecfor_RPPDevice-callable cross product, subroutine form.
distance_to_line_devfunctionvecfor_RPPDevice-callable distance of the point a from the line through pt1 and pt2: distance_to_line, normL2((a - pt1).cross.(a - pt2)) / normL2(pt2 - pt1) open-coded.
distance_to_plane_devfunctionvecfor_RPPDevice-callable signed distance of the point a from the plane through pt1, pt2, pt3: distance_to_plane, the unit face normal dotted with a - pt1, open-coded.
distance_vectorial_to_plane_devsubroutinevecfor_RPPDevice-callable vectorial distance of the point a from the plane through pt1, pt2, pt3: distance_vectorial_to_plane, normal * (normal.dot.(a - pt1)) open-coded.
dotproduct_accurate_devfunctionvecfor_RPPDevice-callable dotproduct_accurate.
dotproduct_devfunctionvecfor_RPPDevice-callable dot product. CPU consumers should keep using a .dot. b or a%dotproduct(b); this entry point is for device kernel code only.
face_normal3_devsubroutinevecfor_RPPDevice-callable normal of the triangle pt1, pt2, pt3: face_normal3 open-coded. With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the triangle.
face_normal4_devsubroutinevecfor_RPPDevice-callable normal of the quadrilateral pt1, pt2, pt3, pt4: face_normal4 open-coded (cross product of the diagonals). With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the quadrilateral.
is_collinear_devfunctionvecfor_RPPDevice-callable test of the point a on the line through pt1 and pt2: is_collinear, the distance from the line not above ZeroRPP + tolerance (0 when absent).
is_concyclic_devfunctionvecfor_RPPDevice-callable test of the points a, pt1, pt2, pt3 on one circle: is_concyclic (Ptolemy's inequality) open-coded, against smallRPP + tolerance (0 when absent).
matrixproduct_devsubroutinevecfor_RPPDevice-callable matrix product c = matrix .matrix. a, subroutine form of matrixproduct.
mirror_by_matrix_devsubroutinevecfor_RPPDevice-callable in-place mirroring by matrix, call a%mirror(matrix=): mirror_by_matrix, matrixproduct_dev applied to a.
mirror_by_normal_devsubroutinevecfor_RPPDevice-callable in-place mirror image across the plane of normal normal, call a%mirror(normal=): mirror_by_normal, the mirror_matrix_dev matrix applied with matrixproduct_dev.
mirror_matrix_devsubroutinevecfor_RPPDevice-callable mirror matrix: mirror_matrix with the matrix as an intent(out) argument.
normalize_devsubroutinevecfor_RPPDevice-callable in-place normalization call a%normalize(): normalize open-coded.
normalized_checked_devsubroutinevecfor_RPPDevice-callable normalized_checked: same arithmetic, same optional min_norm.
normalized_devsubroutinevecfor_RPPDevice-callable normalized copy c = a%normalized(): normalized open-coded, the norm guarded by smallRPP as in normalize.
normL2_devfunctionvecfor_RPPDevice-callable norm L2: normL2 open-coded.
orthogonal_devsubroutinevecfor_RPPDevice-callable component of a orthogonal to b, c = a .ortho. b: orthogonal, a - (a .paral. b).
parallel_devsubroutinevecfor_RPPDevice-callable component of a parallel to b, c = a .paral. b: parallel open-coded, (a.dot.b) * normalized(b) / normL2(b) in the same order (the normalization guarded by smallRPP, the divisor not, as on the host).
polygon_vector_area_devsubroutinevecfor_RPPDevice-callable polygon_vector_area, with the number of vertices explicit.
projection_onto_plane_devsubroutinevecfor_RPPDevice-callable projection of the point a onto the plane through pt1, pt2, pt3: projection_onto_plane, a - distance_vectorial_to_plane.
R8P_mul_vector_devsubroutinevecfor_RPPDevice-callable real(R8P) * vector, subroutine form.
rotate_by_axis_angle_devsubroutinevecfor_RPPDevice-callable in-place rotation about axis by angle, call a%rotate(axis=, angle=): rotate_by_axis_angle, the rotation_matrix_dev matrix applied with matrixproduct_dev.
rotate_by_matrix_devsubroutinevecfor_RPPDevice-callable in-place rotation by matrix, call a%rotate(matrix=): rotate_by_matrix, matrixproduct_dev applied to a.
rotation_matrix_devsubroutinevecfor_RPPDevice-callable rotation matrix: rotation_matrix with the matrix as an intent(out) argument.
angle_R8P_devfunctionvecfor_R8PDevice-callable angle (radians) between a and b: angle_R8P without its polymorphic array constructor ([self%normalized(), other%normalized()], a host-only runtime call on the device): both versors by normalized_dev, then atan2(normL2(v1.cross.v2), v1.dot.v2) as on the host.
barycentric_tetrahedron_R8P_devsubroutinevecfor_R8PDevice-callable barycentric_tetrahedron_R8P, the coordinates as an intent(out) argument.
barycentric_triangle_R8P_devsubroutinevecfor_R8PDevice-callable barycentric_triangle_R8P, the coordinates as an intent(out) argument.
closest_point_triangle_R8P_devsubroutinevecfor_R8PDevice-callable closest_point_triangle_R8P.
crossproduct_accurate_R8P_devsubroutinevecfor_R8PDevice-callable crossproduct_accurate_R8P.
distance_to_line_R8P_devfunctionvecfor_R8PDevice-callable distance of the point a from the line through pt1 and pt2: distance_to_line_R8P, normL2((a - pt1).cross.(a - pt2)) / normL2(pt2 - pt1) open-coded.
distance_to_plane_R8P_devfunctionvecfor_R8PDevice-callable signed distance of the point a from the plane through pt1, pt2, pt3: distance_to_plane_R8P, the unit face normal dotted with a - pt1, open-coded.
distance_vectorial_to_plane_R8P_devsubroutinevecfor_R8PDevice-callable vectorial distance of the point a from the plane through pt1, pt2, pt3: distance_vectorial_to_plane_R8P, normal * (normal.dot.(a - pt1)) open-coded.
dotproduct_accurate_R8P_devfunctionvecfor_R8PDevice-callable dotproduct_accurate_R8P.
face_normal3_R8P_devsubroutinevecfor_R8PDevice-callable normal of the triangle pt1, pt2, pt3: face_normal3_R8P open-coded. With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the triangle.
face_normal4_R8P_devsubroutinevecfor_R8PDevice-callable normal of the quadrilateral pt1, pt2, pt3, pt4: face_normal4_R8P open-coded (cross product of the diagonals). With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the quadrilateral.
is_collinear_R8P_devfunctionvecfor_R8PDevice-callable test of the point a on the line through pt1 and pt2: is_collinear_R8P, the distance from the line not above ZeroRPP + tolerance (0 when absent).
is_concyclic_R8P_devfunctionvecfor_R8PDevice-callable test of the points a, pt1, pt2, pt3 on one circle: is_concyclic_R8P (Ptolemy's inequality) open-coded, against smallRPP + tolerance (0 when absent).
mirror_by_matrix_R8P_devsubroutinevecfor_R8PDevice-callable in-place mirroring by matrix, call a%mirror(matrix=): mirror_by_matrix, matrixproduct_dev applied to a.
mirror_by_normal_R8P_devsubroutinevecfor_R8PDevice-callable in-place mirror image across the plane of normal normal, call a%mirror(normal=): mirror_by_normal, the mirror_matrix_dev matrix applied with matrixproduct_dev.
normalize_R8P_devsubroutinevecfor_R8PDevice-callable in-place normalization call a%normalize(): normalize open-coded.
normalized_checked_R8P_devsubroutinevecfor_R8PDevice-callable normalized_checked_R8P: same arithmetic, same optional min_norm.
normalized_R8P_devsubroutinevecfor_R8PDevice-callable normalized copy c = a%normalized(): normalized_R8P open-coded, the norm guarded by smallRPP as in normalize.
normL2_R8P_devfunctionvecfor_R8PDevice-callable norm L2: normL2_R8P open-coded.
orthogonal_R8P_devsubroutinevecfor_R8PDevice-callable component of a orthogonal to b, c = a .ortho. b: orthogonal, a - (a .paral. b).
parallel_R8P_devsubroutinevecfor_R8PDevice-callable component of a parallel to b, c = a .paral. b: parallel open-coded, (a.dot.b) * normalized(b) / normL2(b) in the same order (the normalization guarded by smallRPP, the divisor not, as on the host).
polygon_vector_area_R8P_devsubroutinevecfor_R8PDevice-callable polygon_vector_area_R8P, with the number of vertices explicit.
projection_onto_plane_R8P_devsubroutinevecfor_R8PDevice-callable projection of the point a onto the plane through pt1, pt2, pt3: projection_onto_plane_R8P, a - distance_vectorial_to_plane.
rotate_by_axis_angle_R8P_devsubroutinevecfor_R8PDevice-callable in-place rotation about axis by angle, call a%rotate(axis=, angle=): rotate_by_axis_angle, the rotation_matrix_dev matrix applied with matrixproduct_dev.
rotate_by_matrix_R8P_devsubroutinevecfor_R8PDevice-callable in-place rotation by matrix, call a%rotate(matrix=): rotate_by_matrix, matrixproduct_dev applied to a.
sq_norm_R8P_devfunctionvecfor_R8PDevice-callable square of the norm L2: sq_norm_R8P open-coded.
tetrahedron_volume_R8P_devfunctionvecfor_R8PDevice-callable tetrahedron_volume_R8P.
triangle_area_R8P_devfunctionvecfor_R8PDevice-callable triangle_area_R8P.
vector_mul_R8P_devsubroutinevecfor_RPPDevice-callable vector * real(R8P), subroutine form.
sq_norm_devfunctionvecfor_RPPDevice-callable square of the norm L2: sq_norm open-coded.
tetrahedron_volume_devfunctionvecfor_RPPDevice-callable tetrahedron_volume.
triangle_area_devfunctionvecfor_RPPDevice-callable triangle_area.
vector_sub_vector_devsubroutinevecfor_RPPDevice-callable vector - vector, subroutine form.
vector_sum_vector_devsubroutinevecfor_RPPDevice-callable vector + vector, subroutine form.
angle_R4Pfunctionvecfor_R4PCalculate the angle (rad) between two vectors.
barycentric_tetrahedron_R4Pfunctionvecfor_R4PBarycentric coordinates of p in the tetrahedron pt1, pt2, pt3, pt4: ratios of signed sub-volumes, so p = sum(l(i)*pt(i)), sum(l) = 1, all in [0, 1] inside (the point-in-cell test of donor search).
barycentric_triangle_R4Pfunctionvecfor_R4PBarycentric coordinates of p (of its projection onto the plane) in the triangle pt1, pt2, pt3: p = l(1)*pt1 + l(2)*pt2 + l(3)*pt3 with sum(l) = 1; all in [0, 1] inside the triangle (Ericson's method, the 2x2 determinants by Kahan's algorithm).
closest_point_triangle_R4Psubroutinevecfor_R4PPoint q of the triangle a, b, c closest to p, and the feature it lies on: 1, 2, 3 the vertices a, b, c; 4, 5, 6 the edges ab, bc, ca; 7 the face (Ericson's Voronoi-region test, the region signs by Kahan's algorithm). For a signed distance to a mesh, sign |p - q| with the angle-weighted pseudo-normal of that feature (face normal on the face, an average over the faces sharing an edge or a vertex otherwise).
crossproduct_accurate_R4Pfunctionvecfor_R4PCross product a .cross. b with each component as accurate as one rounding allows (up to 2 ulps): every component a_i * b_j - a_j * b_i by Kahan's algorithm with a fused multiply-add. The .cross. operator rounds both products first and can lose all digits when they nearly cancel (nearly parallel vectors, sliver faces).
distance_to_line_R4Pfunctionvecfor_R4PCalculate the distance (scalar) to line defined by the 2 points.
distance_to_plane_R4Pfunctionvecfor_R4PCalculate the distance (signed, scalar) to plane defined by the 3 points.
distance_vectorial_to_plane_R4Pfunctionvecfor_R4PCalculate the distance (vectorial) to plane defined by the 3 points.
dotproduct_accurate_R4Pfunctionvecfor_R4PDot product a .dot. b as if computed in twice the working precision, then rounded (Ogita, Rump, Oishi 2005, Dot2: products by TwoProduct with a fused multiply-add, sums by TwoSum). The .dot. operator can lose every digit when the products nearly cancel.
face_normal3_R4Pfunctionvecfor_R4PCalculate the normal of the face defined by the 3 points.
face_normal4_R4Pfunctionvecfor_R4PCalculate the normal of the face defined by 4 points.
iolen_R4Pfunctionvecfor_R4PCompute IO length.
is_collinear_R4Pfunctionvecfor_R4PReturn true if the point is collinear with other two given points.
is_concyclic_R4Pfunctionvecfor_R4PReturn true if the point is concyclic with other three given points.
mirror_matrix_R4Pfunctionvecfor_R4PReturn the mirror matrix (Householder's matrix) given normal of the mirroring plane.
normalized_checked_R4Psubroutinevecfor_R4PNormalize a into c only when its norm is above min_norm (default smallRPP): ok tells which.
normalized_R4Pfunctionvecfor_R4PReturn a normalized copy of vector.
normL2_R4Pfunctionvecfor_R4PReturn the norm L2 of vector.
polygon_vector_area_R4Pfunctionvecfor_R4PVector area of the polygon pts(1), ..., pts(n) (vertices in order, closed implicitly): half the sum of (pts(i) - pts(1)) .cross. (pts(i+1) - pts(1)). Its norm is the area of a planar polygon, its direction the normal by the right-hand rule; it does not depend on the origin, and the outward vector areas of the faces of a closed polyhedron sum to zero (the discrete geometric conservation law of finite volumes).
projection_onto_plane_R4Pfunctionvecfor_R4PCalculate the projection of point onto plane defined by 3 points.
rotation_matrix_R4Pfunctionvecfor_R4PReturn the rotation matrix given axis and angle of ratation.
sq_norm_R4Pfunctionvecfor_R4PReturn the square of the norm of vector.
tetrahedron_volume_R4Pfunctionvecfor_R4PSigned volume of the tetrahedron pt1, pt2, pt3, pt4: (pt2 - pt1) .dot. ((pt3 - pt1) .cross. (pt4 - pt1)) / 6, positive when pt4 lies on the side where (pt2 - pt1) .cross. (pt3 - pt1) points (right-handed order).
triangle_area_R4Pfunctionvecfor_R4PArea of the triangle pt1, pt2, pt3: half the norm of (pt2 - pt1) .cross. (pt3 - pt1).
ex_R4Pparametervecfor_R4PX direction versor.
ey_R4Pparametervecfor_R4PY direction versor.
ez_R4Pparametervecfor_R4PZ direction versor.
vector_R4Ptypevecfor_R4PVector class.
angle_R4P_devfunctionvecfor_R4PDevice-callable angle (radians) between a and b: angle_R4P without its polymorphic array constructor ([self%normalized(), other%normalized()], a host-only runtime call on the device): both versors by normalized_dev, then atan2(normL2(v1.cross.v2), v1.dot.v2) as on the host.
assign_vector_R4P_devsubroutinevecfor_R4PDevice-callable vector = vector. Subroutine form is mandatory because Fortran assignment overloads must be subroutines, and the user-defined assign_vector TBP is unreachable from device code.
barycentric_tetrahedron_R4P_devsubroutinevecfor_R4PDevice-callable barycentric_tetrahedron_R4P, the coordinates as an intent(out) argument.
barycentric_triangle_R4P_devsubroutinevecfor_R4PDevice-callable barycentric_triangle_R4P, the coordinates as an intent(out) argument.
closest_point_triangle_R4P_devsubroutinevecfor_R4PDevice-callable closest_point_triangle_R4P.
crossproduct_accurate_R4P_devsubroutinevecfor_R4PDevice-callable crossproduct_accurate_R4P.
crossproduct_R4P_devsubroutinevecfor_R4PDevice-callable cross product, subroutine form.
distance_to_line_R4P_devfunctionvecfor_R4PDevice-callable distance of the point a from the line through pt1 and pt2: distance_to_line_R4P, normL2((a - pt1).cross.(a - pt2)) / normL2(pt2 - pt1) open-coded.
distance_to_plane_R4P_devfunctionvecfor_R4PDevice-callable signed distance of the point a from the plane through pt1, pt2, pt3: distance_to_plane_R4P, the unit face normal dotted with a - pt1, open-coded.
distance_vectorial_to_plane_R4P_devsubroutinevecfor_R4PDevice-callable vectorial distance of the point a from the plane through pt1, pt2, pt3: distance_vectorial_to_plane_R4P, normal * (normal.dot.(a - pt1)) open-coded.
dotproduct_accurate_R4P_devfunctionvecfor_R4PDevice-callable dotproduct_accurate_R4P.
dotproduct_R4P_devfunctionvecfor_R4PDevice-callable dot product. CPU consumers should keep using a .dot. b or a%dotproduct(b); this entry point is for device kernel code only.
face_normal3_R4P_devsubroutinevecfor_R4PDevice-callable normal of the triangle pt1, pt2, pt3: face_normal3_R4P open-coded. With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the triangle.
face_normal4_R4P_devsubroutinevecfor_R4PDevice-callable normal of the quadrilateral pt1, pt2, pt3, pt4: face_normal4_R4P open-coded (cross product of the diagonals). With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the quadrilateral.
is_collinear_R4P_devfunctionvecfor_R4PDevice-callable test of the point a on the line through pt1 and pt2: is_collinear_R4P, the distance from the line not above ZeroRPP + tolerance (0 when absent).
is_concyclic_R4P_devfunctionvecfor_R4PDevice-callable test of the points a, pt1, pt2, pt3 on one circle: is_concyclic_R4P (Ptolemy's inequality) open-coded, against smallRPP + tolerance (0 when absent).
matrixproduct_R4P_devsubroutinevecfor_R4PDevice-callable matrix product c = matrix .matrix. a, subroutine form of matrixproduct.
mirror_by_matrix_R4P_devsubroutinevecfor_R4PDevice-callable in-place mirroring by matrix, call a%mirror(matrix=): mirror_by_matrix, matrixproduct_dev applied to a.
mirror_by_normal_R4P_devsubroutinevecfor_R4PDevice-callable in-place mirror image across the plane of normal normal, call a%mirror(normal=): mirror_by_normal, the mirror_matrix_dev matrix applied with matrixproduct_dev.
mirror_matrix_R4P_devsubroutinevecfor_R4PDevice-callable mirror matrix: mirror_matrix_R4P with the matrix as an intent(out) argument.
normalize_R4P_devsubroutinevecfor_R4PDevice-callable in-place normalization call a%normalize(): normalize open-coded.
normalized_checked_R4P_devsubroutinevecfor_R4PDevice-callable normalized_checked_R4P: same arithmetic, same optional min_norm.
normalized_R4P_devsubroutinevecfor_R4PDevice-callable normalized copy c = a%normalized(): normalized_R4P open-coded, the norm guarded by smallRPP as in normalize.
normL2_R4P_devfunctionvecfor_R4PDevice-callable norm L2: normL2_R4P open-coded.
orthogonal_R4P_devsubroutinevecfor_R4PDevice-callable component of a orthogonal to b, c = a .ortho. b: orthogonal, a - (a .paral. b).
parallel_R4P_devsubroutinevecfor_R4PDevice-callable component of a parallel to b, c = a .paral. b: parallel open-coded, (a.dot.b) * normalized(b) / normL2(b) in the same order (the normalization guarded by smallRPP, the divisor not, as on the host).
polygon_vector_area_R4P_devsubroutinevecfor_R4PDevice-callable polygon_vector_area_R4P, with the number of vertices explicit.
projection_onto_plane_R4P_devsubroutinevecfor_R4PDevice-callable projection of the point a onto the plane through pt1, pt2, pt3: projection_onto_plane_R4P, a - distance_vectorial_to_plane.
R8P_mul_vector_R4P_devsubroutinevecfor_R4PDevice-callable real(R8P) * vector, subroutine form.
rotate_by_axis_angle_R4P_devsubroutinevecfor_R4PDevice-callable in-place rotation about axis by angle, call a%rotate(axis=, angle=): rotate_by_axis_angle, the rotation_matrix_dev matrix applied with matrixproduct_dev.
rotate_by_matrix_R4P_devsubroutinevecfor_R4PDevice-callable in-place rotation by matrix, call a%rotate(matrix=): rotate_by_matrix, matrixproduct_dev applied to a.
rotation_matrix_R4P_devsubroutinevecfor_R4PDevice-callable rotation matrix: rotation_matrix_R4P with the matrix as an intent(out) argument.
sq_norm_R4P_devfunctionvecfor_R4PDevice-callable square of the norm L2: sq_norm_R4P open-coded.
tetrahedron_volume_R4P_devfunctionvecfor_R4PDevice-callable tetrahedron_volume_R4P.
triangle_area_R4P_devfunctionvecfor_R4PDevice-callable triangle_area_R4P.
vector_mul_R8P_R4P_devsubroutinevecfor_R4PDevice-callable vector * real(R8P), subroutine form.
vector_sub_vector_R4P_devsubroutinevecfor_R4PDevice-callable vector - vector, subroutine form.
vector_sum_vector_R4P_devsubroutinevecfor_R4PDevice-callable vector + vector, subroutine form.
angle_R8Pfunctionvecfor_R8PCalculate the angle (rad) between two vectors.
barycentric_tetrahedron_R8Pfunctionvecfor_R8PBarycentric coordinates of p in the tetrahedron pt1, pt2, pt3, pt4: ratios of signed sub-volumes, so p = sum(l(i)*pt(i)), sum(l) = 1, all in [0, 1] inside (the point-in-cell test of donor search).
barycentric_triangle_R8Pfunctionvecfor_R8PBarycentric coordinates of p (of its projection onto the plane) in the triangle pt1, pt2, pt3: p = l(1)*pt1 + l(2)*pt2 + l(3)*pt3 with sum(l) = 1; all in [0, 1] inside the triangle (Ericson's method, the 2x2 determinants by Kahan's algorithm).
closest_point_triangle_R8Psubroutinevecfor_R8PPoint q of the triangle a, b, c closest to p, and the feature it lies on: 1, 2, 3 the vertices a, b, c; 4, 5, 6 the edges ab, bc, ca; 7 the face (Ericson's Voronoi-region test, the region signs by Kahan's algorithm). For a signed distance to a mesh, sign |p - q| with the angle-weighted pseudo-normal of that feature (face normal on the face, an average over the faces sharing an edge or a vertex otherwise).
crossproduct_accurate_R8Pfunctionvecfor_R8PCross product a .cross. b with each component as accurate as one rounding allows (up to 2 ulps): every component a_i * b_j - a_j * b_i by Kahan's algorithm with a fused multiply-add. The .cross. operator rounds both products first and can lose all digits when they nearly cancel (nearly parallel vectors, sliver faces).
distance_to_line_R8Pfunctionvecfor_R8PCalculate the distance (scalar) to line defined by the 2 points.
distance_to_plane_R8Pfunctionvecfor_R8PCalculate the distance (signed, scalar) to plane defined by the 3 points.
distance_vectorial_to_plane_R8Pfunctionvecfor_R8PCalculate the distance (vectorial) to plane defined by the 3 points.
dotproduct_accurate_R8Pfunctionvecfor_R8PDot product a .dot. b as if computed in twice the working precision, then rounded (Ogita, Rump, Oishi 2005, Dot2: products by TwoProduct with a fused multiply-add, sums by TwoSum). The .dot. operator can lose every digit when the products nearly cancel.
face_normal3_R8Pfunctionvecfor_R8PCalculate the normal of the face defined by the 3 points.
face_normal4_R8Pfunctionvecfor_R8PCalculate the normal of the face defined by 4 points.
iolen_R8Pfunctionvecfor_R8PCompute IO length.
is_collinear_R8Pfunctionvecfor_R8PReturn true if the point is collinear with other two given points.
is_concyclic_R8Pfunctionvecfor_R8PReturn true if the point is concyclic with other three given points.
mirror_matrix_R8Pfunctionvecfor_R8PReturn the mirror matrix (Householder's matrix) given normal of the mirroring plane.
normalized_checked_R8Psubroutinevecfor_R8PNormalize a into c only when its norm is above min_norm (default smallRPP): ok tells which.
normalized_R8Pfunctionvecfor_R8PReturn a normalized copy of vector.
normL2_R8Pfunctionvecfor_R8PReturn the norm L2 of vector.
polygon_vector_area_R8Pfunctionvecfor_R8PVector area of the polygon pts(1), ..., pts(n) (vertices in order, closed implicitly): half the sum of (pts(i) - pts(1)) .cross. (pts(i+1) - pts(1)). Its norm is the area of a planar polygon, its direction the normal by the right-hand rule; it does not depend on the origin, and the outward vector areas of the faces of a closed polyhedron sum to zero (the discrete geometric conservation law of finite volumes).
projection_onto_plane_R8Pfunctionvecfor_R8PCalculate the projection of point onto plane defined by 3 points.
rotation_matrix_R8Pfunctionvecfor_R8PReturn the rotation matrix given axis and angle of ratation.
sq_norm_R8Pfunctionvecfor_R8PReturn the square of the norm of vector.
tetrahedron_volume_R8Pfunctionvecfor_R8PSigned volume of the tetrahedron pt1, pt2, pt3, pt4: (pt2 - pt1) .dot. ((pt3 - pt1) .cross. (pt4 - pt1)) / 6, positive when pt4 lies on the side where (pt2 - pt1) .cross. (pt3 - pt1) points (right-handed order).
triangle_area_R8Pfunctionvecfor_R8PArea of the triangle pt1, pt2, pt3: half the norm of (pt2 - pt1) .cross. (pt3 - pt1).
ex_R8Pparametervecfor_R8PX direction versor.
ey_R8Pparametervecfor_R8PY direction versor.
ez_R8Pparametervecfor_R8PZ direction versor.
vector_R8Ptypevecfor_R8PVector class.
assign_vector_R8P_devsubroutinevecfor_R8PDevice-callable vector = vector. Subroutine form is mandatory because Fortran assignment overloads must be subroutines, and the user-defined assign_vector TBP is unreachable from device code.
crossproduct_R8P_devsubroutinevecfor_R8PDevice-callable cross product, subroutine form.
dotproduct_R8P_devfunctionvecfor_R8PDevice-callable dot product. CPU consumers should keep using a .dot. b or a%dotproduct(b); this entry point is for device kernel code only.
matrixproduct_R8P_devsubroutinevecfor_R8PDevice-callable matrix product c = matrix .matrix. a, subroutine form of matrixproduct.
mirror_matrix_R8P_devsubroutinevecfor_R8PDevice-callable mirror matrix: mirror_matrix_R8P with the matrix as an intent(out) argument.
R8P_mul_vector_R8P_devsubroutinevecfor_R8PDevice-callable real(R8P) * vector, subroutine form.
rotation_matrix_R8P_devsubroutinevecfor_R8PDevice-callable rotation matrix: rotation_matrix_R8P with the matrix as an intent(out) argument.
vector_mul_R8P_R8P_devsubroutinevecfor_R8PDevice-callable vector * real(R8P), subroutine form.
vector_sub_vector_R8P_devsubroutinevecfor_R8PDevice-callable vector - vector, subroutine form.
vector_sum_vector_R8P_devsubroutinevecfor_R8PDevice-callable vector + vector, subroutine form.
angle_R16Pfunctionvecfor_R16PCalculate the angle (rad) between two vectors.
barycentric_tetrahedron_R16Pfunctionvecfor_R16PBarycentric coordinates of p in the tetrahedron pt1, pt2, pt3, pt4: ratios of signed sub-volumes, so p = sum(l(i)*pt(i)), sum(l) = 1, all in [0, 1] inside (the point-in-cell test of donor search).
barycentric_triangle_R16Pfunctionvecfor_R16PBarycentric coordinates of p (of its projection onto the plane) in the triangle pt1, pt2, pt3: p = l(1)*pt1 + l(2)*pt2 + l(3)*pt3 with sum(l) = 1; all in [0, 1] inside the triangle (Ericson's method, the 2x2 determinants by Kahan's algorithm).
closest_point_triangle_R16Psubroutinevecfor_R16PPoint q of the triangle a, b, c closest to p, and the feature it lies on: 1, 2, 3 the vertices a, b, c; 4, 5, 6 the edges ab, bc, ca; 7 the face (Ericson's Voronoi-region test, the region signs by Kahan's algorithm). For a signed distance to a mesh, sign |p - q| with the angle-weighted pseudo-normal of that feature (face normal on the face, an average over the faces sharing an edge or a vertex otherwise).
crossproduct_accurate_R16Pfunctionvecfor_R16PCross product a .cross. b with each component as accurate as one rounding allows (up to 2 ulps): every component a_i * b_j - a_j * b_i by Kahan's algorithm with a fused multiply-add. The .cross. operator rounds both products first and can lose all digits when they nearly cancel (nearly parallel vectors, sliver faces).
distance_to_line_R16Pfunctionvecfor_R16PCalculate the distance (scalar) to line defined by the 2 points.
distance_to_plane_R16Pfunctionvecfor_R16PCalculate the distance (signed, scalar) to plane defined by the 3 points.
distance_vectorial_to_plane_R16Pfunctionvecfor_R16PCalculate the distance (vectorial) to plane defined by the 3 points.
dotproduct_accurate_R16Pfunctionvecfor_R16PDot product a .dot. b as if computed in twice the working precision, then rounded (Ogita, Rump, Oishi 2005, Dot2: products by TwoProduct with a fused multiply-add, sums by TwoSum). The .dot. operator can lose every digit when the products nearly cancel.
face_normal3_R16Pfunctionvecfor_R16PCalculate the normal of the face defined by the 3 points.
face_normal4_R16Pfunctionvecfor_R16PCalculate the normal of the face defined by 4 points.
iolen_R16Pfunctionvecfor_R16PCompute IO length.
is_collinear_R16Pfunctionvecfor_R16PReturn true if the point is collinear with other two given points.
is_concyclic_R16Pfunctionvecfor_R16PReturn true if the point is concyclic with other three given points.
mirror_matrix_R16Pfunctionvecfor_R16PReturn the mirror matrix (Householder's matrix) given normal of the mirroring plane.
normalized_checked_R16Psubroutinevecfor_R16PNormalize a into c only when its norm is above min_norm (default smallRPP): ok tells which.
normalized_R16Pfunctionvecfor_R16PReturn a normalized copy of vector.
normL2_R16Pfunctionvecfor_R16PReturn the norm L2 of vector.
polygon_vector_area_R16Pfunctionvecfor_R16PVector area of the polygon pts(1), ..., pts(n) (vertices in order, closed implicitly): half the sum of (pts(i) - pts(1)) .cross. (pts(i+1) - pts(1)). Its norm is the area of a planar polygon, its direction the normal by the right-hand rule; it does not depend on the origin, and the outward vector areas of the faces of a closed polyhedron sum to zero (the discrete geometric conservation law of finite volumes).
projection_onto_plane_R16Pfunctionvecfor_R16PCalculate the projection of point onto plane defined by 3 points.
rotation_matrix_R16Pfunctionvecfor_R16PReturn the rotation matrix given axis and angle of ratation.
sq_norm_R16Pfunctionvecfor_R16PReturn the square of the norm of vector.
tetrahedron_volume_R16Pfunctionvecfor_R16PSigned volume of the tetrahedron pt1, pt2, pt3, pt4: (pt2 - pt1) .dot. ((pt3 - pt1) .cross. (pt4 - pt1)) / 6, positive when pt4 lies on the side where (pt2 - pt1) .cross. (pt3 - pt1) points (right-handed order).
triangle_area_R16Pfunctionvecfor_R16PArea of the triangle pt1, pt2, pt3: half the norm of (pt2 - pt1) .cross. (pt3 - pt1).
ex_R16Pparametervecfor_R16PX direction versor.
ey_R16Pparametervecfor_R16PY direction versor.
ez_R16Pparametervecfor_R16PZ direction versor.
vector_R16Ptypevecfor_R16PVector class.
angle_R16P_devfunctionvecfor_R16PDevice-callable angle (radians) between a and b: angle_R16P without its polymorphic array constructor ([self%normalized(), other%normalized()], a host-only runtime call on the device): both versors by normalized_dev, then atan2(normL2(v1.cross.v2), v1.dot.v2) as on the host.
assign_vector_R16P_devsubroutinevecfor_R16PDevice-callable vector = vector. Subroutine form is mandatory because Fortran assignment overloads must be subroutines, and the user-defined assign_vector TBP is unreachable from device code.
barycentric_tetrahedron_R16P_devsubroutinevecfor_R16PDevice-callable barycentric_tetrahedron_R16P, the coordinates as an intent(out) argument.
barycentric_triangle_R16P_devsubroutinevecfor_R16PDevice-callable barycentric_triangle_R16P, the coordinates as an intent(out) argument.
closest_point_triangle_R16P_devsubroutinevecfor_R16PDevice-callable closest_point_triangle_R16P.
crossproduct_accurate_R16P_devsubroutinevecfor_R16PDevice-callable crossproduct_accurate_R16P.
crossproduct_R16P_devsubroutinevecfor_R16PDevice-callable cross product, subroutine form.
distance_to_line_R16P_devfunctionvecfor_R16PDevice-callable distance of the point a from the line through pt1 and pt2: distance_to_line_R16P, normL2((a - pt1).cross.(a - pt2)) / normL2(pt2 - pt1) open-coded.
distance_to_plane_R16P_devfunctionvecfor_R16PDevice-callable signed distance of the point a from the plane through pt1, pt2, pt3: distance_to_plane_R16P, the unit face normal dotted with a - pt1, open-coded.
distance_vectorial_to_plane_R16P_devsubroutinevecfor_R16PDevice-callable vectorial distance of the point a from the plane through pt1, pt2, pt3: distance_vectorial_to_plane_R16P, normal * (normal.dot.(a - pt1)) open-coded.
dotproduct_accurate_R16P_devfunctionvecfor_R16PDevice-callable dotproduct_accurate_R16P.
dotproduct_R16P_devfunctionvecfor_R16PDevice-callable dot product. CPU consumers should keep using a .dot. b or a%dotproduct(b); this entry point is for device kernel code only.
face_normal3_R16P_devsubroutinevecfor_R16PDevice-callable normal of the triangle pt1, pt2, pt3: face_normal3_R16P open-coded. With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the triangle.
face_normal4_R16P_devsubroutinevecfor_R16PDevice-callable normal of the quadrilateral pt1, pt2, pt3, pt4: face_normal4_R16P open-coded (cross product of the diagonals). With norm present (any value, as on the host) the normal is normalized, otherwise its length is the area of the quadrilateral.
is_collinear_R16P_devfunctionvecfor_R16PDevice-callable test of the point a on the line through pt1 and pt2: is_collinear_R16P, the distance from the line not above ZeroRPP + tolerance (0 when absent).
is_concyclic_R16P_devfunctionvecfor_R16PDevice-callable test of the points a, pt1, pt2, pt3 on one circle: is_concyclic_R16P (Ptolemy's inequality) open-coded, against smallRPP + tolerance (0 when absent).
matrixproduct_R16P_devsubroutinevecfor_R16PDevice-callable matrix product c = matrix .matrix. a, subroutine form of matrixproduct.
mirror_by_matrix_R16P_devsubroutinevecfor_R16PDevice-callable in-place mirroring by matrix, call a%mirror(matrix=): mirror_by_matrix, matrixproduct_dev applied to a.
mirror_by_normal_R16P_devsubroutinevecfor_R16PDevice-callable in-place mirror image across the plane of normal normal, call a%mirror(normal=): mirror_by_normal, the mirror_matrix_dev matrix applied with matrixproduct_dev.
mirror_matrix_R16P_devsubroutinevecfor_R16PDevice-callable mirror matrix: mirror_matrix_R16P with the matrix as an intent(out) argument.
normalize_R16P_devsubroutinevecfor_R16PDevice-callable in-place normalization call a%normalize(): normalize open-coded.
normalized_checked_R16P_devsubroutinevecfor_R16PDevice-callable normalized_checked_R16P: same arithmetic, same optional min_norm.
normalized_R16P_devsubroutinevecfor_R16PDevice-callable normalized copy c = a%normalized(): normalized_R16P open-coded, the norm guarded by smallRPP as in normalize.
normL2_R16P_devfunctionvecfor_R16PDevice-callable norm L2: normL2_R16P open-coded.
orthogonal_R16P_devsubroutinevecfor_R16PDevice-callable component of a orthogonal to b, c = a .ortho. b: orthogonal, a - (a .paral. b).
parallel_R16P_devsubroutinevecfor_R16PDevice-callable component of a parallel to b, c = a .paral. b: parallel open-coded, (a.dot.b) * normalized(b) / normL2(b) in the same order (the normalization guarded by smallRPP, the divisor not, as on the host).
polygon_vector_area_R16P_devsubroutinevecfor_R16PDevice-callable polygon_vector_area_R16P, with the number of vertices explicit.
projection_onto_plane_R16P_devsubroutinevecfor_R16PDevice-callable projection of the point a onto the plane through pt1, pt2, pt3: projection_onto_plane_R16P, a - distance_vectorial_to_plane.
R8P_mul_vector_R16P_devsubroutinevecfor_R16PDevice-callable real(R8P) * vector, subroutine form.
rotate_by_axis_angle_R16P_devsubroutinevecfor_R16PDevice-callable in-place rotation about axis by angle, call a%rotate(axis=, angle=): rotate_by_axis_angle, the rotation_matrix_dev matrix applied with matrixproduct_dev.
rotate_by_matrix_R16P_devsubroutinevecfor_R16PDevice-callable in-place rotation by matrix, call a%rotate(matrix=): rotate_by_matrix, matrixproduct_dev applied to a.
rotation_matrix_R16P_devsubroutinevecfor_R16PDevice-callable rotation matrix: rotation_matrix_R16P with the matrix as an intent(out) argument.
sq_norm_R16P_devfunctionvecfor_R16PDevice-callable square of the norm L2: sq_norm_R16P open-coded.
tetrahedron_volume_R16P_devfunctionvecfor_R16PDevice-callable tetrahedron_volume_R16P.
triangle_area_R16P_devfunctionvecfor_R16PDevice-callable triangle_area_R16P.
vector_mul_R8P_R16P_devsubroutinevecfor_R16PDevice-callable vector * real(R8P), subroutine form.
vector_sub_vector_R16P_devsubroutinevecfor_R16PDevice-callable vector - vector, subroutine form.
vector_sum_vector_R16P_devsubroutinevecfor_R16PDevice-callable vector + vector, subroutine form.

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.