Comments (2)
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.
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)
- Identity() HOT 3
- User Code Extensions HOT 3
- Undefined behavior on operator[] overload prevents use in constexpr context HOT 3
- Fix semantics of operator overloads on matrices. HOT 4
- Finish documentation for `v3` branch. HOT 1
- Impossible to create row vectors HOT 5
- Question about column order. HOT 1
- Doesn't build on MSVC 2017 HOT 3
- Future usability wishlist HOT 4
- `mul()` gives wrong answer? HOT 1
- Feature request: Disable operator * for matrices? HOT 2
- Initializing a std::array of vecs HOT 3
- glm::lookAt equivalent? HOT 10
- `using namespace linalg::ostream_overloads` sometimes does not work. HOT 1
- Suggestion: projection_onto() and rejection_from() functions for vectors HOT 1
- Convert a mat4 to a mat3 and back
- Compilation with clang fails on OS X (error: ambiguous call to std::abs()) HOT 1
- rotation_quat fails in some cases HOT 8
- avoid GCC -Wshadow warnings? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linalg.