Add deleteColumn function.

This commit is contained in:
sunwen
2023-05-24 16:34:51 +08:00
parent e0aebc7922
commit eddc4f57c0
2 changed files with 30 additions and 0 deletions

View File

@@ -790,6 +790,34 @@ Matrix Aurora::xcorr(const Matrix& aMatrix1, const Matrix& aMatrix2)
return Matrix::New(resultData,resultSize);
}
Matrix Aurora::deleteColumn(const Matrix& aMatrix, int aColumnIndex)
{
int rows = aMatrix.getDimSize(0);
int columns = aMatrix.getDimSize(1);
if (aColumnIndex < 0 || aColumnIndex >= columns)
{
return aMatrix;
}
double* resultData = Aurora::malloc(rows* (columns-1));
if(aColumnIndex == 0)
{
cblas_dcopy(rows* (columns-1), aMatrix.getData() + rows, 1, resultData, 1);
}
else if(aColumnIndex == (columns - 1))
{
cblas_dcopy(rows* (columns-1), aMatrix.getData(), 1, resultData, 1);
}
else
{
cblas_dcopy(rows * aColumnIndex, aMatrix.getData(), 1, resultData, 1);
cblas_dcopy(rows * (columns - aColumnIndex - 1), aMatrix.getData() + rows * (aColumnIndex + 1), 1, resultData + rows * aColumnIndex, 1);
}
return Matrix::New(resultData, rows, columns-1);
}
Matrix Aurora::reshape(const Matrix& aMatrix, int aRows, int aColumns, int aSlices)
{
if(aMatrix.isNull() || (aMatrix.getDataSize() != aRows * aColumns * aSlices))

View File

@@ -86,6 +86,8 @@ namespace Aurora {
Matrix reshape(const Matrix& aMatrix, int aRows, int aColumns, int aSlices);
Matrix xcorr(const Matrix& aMatrix1, const Matrix& aMatrix2);
Matrix deleteColumn(const Matrix& aMatrix, int aColumnIndex);
/**
* 并集
* @param aIa, [C,ia,~] = intersect(A,B)用法中ia的返回值