From 50a668ba968146dfe11e4d9ac566956f02fad72f Mon Sep 17 00:00:00 2001 From: Krad Date: Thu, 27 Apr 2023 14:36:46 +0800 Subject: [PATCH] Change compare shape logic --- src/Matrix.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index 86726e4..1377513 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -292,18 +292,10 @@ namespace Aurora { return ret; } - bool Matrix::compareShape(const Matrix &other) const { - if (mInfo.size() != other.mInfo.size()) { - // all vector compare length - if (mInfo.size() + other.mInfo.size() == 3){ - return getDataSize()== other.getDataSize(); - } - // 2 and 3 - else if (mInfo.size() + other.mInfo.size() == 5){ - return (mInfo.size()==3&& mInfo[2]==1)|| (other.mInfo.size()==3&& other.mInfo[2]==1); - } - return false; + if (mInfo[2] == 1 && other.mInfo[2] == 1) { + if (mInfo[0]==1 && other.mInfo[1] == 1 && mInfo[1] == other.mInfo[0]) return true; + if (mInfo[1]==1 && other.mInfo[0] == 1 && mInfo[0] == other.mInfo[1]) return true; } for (int i = 0; i < mInfo.size(); ++i) { if (mInfo[i] != other.mInfo[i]) return false;