From 429f944eebba388fe2da591af3243c03b13e5e91 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Thu, 17 Jan 2013 17:02:09 -0500 Subject: [PATCH] .mat column-major order bug fix --- sdk/plugins/format.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/plugins/format.cpp b/sdk/plugins/format.cpp index de4c88c..c33c6a5 100644 --- a/sdk/plugins/format.cpp +++ b/sdk/plugins/format.cpp @@ -38,7 +38,7 @@ namespace br * \author Josh Klonyz \cite jklontz * First 4 bytes indicate the number of rows. * Second 4 bytes indicate the number of columns. - * The rest of the bytes are 32-bit floating data elements. + * The rest of the bytes are 32-bit floating data elements in row-major order. */ class binFormat : public Format { @@ -318,8 +318,11 @@ class matFormat : public Format } } - if ((rows > 0) && (columns > 0) && (matrixType != 0) && !matrixData.isEmpty()) - t.append(Mat(rows, columns, matrixType, matrixData.data()).clone()); + if ((rows > 0) && (columns > 0) && (matrixType != 0) && !matrixData.isEmpty()) { + Mat transposed; + transpose(Mat(rows, columns, matrixType, matrixData.data()), transposed); + t.append(transposed); + } } } @@ -404,9 +407,11 @@ class matFormat : public Format } quint32 bytes = m.elemSize() * m.rows * m.cols; QByteArray buffer((8 - bytes%8)%8, 0); + Mat transposed; + transpose(m, transposed); substream.writeRawData((const char*)&type, 4); substream.writeRawData((const char*)&bytes, 4); - substream.writeRawData((const char*)m.data, bytes); + substream.writeRawData((const char*)transposed.data, bytes); substream.writeRawData(buffer.data(), buffer.size()); } -- libgit2 0.21.4