Add transpose and transpose's unittest.

This commit is contained in:
sunwen
2023-04-25 14:21:52 +08:00
parent a6b2474dd1
commit 8d75783db6
3 changed files with 62 additions and 0 deletions

View File

@@ -462,3 +462,29 @@ double Aurora::norm(const Matrix& aMatrix, NormMethod aNormMethod)
return 0;
}
Matrix Aurora::transpose(const Matrix& aMatrix)
{
//not surpport for 3 dims.
if(aMatrix.isNull() || aMatrix.getDimSize(2) > 1)
{
return Matrix();
}
size_t size = aMatrix.getDataSize();
int row = aMatrix.getDimSize(0);
int col = aMatrix.getDimSize(1);
double* resultData;
double* data = aMatrix.getData();
if(aMatrix.isComplex())
{
resultData = Aurora::malloc(size, true);
mkl_zomatcopy('C', 'T',row ,col, 1.0, (MKL_Complex16*)data, row, (MKL_Complex16*)resultData, col);
}
else
{
resultData = Aurora::malloc(size);
mkl_domatcopy('C', 'T',row ,col, 1.0, data, row, resultData, col);
}
return Matrix::New(resultData,col,row,1,aMatrix.getValueType());
}