-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Clause 10Standard Clause 10: Expressions and assignmentStandard Clause 10: Expressions and assignment
Description
As proposed by a reader at comp.lang.fortran: https://groups.google.com/d/msg/comp.lang.fortran/m6qz7hC4a7M/78maOb9uEgAJ
(see the thread for further comments and discussion)
Adding matrix literals
This is mostly a quality of life thing, but something like
INTEGER, DIMENSION(2, 2) :: A = [1, 2; 3, 4]
representing the matrix
/ 1 2 \
\ 3 4 /
is, to me, a lot more readable than
INTEGER, DIMENSION(2, 2) :: A = TRANSPOSE(RESHAPE([1, 2, 3, 4], [2, 2]))
This could even be extended to more complex arrays by, for instance, repeating
semicolons, eg.
INTEGER, DIMENSION(2, 2, 2) :: B = [1, 2; 3, 4;; 5, 6; 7, 8]
One issue with this syntax is of course that the values are given row major,
which is different from the memory layout of Fortran an thus also the way
RESHAPE works.
Alternatively [1, 2; 3, 4] could represent
/ 1 3 \
\ 2 4 /
certik, jacobwilliams, epagone, marshallward, Leonard-Reuter and 10 morecertik, marshallward, bwearley and AboAmmar
Metadata
Metadata
Assignees
Labels
Clause 10Standard Clause 10: Expressions and assignmentStandard Clause 10: Expressions and assignment