package jsci.maths.vectors;

import jsci.maths.ExtraMath;
import jsci.maths.algebras.Module;
import jsci.maths.fields.Ring;
import jsci.maths.groups.AbelianGroup;

/**
* The AbstractIntegerVector class encapsulates vectors containing integers.
* @version 1.0
* @author Mark Hale
*/
public abstract class AbstractIntegerVector extends MathVector {
        protected AbstractIntegerVector(final int dim) {
                super(dim);
        }
        /**
        * Compares two integer vectors for equality.
        * Two vectors are considered to be equal if the norm of their difference is zero.
        * @param obj an integer vector
        */
        public boolean equals(Object obj) {
                if(obj != null && (obj instanceof AbstractIntegerVector)) {
                        final AbstractIntegerVector vec = (AbstractIntegerVector) obj;
                        return (this.dimension() == vec.dimension() && this.subtract(vec).norm() == 0.0);
                } 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.
        */
        public double norm(final int n) {
                double answer = Math.pow(Math.abs(getComponent(0)), n);
                for(int i=1; i2-norm (magnitude).
        */
        public double norm() {
                double answer = getComponent(0);
                for(int i=1; iinfinity-norm.
        * @author Taber Smith
        */
        public double infNorm() {
                int infNorm = Math.abs(getComponent(0));
                for(int i=1; i infNorm)
                                infNorm = abs;
                }
                return infNorm;
        }

//============
// OPERATIONS
//============

        /**
        * Returns the addition of this vector and another.
        * @param v an integer vector
        * @exception VectorDimensionException If the vectors are different sizes.
        */
        public abstract AbstractIntegerVector add(AbstractIntegerVector v);
        /**
        * Returns the subtraction of this vector by another.
        * @param v an integer vector
        * @exception VectorDimensionException If the vectors are different sizes.
        */
        public abstract AbstractIntegerVector subtract(AbstractIntegerVector v);
        /**
        * Returns the multiplication of this vector by a scalar.
        * @param x an integer
        */
        public abstract AbstractIntegerVector scalarMultiply(int x);
        /**
        * Returns the scalar product of this vector and another.
        * @param v an integer vector
        * @exception VectorDimensionException If the vectors are different sizes.
        */
        public abstract int scalarProduct(AbstractIntegerVector v);
}


 

Ads help maintain this website.