-
Notifications
You must be signed in to change notification settings - Fork 173
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 eye
: allow generalized return type and kind
#902
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @perazz . This is a nice extension. I just wonder if we should keep the default output as integer(int8)
or as integer
?
@jvdp1 let me know if you have further comments since I switched the default return to |
Thanks @perazz for this improvement! I think it is indeed almost ready. One suggestion, feel free to neglect it: Quite often it is required to initialize arrays with zero or one, why not add these parameters to one of the constants modules? taking for instance the one added in the stdlib_sparse_constants:
Make them accesible elsewhere, in that case, I would propose the following small modification to the
Note: I approve it even if these suggestions are not used as I think it is ready as is ;) |
What would be the advantage of this approach for |
@jvdp1 I think that if consistently used, it would avoid the small kind conversion errors under assignment. Agree, let's postpone that for another PR. |
OK. I see your point and fully agree with it! |
@jvdp1 @jalvesz note that we already have many such constants (including precision-related) in the BLAS modules.
|
It was recently suggested (#901) that it may be confusing that
eye
always returns aninteger(int8)
result.This PR proposes to extend the current identity matrix implementation via an optional
mold
keyword.If present,
mold
is used to give a type and kind to the return matrix.Proposed interface
A = eye(dim1 [, dim2] [, mold])
Key facts
Prior art
mold
already exists, and with the same meaning, both in the Fortran standard (allocate(a, mold=b)
), and here in stdlib:cc: @jvdp1 @jalvesz @fortran-lang/stdlib