From 16b48e0a6db6dc6c9d64d62aea31fc9865e8ddd4 Mon Sep 17 00:00:00 2001 From: sunwen Date: Fri, 21 Apr 2023 13:46:35 +0800 Subject: [PATCH] Fix Matrix mInfo to column and slice with default value 1. --- src/Matrix.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index 2e5661b..f6b054b 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -212,10 +212,15 @@ namespace Aurora{ namespace Aurora { Matrix::Matrix(std::shared_ptr aData, std::vector aInfo, ValueType aValueType) - : mData(aData) + : mValueType(aValueType) + , mData(aData) , mInfo(aInfo) - , mValueType(aValueType) { + size_t infoSize = aInfo.size(); + for(;infoSize<3;++infoSize) + { + aInfo.push_back(1); + } } Matrix::Matrix(const Matrix::MatrixSlice& slice) { @@ -230,7 +235,15 @@ namespace Aurora { } int Matrix::getDims() const { - return mInfo.size(); + if(mInfo[2] > 1) + { + return 3; + } + if(mInfo[1] > 1) + { + return 2; + } + return 1; } double *Matrix::getData() const { @@ -405,8 +418,8 @@ namespace Aurora { void Matrix::printf() { - int k_count = getDimSize(2)==0?1:getDimSize(2); - int j_count = getDimSize(1)==0?1:getDimSize(1); + int k_count = getDimSize(2); + int j_count = getDimSize(1); int complexstep = 1; const char* mark = "+"; if(mValueType == Complex)