Skip to content

Commit

Permalink
Change input arrays to const&
Browse files Browse the repository at this point in the history
  • Loading branch information
morriscb committed Nov 5, 2021
1 parent 33ebbdd commit 7f637bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions include/lsst/meas/astrom/pessimisticPatternMatcherUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ namespace astrom {
* @return ID of the candidate reference object successfully matched or -1 if
* no match is found.
*/
int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<double, 1, 1> ref_ctr,
uint16_t ref_ctr_id, ndarray::Array<double, 1, 1> proj_ref_ctr_delta,
double proj_ref_ctr_dist_sq, ndarray::Array<long int, 1, 1> ref_dist_idx_array,
ndarray::Array<uint16_t, 1, 1> ref_id_array, ndarray::Array<double, 2, 1> reference_array,
double src_sin_tol);
int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<double, 1, 1> const& ref_ctr,
uint16_t ref_ctr_id, ndarray::Array<double, 1, 1> const& proj_ref_ctr_delta,
double proj_ref_ctr_dist_sq, ndarray::Array<long int, 1, 1> const& ref_dist_idx_array,
ndarray::Array<uint16_t, 1, 1> const& ref_id_array,
ndarray::Array<double, 2, 1> const& reference_array, double src_sin_tol);

} // namespace astrom
} // namespace meas
Expand Down
46 changes: 23 additions & 23 deletions src/pessimisticPatternMatcherUtils.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- LSST-C++ -*-
/// -*- LSST-C++ -*-

/*
* This file is part of meas_astrom.
*
* Developed for the LSST Data Management System.
* This product includes software developed by the LSST Project
* (https://www.lsst.org).
* (https:///www.lsst.org).
* See the COPYRIGHT file at the top-level directory of this distribution
* for details of code ownership.
*
Expand All @@ -20,7 +20,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <https:///www.gnu.org/licenses/>.
*/

#include <cmath>
Expand All @@ -31,14 +31,14 @@ namespace lsst {
namespace meas {
namespace astrom {

int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<double, 1, 1> ref_ctr,
uint16_t ref_ctr_id, ndarray::Array<double, 1, 1> proj_ref_ctr_delta, double proj_ref_ctr_dist_sq,
ndarray::Array<long int, 1, 1> ref_dist_idx_array,
ndarray::Array<uint16_t, 1, 1> ref_id_array, ndarray::Array<double, 2, 1> reference_array,
double src_sin_tol) {
// Loop over our candidate reference objects.
int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<double, 1, 1> const& ref_ctr,
uint16_t ref_ctr_id, ndarray::Array<double, 1, 1> const& proj_ref_ctr_delta,
double proj_ref_ctr_dist_sq, ndarray::Array<long int, 1, 1> const& ref_dist_idx_array,
ndarray::Array<uint16_t, 1, 1> const& ref_id_array,
ndarray::Array<double, 2, 1> const& reference_array, double src_sin_tol) {
/// Loop over our candidate reference objects.
for (auto idx = ref_dist_idx_array.begin(); idx != ref_dist_idx_array.end(); idx++) {
// Compute the delta vector from the pattern center.
/// Compute the delta vector from the pattern center.
unsigned int ref_id = ref_id_array[*idx];
double ref_delta[3];
double proj_ref_delta[3];
Expand All @@ -50,8 +50,8 @@ int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<doubl
proj_ref_delta[0] = ref_delta[0] - ref_dot * ref_ctr[0];
proj_ref_delta[1] = ref_delta[1] - ref_dot * ref_ctr[1];
proj_ref_delta[2] = ref_delta[2] - ref_dot * ref_ctr[2];
// Compute the cos between our "center" reference vector and the
// current reference candidate.
/// Compute the cos between our "center" reference vector and the
/// current reference candidate.
double proj_delta_dist_sq =
(proj_ref_delta[0] * proj_ref_delta[0] + proj_ref_delta[1] * proj_ref_delta[1] +
proj_ref_delta[2] * proj_ref_delta[2]);
Expand All @@ -61,8 +61,8 @@ int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<doubl
proj_ref_delta[2] * proj_ref_ctr_delta[2]) /
geom_dist_ref;

// Make sure we can safely make the comparison in case
// our "center" and candidate vectors are mostly aligned.
/// Make sure we can safely make the comparison in case
/// our "center" and candidate vectors are mostly aligned.
double cos_sq_comparison;
if (cos_theta_ref * cos_theta_ref < (1 - src_sin_tol * src_sin_tol)) {
cos_sq_comparison = (cos_theta_src - cos_theta_ref) * (cos_theta_src - cos_theta_ref) /
Expand All @@ -71,15 +71,15 @@ int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<doubl
cos_sq_comparison = (cos_theta_src - cos_theta_ref) * (cos_theta_src - cos_theta_ref) /
(src_sin_tol * src_sin_tol);
}
// Test the difference of the cosine of the reference angle against
// the source angle. Assumes that the delta between the two is
// small.
/// Test the difference of the cosine of the reference angle against
/// the source angle. Assumes that the delta between the two is
/// small.
if (cos_sq_comparison > src_sin_tol * src_sin_tol) {
continue;
}
// The cosine tests the magnitude of the angle but not
// its direction. To do that we need to know the sine as well.
// This cross product calculation does that.
/// The cosine tests the magnitude of the angle but not
/// its direction. To do that we need to know the sine as well.
/// This cross product calculation does that.
double cross_ref[3];
cross_ref[0] =
(proj_ref_delta[1] * proj_ref_ctr_delta[2] - proj_ref_delta[2] * proj_ref_ctr_delta[1]) /
Expand All @@ -92,8 +92,8 @@ int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<doubl
geom_dist_ref;
double sin_theta_ref =
cross_ref[0] * ref_ctr[0] + cross_ref[1] * ref_ctr[1] + cross_ref[2] * ref_ctr[2];
// Check the value of the cos again to make sure that it is not
// near zero.
/// Check the value of the cos again to make sure that it is not
/// near zero.
double sin_comparison;
if (abs(cos_theta_src) < src_sin_tol) {
sin_comparison = (sin_theta_src - sin_theta_ref) / src_sin_tol;
Expand All @@ -104,7 +104,7 @@ int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<doubl
if (abs(sin_comparison) > src_sin_tol) {
continue;
}
// Return the correct id of the candidate we found.
/// Return the correct id of the candidate we found.
return ref_id;
}
return -1;
Expand Down

0 comments on commit 7f637bc

Please sign in to comment.