vector Derived Type

type, public :: vector


Contents


Constructor

public interface vector

Construct a vector object

Read more…
  • private pure function vector_constructor_int(array) result(this)

    Construct a vector from an array of integers

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in), dimension(:):: array

    input data

    Return Value type(vector)

  • private pure function vector_constructor_r32(array) result(this)

    Construct a vector from an array of single precision reals

    Arguments

    Type IntentOptional AttributesName
    real(kind=real32), intent(in), dimension(:):: array

    input data

    Return Value type(vector)

  • private pure function vector_constructor_r64(array) result(this)

    Construct a vector from an array of double precision reals

    Arguments

    Type IntentOptional AttributesName
    real(kind=real64), intent(in), dimension(:):: array

    input data

    Return Value type(vector)

  • private elemental function vector_constructor_dim(dim) result(this)

    Construct a vector by declaring its size Allocate an -dimensional vector and fill its values with 0

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: dim

    Return Value type(vector)

  • private elemental function vector_constructor_dim_value_int(dim, val) result(this)

    Construct a vector of dimension and fill its values with integer

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: dim

    integer, intent(in) :: val

    Return Value type(vector)

  • private elemental function vector_constructor_dim_value_r32(dim, val) result(this)

    Construct a vector of dimension and fill its values with single precision real

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: dim

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

    Return Value type(vector)

  • private elemental function vector_constructor_dim_value_r64(dim, val) result(this)

    Construct a vector of dimension and fill its values with double precision real

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: dim

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

    Return Value type(vector)

  • private elemental function vector_constructor_vector(v1) result(v2)

    Construct a vector from another vector

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: v1

    Return Value type(vector)


Finalization Procedures

final :: vector_destructor

  • private subroutine vector_destructor(self)

    Arguments

    Type IntentOptional AttributesName
    type(vector), intent(inout) :: self

Type-Bound Procedures

procedure, public :: size => vector_size

Return the number of elements of the currently allocated vector

  • private elemental function vector_size(self) result(n)

    Return the number of elements allocated for

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value integer

procedure, public :: clear => clear_vector

Deallocate the data, set dim to 0

  • private elemental subroutine clear_vector(self)

    Deallocate a vector if it is allocated, set the dimension equal to 0

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

procedure, public :: print_info => vector_print_info

Print diagnostic information about the vector

  • private subroutine vector_print_info(self)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

procedure, public :: print => vector_print_coordinates

Print only the data stored in the vector object as a row vector

  • private subroutine vector_print_coordinates(self)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

procedure, public :: at => vector_at_index

Return the element

  • private elemental function vector_at_index(self, index) result(x_n)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    integer, intent(in) :: index

    Return Value real(kind=real64)

generic, public :: set => set_int_, set_r32_, set_r64_

Set the value of the element at index

  • private elemental subroutine vector_set_index_int(self, index, val)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in) :: index
    integer, intent(in) :: val
  • private elemental subroutine vector_set_index_r32(self, index, val)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in) :: index
    real(kind=real32), intent(in) :: val
  • private elemental subroutine vector_set_index_r64(self, index, val)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in) :: index
    real(kind=real64), intent(in) :: val

procedure, public :: length => vector_euclidiean_norm

Calculate the euclidean norm of a vector

  • private elemental function vector_euclidiean_norm(self) result(length)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value real(kind=real64)

procedure, public :: pnorm => vector_pnorm

Calculate the pnorm of a vector

  • private elemental function vector_pnorm(self, p) result(pnorm)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    integer, intent(in) :: p

    Return Value real(kind=real64)

procedure, public :: normalize => vector_normalize

Normalize the elements of the passed vector Normalize is a subroutine such that it alters the elements of the passed vector to avoid costs of copying involved with a function

  • private elemental subroutine vector_normalize(self)

    Normalize a vector such that its euclidian norm is 1

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

procedure, public :: normalized => vector_normalized

Return a normalized vector pointing in the same direction as

  • private elemental function vector_normalized(self) result(normalized_vector)

    Normalize a vector such that its euclidian norm is 1

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value type(vector)

procedure, public :: orthogonalize => vector_orthogonalize

Orthogonalize a vector against a passed normalized vector

  • private elemental subroutine vector_orthogonalize(self, v2)

    Orthogonalize a vector with respect to another

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2

procedure, public :: orthogonalized => vector_orthogonalized

