Add meshgrid and unitTest.

This commit is contained in:
sunwen
2023-06-08 15:26:13 +08:00
parent 36d8866667
commit fe84729646
3 changed files with 75 additions and 0 deletions

27
src/common/meshgrid.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "meshgrid.h"
#include "Function1D.h"
#include "Matrix.h"
using namespace Aurora;
using namespace Recon;
MeshgridResult Recon::meshgrid(const Aurora::Matrix& aX, const Aurora::Matrix& aY, const Aurora::Matrix& aZ)
{
MeshgridResult result;
if(aX.isNull() || aY.isNull() || aZ.isNull())
{
return result;
}
size_t nx = aX.getDataSize();
size_t ny = aY.getDataSize();
size_t nz = aZ.getDataSize();
Matrix xx = reshape(aX, 1, nx, 1);
Matrix yy = reshape(aY, ny, 1, 1);
Matrix zz = reshape(aZ, 1, 1, nz);
result.xx = repmat(xx, ny, 1, nz);
result.yy = repmat(yy, 1, nx, nz);
result.zz = repmat3d(zz, ny, nx, 1);
return result;
}

18
src/common/meshgrid.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef MESHGRID_H
#define MESHGRID_H
#include "Matrix.h"
namespace Recon
{
struct MeshgridResult
{
Aurora::Matrix xx;
Aurora::Matrix yy;
Aurora::Matrix zz;
};
MeshgridResult meshgrid(const Aurora::Matrix& aX, const Aurora::Matrix& aY, const Aurora::Matrix& aZ);
}
#endif