QGenericMatrix? why not QMatrix a template? is there anything like boost::numeric::ublas::matrix<AAA>?
-
QGenericMatrix?
can i use like this QGenericMatrix<VARIANT>
VARIANT is from msdn -
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 -
@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
) -
@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 oldQMatrix
are designed to be used as transformation matrices: https://en.wikipedia.org/wiki/Transformation_matrix. They are not designed to hold row+column data. -
@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? -
@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);
-
If you need a 2d container for type
T
with fixed dimensions and having all rows with the same number of columns you should useboost::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]);