Code Monkey home page Code Monkey logo

Comments (2)

sgorsten avatar sgorsten commented on September 26, 2024 3

Extending the fold functions over matrices shouldn't be too hard.

argmax() is a trickier case. I've painted myself into a bit of a consistency corner. maxelem(a) is defined as a[argmax(a)] for vectors, there's a nice symmetry between argmax returning an int and operator[] taking an int. argmax on a matrix COULD return the index of the "greatest" column, as linalg::vec does model LessThanComparable, but this seems a little nonsensical and not very useful. A matrix is semantically quite a bit different from a sequence of vectors.

argmax could return the index of the greatest element as though the matrix were a flat array in column major order. I do define a few other operations on matrices (comparison ops, etc.) as though they were a flat sequence of numbers, but I don't have any sort of function for "flat indexing" into a linalg::mat.

I suppose argmax could return an int2, and I could add an overload of operator[] which accepts an int2. The only remaining question is whether mat[{x,y}] should be equal to mat[x][y] (less confusing) or mat[y][x] which would match the sort of "row,column" subscripting you see in math textbooks.

I'll do the fold functions right away, and I welcome your input on what would be most logical for something like argmax.

from linalg.

sgorsten avatar sgorsten commented on September 26, 2024 1

I'm going to close this issue for now, as the obvious improvements were made and there was no further input on the argmax semantics.

from linalg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.