Return a vector that is orthogonalized against a passed normalized vector

  • private elemental function vector_orthogonalized(self, v2) result(v3)

    Orthogonalize a vector with respect to another

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

procedure, public :: orthonormalize => vector_orthonormalize

Orthogonalize and normalize a vector against a passed normalized vector

  • private elemental subroutine vector_orthonormalize(self, v2)

    Orthogonalize a vector with respect to another

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2

procedure, public :: orthonormalized => vector_orthonormalized

Return an orthogonalized and normalized vector against a passed normalized vector

  • private elemental function vector_orthonormalized(self, v2) result(v3)

    Orthogonalize a vector with respect to another

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

procedure, public :: householder_transform => vector_householder_sub

Rotate a passed vector about the hyper plane described by the passed normalized vector

  • private elemental subroutine vector_householder_sub(self, normal)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: normal

    MUST BE A UNIT VECTOR

procedure, public :: id => vector_constructor_eye

  • private elemental function vector_constructor_eye(self, dim, col) result(v2)

    Construct a vector that is equal to the th column of the Identity matrix The and parameters are both optional. If the parameter is absent, then take the th column from the identity matrix whose dimension is . If the parameter is missing, set its default value to the dimension.

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    integer, intent(in), optional :: dim

    Dimension of the Identity matrix

    integer, intent(in), optional :: col

    Column to extract

    Return Value type(vector)

    th column of the Identity matrix

procedure, public :: is_ortho => vector_is_orthogonal

  • private elemental function vector_is_orthogonal(self, v2, eps) result(bool)

    Check if two vectors are orthogonal within a certain tolerance.

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

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

    real(kind=real64), intent(in), optional :: eps

    Return Value logical

    True when

procedure, public :: is_normal => vector_is_normal

  • private elemental function vector_is_normal(self) result(bool)

    Check if a vector is normal. A vector is normal if it's length is equal to 1 (within a tolerance)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value logical

procedure, public :: data => vector_as_array

  • private pure function vector_as_array(self) result(array)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value real(kind=real64), dimension(self%dim)

procedure, public :: zero => vector_zero

  • private elemental function vector_zero(self, dim) result(zero)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    integer, intent(in), optional :: dim

    Return Value type(vector)

procedure, public :: set_zero => vector_zero_sub

  • private elemental subroutine vector_zero_sub(self, dim)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in), optional :: dim

procedure, public :: allocated => vector_is_allocated

  • private elemental function vector_is_allocated(self) result(bool)

    Check if a vector is allocated

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value logical

procedure, public :: alloc_ => allocate_vector_data

  • private elemental subroutine allocate_vector_data(self, dim)

    Allocate the underlying array containing 's data and set 's dimension to

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

    integer, intent(in) :: dim

procedure, public :: dealloc_ => deallocate_vector_data

  • private elemental subroutine deallocate_vector_data(self)

    Deallocate the underlying array containing 's elements

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

generic, public :: assignment(=) => from_array_int_, from_array_r32_, from_array_r64_, from_vector_, from_int_, from_r32_, from_r64_

  • private pure subroutine vector_from_array_int(self, array)

    Assign a vector to an array of integers.

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in), dimension(:):: array
  • private pure subroutine vector_from_array_r32(self, array)

    Assign a vector to an array of integers.

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    real(kind=real32), intent(in), dimension(:):: array
  • private pure subroutine vector_from_array_r64(self, array)

    Assign a vector to an array of integers.

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    real(kind=real64), intent(in), dimension(:):: array
  • private elemental subroutine vector_from_vector(self, v1)

    Copy the elements of a vector into

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

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

  • private pure subroutine vector_from_int(self, val)

    Assign a vector to an int value. If is already allocated, fill the elements with . If is not already allocated, create a new vector of dimension 1 and set the element equal to

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

    integer, intent(in) :: val

    Value used to fill

  • private pure subroutine vector_from_r32(self, val)

    Assign a vector to single precision value. If is already allocated, fill the elements with . If is not already allocated, create a new vector of dimension 1 and set the element equal to

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

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

    Value used to fill

  • private pure subroutine vector_from_r64(self, val)

    Assign a vector to a double precision value. If is already allocated, fill the elements with . If is not already allocated, create a new vector of dimension 1 and set the element equal to

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self

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

    Value used to fill

generic, public :: operator(.dot.) => dot_

  • private elemental function vector_dot_vector(self, v2) result(inner_product)

    Calculate the inner product of two vectors

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value real(kind=real64)

