LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches. More...
#include <GaussianProcess.h>
Public Member Functions | |
KdTree (const KdTree &)=delete | |
KdTree & | operator= (const KdTree &)=delete |
KdTree (KdTree &&)=delete | |
KdTree & | operator= (KdTree &&)=delete |
KdTree ()=default | |
void | Initialize (ndarray::Array< T, 2, 2 > const &dt) |
Build a KD Tree to store the data for GaussianProcess. More... | |
void | findNeighbors (ndarray::Array< int, 1, 1 > neighdex, ndarray::Array< double, 1, 1 > dd, ndarray::Array< const T, 1, 1 > const &v, int n_nn) const |
Find the nearest neighbors of a point. More... | |
T | getData (int ipt, int idim) const |
Return one element of one node on the tree. More... | |
ndarray::Array< T, 1, 1 > | getData (int ipt) const |
Return an entire node from the tree. More... | |
void | addPoint (ndarray::Array< const T, 1, 1 > const &v) |
Add a point to the tree. More... | |
void | removePoint (int dex) |
Remove a point from the tree. More... | |
int | getNPoints () const |
return the number of data points stored in the tree More... | |
void | getTreeNode (ndarray::Array< int, 1, 1 > const &v, int dex) const |
Return the _tree information for a given data point. More... | |
The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches.
Note: I have removed the ability to arbitrarily specify a distance function. The KD Tree nearest neighbor search algorithm only makes sense in the case of Euclidean distances, so I have forced KdTree to use Euclidean distances.
Definition at line 224 of file GaussianProcess.h.
|
delete |
|
delete |
|
default |
void lsst::afw::math::KdTree< T >::addPoint | ( | ndarray::Array< const T, 1, 1 > const & | v | ) |
Add a point to the tree.
Allot more space in _tree and data if needed.
[in] | v | the point you are adding to the tree |
pex::exceptions::RuntimeError | if the branch ending in the new point is not properly constructed |
Definition at line 210 of file GaussianProcess.cc.
void lsst::afw::math::KdTree< T >::findNeighbors | ( | ndarray::Array< int, 1, 1 > | neighdex, |
ndarray::Array< double, 1, 1 > | dd, | ||
ndarray::Array< const T, 1, 1 > const & | v, | ||
int | n_nn | ||
) | const |
Find the nearest neighbors of a point.
[out] | neighdex | this is where the indices of the nearest neighbor points will be stored |
[out] | dd | this is where the distances to the nearest neighbors will be stored |
[in] | v | the point whose neighbors you want to find |
[in] | n_nn | the number of nearest neighbors you want to find |
neighbors will be returned in ascending order of distance
note that distance is forced to be the Euclidean distance
Definition at line 135 of file GaussianProcess.cc.
ndarray::Array< T, 1, 1 > lsst::afw::math::KdTree< T >::getData | ( | int | ipt | ) | const |
Return an entire node from the tree.
[in] | ipt | the index of the node to return |
I currently have this as a return-by-value method. When I tried it as a return-by-reference, the compiler gave me
warning: returning reference to local temporary object
Based on my reading of Stack Overflow, this is because ndarray was implicitly creating a new ndarray::Array<T,1,1> object and passing a reference thereto. It is unclear to me whether or not this object would be destroyed once the call to getData was complete.
The code still compiled, ran, and passed the unit tests, but the above behavior seemed to me like it could be dangerous (and, because ndarray was still creating a new object, it did not seem like we were saving any time), so I reverted to return-by-value.
Definition at line 200 of file GaussianProcess.cc.
T lsst::afw::math::KdTree< T >::getData | ( | int | ipt, |
int | idim | ||
) | const |
Return one element of one node on the tree.
[in] | ipt | the index of the node to return |
[in] | idim | the index of the dimension to return |
Definition at line 185 of file GaussianProcess.cc.
int lsst::afw::math::KdTree< T >::getNPoints |
return the number of data points stored in the tree
Definition at line 274 of file GaussianProcess.cc.
void lsst::afw::math::KdTree< T >::getTreeNode | ( | ndarray::Array< int, 1, 1 > const & | v, |
int | dex | ||
) | const |
Return the _tree information for a given data point.
[out] | v | the array in which to store the entry from _tree |
[in] | dex | the index of the node whose information you are requesting |
Definition at line 279 of file GaussianProcess.cc.
void lsst::afw::math::KdTree< T >::Initialize | ( | ndarray::Array< T, 2, 2 > const & | dt | ) |
Build a KD Tree to store the data for GaussianProcess.
[in] | dt | an array, the rows of which are the data points (dt[i][j] is the jth component of the ith data point) |
pex::exceptions::RuntimeError | if the tree is not properly constructed |
Definition at line 104 of file GaussianProcess.cc.
|
delete |
|
delete |
void lsst::afw::math::KdTree< T >::removePoint | ( | int | dex | ) |
Remove a point from the tree.
Reorganize what remains so that the tree remains self-consistent
[in] | dex | the index of the point you want to remove from the tree |
pex::exceptions::RuntimeError | if the entire tree is not poperly constructed after the point has been removed |
Definition at line 582 of file GaussianProcess.cc.