Add calculateMinimalMaximalTransducerPositions to
Transmission reconstruction.
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
#include "reconstruction.h"
|
||||||
|
#include "Function.h"
|
||||||
|
#include "Function1D.h"
|
||||||
|
#include "Function2D.h"
|
||||||
|
#include "Matrix.h"
|
||||||
|
using namespace Aurora;
|
||||||
|
namespace Recon {
|
||||||
|
Aurora::Matrix calculateMinimalMaximalTransducerPositions(
|
||||||
|
const Aurora::Matrix &aMSenderList, const Aurora::Matrix &aMReceiverList) {
|
||||||
|
|
||||||
|
auto minEmitter = min(aMSenderList, Row);
|
||||||
|
auto maxEmitter = max(aMSenderList, Row);
|
||||||
|
|
||||||
|
auto minReceiver = min(aMReceiverList, Row);
|
||||||
|
auto maxReceiver = max(aMReceiverList, Row);
|
||||||
|
|
||||||
|
auto data1 = Aurora::malloc(minEmitter.getDataSize() * 2);
|
||||||
|
auto data2 = Aurora::malloc(minEmitter.getDataSize() * 2);
|
||||||
|
|
||||||
|
auto minM = Matrix::New(data1,minEmitter.getDimSize(0),2);
|
||||||
|
auto maxM = Matrix::New(data2,minEmitter.getDimSize(0),2);
|
||||||
|
minM($,0) = minEmitter;
|
||||||
|
minM($,1) = minReceiver;
|
||||||
|
maxM($,0) = maxEmitter;
|
||||||
|
maxM($,1) = maxReceiver;
|
||||||
|
minM = min(minM,Row);
|
||||||
|
maxM = max(maxM,Row);
|
||||||
|
auto data3 = Aurora::malloc(minM.getDataSize() * 2);
|
||||||
|
auto ddims = Matrix::New(data3,minM.getDimSize(0),2);
|
||||||
|
ddims($,0) = minM;
|
||||||
|
ddims($,1) = maxM;
|
||||||
|
ddims.forceReshape(1, ddims.getDataSize(), 1);
|
||||||
|
return ddims;
|
||||||
|
}
|
||||||
|
} // namespace Recon
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _TRANS_RECONSTRUCTION_H__
|
||||||
|
#define _TRANS_RECONSTRUCTION_H__
|
||||||
|
#include "Matrix.h"
|
||||||
|
namespace Recon {
|
||||||
|
Aurora::Matrix calculateMinimalMaximalTransducerPositions(
|
||||||
|
const Aurora::Matrix &aMSenderList, const Aurora::Matrix &aMReceiverList);
|
||||||
|
}
|
||||||
|
#endif // __RECONSTRUCTION_H__
|
||||||
47
test/Reconstruction_Test.cpp
Normal file
47
test/Reconstruction_Test.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include "Function1D.h"
|
||||||
|
#include "MatlabReader.h"
|
||||||
|
#include "Matrix.h"
|
||||||
|
#include "transmissionReconstruction/reconstruction/reconstruction.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline double fourDecimalRound(double src){
|
||||||
|
return round(src*10000.0)/10000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EXPECT_DOUBLE_AE(valueA,valueB)\
|
||||||
|
EXPECT_DOUBLE_EQ(fourDecimalRound(valueA),fourDecimalRound(valueB))
|
||||||
|
|
||||||
|
class Reconstruction_Test : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
static void SetUpReconstructionTester() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestCase() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(Reconstruction_Test, calculateMinimalMaximalTransducerPositions) {
|
||||||
|
auto senderList = Aurora::Matrix::fromRawData(new double[6]{1, 2, 3, 1, 2, 4}, 3, 2);
|
||||||
|
auto receiverList = Aurora::Matrix::fromRawData(new double[6]{1, 8, 3, 1, 2, 1}, 3, 2);
|
||||||
|
auto result = Recon::calculateMinimalMaximalTransducerPositions(senderList,receiverList);
|
||||||
|
EXPECT_DOUBLE_EQ(1.0,result.getData()[0]);
|
||||||
|
EXPECT_DOUBLE_EQ(2,result.getData()[1]);
|
||||||
|
EXPECT_DOUBLE_EQ(1.0,result.getData()[2]);
|
||||||
|
EXPECT_DOUBLE_EQ(1.0,result.getData()[3]);
|
||||||
|
EXPECT_DOUBLE_EQ(8,result.getData()[4]);
|
||||||
|
EXPECT_DOUBLE_EQ(4,result.getData()[5]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user