org.apache.commons.math3.geometry.Vector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cf4j-recsys Show documentation
Show all versions of cf4j-recsys Show documentation
A Java's Collaborative Filtering library to carry out experiments in research of Collaborative Filtering based Recommender Systems. The library has been designed from researchers to researchers.
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math3.geometry;
import java.text.NumberFormat;
import org.apache.commons.math3.exception.MathArithmeticException;
/** This interface represents a generic vector in a vectorial space or a point in an affine space.
* @param Type of the space.
* @see Space
* @see Point
* @since 3.0
*/
public interface Vector extends Point {
/** Get the null vector of the vectorial space or origin point of the affine space.
* @return null vector of the vectorial space or origin point of the affine space
*/
Vector getZero();
/** Get the L1 norm for the vector.
* @return L1 norm for the vector
*/
double getNorm1();
/** Get the L2 norm for the vector.
* @return Euclidean norm for the vector
*/
double getNorm();
/** Get the square of the norm for the vector.
* @return square of the Euclidean norm for the vector
*/
double getNormSq();
/** Get the L∞ norm for the vector.
* @return L∞ norm for the vector
*/
double getNormInf();
/** Add a vector to the instance.
* @param v vector to add
* @return a new vector
*/
Vector add(Vector v);
/** Add a scaled vector to the instance.
* @param factor scale factor to apply to v before adding it
* @param v vector to add
* @return a new vector
*/
Vector add(double factor, Vector v);
/** Subtract a vector from the instance.
* @param v vector to subtract
* @return a new vector
*/
Vector subtract(Vector v);
/** Subtract a scaled vector from the instance.
* @param factor scale factor to apply to v before subtracting it
* @param v vector to subtract
* @return a new vector
*/
Vector subtract(double factor, Vector v);
/** Get the opposite of the instance.
* @return a new vector which is opposite to the instance
*/
Vector negate();
/** Get a normalized vector aligned with the instance.
* @return a new normalized vector
* @exception MathArithmeticException if the norm is zero
*/
Vector normalize() throws MathArithmeticException;
/** Multiply the instance by a scalar.
* @param a scalar
* @return a new vector
*/
Vector scalarMultiply(double a);
/**
* Returns true if any coordinate of this vector is infinite and none are NaN;
* false otherwise
* @return true if any coordinate of this vector is infinite and none are NaN;
* false otherwise
*/
boolean isInfinite();
/** Compute the distance between the instance and another vector according to the L1 norm.
* Calling this method is equivalent to calling:
* q.subtract(p).getNorm1()
except that no intermediate
* vector is built
* @param v second vector
* @return the distance between the instance and p according to the L1 norm
*/
double distance1(Vector v);
/** Compute the distance between the instance and another vector according to the L2 norm.
* Calling this method is equivalent to calling:
* q.subtract(p).getNorm()
except that no intermediate
* vector is built
* @param v second vector
* @return the distance between the instance and p according to the L2 norm
*/
double distance(Vector v);
/** Compute the distance between the instance and another vector according to the L∞ norm.
* Calling this method is equivalent to calling:
* q.subtract(p).getNormInf()
except that no intermediate
* vector is built
* @param v second vector
* @return the distance between the instance and p according to the L∞ norm
*/
double distanceInf(Vector v);
/** Compute the square of the distance between the instance and another vector.
* Calling this method is equivalent to calling:
* q.subtract(p).getNormSq()
except that no intermediate
* vector is built
* @param v second vector
* @return the square of the distance between the instance and p
*/
double distanceSq(Vector v);
/** Compute the dot-product of the instance and another vector.
* @param v second vector
* @return the dot product this.v
*/
double dotProduct(Vector v);
/** Get a string representation of this vector.
* @param format the custom format for components
* @return a string representation of this vector
*/
String toString(final NumberFormat format);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy