/* SCCS - @(#)NslDouble2.java 1.15 - 09/20/99 - 19:19:27 */ // Copyright: Copyright (c) 1997 University of Southern California Brain Project. // Copyright: This software may be freely copied provided the toplevel // Copyright: COPYRIGHT file is included with each such copy. // Copyright: Email nsl@java.usc.edu. //////////////////////////////////////////////////////////////////////////////// // NslDouble2.java package nslj.src.lang; //import tcl.lang.*; //import nslj.src.math.NslSigmoid; public class NslDouble2 extends NslNumeric2 { // public double[][] _data; //public String _name; //boolean visibility = true; //NslHierarchy module; public NslDouble2(double[][] d) { super(); _data = new double[d.length][d[0].length]; set(d); //_name = null; } public NslDouble2(NslNumeric2 n) { super(); _data = new double[n.getSize1()][n.getSize2()]; set(n.getdouble2()); //_name = null; } public NslDouble2(int size1, int size2) { super(); _data = new double[size1][size2]; //_name = null; } public NslDouble2() { super(); _data=null; //_name = null; } /** * This constructs a number with specified name * @param name - name of the variable */ public NslDouble2(String name) { super(name); _data = null; //_name = name; } public NslDouble2(String name, NslHierarchy curParent) { super(name,curParent,curParent.nslGetAccess()); _data = null; //_name = name; //module = curParent; //visibility = module.getVisibility(); //module.enableAccess(this); } /** * This constructs a number with specified name * @param name - name of the variable * @param size1 - size of the array 1st-Dimension * @param size2 - size of the array 2nd-Dimension */ public NslDouble2(String name, int size1, int size2) { super(name); //_data = new double[size1][size2]; //_name = name; } public NslDouble2(String name, NslHierarchy curParent, int size1, int size2) { super(name,curParent,curParent.nslGetAccess()); _data = new double[size1][size2]; //_name = name; //module = curParent; //visibility = module.getVisibility(); //module.enableAccess(this); } /** * This constructs a number with specified name * @param name - name of the variable * @param n - initialized values */ public NslDouble2(String name, NslHierarchy curParent,NslNumeric2 n) { super(name,curParent,curParent.nslGetAccess()); _data = new double[n.getSize1()][n.getSize2()]; set(n.getdouble2()); //_name = name; // module = curParent; //visibility = module.getVisibility(); //module.enableAccess(this); } public NslDouble2(String name, NslNumeric2 n) { super(name); _data = new double[n.getSize1()][n.getSize2()]; set(n.getdouble2()); //_name = name; } /** * This constructs a number with specified name * @param name - name of the variable * @param n - initialized values */ // aa public NslDouble2(String name, double[][] d) { super(name); _data = new double[d.length][d[0].length]; set(d); //_name = name; } public void nslMemAlloc(int size1, int size2) { _data = new double[size1][size2]; } //------------------gets------------------- public double[][] get() { return _data; } public double[] get(int pos1) { return _data[pos1]; } public double get(int pos1, int pos2) { return _data[pos1][pos2]; } public double[][] getdouble2() { return _data; } public float[][] getfloat2() { float[][] floatdata; int i; int j; int size1 = _data.length; int size2 = _data[0].length; floatdata = new float[size1][size2]; for (i=0; i _data.length) end1 = _data.length; if (end2 > _data[0].length) end2 = _data[0].length; length1 = end1-start1+1; length2 = end2-start2+1; doubledata = new double[length1][length2]; i1 = start1; i2 = start2; for (j1=0; j1value * @param value */ public void set(int pos, float[] value) { if (_data[0].length != value.length) { System.out.println("NslDouble2: array size not match"); return; } for (int i=0; i<_data[0].length; i++) { _data[pos][i]=value[i]; } return; } /** * Set the value of this number to value * @param value */ public void set(int pos, int[] value) { if (_data[0].length != value.length) { System.out.println("NslDouble1: array size not match"); return; } for (int i=0; i<_data[0].length; i++) { _data[pos][i]=value[i]; } return; } public void set(int pos1, int pos2, double value) { _data[pos1][pos2]=value; return; } public void set(int pos1, int pos2, float value) { _data[pos1][pos2]=(double)value; return; } public void set(int pos1, int pos2, int value) { _data[pos1][pos2]=(double)value; return; } public void set(double value) { int i, j; int size1 = _data.length; int size2 = _data[0].length; for (i=0; i _data.length) return; if (startpos2 > _data[0].length) return; if (endpos1 > _data.length) endpos1 = _data.length; if (endpos2 > _data[0].length) endpos2 = _data[0].length; for (i1=startpos1, j1=0; i1value) { pos1 = i; pos2 = j; value = _data[i][j]; } } } max_elem_pos1.set(pos1); max_elem_pos2.set(pos2); return value; } public double max() { return maxElem(new NslInt0(0), new NslInt0(0)); } public double minElem(NslInt0 max_elem_pos1, NslInt0 max_elem_pos2) { double value = java.lang.Double.POSITIVE_INFINITY; int i, j; int size1 = _data.length; int size2 = _data[0].length; int pos1 = -1; int pos2 = -1; for (i=0; i