Behaviour and limitations
What VecFor does at the edges, and what it does not do. Every statement of this page is checked by a program of the docs or by the sources.
Comparisons
<,<=,>,>=between two vectors compare their lengths: two vectors of equal length and different direction are both<=and>=each other. Between a vector and a number, all six compare the length with the number.==between two vectors compares the lengths and then the components of the unit vectors;/=is its negation.- All are exact: no tolerance. For computed vectors, compare
normL2(a - b)with a tolerance of your own.
Tolerances of the predicates
is_collinear and is_concyclic take an optional tolerance, 0 by default (is_concyclic adds tiny, the smallest positive normal number). Without it the tests are exact, and points that are collinear or concyclic only up to rounding, as computed points are, pass or fail by chance: pass a tolerance scaled to your geometry. is_concyclic also needs the points in their order around the circle.
Zero vectors and degenerate geometry
| Case | Result |
|---|---|
normalize, normalized of the zero vector | the zero vector |
normalized_checked of a vector not longer than min_norm | ok false, the zero vector |
angle with a zero vector | 0 |
a .paral. b, a .ortho. b with b zero | NaN |
distance_to_line with pt1 = pt2 | NaN |
distance_to_plane and the projections, with three collinear points | 0, and the point itself: silently |
face_normal3, face_normal4 of a degenerate face | the zero vector, also with norm |
barycentric_triangle, barycentric_tetrahedron of a degenerate cell | IEEE infinities or NaN |
a / b with a zero component of b; a / 0 | IEEE infinities or NaN, as for numbers |
Input and output
save_into_file,load_from_fileandprintfnever stop the program on an I/O error: withoutiostatthe error is silently ignored, and a vector that fails to load keeps its old value. Always passiostat.fmtis a format string:'*'is not list-directed I/O.- There is no
rec=for direct access files: write the components. - The I/O procedures and
iolenare notpure.
Types and kinds
- Vectors of two kinds do not mix: no
a4 + a8, noa8 = a4. Convert by components. vectorandvector_R8Pare two different types, although of the same kind;exandex_R8Plikewise.vector_R16Pis quadruple precision only when PENF and VecFor are compiled with-DPENF_R16P, as the GNU and Intel builds are. nvfortran has no 128-bit real kind: therevector_R16Pis double precision (see Precision and kinds).- The scalar arguments of the methods (
angle=,tolerance=) and the matrices must have the kind of the vector; the numbers of the operators may have any kind.
Fortran itself
- A method needs a variable or a named constant:
(a - b)%normL2()is not Fortran; use the free function,normL2(a - b). - The user-defined operators bind more loosely than any intrinsic one:
a .dot. b + cisa .dot. (b + c); parenthesise (see Precedence). - The intrinsics
sum,dot_product,matmul,maxval, ... do not apply to arrays of vectors.
Not elemental
rotate, mirror, rotation_matrix, mirror_matrix, .matrix. and the I/O procedures work on one vector at a time; loop over arrays. polygon_vector_area takes an array, the vertices of one polygon, and barycentric_triangle and barycentric_tetrahedron return an array, the coordinates of one point: they are pure, not elemental. Every other operator and function, and normalize, normalized_checked and closest_point_triangle, are elemental.
Not on the device
Only the routines of the device-callable API run inside an OpenACC kernel: the sum, the difference and the products of vectors, the products with an R8P number, the matrices, the geometric methods, the accurate products, the measures and the point location. The other operators, the comparisons and the input/output do not.
Not available
Vectors of two or of more than three components; non-Cartesian frames; a type for points distinct from the type for directions (VecFor uses one type for both); quaternions.