package jsci.maths.vectors;
import jsci.GlobalSettings;
import jsci.maths.ExtraMath;
import jsci.maths.Mapping;
import jsci.maths.algebras.*;
import jsci.maths.fields.*;
import jsci.maths.groups.AbelianGroup;
/**
* The AbstractDoubleVector class encapsulates vectors containing doubles.
* @version 1.0
* @author Mark Hale
*/
public abstract class AbstractDoubleVector extends MathVector implements BanachSpace.Member {
protected AbstractDoubleVector(final int dim) {
super(dim);
}
/**
* Compares two double vectors for equality.
* Two vectors are considered to be equal if the norm of their difference is within the zero tolerance.
* @param obj a double vector
*/
public final boolean equals(Object obj) {
return equals(obj, GlobalSettings.ZERO_TOL);
}
public boolean equals(Object obj, double tol) {
if(obj != null && (obj instanceof AbstractDoubleVector)) {
final AbstractDoubleVector vec = (AbstractDoubleVector) obj;
return (this.dimension() == vec.dimension() && this.subtract(vec).norm() <= tol);
} else
return false;
}
/**
* Returns a comma delimited string representing the value of this vector.
*/
public String toString() {
final StringBuffer buf = new StringBuffer(8*N);
int i;
for(i=0; in-norm.
* @jsci.planetmath VectorPnorm
*/
public double norm(int n) {
double answer = Math.pow(Math.abs(getComponent(0)), n);
for(int i=1; i2-norm (magnitude).
* @jsci.planetmath VectorPnorm
*/
public double norm() {
double answer = getComponent(0);
for(int i=1; i
-norm.
* @author Taber Smith
* @jsci.planetmath VectorPnorm
*/
public double infNorm() {
double infNorm = Math.abs(getComponent(0));
for(int i=1; i infNorm)
infNorm = abs;
}
return infNorm;
}
/**
* Returns the mass (l1-norm).
*/
public double mass() {
double mass=0.0;
for(int i=1; i
Ads help maintain this website.