MCPcopy Create free account
hub / github.com/apache/madlib / distAngle

Function distAngle

src/modules/linalg/metric.cpp:206–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206double
207distAngle(const MappedColumnVector& inX, const MappedColumnVector& inY) {
208 if (inX.size() != inY.size()) {
209 throw std::runtime_error("Found input arrays of "
210 "different lengths unexpectedly.");
211 }
212
213 // Deal with the undefined case where one of the norm is zero
214 // Angle is not defined. Just return \pi.
215 double xnorm = inX.norm(), ynorm = inY.norm();
216 if (xnorm < std::numeric_limits<double>::denorm_min()
217 || ynorm < std::numeric_limits<double>::denorm_min())
218 return std::acos(-1);
219
220 double cosine = dot(inX, inY) / (xnorm * ynorm);
221 if (cosine > 1)
222 cosine = 1;
223 else if (cosine < -1)
224 cosine = -1;
225 return std::acos(cosine);
226}
227
228double
229distTanimoto(const MappedColumnVector& inX, const MappedColumnVector& inY) {

Callers 1

runMethod · 0.85

Calls 2

dotFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected