Add convertToLinearIndices to common

This commit is contained in:
kradchen
2023-05-10 10:39:40 +08:00
parent 04608db7e0
commit aff5106a37
3 changed files with 57 additions and 2 deletions

View File

@@ -52,4 +52,32 @@ namespace Recon
// Data2 = ifft(Data2, [], 1);
return Aurora::Matrix();
}
}
Aurora::Matrix convertToLinearIndices(Aurora::Matrix aVMatrixSize, Aurora::Matrix aMCoordinates)
{
if (aVMatrixSize.getDataSize() != aMCoordinates.getDimSize(1)){
std::cerr<<"convertToLinearIndices fail, Dimension of coordinates and matrix do not fit."<<std::endl;
return Aurora::Matrix();
}
size_t columns = aMCoordinates.getDimSize(1);
auto coord_col1= aMCoordinates(Aurora::$,0).toMatrix();
auto coord_col2Sub1= aMCoordinates(Aurora::$,1).toMatrix()-1;
auto matrixSize_1 = aVMatrixSize.getData()[0];
switch (columns) {
case 3:
{
auto matrixSize_2 = aVMatrixSize.getData()[1];
auto coord_col3Sub1= aMCoordinates(Aurora::$,2).toMatrix()-1;
return coord_col1 + coord_col2Sub1 * matrixSize_1 + coord_col3Sub1 * matrixSize_1 * matrixSize_2;
}
case 2:
{
return coord_col1 + coord_col2Sub1 * matrixSize_1;
}
default:
std::cerr<<"convertToLinearIndices fail,NotImplemented, Converting into linear indices only implemented for 2D and 3D matrices."<<std::endl;
return Aurora::Matrix();
}
}
}

View File

@@ -12,6 +12,6 @@ namespace Recon {
*/
Aurora::Matrix reconstructBandpasssubsampling(Aurora::Matrix aMatrix, double aAScanReconstructionFreq, double SampleRate);
Aurora::Matrix convertToLinearIndices(Aurora::Matrix aVMatrixSize, Aurora::Matrix aMCoordinates);
}
#endif //RECON_COMMON_H