[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[IMP-dev] Remove Vector3D::get_component()
- To: "IMP developers' list" <imp-dev@salilab.org>
- Subject: [IMP-dev] Remove Vector3D::get_component()
- From: Ben Webb <ben@salilab.org>
- Date: Mon, 17 Mar 2008 13:10:31 -0700
The attached patch removes Vector3D::get_component(). We don't need it
any more, since we have operator[] now which does the same thing.
Ben
--
ben@salilab.org http://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
- Sir Arthur Conan Doyle
Index: kernel/include/IMP/internal/Grid3D.h
===================================================================
--- kernel/include/IMP/internal/Grid3D.h (revision 476)
+++ kernel/include/IMP/internal/Grid3D.h (working copy)
@@ -197,14 +197,14 @@
int index[3];
for (unsigned int i=0; i< 3; ++i ) {
IMP_assert(d_[i] != 0, "Invalid grid in Index");
- float d= pt.get_component(i)- min_.get_component(i);
+ float d = pt[i] - min_[i];
float fi= d/edge_size_[i];
index[i]= static_cast<int>(std::floor(fi));
IMP_assert(std::abs(index[i]) < 200000000,
"Something is probably wrong " << d
- << " " << pt.get_component(i)
- << " " << min_.get_component(i)
+ << " " << pt[i]
+ << " " << min_[i]
<< " " << edge_size_[i]);
}
return IndexType(index[0], index[1], index[2]);
@@ -264,13 +264,10 @@
// I would like to find something more reliable
if (d_[i]==1) {
// make sure that the total grid size is not vanishing
- // this is probably not hte right thing to do
- edge_size_[i]= std::max(1.05*(max.get_component(i)
- - min_.get_component(i))/d_[i],
- 1.0);
+ // this is probably not the right thing to do
+ edge_size_[i]= std::max(1.05*(max[i] - min_[i])/d_[i], 1.0);
} else {
- edge_size_[i]= 1.05*(max.get_component(i)
- - min_.get_component(i))/d_[i];
+ edge_size_[i]= 1.05*(max[i] - min_[i])/d_[i];
}
}
}
@@ -286,11 +283,9 @@
VoxelData def) {
min_=minc;
for (unsigned int i=0; i< 3; ++i ) {
- IMP_assert(minc.get_component(i) <= maxc.get_component(i),
- "Min must not be larger than max");
+ IMP_assert(minc[i] <= maxc[i], "Min must not be larger than max");
// add 10% to handle rounding errors
- d_[i]= std::max(static_cast<int>(std::ceil(1.1*(maxc.get_component(i)
- - minc.get_component(i))
+ d_[i]= std::max(static_cast<int>(std::ceil(1.1*(maxc[i] - minc[i])
/ side)),
1);
edge_size_[i]= side;
@@ -364,9 +359,9 @@
//! Return a point at the center of the voxel
Vector3D get_center(VirtualIndex gi) const {
- return Vector3D(edge_size_[0]*(.5f+ gi[0]) + min_.get_component(0),
- edge_size_[1]*(.5f+ gi[1]) + min_.get_component(1),
- edge_size_[2]*(.5f+ gi[2]) + min_.get_component(2));
+ return Vector3D(edge_size_[0]*(.5f+ gi[0]) + min_[0],
+ edge_size_[1]*(.5f+ gi[1]) + min_[1],
+ edge_size_[2]*(.5f+ gi[2]) + min_[2]);
}
Index: kernel/include/IMP/Vector3D.h
===================================================================
--- kernel/include/IMP/Vector3D.h (revision 476)
+++ kernel/include/IMP/Vector3D.h (working copy)
@@ -33,16 +33,11 @@
Vector3D() {}
//! \return A single component of this vector (0-2).
- Float get_component(unsigned int i) const {
+ Float operator[](unsigned int i) const {
IMP_assert(i < 3, "Invalid component of vector requested");
return vec_[i];
}
- //! \return A single component of this vector (0-2).
- Float operator[](unsigned int i) const {
- return get_component(i);
- }
-
//! \return the scalar product of two vectors.
/** \param[in] vec2 The other vector to use in the product.
*/
Index: kernel/src/singleton_scores/DistanceToSingletonScore.cpp
===================================================================
--- kernel/src/singleton_scores/DistanceToSingletonScore.cpp (revision 476)
+++ kernel/src/singleton_scores/DistanceToSingletonScore.cpp (working copy)
@@ -36,7 +36,7 @@
return 0;
}
for (int i = 0; i < 3; ++i) {
- delta[i] = v.get_component(i) - d1.get_coordinate(i);
+ delta[i] = v[i] - d1.get_coordinate(i);
d2 += square(delta[i]);
}
Index: kernel/src/restraints/DihedralRestraint.cpp
===================================================================
--- kernel/src/restraints/DihedralRestraint.cpp (revision 476)
+++ kernel/src/restraints/DihedralRestraint.cpp (working copy)
@@ -98,8 +98,8 @@
Float fact3 = skjkl2 > 1e-8 ? -skj / skjkl2 : 0.0;
for (int i = 0; i < 3; ++i) {
- Float derv0 = deriv * fact0 * vijkj.get_component(i);
- Float derv3 = deriv * fact3 * vkjkl.get_component(i);
+ Float derv0 = deriv * fact0 * vijkj[i];
+ Float derv3 = deriv * fact3 * vkjkl[i];
Float derv1 = (fact1 - 1.0) * derv0 - fact2 * derv3;
Float derv2 = (fact2 - 1.0) * derv3 - fact1 * derv0;
Index: kernel/src/triplet_scores/AngleTripletScore.cpp
===================================================================
--- kernel/src/triplet_scores/AngleTripletScore.cpp (revision 476)
+++ kernel/src/triplet_scores/AngleTripletScore.cpp (working copy)
@@ -60,10 +60,8 @@
fact_kj = std::max(static_cast<float>(1e-12), fact_kj);
for (int i = 0; i < 3; ++i) {
- Float derv0 = deriv * (rij.get_component(i) * cosangle
- - rkj.get_component(i)) / fact_ij;
- Float derv2 = deriv * (rkj.get_component(i) * cosangle
- - rij.get_component(i)) / fact_kj;
+ Float derv0 = deriv * (rij[i] * cosangle - rkj[i]) / fact_ij;
+ Float derv2 = deriv * (rkj[i] * cosangle - rij[i]) / fact_kj;
d0.add_to_coordinate_derivative(i, derv0, *da);
d1.add_to_coordinate_derivative(i, -derv0 - derv2, *da);
d2.add_to_coordinate_derivative(i, derv2, *da);