Add deleteColumn and createCudaVectorMatrix.
This commit is contained in:
@@ -1433,3 +1433,50 @@ CudaMatrix Aurora::xcorr(const CudaMatrix& aMatrix1, const CudaMatrix& aMatrix2)
|
||||
|
||||
return CudaMatrix::fromRawData(data, size);
|
||||
}
|
||||
|
||||
CudaMatrix Aurora::deleteColumn(const CudaMatrix& aMatrix, int aColumnIndex)
|
||||
{
|
||||
int rows = aMatrix.getDimSize(0);
|
||||
int columns = aMatrix.getDimSize(1);
|
||||
if (aColumnIndex < 0 || aColumnIndex >= columns)
|
||||
{
|
||||
return aMatrix;
|
||||
}
|
||||
|
||||
float* resultData = nullptr;
|
||||
cudaMalloc((void**)&resultData, sizeof(float) * rows* (columns-1));
|
||||
if(aColumnIndex == 0)
|
||||
{
|
||||
cudaMemcpy(resultData, aMatrix.getData() + rows, sizeof(float) * rows* (columns-1), cudaMemcpyDeviceToDevice);
|
||||
}
|
||||
else if(aColumnIndex == (columns - 1))
|
||||
{
|
||||
cblas_scopy(rows* (columns-1), aMatrix.getData(), 1, resultData, 1);
|
||||
cudaMemcpy(resultData, aMatrix.getData(), sizeof(float) * rows* (columns-1), cudaMemcpyDeviceToDevice);
|
||||
}
|
||||
else
|
||||
{
|
||||
cudaMemcpy(resultData, aMatrix.getData(), sizeof(float) * rows * aColumnIndex, cudaMemcpyDeviceToDevice);
|
||||
cudaMemcpy(resultData + rows * aColumnIndex, aMatrix.getData() + rows * (aColumnIndex + 1), sizeof(float) * rows * (columns - aColumnIndex - 1), cudaMemcpyDeviceToDevice);
|
||||
}
|
||||
|
||||
return CudaMatrix::fromRawData(resultData, rows, columns-1);
|
||||
}
|
||||
|
||||
CudaMatrix Aurora::createCudaVectorMatrix(float aStartValue, float aStepValue, float aEndValue)
|
||||
{
|
||||
std::vector<float> matrixData;
|
||||
float tempValue = aStartValue;
|
||||
matrixData.push_back(tempValue);
|
||||
long long compare1 = std::round(aEndValue * 10e13);
|
||||
long long compare2 = std::round(tempValue * 10e13);
|
||||
while(std::round(tempValue* 10e13) <= compare1)
|
||||
{
|
||||
tempValue += aStepValue;
|
||||
matrixData.push_back(tempValue);
|
||||
compare2 = std::round(tempValue * 10e14);
|
||||
}
|
||||
matrixData.pop_back();
|
||||
|
||||
return Matrix::copyFromRawData(matrixData.data(), 1, matrixData.size()).toDeviceMatrix();
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ namespace Aurora
|
||||
CudaMatrix reshape(const CudaMatrix& aMatrix, int aRows, int aColumns, int aSlices);
|
||||
|
||||
CudaMatrix xcorr(const CudaMatrix& aMatrix1, const CudaMatrix& aMatrix2);
|
||||
|
||||
CudaMatrix deleteColumn(const CudaMatrix& aMatrix, int aColumnIndex);
|
||||
|
||||
CudaMatrix createCudaVectorMatrix(float aStartValue, float aStepValue, float aEndValue);
|
||||
|
||||
/**
|
||||
* 将所有nan值设置为特定值
|
||||
|
||||
Reference in New Issue
Block a user