package jsci.maths.vectors;
import jsci.maths.ExtraMath;
import jsci.maths.Mapping;
import jsci.maths.MathDouble;
import jsci.maths.MathInteger;
import jsci.maths.algebras.Module;
import jsci.maths.algebras.VectorSpace;
import jsci.maths.fields.Field;
import jsci.maths.fields.Ring;
import jsci.maths.groups.AbelianGroup;
/**
* An array-based implementation of a double vector.
* @version 2.1
* @author Mark Hale
*/
public class DoubleVector extends AbstractDoubleVector {
/**
* Array containing the components of the vector.
*/
protected double vector[];
/**
* Constructs an empty vector.
* @param dim the dimension of the vector.
*/
public DoubleVector(final int dim) {
super(dim);
vector=new double[dim];
}
/**
* Constructs a vector by wrapping an array.
* @param array an assigned value.
*/
public DoubleVector(final double array[]) {
super(array.length);
vector=array;
}
/**
* Compares two double vectors for equality.
* @param a a double vector.
*/
public boolean equals(Object a, double tol) {
if(a!=null && (a instanceof AbstractDoubleVector) && N==((AbstractDoubleVector)a).N) {
final AbstractDoubleVector dv=(AbstractDoubleVector)a;
double sumSqr = 0.0;
for(int i=0; i=0 && n=0 && nn-norm.
* @jsci.planetmath VectorPnorm
*/
public double norm(int n) {
double answer=Math.pow(Math.abs(vector[0]), n);
for(int i=1; i2-norm (magnitude).
* @jsci.planetmath VectorPnorm
*/
public double norm() {
double answer=vector[0];
for(int i=1;i
-norm.
* @author Taber Smith
* @jsci.planetmath VectorPnorm
*/
public double infNorm() {
double infNorm = Math.abs(vector[0]);
for(int i=1; i infNorm)
infNorm = abs;
}
return infNorm;
}
//============
// OPERATIONS
//============
/**
* Returns the negative of this vector.
*/
public AbelianGroup.Member negate() {
final double array[]=new double[N];
array[0]=-vector[0];
for(int i=1;i
Ads help maintain this website.