Attempt to play around with a vector object
A vector, has the following operations:
Addition with another vector Multiplication with a scalar Inner product Outer product Norm (which norm?) Projection of a onto b
The internal representaion of a vector is an allocatable array. This way we can use the fundamental data of an array within our specific class
Construct a vector object
Construct a vector from an array of integers
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(:) | :: | array | input data |
Construct a vector from an array of single precision reals
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in), | dimension(:) | :: | array | input data |
Construct a vector from an array of double precision reals
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in), | dimension(:) | :: | array | input data |
Construct a vector by declaring its size Allocate an -dimensional vector and fill its values with 0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | dim |
|
Construct a vector of dimension and fill its values with integer
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | dim |
|
||
integer, | intent(in) | :: | val |
|
Construct a vector of dimension and fill its values with single precision real
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | dim |
|
||
real(kind=real32), | intent(in) | :: | val |
|
Construct a vector of dimension and fill its values with double precision real
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | dim |
|
||
real(kind=real64), | intent(in) | :: | val |
|
Construct a vector from another vector
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(vector), | intent(in) | :: | v1 |
Extend multiplication operator to allow a scalar times a vector such that
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | scalar | |||
class(vector), | intent(in) | :: | vec |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | scalar | |||
class(vector), | intent(in) | :: | vec |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | scalar | |||
class(vector), | intent(in) | :: | vec |
Extend division operator to allow a scalar divided by a vector
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | scalar | |||
class(vector), | intent(in) | :: | vec |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real32), | intent(in) | :: | scalar | |||
class(vector), | intent(in) | :: | vec |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | scalar | |||
class(vector), | intent(in) | :: | vec |
Construct a vector object
private pure function vector_constructor_int(array) | Construct a vector from an array of integers |
private pure function vector_constructor_r32(array) | Construct a vector from an array of single precision reals |
private pure function vector_constructor_r64(array) | Construct a vector from an array of double precision reals |
private elemental function vector_constructor_dim(dim) | Construct a vector by declaring its size Allocate an -dimensional vector and fill its values with 0 |
private elemental function vector_constructor_dim_value_int(dim, val) | Construct a vector of dimension and fill its values with integer |
private elemental function vector_constructor_dim_value_r32(dim, val) | Construct a vector of dimension and fill its values with single precision real |
private elemental function vector_constructor_dim_value_r64(dim, val) | Construct a vector of dimension and fill its values with double precision real |
private elemental function vector_constructor_vector(v1) | Construct a vector from another vector |
final :: vector_destructor |
procedure, public :: size => vector_size | Return the number of elements of the currently allocated vector |
procedure, public :: clear => clear_vector | Deallocate the data, set dim to 0 |
procedure, public :: print_info => vector_print_info | Print diagnostic information about the vector |
procedure, public :: print => vector_print_coordinates | Print only the data stored in the vector object as a row vector |
procedure, public :: at => vector_at_index | Return the element |
generic, public :: set => set_int_, set_r32_, set_r64_ | Set the value of the element at index |
procedure, public :: length => vector_euclidiean_norm | Calculate the euclidean norm of a vector |
procedure, public :: pnorm => vector_pnorm | Calculate the pnorm of a vector |
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 |
procedure, public :: normalized => vector_normalized | Return a normalized vector pointing in the same direction as |
procedure, public :: orthogonalize => vector_orthogonalize | Orthogonalize a vector against a passed normalized vector |
procedure, public :: orthogonalized => vector_orthogonalized | Return a vector that is orthogonalized against a passed normalized vector |
procedure, public :: orthonormalize => vector_orthonormalize | Orthogonalize and normalize a vector against a passed normalized vector |
procedure, public :: orthonormalized => vector_orthonormalized | Return an orthogonalized and normalized vector against a passed normalized vector |
procedure, public :: householder_transform => vector_householder_sub | Rotate a passed vector about the hyper plane described by the passed normalized vector |
procedure, public :: id => vector_constructor_eye | |
procedure, public :: is_ortho => vector_is_orthogonal | |
procedure, public :: is_normal => vector_is_normal | |
procedure, public :: data => vector_as_array | |
procedure, public :: zero => vector_zero | |
procedure, public :: set_zero => vector_zero_sub | |
procedure, public :: allocated => vector_is_allocated | |
procedure, public :: alloc_ => allocate_vector_data | |
procedure, public :: dealloc_ => deallocate_vector_data | |
generic, public :: assignment(=) => from_array_int_, from_array_r32_, from_array_r64_, from_vector_, from_int_, from_r32_, from_r64_ | |
generic, public :: operator(.dot.) => dot_ | |
generic, public :: operator(.inner.) => dot_ | |
generic, public :: operator(.outer.) => outer_ | |
generic, public :: operator(.proj.) => proj_ | |
generic, public :: operator(.hh.) => householder_ | |
generic, public :: operator(.hhnorm.) => householder_normal_ | |
generic, public :: operator(*) => scalar_mult_int_, scalar_mult_r32_, scalar_mult_r64_ | |
generic, public :: operator(.o.) => hadamard_vec_ | |
generic, public :: operator(/) => scalar_div_int_, scalar_div_r32_, scalar_div_r64_, div_vec_ | |
generic, public :: operator(+) => plus_ | |
generic, public :: operator(-) => minus_, unary_minus_ | |
generic, public :: times => times_int_sub_, times_r32_sub_, times_r64_sub_, times_vec_sub_ | |
generic, public :: div => div_int_sub_, div_r32_sub_, div_r64_sub_, div_vec_sub_ | |
generic, public :: proj => project_onto_sub_ | |
generic, public :: plus => plus_vector_sub_ | |
generic, public :: minus => minus_vector_sub_ |