• Re: Vector sum

    From minforth@21:1/5 to All on Sat Jul 19 13:53:20 2025
    Am 19.07.2025 um 12:18 schrieb Anton Ertl:

    One way to deal with all that would be to have a long-vector stack and
    have something like my vector wordset
    <https://github.com/AntonErtl/vectors>, where the sum of a vector
    would be a word that is implemented in some lower-level way (e.g.,
    assembly language); the sum of a vector is actually a planned, but not
    yet existing feature of this wordset.


    Not wanting to sound negative, but who in practice adds up long
    vectors, apart from testing compilers and fp-arithmetic?

    Dot products, on the other hand, are fundamental for many linear
    algebra algorithms, eg. matrix multiplication and AI.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to minforth on Sat Jul 19 14:51:00 2025
    minforth <minforth@gmx.net> writes:
    Am 19.07.2025 um 12:18 schrieb Anton Ertl:

    One way to deal with all that would be to have a long-vector stack and
    have something like my vector wordset
    <https://github.com/AntonErtl/vectors>, where the sum of a vector
    would be a word that is implemented in some lower-level way (e.g.,
    assembly language); the sum of a vector is actually a planned, but not
    yet existing feature of this wordset.


    Not wanting to sound negative, but who in practice adds up long
    vectors, apart from testing compilers and fp-arithmetic?

    Everyone who does dot-products.

    Dot products, on the other hand, are fundamental for many linear
    algebra algorithms, eg. matrix multiplication and AI.

    If I add a vector-sum word

    df+red ( dfv -- r )
    \ r is the sum of the elements of dfv

    to the vector wordset, then the dot-product is:

    : dot-product ( dfv1 dfv2 -- r )
    df*v df+red ;

    Concerning matrix multiplication, while you can use the dot-product
    for it, there are many other ways to do it, and some are more
    efficient (although, admittedly, I have not used pairwise addition for
    these ways).

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2025 CFP: http://www.euroforth.org/ef25/cfp.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Sun Jul 20 06:27:53 2025
    Am 19.07.2025 um 16:51 schrieb Anton Ertl:
    minforth <minforth@gmx.net> writes:
    Am 19.07.2025 um 12:18 schrieb Anton Ertl:

    One way to deal with all that would be to have a long-vector stack and
    have something like my vector wordset
    <https://github.com/AntonErtl/vectors>, where the sum of a vector
    would be a word that is implemented in some lower-level way (e.g.,
    assembly language); the sum of a vector is actually a planned, but not
    yet existing feature of this wordset.


    Not wanting to sound negative, but who in practice adds up long
    vectors, apart from testing compilers and fp-arithmetic?

    Everyone who does dot-products.

    Dot products, on the other hand, are fundamental for many linear
    algebra algorithms, eg. matrix multiplication and AI.

    If I add a vector-sum word

    df+red ( dfv -- r )
    \ r is the sum of the elements of dfv

    to the vector wordset, then the dot-product is:

    : dot-product ( dfv1 dfv2 -- r )
    df*v df+red ;

    Sure, slow hand is not just for guitar players.
    With FMA, one could traverse the vectors in one go.

    https://docs.nvidia.com/cuda/floating-point/index.html

    Concerning matrix multiplication, while you can use the dot-product
    for it, there are many other ways to do it, and some are more
    efficient (although, admittedly, I have not used pairwise addition for
    these ways).

    There are tons of algorithms depending on various matrix properties.

    Then, given a desktop and a fat CPU, LAPACK et al. are your friends.
    Embedded or special CPU .. is a different story.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)