Speed up of removeDataFromArrays.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "Function2D.h"
|
#include "Function2D.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <mkl_cblas.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace Recon;
|
using namespace Recon;
|
||||||
@@ -11,36 +12,41 @@ using namespace Aurora;
|
|||||||
|
|
||||||
Aurora::Matrix Recon::removeDataFromArrays(const Aurora::Matrix& aOutPutMatrix, const Aurora::Matrix& aRemoveList)
|
Aurora::Matrix Recon::removeDataFromArrays(const Aurora::Matrix& aOutPutMatrix, const Aurora::Matrix& aRemoveList)
|
||||||
{
|
{
|
||||||
Matrix result = aOutPutMatrix;
|
size_t columnSize = sum(aRemoveList, FunctionDirection::All)[0];
|
||||||
int minusNum = 0;
|
size_t rowSize = aOutPutMatrix.getDimSize(0);
|
||||||
for(int i=0; i<aRemoveList.getDataSize(); ++i)
|
double* resultData = Aurora::malloc(columnSize * rowSize);
|
||||||
|
Matrix result = Matrix::New(resultData, rowSize, columnSize);
|
||||||
|
std::vector<std::pair<int,size_t>> copyList;
|
||||||
|
size_t length = 0;
|
||||||
|
int end = 0;
|
||||||
|
for(size_t i=0; i<aRemoveList.getDataSize(); ++i)
|
||||||
{
|
{
|
||||||
if(aRemoveList[i] == 0)
|
if(aRemoveList[i] == 1)
|
||||||
{
|
{
|
||||||
result = deleteColumn(result, i - minusNum);
|
end = i;
|
||||||
++minusNum;
|
++length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(aRemoveList[i] == 0 && length != 0)
|
||||||
|
{
|
||||||
|
copyList.push_back({end - length + 1, length});
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length != 0)
|
||||||
|
{
|
||||||
|
copyList.push_back({end - length + 1, length});
|
||||||
|
}
|
||||||
|
|
||||||
|
double* start = aOutPutMatrix.getData();
|
||||||
|
#pragma omp parallel for
|
||||||
|
for(size_t i=0; i<copyList.size(); ++i)
|
||||||
|
{
|
||||||
|
size_t copyLength = copyList[i].second * rowSize;
|
||||||
|
cblas_dcopy(copyLength, start + copyList[i].first * rowSize, 1, resultData, 1);
|
||||||
|
resultData += copyLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// size_t columnSize = sum(aRemoveList, FunctionDirection::All)[0];
|
|
||||||
// double* resultData = Aurora::malloc(columnSize * aOutPutMatrix.getDimSize(0));
|
|
||||||
// Matrix result = Matrix::New(resultData, aOutPutMatrix.getDimSize(0), columnSize);
|
|
||||||
// std::vector<std::pair<int,int>> copyList;
|
|
||||||
// size_t length = 0;
|
|
||||||
// for(size_t i=0; i<aRemoveList.getDataSize(); ++i)
|
|
||||||
// {
|
|
||||||
// if(aRemoveList[i] == 1)
|
|
||||||
// {
|
|
||||||
// ++length;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(aRemoveList[i] == 0 && length != 0)
|
|
||||||
// {
|
|
||||||
// copyList.push_back({});
|
|
||||||
// length = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user