summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-06-20 12:06:11 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-06-24 16:51:37 -0400
commitdf90b9eaa16a52d076658ffc2fd1f65f12d1a622 (patch)
treeb88d150bcadcab3cfbde893cb2accb7d93a48a52 /sc
parent57538e5f5002ecc2df95087244cb0431867c443e (diff)
Add Dump() method to ScMatrix, which is useful when debugging.
Change-Id: I45e6c28b58a03782814ef1089b49a52b873573a6
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/scmatrix.hxx6
-rw-r--r--sc/source/core/tool/scmatrix.cxx52
2 files changed, 58 insertions, 0 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index c91b0ca8bdb9..6ba2b7f53e62 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -28,6 +28,8 @@
#include <boost/intrusive_ptr.hpp>
+#define DEBUG_MATRIX 1
+
class ScInterpreter;
class SvNumberFormatter;
class ScMatrixImpl;
@@ -349,6 +351,10 @@ public:
// All other matrix functions MatMult, MInv, ... are in ScInterpreter
// to be numerically safe.
+
+#if DEBUG_MATRIX
+ void Dump() const;
+#endif
};
inline void intrusive_ptr_add_ref(const ScMatrix* p)
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9b2c634d959d..010f8dcc5a8c 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -37,6 +37,12 @@
#include <mdds/multi_type_vector_types.hpp>
#include <mdds/multi_type_vector_trait.hpp>
+#if DEBUG_MATRIX
+#include <iostream>
+using std::cout;
+using std::endl;
+#endif
+
using ::std::pair;
using ::std::for_each;
using ::std::count_if;
@@ -216,6 +222,10 @@ public:
ScMatrix::IterateResult Product(bool bTextAsZero) const;
size_t Count(bool bCountStrings) const;
+#if DEBUG_MATRIX
+ void Dump() const;
+#endif
+
private:
void CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const;
};
@@ -957,6 +967,41 @@ size_t ScMatrixImpl::Count(bool bCountStrings) const
return aFunc.getCount();
}
+#if DEBUG_MATRIX
+void ScMatrixImpl::Dump() const
+{
+ cout << "-- matrix content" << endl;
+ SCSIZE nCols, nRows;
+ GetDimensions(nCols, nRows);
+ for (SCSIZE nRow = 0; nRow < nRows; ++nRow)
+ {
+ for (SCSIZE nCol = 0; nCol < nCols; ++nCol)
+ {
+ cout << " row=" << nRow << ", col=" << nCol << " : ";
+ switch (maMat.get_type(nRow, nCol))
+ {
+ case mdds::mtm::element_string:
+ cout << "string (" << maMat.get_string(nRow, nCol) << ")";
+ break;
+ case mdds::mtm::element_numeric:
+ cout << "numeric (" << maMat.get_numeric(nRow, nCol) << ")";
+ break;
+ case mdds::mtm::element_boolean:
+ cout << "boolean (" << maMat.get_boolean(nRow, nCol) << ")";
+ break;
+ case mdds::mtm::element_empty:
+ cout << "empty";
+ break;
+ default:
+ ;
+ }
+
+ cout << endl;
+ }
+ }
+}
+#endif
+
void ScMatrixImpl::CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const
{
SCSIZE nRowSize = maMat.size().row;
@@ -1264,4 +1309,11 @@ size_t ScMatrix::Count(bool bCountStrings) const
return pImpl->Count(bCountStrings);
}
+#if DEBUG_MATRIX
+void ScMatrix::Dump() const
+{
+ pImpl->Dump();
+}
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */