mat Derived Type

type, public :: mat


Components

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

Matrix values


Constructor

public interface mat

Intalise Matrix with 1D Array

  • private function mat_init(array)

    Initalise matrix type from 1D array

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp) :: array(16)

    1D array to initalise from.

    Return Value type(mat)


Type-Bound Procedures

procedure, private, pass(a) :: mat_add_scal

  • private function mat_add_scal(a, b)

    Matrix + Scalar = Matrix

    Arguments

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

    Input Matrix

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

    Scalar to add

    Return Value type(mat)

procedure, private, pass(a) :: mat_div_scal

  • private function mat_div_scal(a, b)

    Matrix / scalar

    Arguments

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

    Input Matrix

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

    Scalar to divide by

    Return Value type(mat)

procedure, private, pass(a) :: mat_minus_scal

  • private function mat_minus_scal(a, b)

    Matrix - Scalar

    Arguments

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

    Input Matrix

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

    Scalar to subtract

    Return Value type(mat)

procedure, private, pass(a) :: mat_mult_mat

  • private function mat_mult_mat(a, b)

    Matrix * vec4

    Arguments

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

    Input Matrix

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

    Vec4 to multiply by

    Return Value type(vec4)

procedure, private, pass(a) :: mat_mult_scal

  • private function mat_mult_scal(a, b)

    Matrix * Scalar

    Arguments

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

    Input Matrix

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

    Scalar to multiply by

    Return Value type(mat)

generic, public :: operator(*) => mat_mult_scal, scal_mult_mat, mat_mult_mat

Overload for Multiplication operator

  • private function mat_mult_scal(a, b)

    Matrix * Scalar

    Arguments

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

    Input Matrix

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

    Scalar to multiply by

    Return Value type(mat)

  • private function scal_mult_mat(a, b)

    Matrix * Scalar

    Arguments

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

    Scalar to multiply by

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

    Input Matrix

    Return Value type(mat)

  • private function mat_mult_mat(a, b)

    Matrix * vec4

    Arguments

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

    Input Matrix

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

    Vec4 to multiply by

    Return Value type(vec4)

generic, public :: operator(+) => mat_add_scal, scal_add_mat

Overload for Addition operator

  • private function mat_add_scal(a, b)

    Matrix + Scalar = Matrix

    Arguments

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

    Input Matrix

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

    Scalar to add

    Return Value type(mat)

  • private function scal_add_mat(a, b)

    Scaler + Matrix

    Arguments

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

    Scalat to add

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

    Input Matrix

    Return Value type(mat)

generic, public :: operator(-) => mat_minus_scal

Overload for Subtraction operator

  • private function mat_minus_scal(a, b)

    Matrix - Scalar

    Arguments

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

    Input Matrix

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

    Scalar to subtract

    Return Value type(mat)

generic, public :: operator(/) => mat_div_scal

Overload for Division operator

  • private function mat_div_scal(a, b)

    Matrix / scalar

    Arguments

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

    Input Matrix

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

    Scalar to divide by

    Return Value type(mat)

procedure, private, pass(b) :: scal_add_mat

  • private function scal_add_mat(a, b)

    Scaler + Matrix

    Arguments

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

    Scalat to add

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

    Input Matrix

    Return Value type(mat)

procedure, private, pass(b) :: scal_mult_mat

  • private function scal_mult_mat(a, b)

    Matrix * Scalar

    Arguments

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

    Scalar to multiply by

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

    Input Matrix

    Return Value type(mat)

Source Code

    type :: mat
        !> Matrix values
        real(kind=wp) :: vals(4, 4)
        contains

        !> Overload for Division operator
        generic   :: operator(/)     => mat_div_scal
        !> Overload for Multiplication operator
        generic   :: operator(*)     => mat_mult_scal, scal_mult_mat, mat_mult_mat
        !> Overload for Addition operator
        generic   :: operator(+)     => mat_add_scal, scal_add_mat
        !> Overload for Subtraction operator
        generic   :: operator(-)     => mat_minus_scal

        procedure, pass(a), private :: mat_div_scal

        procedure, pass(a), private :: mat_mult_mat
        procedure, pass(a), private :: mat_mult_scal
        procedure, pass(b), private :: scal_mult_mat

        procedure, pass(a), private :: mat_add_scal
        procedure, pass(b), private :: scal_add_mat

        procedure, pass(a), private :: mat_minus_scal

    end type mat