Add horzcat and horzcat's unittest.

This commit is contained in:
sunwen
2023-04-25 15:17:15 +08:00
parent 493b84e4d1
commit de1c1b0dda
3 changed files with 47 additions and 0 deletions

View File

@@ -488,3 +488,22 @@ Matrix Aurora::transpose(const Matrix& aMatrix)
return Matrix::New(resultData,col,row,1,aMatrix.getValueType());
}
Matrix Aurora::horzcat(const Matrix& aMatrix1, const Matrix& aMatrix2)
{
if(aMatrix1.isNull() || aMatrix2.isNull() || aMatrix1.getDims() !=2 || aMatrix2.getDims() !=2 ||
aMatrix1.getDimSize(0) != aMatrix2.getDimSize(0) || aMatrix1.getValueType() != aMatrix2.getValueType())
{
return Matrix();
}
int column1 = aMatrix1.getDimSize(1);
int column2 = aMatrix2.getDimSize(1);
int row = aMatrix1.getDimSize(0);
size_t size1= aMatrix1.getDataSize();
size_t size2= aMatrix2.getDataSize();
double* resultData = Aurora::malloc(size1 + size2,aMatrix1.getValueType());
cblas_dcopy(size1, aMatrix1.getData(), 1, resultData, 1);
cblas_dcopy(size2, aMatrix2.getData(), 1, resultData + size1, 1);
return Matrix::New(resultData, row, column1+column2, 1, aMatrix1.getValueType());
}

View File

@@ -68,6 +68,8 @@ namespace Aurora {
Matrix transpose(const Matrix& aMatrix);
Matrix horzcat(const Matrix& aMatrix1, const Matrix& aMatrix2);
/**
* 多项式计算
* @brief 例如p[1 0 1],x[3 2 5],代表对多项式 y = x^2 + 1 求(x=3, x=2, x=5)时所有的y