Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linalg: generalize return type for eye #901

Closed
perazz opened this issue Nov 30, 2024 · 0 comments
Closed

linalg: generalize return type for eye #901

perazz opened this issue Nov 30, 2024 · 0 comments
Labels
idea Proposition of an idea and opening an issue to discuss it

Comments

@perazz
Copy link
Member

perazz commented Nov 30, 2024

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

@perazz perazz added the idea Proposition of an idea and opening an issue to discuss it label Nov 30, 2024
@perazz perazz closed this as completed Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Proposition of an idea and opening an issue to discuss it
Projects
None yet
Development

No branches or pull requests

1 participant