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

jscl.math.numeric.NumericMatrix Maven / Gradle / Ivy

The newest version!
package jscl.math.numeric;

import jscl.util.ArrayComparator;

public class NumericMatrix extends Numeric {
    protected final Numeric element[][];
    protected final int n,p;

    public NumericMatrix(Numeric element[][]) {
        this.element=element;
        n=element.length;
        p=element.length>0?element[0].length:0;
    }

    public Numeric[][] elements() {
        return element;
    }

    public NumericMatrix add(NumericMatrix matrix) {
        NumericMatrix m=(NumericMatrix)newinstance();
        for(int i=0;i0) return 1;
            }
        }
        return 0;
    }

    public Numeric valueof(Numeric numeric) {
        if(numeric instanceof NumericMatrix || numeric instanceof NumericVector) {
            throw new ArithmeticException();
        } else {
            NumericMatrix m=(NumericMatrix)identity(n,p).multiply(numeric);
            return newinstance(m.element);
        }
    }

    public Numeric[] vectors() {
        NumericVector v[]=new NumericVector[n];
        for(int i=0;i1) {
            Numeric a=JSCLDouble.valueOf(0);
            for(int i=0;i0) return element[0][0];
        else return JSCLDouble.valueOf(0);
    }

    public Numeric log() {
        throw new ArithmeticException();
    }

    public Numeric exp() {
        throw new ArithmeticException();
    }

    public Numeric conjugate() {
        NumericMatrix m=(NumericMatrix)newinstance();
        for(int i=0;i");
        for(int i=0;i");
            for(int j=0;j");
        }
	b.append("");
	return b.toString();
    }

    protected NumericMatrix newinstance() {
        return newinstance(new Numeric[n][p]);
    }

    protected NumericMatrix newinstance(Numeric element[][]) {
        return new NumericMatrix(element);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy