A KISS pure Fortran OOD class for computing Vectorial (3D) algebra
- VecFor is a pure Fortran (KISS) library for building easily nice Command Line Interfaces (CLI) for modern Fortran projects;
- VecFor is Fortran 2003+ standard compliant;
- VecFor is OOP designed;
- VecFor is a Free, Open Source Project.
VecFor is a user-friendly and Object-Oriented designed API for handling vectors in a (3D) three dimensional frame of reference. It exposes (among others) the object Vector that posses a far complete set of overloaded operators for performing vectorial calculus algebra.
VecFor adheres to the KISS concept: it is a pure Fortran (2003+) library coded into a single module file, vecfor.F90
.
Go to Top
- Pure Fortran implementation;
- KISS and user-friendly:
- simple API (one main object plus few other helpers);
- easy building and porting on heterogeneous architectures:
- the vector components are defined as real with parametrized kind; the default kind parameter is set to be 64-bit-like finite precision (defined by means of the portable
select_real_kind
intrinsic function), but it can be easily changed at compile time;
- the vector components are defined as real with parametrized kind; the default kind parameter is set to be 64-bit-like finite precision (defined by means of the portable
- comprehensive (almost complete set of operators for vectorial calculus algebra);
- all operators accept mixed type/kind arguments: vectors can be mixed with integers and reals of any kinds by means of generic interfaces with dynamic dispatch resolved at compile time;
- efficient and non intrusive (all object methods and operators are pure or elemental):
- threads/processes safe;
- Tests-Driven Developed (TDD);
- well documented:
- collaborative developed on GitHub;
- FOSS licensed;
Any feature request is welcome.
Go to Top
VecFor is an open source project, it is distributed under a multi-licensing system:
- for FOSS projects:
- for closed source/commercial projects:
Anyone is interest to use, to develop or to contribute to VecFor is welcome, feel free to select the license that best matches your soul!
More details can be found on wiki.
Go to Top
Besides this README file the VecFor documentation is contained into its own wiki. Detailed documentation of the API is contained into the GitHub Pages that can also be created locally by means of ford tool.
VecFor allows a very simple, high-level implementation of vectorial calculus algebra.
use vecfor ! load vector type and all helpers
type(vector) :: point1
type(vector) :: point2
type(vector) :: distance
point1 = 1 * ex ! ex is the versor along x direction exposed by VecFor
point2 = 1 * ex + 2 * ey ! ey is the versor along y direction exposed by VecFor
Note that ex, ey and ez are the Cartesian versors exposed by VecFor.
distance = point2 - point1
print "(A)", " Vectorial distance"
call distance%printf
print "(A)", " Distance module"
print*, distance%normL2()
! expected output
! Vectorial distance
! Component x 0.000000000000000E+000
! Component y +0.200000000000000E+001
! Component z 0.000000000000000E+000
! Distance module
! +0.200000000000000E+001
As you can see from the above example, defining and using a vector become very close to the mathematical formulation. Note that, using the dynamic dispatching resolved at compile time, there is no performance penalty on using a type(vector)
variable instead of an hard-coded real, dimension(3)
array variable (or even more verbose and less clear real :: x, y, z
variables for each vector...).
Go to Top