Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?
Forum Updated to NodeBB v4.3 + New Features

QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by opengpu
    #1

    why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?

    JKSHJ 1 Reply Last reply
    0
    • O Offline
      O Offline
      opengpu
      wrote on last edited by
      #2

      QGenericMatrix?
      can i use like this QGenericMatrix<VARIANT>
      VARIANT is from msdn

      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu
        wrote on last edited by
        #3

        actually, i just want to map the content(which are all number) into an abstract layer.
        so i want to use QGenericMatrix which also has row and column, and can get numer-data by row&coloumn.
        is there better way?
        now i want to store the real VARIANT, and not store the QString which is convert from the number-data

        1 Reply Last reply
        0
        • O opengpu

          why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @opengpu said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

          why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?

          QMatrix is obsolete. Don't use it.

          Use QGenericMatrix. It is a template class, like the Boost matrix.

          @opengpu said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

          now i want to store the real VARIANT

          Why not just store a number? (Like int32_t)

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          O 1 Reply Last reply
          3
          • JKSHJ JKSH

            @opengpu said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

            why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?

            QMatrix is obsolete. Don't use it.

            Use QGenericMatrix. It is a template class, like the Boost matrix.

            @opengpu said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

            now i want to store the real VARIANT

            Why not just store a number? (Like int32_t)

            O Offline
            O Offline
            opengpu
            wrote on last edited by
            #5

            @JKSH said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

            VARIANT

            other than Qt type is not adivised to use?

            jsulmJ 1 Reply Last reply
            0
            • O opengpu

              @JKSH said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

              VARIANT

              other than Qt type is not adivised to use?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @opengpu Can you explain what you want to do? Why do you want to store a variant in a QGenericMatrix? What is the use case?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              O 1 Reply Last reply
              0
              • jsulmJ jsulm

                @opengpu Can you explain what you want to do? Why do you want to store a variant in a QGenericMatrix? What is the use case?

                O Offline
                O Offline
                opengpu
                wrote on last edited by
                #7

                @jsulm VARIANT is the data i get from 3rdParty

                jsulmJ 1 Reply Last reply
                0
                • O opengpu

                  @jsulm VARIANT is the data i get from 3rdParty

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @opengpu But what is it? A struct/class? A number? Or something like QVariant?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  O 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @opengpu But what is it? A struct/class? A number? Or something like QVariant?

                    O Offline
                    O Offline
                    opengpu
                    wrote on last edited by opengpu
                    #9

                    @jsulm
                    https://docs.microsoft.com/en-us/windows/desktop/winauto/variant-structure

                    jsulmJ 1 Reply Last reply
                    0
                    • O opengpu

                      @jsulm
                      https://docs.microsoft.com/en-us/windows/desktop/winauto/variant-structure

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @opengpu Why do you want to put VARIANT in a matrix? Do you want to do matrix based calculations? Maybe a two dimensional QVector would be enough?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      O 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @opengpu Why do you want to put VARIANT in a matrix? Do you want to do matrix based calculations? Maybe a two dimensional QVector would be enough?

                        O Offline
                        O Offline
                        opengpu
                        wrote on last edited by
                        #11

                        @jsulm said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                        dimensional QVector

                        dimensional QVector?
                        yes, i just want to get the Var besed on row&column

                        jsulmJ JKSHJ 2 Replies Last reply
                        0
                        • O opengpu

                          @jsulm said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                          dimensional QVector

                          dimensional QVector?
                          yes, i just want to get the Var besed on row&column

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by jsulm
                          #12

                          @opengpu

                          QVector<QVector<VARIANT>> _2dArray;
                          

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          2
                          • O opengpu

                            @jsulm said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                            dimensional QVector

                            dimensional QVector?
                            yes, i just want to get the Var besed on row&column

                            JKSHJ Offline
                            JKSHJ Offline
                            JKSH
                            Moderators
                            wrote on last edited by
                            #13

                            @opengpu said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                            yes, i just want to get the Var besed on row&column

                            I agree with @jsulm -- you should use QVector<QVector<T>>.

                            QGenericMatrix and the old QMatrix are designed to be used as transformation matrices: https://en.wikipedia.org/wiki/Transformation_matrix. They are not designed to hold row+column data.

                            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                            1 Reply Last reply
                            2
                            • O Offline
                              O Offline
                              opengpu
                              wrote on last edited by
                              #14

                              @jsulm said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                              QVector<QVector<VARIANT>> _2dArray;

                              _2dArray[iRow][iCol] = 1.0f; //this is ok
                              but how should i set the presice size of _2dArray?
                              _2dArray.resize(rowCount * colCount); //this is not correct, right?

                              jsulmJ 1 Reply Last reply
                              0
                              • O opengpu

                                @jsulm said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                                QVector<QVector<VARIANT>> _2dArray;

                                _2dArray[iRow][iCol] = 1.0f; //this is ok
                                but how should i set the presice size of _2dArray?
                                _2dArray.resize(rowCount * colCount); //this is not correct, right?

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @opengpu said in QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?:

                                _2dArray.resize(rowCount * colCount); //this is not correct, right?

                                No, it isn't

                                _2dArray.resize(rowCount);
                                // And now for each row
                                _2dArray[row].resize(colCount);
                                

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                1
                                • O Offline
                                  O Offline
                                  opengpu
                                  wrote on last edited by opengpu
                                  #16
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • O Offline
                                    O Offline
                                    opengpu
                                    wrote on last edited by
                                    #17

                                    this is right

                                    _2dArray.resize(rowCount);
                                    for (int i = 0; i <_2dArray.size(); ++i)
                                    {
                                    _2dArray[i].resize(colCount);
                                    }

                                    1 Reply Last reply
                                    0
                                    • VRoninV Offline
                                      VRoninV Offline
                                      VRonin
                                      wrote on last edited by
                                      #18

                                      If you need a 2d container for type T with fixed dimensions and having all rows with the same number of columns you should use boost::multi_array<T,2>.
                                      QVector<QVector<T>> is fine but it's more flexible than you need and hence less efficient. I would stick with the good old boost:

                                      boost::multi_array<VARIANT,2> _2dArray(boost::extents[rowCount][colCount]);

                                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                      ~Napoleon Bonaparte

                                      On a crusade to banish setIndexWidget() from the holy land of Qt

                                      1 Reply Last reply
                                      2

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved