mat_class Module

Matrix class module. Defines a matrix type (4x4 matrix) and associated operations on matrices and other types.

not fully implmented matix class minimum implmented for neural sdf type



Interfaces

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)


Derived Types

type, public ::  mat

Components

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

Matrix values

Constructor

Intalise Matrix with 1D Array

private function mat_init (array)

Initalise matrix type from 1D array

Type-Bound Procedures

procedure, private, pass(a) :: mat_add_scal
procedure, private, pass(a) :: mat_div_scal
procedure, private, pass(a) :: mat_minus_scal
procedure, private, pass(a) :: mat_mult_mat
procedure, private, pass(a) :: mat_mult_scal
generic, public :: operator(*) => mat_mult_scal, scal_mult_mat, mat_mult_mat ../../

Overload for Multiplication operator

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

Overload for Addition operator

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

Overload for Subtraction operator

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

Overload for Division operator

procedure, private, pass(b) :: scal_add_mat
procedure, private, pass(b) :: scal_mult_mat

Functions

public pure function invert(A) result(B)

Performs a direct calculation of the inverse of a 4×4 matrix. from http://fortranwiki.org/fortran/show/Matrix+inversion

Arguments

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

Input Matric

Return Value real(kind=wp), (4,4)

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 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)

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)

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)

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)

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_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)

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)