@@ -1543,7 +1543,7 @@ class ivf_pq_index {
15431543 if (::num_vectors (lhs) != ::num_vectors (rhs) ||
15441544 ::dimensions (lhs) != ::dimensions(rhs)) {
15451545 std::cout << " num_vectors(lhs) != num_vectors(rhs) || dimensions(lhs) != "
1546- " dimensions(rhs)n "
1546+ " dimensions(rhs)"
15471547 << std::endl;
15481548 std::cout << " num_vectors(lhs): " << ::num_vectors (lhs)
15491549 << " num_vectors(rhs): " << ::num_vectors (rhs) << std::endl;
@@ -1578,13 +1578,32 @@ class ivf_pq_index {
15781578 * @return
15791579 */
15801580 template <feature_vector L, feature_vector R>
1581- auto compare_feature_vectors (const L& lhs, const R& rhs) const {
1581+ auto compare_feature_vectors (
1582+ const L& lhs, const R& rhs, const std::string& msg = " " ) const {
15821583 if (::dimensions (lhs) != ::dimensions (rhs)) {
1583- std::cout << " dimensions(lhs) != dimensions(rhs) (" << ::dimensions (lhs)
1584+ std::cout << " [ivf_pq_index@compare_feature_vectors] " << msg
1585+ << " dimensions(lhs) != dimensions(rhs) (" << ::dimensions (lhs)
15841586 << " != " << ::dimensions (rhs) << " )" << std::endl;
15851587 return false ;
15861588 }
1587- return std::equal (begin (lhs), end (lhs), begin (rhs));
1589+ auto equal = std::equal (begin (lhs), end (lhs), begin (rhs));
1590+ if (!equal) {
1591+ std::cout << " [ivf_pq_index@compare_feature_vectors] " << msg
1592+ << " failed the equality check." << std::endl;
1593+ auto printed = 0 ;
1594+ for (size_t i = 0 ; i < ::dimensions (lhs); ++i) {
1595+ if (lhs[i] != rhs[i]) {
1596+ std::cout << " lhs[" << i << " ]: " << lhs[i] << " - rhs[" << i
1597+ << " ]: " << rhs[i] << std::endl;
1598+ printed++;
1599+ }
1600+ if (printed > 50 ) {
1601+ std::cout << " ..." << std::endl;
1602+ break ;
1603+ }
1604+ }
1605+ }
1606+ return equal;
15881607 }
15891608
15901609 auto compare_cluster_centroids (const ivf_pq_index& rhs) const {
@@ -1611,7 +1630,8 @@ class ivf_pq_index {
16111630 }
16121631 return compare_feature_vectors (
16131632 partitioned_pq_vectors_->indices (),
1614- rhs.partitioned_pq_vectors_ ->indices ());
1633+ rhs.partitioned_pq_vectors_ ->indices (),
1634+ " partitioned_pq_vectors_->indices()" );
16151635 }
16161636
16171637 auto compare_ivf_ids (const ivf_pq_index& rhs) const {
@@ -1622,7 +1642,9 @@ class ivf_pq_index {
16221642 return false ;
16231643 }
16241644 return compare_feature_vectors (
1625- partitioned_pq_vectors_->ids (), rhs.partitioned_pq_vectors_ ->ids ());
1645+ partitioned_pq_vectors_->ids (),
1646+ rhs.partitioned_pq_vectors_ ->ids (),
1647+ " partitioned_pq_vectors_->ids()" );
16261648 }
16271649
16281650 auto compare_pq_ivf_vectors (const ivf_pq_index& rhs) const {
0 commit comments