vector_class Module

Vector class module. Defines a vector type (x, y, z) and associated operations on vectors and other types.


Uses


Interfaces

public interface abs

Overload of the abs intrinsic for a vec3

  • private pure elemental function abs_vec(this)

    Calculate the absoulte of a vector elementwise

    Arguments

    Type IntentOptional Attributes Name
    type(vector), intent(in) :: this

    Input vector

    Return Value type(vector)

public interface max

Overload of the max intrinsic for a vec3

  • private pure elemental function max_vec(this, val)

    Get the max value elementwise between a vec3 and a scalar

    Arguments

    Type IntentOptional Attributes Name
    type(vector), intent(in) :: this

    Input vector

    real(kind=wp), intent(in) :: val

    Input max value

    Return Value type(vector)

  • private pure elemental function maxval_vec(this)

    Get the max value in a vec3

    Arguments

    Type IntentOptional Attributes Name
    type(vector), intent(in) :: this

    Input vector

    Return Value real(kind=wp)

public interface min

Overload of the min intrinsic for a vec3

  • private pure elemental function min_vec(this, val)

    Get the min value elementwise between a vec3 and a scalar

    Arguments

    Type IntentOptional Attributes Name
    type(vector), intent(in) :: this

    Input vector

    real(kind=wp), intent(in) :: val

    Input minimum value

    Return Value type(vector)

  • private pure elemental function minval_vec(this)

    Get the min value in a vec3

    Arguments

    Type IntentOptional Attributes Name
    type(vector), intent(in) :: this

    Input vector

    Return Value real(kind=wp)

public interface nint

Overload of the nint intrinsic for a vec3

  • private pure elemental function nint_vec(this)

    Overload the nint intrinsic for a vec3 elementwise

    Arguments

    Type IntentOptional Attributes Name
    type(vector), intent(in) :: this

    Input vector

    Return Value type(vector)


Derived Types

type, public ::  vector

Vector class

Components

Type Visibility Attributes Name Initial
real(kind=wp), public :: x

vector components

real(kind=wp), public :: y

vector components

real(kind=wp), public :: z

vector components

Type-Bound Procedures

procedure, public :: length ../../

Returns the length of the vector

procedure, public :: magnitude ../../

Returns the magnitude of the vector

generic, public :: operator(*) => vec_mult_vec, vec_mult_scal, scal_mult_vec ../../

Overloads the Multiplication operator for vec3

generic, public :: operator(**) => vec_mult_exp_scal_int, vec_mult_exp_scal_r4, vec_mult_exp_scal_r8 ../../

Overloads the exponential operator for vec3

generic, public :: operator(+) => vec_add_vec, vec_add_scal, scal_add_vec ../../

Overloads the Addition operator for vec3

generic, public :: operator(-) => vec_minus_vec, vec_minus_scal, scal_minus_vec ../../

Overloads the Subtraction operator for vec3

generic, public :: operator(.cross.) => vec_cross_vec ../../

.cross. operator. Cross product

generic, public :: operator(.dot.) => vec_dot_vec, vec_dot_mat ../../

.dot. operator. Dot product

generic, public :: operator(/) => vec_div_scal_r4, vec_div_scal_r8, vec_div_scal_int ../../

Overloads the Division operator for vec3

generic, public :: operator(==) => vec_equal_vec ../../

Overloads the equal operator for vec3

procedure, private, pass(b) :: scal_add_vec
procedure, private, pass(b) :: scal_minus_vec
procedure, private, pass(b) :: scal_mult_vec
procedure, private, pass(a) :: vec_add_scal
procedure, private, pass(a) :: vec_add_vec
procedure, private, pass(a) :: vec_cross_vec
procedure, private, pass(a) :: vec_div_scal_int
procedure, private, pass(a) :: vec_div_scal_r4
procedure, private, pass(a) :: vec_div_scal_r8
procedure, private, pass(a) :: vec_dot_mat
procedure, private, pass(a) :: vec_dot_vec
procedure, private, pass(a) :: vec_equal_vec
procedure, private, pass(a) :: vec_minus_scal
procedure, private, pass(a) :: vec_minus_vec
procedure, private, pass(a) :: vec_mult_exp_scal_int
procedure, private, pass(a) :: vec_mult_exp_scal_r4
procedure, private, pass(a) :: vec_mult_exp_scal_r8
procedure, private, pass(a) :: vec_mult_scal
procedure, private, pass(a) :: vec_mult_vec

Functions

private pure elemental function abs_vec(this)

Calculate the absoulte of a vector elementwise

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: this

Input vector

Return Value type(vector)

public pure elemental function length(this)

