All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JSci.maths.vectors.IntegerVector Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci.maths.vectors;

import JSci.maths.ExtraMath;
import JSci.maths.MathInteger;
import JSci.maths.groups.AbelianGroup;
import JSci.maths.algebras.Module;
import JSci.maths.algebras.VectorSpace;
import JSci.maths.fields.Ring;
import JSci.maths.algebras.Module;

/**
* 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;iinfinity-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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy