| Code with Finding: |
class ArrayFieldVector {
/** Find the orthogonal projection of this vector onto another vector.
* @param v vector onto which {@code this} must be projected
* @return projection of {@code this} onto {@code v}
* @throws DimensionMismatchException if {@code v} is not the same size as
* {@code this}
* @throws MathArithmeticException if {@code v} is the null vector.
*/
public ArrayFieldVector<T> projection(ArrayFieldVector<T> v)
throws DimensionMismatchException, MathArithmeticException {
return (ArrayFieldVector<T>) v.mapMultiply(dotProduct(v).divide(v.dotProduct(v)));
}
}
|