Returns the length of a vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: this

Return Value real(kind=wp)

public pure elemental function magnitude(this)

Returns the magnitude of a vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: this

Return Value type(vector)

private pure elemental function max_vec(this, val)

Get the max value elementwise between a vec3 and a scalar

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: this

Input vector

real(kind=wp), intent(in) :: val

Input max value

Return Value type(vector)

private pure elemental function maxval_vec(this)

Get the max value in a vec3

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: this

Input vector

Return Value real(kind=wp)

private pure elemental function min_vec(this, val)

Get the min value elementwise between a vec3 and a scalar

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: this

Input vector

real(kind=wp), intent(in) :: val

Input minimum value

Return Value type(vector)

private pure elemental function minval_vec(this)

Get the min value in a vec3

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: this

Input vector

Return Value real(kind=wp)

private pure elemental function nint_vec(this)

Overload the nint intrinsic for a vec3 elementwise

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: this

Input vector

Return Value type(vector)

private pure elemental function scal_add_vec(a, b)

vec3 + scalar

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a

Scalar to add

class(vector), intent(in) :: b

Input vector

Return Value type(vector)

private pure elemental function scal_minus_vec(a, b)

scalar - vec3

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a

Scalar to subtract from

class(vector), intent(in) :: b

Input vector

Return Value type(vector)

private pure elemental function scal_mult_vec(a, b)

Scalar * vec3 elementwise

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a

Scalar to multiply by

class(vector), intent(in) :: b

input vec3

Return Value type(vector)

private pure elemental function vec_add_scal(a, b)

vec3 + scalar

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vector

real(kind=wp), intent(in) :: b

Scalar to add

Return Value type(vector)

private pure elemental function vec_add_vec(a, b)

vec3 + vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vector

type(vector), intent(in) :: b

Vec3 to add

Return Value type(vector)

private pure elemental function vec_cross_vec(a, b) result(cross)

vec3 x vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vector

type(vector), intent(in) :: b

vec3 to cross with

Return Value type(vector)

private pure elemental function vec_div_scal_int(a, b)

vec3 / scalar elementwise. Scalar is an integer

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

input vec3

integer, intent(in) :: b

Scalar to divide by

Return Value type(vector)

private pure elemental function vec_div_scal_r4(a, b)

vec3 / scalar elementwise. Scalar is a 32-bit float

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

input vec3

real(kind=sp), intent(in) :: b

Scalar to divide by

Return Value type(vector)

private pure elemental function vec_div_scal_r8(a, b)

vec3 / scalar elementwise. Scalar is a 64-bit float

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

input vec3

real(kind=dp), intent(in) :: b

Scalar to divide by

Return Value type(vector)

private pure function vec_dot_mat(a, b) result(dot)

vec3 . matrix

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vec3

real(kind=wp), intent(in) :: b(4,4)

Matrix to dot with

Return Value type(vector)

private pure elemental function vec_dot_vec(a, b) result(dot)

vec3 . vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vec3

type(vector), intent(in) :: b

vec3 to dot

Return Value real(kind=wp)

private pure elemental function vec_equal_vec(a, b)

vec3 == vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vec3s

class(vector), intent(in) :: b

Input vec3s

Return Value logical

private pure elemental function vec_minus_scal(a, b)

vec3 - scalar

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vector

real(kind=wp), intent(in) :: b

Scalar to subtract

Return Value type(vector)

private pure elemental function vec_minus_vec(a, b)

vec3 - vec3

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input vector

type(vector), intent(in) :: b

vec3 to subtract

Return Value type(vector)

private pure elemental function vec_mult_exp_scal_int(a, b)

vec3**scalar for integer scalar

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input Vector

integer, intent(in) :: b

Input scalar

Return Value type(vector)

private pure elemental function vec_mult_exp_scal_r4(a, b)

vec3**scalar for 32-bit float scalar

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input Vector

real(kind=sp), intent(in) :: b

Input scalar

Return Value type(vector)

private pure elemental function vec_mult_exp_scal_r8(a, b)

vec3**scalar for 64-bit float scalar

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

Input Vector

real(kind=dp), intent(in) :: b

Input scalar

Return Value type(vector)

private pure elemental function vec_mult_scal(a, b)

vec3 * scalar elementwise

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

input vec3

real(kind=wp), intent(in) :: b

Scalar to multiply by

Return Value type(vector)

private pure elemental function vec_mult_vec(a, b)

vec3 * vec3 elementwise

Arguments

Type IntentOptional Attributes Name
class(vector), intent(in) :: a

input vec3

type(vector), intent(in) :: b

vec3 to multiply by

Return Value type(vector)