Java API By Example, From Geeks To Geeks.

# Java > Open Source Codes > JSci > maths > vectors > IntegerVector

 `1 package JSci.maths.vectors;2 3 import JSci.maths.ExtraMath;4 import JSci.maths.MathInteger;5 import JSci.maths.groups.AbelianGroup;6 import JSci.maths.algebras.Module;7 import JSci.maths.algebras.VectorSpace;8 import JSci.maths.fields.Ring;9 import JSci.maths.algebras.Module;10 11 /**12 * An array-based implementation of an integer vector.13 * @version 2.114 * @author Mark Hale15 */16 public class IntegerVector extends AbstractIntegerVector {17         /**18         * Array containing the components of the vector.19         */20         protected int vector[];21         /**22         * Constructs an empty vector.23         * @param dim the dimension of the vector.24         */25         public IntegerVector(final int dim) {26                 super(dim);27                 vector=new int[dim];28         }29         /**30         * Constructs a vector by wrapping an array.31         * @param array an assigned value32         */33         public IntegerVector(final int array[]) {34                 super(array.length);35                 vector=array;36         }37         /**38         * Compares two integer vectors for equality.39         * @param a an integer vector40         */41         public boolean equals(Object a) {42                 if(a!=null && (a instanceof AbstractIntegerVector) && N==((AbstractIntegerVector)a).N) {43                         final AbstractIntegerVector iv=(AbstractIntegerVector)a;44                         int sumSqr = 0;45                         for(int i=0; i=0 && n=0 && nn-norm.111         */112         public double norm(final int n) {113                 double answer=Math.pow(Math.abs(vector[0]),n);114                 for(int i=1;i2-norm (magnitude).120         */121         public double norm() {122                 double answer=vector[0];123                 for(int i=1;i-norm.129         * @author Taber Smith130         */131         public double infNorm() {132                 int infNorm=Math.abs(vector[0]);133                 for(int i=1;iinfNorm)136                                 infNorm=abs;137                 }138                 return infNorm;139         }140 141 //============142 // OPERATIONS143 //============144 145         /**146         * Returns the negative of this vector.147         */148         public AbelianGroup.Member negate() {149                 final int array[]=new int[N];150                 array[0]=-vector[0];151                 for(int i=1;i