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