LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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. | |
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. | |
T | getData (int ipt, int idim) const |
Return one element of one node on the tree. | |
ndarray::Array< T, 1, 1 > | getData (int ipt) const |
Return an entire node from the tree. | |
void | addPoint (ndarray::Array< const T, 1, 1 > const &v) |
Add a point to the tree. | |
void | removePoint (int dex) |
Remove a point from the tree. | |
int | getNPoints () const |
return the number of data points stored in the tree | |
void | getTreeNode (ndarray::Array< int, 1, 1 > const &v, int dex) const |
Return the _tree information for a given data point. | |
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 | ( | ) | const |
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.