Skip to content

linalg: generalize return type for eye #901

Closed
@perazz

Description

@perazz

Motivation

It was recently suggested that the eye (#481) function is misleading. I would like to suggest that the eye function is extended by allowing a general return type. This could be accomplished by introducing an optional mold keyword:

A = eye(m, n [, mold])

that would tell the eye interface which return type should have A:

pure function eye_${rk}$(m, n, mold)
   integer, intent(in) :: m
   integer, intent(in), optional :: n
   ${rt}$, optional, intent(in) :: mold
   ${rt}$, dimension(:,:), allocatable :: eye
end function eye_${rk}$

Prior Art

mold is a Fortran Standard keyword that specifies that the return type of a polymorphic allocation should be taken from another variable:

allocate(a, mold=b)

Similarly, here we may want to specify that the return type of the eye matrix should be taken from the mold variable.

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaProposition of an idea and opening an issue to discuss it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions