Change compare shape logic

This commit is contained in:
Krad
2023-04-27 14:36:46 +08:00
parent 6d709f74e0
commit 50a668ba96

View File

@@ -292,18 +292,10 @@ namespace Aurora {
return ret; return ret;
} }
bool Matrix::compareShape(const Matrix &other) const { bool Matrix::compareShape(const Matrix &other) const {
if (mInfo.size() != other.mInfo.size()) { if (mInfo[2] == 1 && other.mInfo[2] == 1) {
// all vector compare length if (mInfo[0]==1 && other.mInfo[1] == 1 && mInfo[1] == other.mInfo[0]) return true;
if (mInfo.size() + other.mInfo.size() == 3){ if (mInfo[1]==1 && other.mInfo[0] == 1 && mInfo[0] == other.mInfo[1]) return true;
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;
} }
for (int i = 0; i < mInfo.size(); ++i) { for (int i = 0; i < mInfo.size(); ++i) {
if (mInfo[i] != other.mInfo[i]) return false; if (mInfo[i] != other.mInfo[i]) return false;