Search code examples
c++qtmatrix-multiplication

Initializing QGenericMatrix


I need a matrix for matrix multiplication for neural networks and since I use the Qt Framework which provides QGenericMatrix I thought I give it a try. But I have no idea how to initialize the matrix with data.

It got this constructor but I am not able to use it right.

QGenericMatrix::QGenericMatrix(const T * values)

So it would help if someone could give me an example initialization for e.g.

    QGenericMatrix<2,2,int> a();

If I search for QGenericMatrix I hardly find anything except the official class definition, so I was wondering if QGenericMatrix is a good choice at all?


Solution

  • It is simple to pass values directly to the constructor:

    int values[] = {
        1, 2,
        3, 4
    };
    
    QGenericMatrix<2,2,int> matrix(values);