Skip to content

added dot product distance#21

Open
morganprior wants to merge 1 commit intoURI-ABD:masterfrom
morganprior:feat-inner-product
Open

added dot product distance#21
morganprior wants to merge 1 commit intoURI-ABD:masterfrom
morganprior:feat-inner-product

Conversation

@morganprior
Copy link
Collaborator

  • Added dot product function
  • Added "dot_product_distance" function for creating a distance function based on the dot product (right now, this is just the reciprocal of the dot product)

N.B. Because we haven't reached a consensus about how to deal with distance in the case of 0 dot product and because we are likely to change this function, I just have dot_product_distance return the dot product in this case. It really should return something near infinity. I marked that the function isn't stable.

Also N.B., I was originally going to call the functions inner_product and inner_product_distance to be consistent with the language in the competition, but I changed the phrasing to dot product because the vectors are finite dimensional and real-valued, and so it is just a dot product. I thought it would be better to reserve the name inner_product for a more general class of inner_product functions (i.e., for anything that satisfies the four criteria for an inner product, even if it is not the same as the dot product).

Comment on lines +265 to +269
if dot_product < U::epsilon() {
dot_product
} else {
U::one() / dot_product
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot_product function already tests for a comparison with epsilon. The check here is unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants