Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
Add algorithm for detecting resolution / bin sidelength
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcslws committed Jan 22, 2019
1 parent 0e15d3f commit 9cba270
Show file tree
Hide file tree
Showing 3 changed files with 482 additions and 108 deletions.
48 changes: 48 additions & 0 deletions src/nupic/bindings/experimental.i
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,54 @@ using namespace nupic;
}
}


%pythoncode %{
def computeBinSidelength(domainToPlaneByModule, phaseResolution,
resultPrecision, upperBound=1000.0):
domainToPlaneByModule = numpy.asarray(domainToPlaneByModule, dtype="float64")

return _computeBinSidelength(
domainToPlaneByModule, phaseResolution, resultPrecision, upperBound)
%}

%inline {
PyObject* _computeBinSidelength(PyObject* py_domainToPlaneByModule,
Real64 readoutResolution,
Real64 resultPrecision,
Real64 upperBound)
{
PyArrayObject* pyArr_domainToPlaneByModule =
(PyArrayObject*)py_domainToPlaneByModule;
NTA_CHECK(PyArray_NDIM(pyArr_domainToPlaneByModule) == 3);
npy_intp* npy_dims = PyArray_DIMS(pyArr_domainToPlaneByModule);

std::vector<std::vector<std::vector<Real64>>> domainToPlaneByModule;
for (size_t i = 0; i < npy_dims[0]; i++)
{
std::vector<std::vector<Real64>> module;
for (size_t j = 0; j < npy_dims[1]; j++)
{
std::vector<Real64> row;
for (size_t k = 0; k < npy_dims[2]; k++)
{
row.push_back(*(Real64*)PyArray_GETPTR3(pyArr_domainToPlaneByModule,
i, j, k));
}
module.push_back(row);
}
domainToPlaneByModule.push_back(module);
}

Real64 result =
nupic::experimental::grid_uniqueness::computeBinSidelength(
domainToPlaneByModule, readoutResolution, resultPrecision,
upperBound);

return PyFloat_FromDouble(result);
}
}


#endif NTA_OS_WINDOWS

//--------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 9cba270

Please sign in to comment.