package jsci.maths;

import jsci.maths.fields.Ring;
import jsci.maths.groups.AbelianGroup;

/**
* The Supernumber class encapsulates supernumbers.
* They are actually implemented as elements of the Grassmann algebra Lambda4
* rather than the full Lambdainfinity.
* @jsci.planetmath Supernumber
* @version 0.1
* @author Mark Hale
*/
public final class Supernumber implements Ring.Member {
        private final int N=4;
        private Complex body=Complex.ZERO;
        private Complex soul1[]={Complex.ZERO,Complex.ZERO,Complex.ZERO,Complex.ZERO};
        private Complex soul2[]={Complex.ZERO,Complex.ZERO,Complex.ZERO,Complex.ZERO,Complex.ZERO,Complex.ZERO};
        private Complex soul3[]={Complex.ZERO,Complex.ZERO,Complex.ZERO,Complex.ZERO};
        private Complex soul4=Complex.ZERO;
        /**
        * Constructs a supernumber.
        */
        public Supernumber() {}
        /**
        * Returns a string representing the value of this supernumber.
        */
        public String toString() {
                final StringBuffer buf=new StringBuffer(100);
                buf.append("(").append(body.toString()).append(")1+\n(");
                buf.append(soul1[0].toString()).append(", ");
                buf.append(soul1[1].toString()).append(", ");
                buf.append(soul1[2].toString()).append(", ");
                buf.append(soul1[3].toString()).append(")S1+\n(");
                buf.append(soul2[0].toString()).append(", ");
                buf.append(soul2[1].toString()).append(", ");
                buf.append(soul2[2].toString()).append(", ");
                buf.append(soul2[3].toString()).append(", ");
                buf.append(soul2[4].toString()).append(", ");
                buf.append(soul2[5].toString()).append(")S2+\n(");
                buf.append(soul3[0].toString()).append(", ");
                buf.append(soul3[1].toString()).append(", ");
                buf.append(soul3[2].toString()).append(", ");
                buf.append(soul3[3].toString()).append(")S3+\n(");
                buf.append(soul4.toString()).append(")S4");
                return buf.toString();
        }
        /**
        * Returns the body (rank 0) of this supernumber.
        */
        public Complex getBody() {
                return body;
        }
        /**
        * Sets the body (rank 0) of this supernumber.
        */
        public void setBody(final Complex b) {
                body=b;
        }
        /**
        * Returns the a-number soul (rank 1) of this supernumber.
        */
        public Complex getSoul1(final int i) {
                return soul1[i];
        }
        /**
        * Sets the a-number soul (rank 1) of this supernumber.
        */
        public void setSoul1(final int i,final Complex s) {
                soul1[i]=s;
        }
        /**
        * Returns the c-number soul (rank 2) of this supernumber.
        */
        public Complex getSoul2(final int i) {
                return soul2[i];
        }
        /**
        * Sets the c-number soul (rank 2) of this supernumber.
        */
        public void setSoul2(final int i,final Complex s) {
                soul2[i]=s;
        }
        /**
        * Returns the a-number soul (rank 3) of this supernumber.
        */
        public Complex getSoul3(final int i) {
                return soul3[i];
        }
        /**
        * Sets the a-number soul (rank 3) of this supernumber.
        */
        public void setSoul3(final int i,final Complex s) {
                soul3[i]=s;
        }
        /**
        * Returns the c-number soul (rank 4) of this supernumber.
        */
        public Complex getSoul4() {
                return soul4;
        }
        /**
        * Sets the c-number soul (rank 4) of this supernumber.
        */
        public void setSoul4(final Complex s) {
                soul4=s;
        }
        /**
        * Returns the dimension.
        */
        public int dimension() {
                return 1< 

Ads help maintain this website.