LSST Applications g063fba187b+eddd1b24d7,g0f08755f38+4a855ab515,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+062a45aee3,g1dcb35cd9c+45d3fa5522,g20f6ffc8e0+4a855ab515,g217e2c1bcf+f55e51b560,g28da252d5a+7d8e536cc7,g2bbee38e9b+2d92fc7d83,g2bc492864f+2d92fc7d83,g3156d2b45e+6e55a43351,g32e5bea42b+625186cc6b,g347aa1857d+2d92fc7d83,g35bb328faa+a8ce1bb630,g3a166c0a6a+2d92fc7d83,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+1af189bab1,g7af13505b9+7b6a50a2f8,g80478fca09+6174b7f182,g82479be7b0+5b71efbaf0,g858d7b2824+4a855ab515,g9125e01d80+a8ce1bb630,ga5288a1d22+61618a97c4,gb58c049af0+d64f4d3760,gc28159a63d+2d92fc7d83,gc5452a3dca+f4add4ffd5,gcab2d0539d+d9f5af7f69,gcf0d15dbbd+6c7e0a19ec,gda6a2b7d83+6c7e0a19ec,gdaeeff99f8+1711a396fd,ge79ae78c31+2d92fc7d83,gef2f8181fd+55fff6f525,gf0baf85859+c1f95f4921,gfa517265be+4a855ab515,gfa999e8aa5+17cd334064,w.2024.51
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.