generic, public :: operator(.inner.) => dot_

  • private elemental function vector_dot_vector(self, v2) result(inner_product)

    Calculate the inner product of two vectors

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value real(kind=real64)

generic, public :: operator(.outer.) => outer_

  • private pure function vector_outer_vector(self, v2) result(array)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value real(kind=real64), dimension(self%dim, v2%dim)

generic, public :: operator(.proj.) => proj_

  • private elemental function vector_proj_vector(self, v2) result(v3)

    Project vector self ONTO v2

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

generic, public :: operator(.hh.) => householder_

  • private elemental function vector_householder(self, normal) result(rotated)

    Perform a householder reflection about a normal vector

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: normal

    MUST BE A UNIT VECTOR

    Return Value type(vector)

generic, public :: operator(.hhnorm.) => householder_normal_

  • private function vector_find_householder_normal(self, direction) result(normal)

    Find the normal vector about which to rotate a vector when given a destination direction

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: direction

    A Unit vector pointing in the direction that we would like to end up at

    Return Value type(vector)

generic, public :: operator(*) => scalar_mult_int_, scalar_mult_r32_, scalar_mult_r64_

  • private elemental function vector_times_scalar_int(self, scalar) result(v2)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    integer, intent(in) :: scalar

    Return Value type(vector)

  • private elemental function vector_times_scalar_r32(self, scalar) result(v2)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    real(kind=real32), intent(in) :: scalar

    Return Value type(vector)

  • private elemental function vector_times_scalar_r64(self, scalar) result(v2)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    real(kind=real64), intent(in) :: scalar

    Return Value type(vector)

generic, public :: operator(.o.) => hadamard_vec_

  • private elemental function vector_hadamard_vector(self, v2) result(v3)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

generic, public :: operator(/) => scalar_div_int_, scalar_div_r32_, scalar_div_r64_, div_vec_

  • private elemental function vector_div_scalar_int(self, scalar) result(v2)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    integer, intent(in) :: scalar

    Return Value type(vector)

  • private elemental function vector_div_scalar_r32(self, scalar) result(v2)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    real(kind=real32), intent(in) :: scalar

    Return Value type(vector)

  • private elemental function vector_div_scalar_r64(self, scalar) result(v2)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    real(kind=real64), intent(in) :: scalar

    Return Value type(vector)

  • private elemental function vector_div_vector(self, v2) result(v3)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

generic, public :: operator(+) => plus_

  • private elemental function vector_plus_vector(self, v2) result(v3)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

generic, public :: operator(-) => minus_, unary_minus_

  • private elemental function vector_minus_vector(self, v2) result(v3)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self
    class(vector), intent(in) :: v2

    Return Value type(vector)

  • private elemental function vector_unary_minus(self) result(v2)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: self

    Return Value type(vector)

generic, public :: times => times_int_sub_, times_r32_sub_, times_r64_sub_, times_vec_sub_

  • private elemental subroutine vector_times_scalar_int_sub(self, scalar)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in) :: scalar
  • private elemental subroutine vector_times_scalar_r32_sub(self, scalar)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    real(kind=real32), intent(in) :: scalar
  • private elemental subroutine vector_times_scalar_r64_sub(self, scalar)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    real(kind=real64), intent(in) :: scalar
  • private elemental subroutine vector_times_vector_sub(self, v2)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2

generic, public :: div => div_int_sub_, div_r32_sub_, div_r64_sub_, div_vec_sub_

  • private elemental subroutine vector_div_scalar_int_sub(self, scalar)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    integer, intent(in) :: scalar
  • private elemental subroutine vector_div_scalar_r32_sub(self, scalar)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    real(kind=real32), intent(in) :: scalar
  • private elemental subroutine vector_div_scalar_r64_sub(self, scalar)

    Multiply a vector times an integer scalar

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    real(kind=real64), intent(in) :: scalar
  • private elemental subroutine vector_div_vector_sub(self, v2)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2

generic, public :: proj => project_onto_sub_

  • private elemental subroutine vector_proj_vector_sub(self, v2)

    Project vector self ONTO v2

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2

generic, public :: plus => plus_vector_sub_

  • private elemental subroutine vector_plus_vector_sub(self, v2)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2

generic, public :: minus => minus_vector_sub_

  • private elemental subroutine vector_minus_vector_sub(self, v2)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(inout) :: self
    class(vector), intent(in) :: v2