• optimised code for small matrix (look mum no loops)?

    From Woozy Song@suzyw0ng@outlook.com to comp.lang.fortran on Thu Apr 16 20:37:32 2026
    From Newsgroup: comp.lang.fortran

    I came across some old NASA Fortran subroutines for inverting small
    matrices. Basically, no loops just long equations for each cell (and a determinant). So efficient for speed, not memory. Interestingly for 5x5 matrix, there are extra lines like
    A11=A(1,1)
    A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25 copy operations are offset by faster access later using scalar instead of
    indexed array fetch?
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Ian@gay@sfuu.ca to comp.lang.fortran on Thu Apr 16 09:36:39 2026
    From Newsgroup: comp.lang.fortran

    Woozy Song wrote:

    I came across some old NASA Fortran subroutines for inverting small
    matrices. Basically, no loops just long equations for each cell (and a determinant). So efficient for speed, not memory. Interestingly for
    5x5 matrix, there are extra lines like
    A11=A(1,1)
    A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25
    copy operations are offset by faster access later using scalar instead
    of indexed array fetch?

    Must be a very old compiler where those assignments would gain anything. Determinant? Don't tell me it's using Cramer's rule!
    --
    *********** To reply by e-mail, make w single in address **************
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Thomas Koenig@tkoenig@netcologne.de to comp.lang.fortran on Thu Apr 16 18:54:42 2026
    From Newsgroup: comp.lang.fortran

    Woozy Song <suzyw0ng@outlook.com> schrieb:
    I came across some old NASA Fortran subroutines for inverting small matrices. Basically, no loops just long equations for each cell (and a determinant). So efficient for speed, not memory. Interestingly for 5x5 matrix, there are extra lines like
    A11=A(1,1)
    A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25 copy operations are offset by faster access later using scalar instead of
    indexed array fetch?

    I very much doubt this would make a difference for modern optimizing
    compilers.

    Do these routines actually invert matrices? This is rarely needed.
    What is the dimension of these matrices?
    --
    This USENET posting was made without artificial intelligence,
    artificial impertinence, artificial arrogance, artificial stupidity,
    artificial flavorings or artificial colorants.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Woozy Song@suzyw0ng@outlook.com to comp.lang.fortran on Fri Apr 17 09:48:19 2026
    From Newsgroup: comp.lang.fortran

    Thomas Koenig wrote:
    Woozy Song <suzyw0ng@outlook.com> schrieb:
    I came across some old NASA Fortran subroutines for inverting small
    matrices. Basically, no loops just long equations for each cell (and a
    determinant). So efficient for speed, not memory. Interestingly for 5x5
    matrix, there are extra lines like
    A11=A(1,1)
    A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25 copy
    operations are offset by faster access later using scalar instead of
    indexed array fetch?

    I very much doubt this would make a difference for modern optimizing compilers.

    Do these routines actually invert matrices? This is rarely needed.
    What is the dimension of these matrices?


    dimensions 3x3 to 6x6. I have seen similar snippets elsewhere, but only
    for 3x3 and 4x4. I presume there are niche algorithms that do lots of
    small matrix inversions.

    So if it doesn't gain anything, I guess it was to make the code text
    less unwieldly replacing 6 characters with 3.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Gary Scott@garylscott@sbcglobal.net to comp.lang.fortran on Thu Apr 16 21:13:20 2026
    From Newsgroup: comp.lang.fortran

    On 4/16/2026 8:48 PM, Woozy Song wrote:
    Thomas Koenig wrote:
    Woozy Song <suzyw0ng@outlook.com> schrieb:
    I came across some old NASA Fortran subroutines for inverting small
    matrices. Basically, no loops just long equations for each cell (and a
    determinant). So efficient for speed, not memory. Interestingly for 5x5
    matrix, there are extra lines like
       A11=A(1,1)
       A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25 copy
    operations are offset by faster access later using scalar instead of
    indexed array fetch?

    I very much doubt this would make a difference for modern optimizing
    compilers.

    Do these routines actually invert matrices?  This is rarely needed.
    What is the dimension of these matrices?


    dimensions 3x3 to 6x6. I have seen similar snippets elsewhere, but only
    for 3x3 and 4x4. I presume there are niche algorithms that do lots of
    small matrix inversions.

    So if it doesn't gain anything, I guess it was to make the code text
    less unwieldly replacing 6 characters with 3.

    It might have gain something in some historical context (and for a
    particular problem set).
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From Thomas Koenig@tkoenig@netcologne.de to comp.lang.fortran on Fri Apr 17 05:40:23 2026
    From Newsgroup: comp.lang.fortran

    Woozy Song <suzyw0ng@outlook.com> schrieb:
    Thomas Koenig wrote:
    Woozy Song <suzyw0ng@outlook.com> schrieb:
    I came across some old NASA Fortran subroutines for inverting small
    matrices. Basically, no loops just long equations for each cell (and a
    determinant). So efficient for speed, not memory. Interestingly for 5x5
    matrix, there are extra lines like
    A11=A(1,1)
    A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25 copy
    operations are offset by faster access later using scalar instead of
    indexed array fetch?

    I very much doubt this would make a difference for modern optimizing
    compilers.

    Do these routines actually invert matrices? This is rarely needed.
    What is the dimension of these matrices?


    dimensions 3x3 to 6x6. I have seen similar snippets elsewhere, but only
    for 3x3 and 4x4. I presume there are niche algorithms that do lots of
    small matrix inversions.

    So if it doesn't gain anything, I guess it was to make the code text
    less unwieldly replacing 6 characters with 3.

    This might have gained something in the grey mists of time, when
    dinosaurs roamed the computer centers. Compilers these days have
    progressed enormously, from ongoing development and from having
    much more computing power available, so much many more and more
    expensive passes can be run.
    --
    This USENET posting was made without artificial intelligence,
    artificial impertinence, artificial arrogance, artificial stupidity,
    artificial flavorings or artificial colorants.
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From R Daneel Olivaw@Danni@hyperspace.vogon.gov.invalid to comp.lang.fortran on Fri Apr 17 11:08:59 2026
    From Newsgroup: comp.lang.fortran

    Thomas Koenig wrote:
    Woozy Song <suzyw0ng@outlook.com> schrieb:
    I came across some old NASA Fortran subroutines for inverting small
    matrices. Basically, no loops just long equations for each cell (and a
    determinant). So efficient for speed, not memory. Interestingly for 5x5
    matrix, there are extra lines like
    A11=A(1,1)
    A12=A(1,2)
    then the scalar variables are used thereafter. So I presume the 25 copy
    operations are offset by faster access later using scalar instead of
    indexed array fetch?

    I very much doubt this would make a difference for modern optimizing compilers.

    Do these routines actually invert matrices? This is rarely needed.
    What is the dimension of these matrices?


    I can see a need for that if matrices were to be used with programs
    written in other languages.
    Just as a reminder,
    a (3,3) matrix would be stored in Fortran as 1,1 2,1 3,1 1,2 2,2
    3,2 1,3 2,3 3,3.
    in other languages it would be 1,1 1,2 1,3 2,1 2,2 2,3 3,1 3,2 3,3
    One of a couple of weird decisions made with the original language specs.
    --- Synchronet 3.21f-Linux NewsLink 1.2