Code Monkey home page Code Monkey logo

Comments (13)

arrufat avatar arrufat commented on September 7, 2024 2

Maybe I can break it for you:

M:
1 2 3 
4 5 6 
7 8 9 

M has three rows:

  1. 1 2 3
  2. 4 5 6
  3. 7 8 9

In order to sum the rows, we have to add the first row to the second row and then to the third row.

That means adding
1+4+7, 2+5+8, 3+6+9

If you take the first row (1 2 3) and add the elements together, you are not adding the rows, you are adding the columns. If you write the loops to do that, you'll see that when you do the addition, the row index stays constant, and the column index changes: you are adding the columns.

from dlib.

davisking avatar davisking commented on September 7, 2024 1

This?

M:
1 2 3 
4 5 6 
7 8 9 

Sum of Rows:
12 15 18 

Sum of Cols:
 6 
15 
24 

That's the right output. sum_rows() adds all the row vectors together, which gives the result you have there from your program.

from dlib.

PhilippFeO avatar PhilippFeO commented on September 7, 2024 1

I am very glad how kind you respond to my issue! (I also made ..let's say, "other experiences".) I feel very sorry, that I flagged my issue directly as "Bug". I should have started a discussion or opened a normal issue.

from dlib.

davisking avatar davisking commented on September 7, 2024 1

Yeah, updated the docs. Can't rename the functions though, too much code and people are using the current names :D

from dlib.

arrufat avatar arrufat commented on September 7, 2024

After reading the documentation, it seems to me like it's working as intended.

from dlib.

PhilippFeO avatar PhilippFeO commented on September 7, 2024

I read

    const matrix_exp sum_rows (
        const matrix_exp& m
    );
    /*!
        requires
            - m.size() > 0
        ensures
            - returns a row matrix that contains the sum of all the rows in m. 
            - returns a matrix M such that
                - M::type == the same type that was in m
                - M.nr() == 1
                - M.nc() == m.nc()
                - for all valid i:
                    - M(i) == sum(colm(m,i)) 
    !*/

especially sum(colm(m, i)) as a sum over column i of matrix m, although the function is called sum_rows and the first sentence says that it "returns a row matrix that contains the sum of all the rows in m." I can't exclude mistakes on my side. I'm glad for clarification.

Source:

const matrix_exp sum_rows (

from dlib.

davisking avatar davisking commented on September 7, 2024

Yep, it's doing what it's supposed to do :)

from dlib.

PhilippFeO avatar PhilippFeO commented on September 7, 2024

Then I'm puzzled. When sum_rows() and sum_cols() work appropriately, am I reading the output of my example program incorrectly?

from dlib.

PhilippFeO avatar PhilippFeO commented on September 7, 2024

Although I closed the issue, I want to give some feedback—you can freely decide, what you will do with it!

For me "sum of all the rows" still sounds more like I thought in the first place (but I am obviously biased). Hence, the documentation, ie. sum(colm(m, i)), looked contradictory. I would advocate for a less ambiguous description. In case you agree, I can try my best and submit a PR.

from dlib.

davisking avatar davisking commented on September 7, 2024

No worries.

What if it said "sum of all the row vectors", that clearer?

from dlib.

PhilippFeO avatar PhilippFeO commented on September 7, 2024

Yes, definitely! 🚀

(In my opinion, sum_row_vectors() additionally as function name would be even better but I guess this is not feasible due to backwards compatibility, ie. deleting/changing the name sum_rows() is a big nono. 😄)

from dlib.

PhilippFeO avatar PhilippFeO commented on September 7, 2024

Nice!

... As mentioned, I can fully understand a renaming is out of scope.. but we all have hopes and wishes! :D

To conclude: Thank you for the nice conversation on my fake bug! :)

from dlib.

davisking avatar davisking commented on September 7, 2024

My pleasure :D

from dlib.

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.