Add meshgrid and unitTest.
This commit is contained in:
27
src/common/meshgrid.cpp
Normal file
27
src/common/meshgrid.cpp
Normal 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
18
src/common/meshgrid.h
Normal 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
|
||||
Reference in New Issue
Block a user