/* SCCS - @(#)NslDouble4.java 1.14 - 09/20/99 - 19:19:28 */
// 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.
////////////////////////////////////////////////////////////////////////////////
// NslDouble4.java
package nslj.src.lang;
public class NslDouble4 extends NslNumeric4 {
public double[][][][] _data;
// public String _name;
// boolean visibility = true;
// NslHierarchy module;
public NslDouble4(double[][][][] d) {
super();
_data = new double[d.length][d[0].length][d[0][0].length][d[0][0][0].length];
set(d);
//_name = null;
}
public NslDouble4(NslNumeric4 n) {
super();
_data = new double[n.getSize1()][n.getSize2()][n.getSize3()][n.getSize4()];
set(n.getdouble4());
//_name = null;
}
public NslDouble4(int size1, int size2, int size3, int size4) {
super();
_data = new double[size1][size2][size3][size4];
//_name = null;
}
public NslDouble4() {
super();
_data=null;
//_name = null;
}
/**
* This constructs a number with specified name
* @param name - name of the variable
*/
public NslDouble4(String name) {
super(name);
_data = null;
//_name = name;
}
public NslDouble4(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
* @param size3 - size of the array 3rd-Dimension
* @param size4 - size of the array 4th-Dimension
*/
public NslDouble4(String name, int size1, int size2, int size3, int size4) {
super(name);
_data = new double[size1][size2][size3][size4];
//_name = name;
}
public NslDouble4(String name, NslHierarchy curParent, int size1, int size2, int size3, int size4) {
super(name,curParent,curParent.nslGetAccess());
_data = new double[size1][size2][size3][size4];
//_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 NslDouble4(String name, NslHierarchy curParent,NslNumeric4 n) {
super(name,curParent,curParent.nslGetAccess());
_data = new double[n.getSize1()][n.getSize2()][n.getSize3()][n.getSize4()];
set(n.getdouble4());
//_name = name;
//module = curParent;
//visibility = module.getVisibility();
//module.enableAccess(this);
}
public NslDouble4(String name, NslNumeric4 n) {
super(name);
_data = new double[n.getSize1()][n.getSize2()][n.getSize3()][n.getSize4()];
set(n.getdouble4());
//_name = name;
}
/**
* This constructs a number with specified name
* @param name - name of the variable
* @param n - initialized values
*/
public NslDouble4(String name, double[][][][] d) {
super(name);
_data = new double[d.length][d[0].length][d[0][0].length][d[0][0][0].length];
set(d);
//_name = name;
}
public void nslMemAlloc(int size1, int size2, int size3, int size4) {
_data = new double[size1][size2][size3][size4];
}
//----------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[] get(int pos1, int pos2, int pos3){
return _data[pos1][pos2][pos3];
}
public double get(int pos1, int pos2, int pos3, int pos4) {
return _data[pos1][pos2][pos3][pos4];
}
// this method here because parser does not change
// NslInt0 to ints for 3d and 4d types
public double get(NslInt0 pos1, NslInt0 pos2, NslInt0 pos3, NslInt0 pos4){
return _data[pos1.get()][pos2.get()][pos3.get()][pos4.get()];
}
//------------------------------------
public double[][][][] getdouble4() {
return _data;
}
/**
* @return - the value of this object in java numerical array type
float[][][][].
*/
// override in NslFloat4 for better efficiency
public float[][][][] getfloat4() {
float[][][][] floatdata;
int i;
int j;
int k;
int l;
int size1 = _data.length;
int size2 = _data[0].length;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
floatdata = new float[size1][size2][size3][size4];
for (i=0; iint[][][][].
*/
// override in NslInt4 for better efficiency
public int[][][][] getint4() {
int[][][][] intdata;
int i;
int j;
int k;
int l;
int size1 = _data.length;
int size2 = _data[0].length;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
intdata = new int[size1][size2][size3][size4];
for (i=0; ipos1th and
pos2th and pos3th in java numerical type double[][][].
*/
public double[][][] getdouble3(int pos1) {
return _data[pos1];
}
/**
* @param pos1 - left most index
* @param pos2 - second to the left most index
* @param pos3 - third from left most index
* @return the value of the element in pos1th and
pos2th and pos3th in java numerical type float.
*/
public float[][][] getfloat3(int pos1) {
int h, i, j;
int size2 = _data[0].length;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
float[][][] tmp = new float[size2][size3][size4];
for (h=0; hpos1th and
pos2th and pos3th in java numerical type int.
*/
public int[][][] getint3(int pos1) {
int h, i, j;
int size2 = _data[0].length;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
int[][][] tmp = new int[size2][size3][size4];
for (h=0; hpos1th and
pos2th and pos3th in java numerical type double[][].
*/
public double[][] getdouble2(int pos1, int pos2) {
return _data[pos1][pos2];
}
/**
* @param pos1 - left most index
* @param pos2 - second to the left most index
* @param pos3 - third from left most index
* @return the value of the element in pos1th and
pos2th and pos3th in java numerical type float[][].
*/
// override in NslFloat4 for better efficiency
public float[][] getfloat2(int pos1, int pos2) {
int i, j;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
float[][] tmp = new float[size3][size4];
for (i=0; ipos1th and
pos2th and pos3th in java numerical type int[][].
*/
// override in NslInt4 for better efficiency
public int[][] getint2(int pos1, int pos2) {
int i, j;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
int[][] tmp = new int[size3][size4];
for (i=0; ipos1th and
pos2th and pos3th in java numerical type double[].
*/
public double[] getdouble1(int pos1, int pos2, int pos3) {
return _data[pos1][pos2][pos3];
}
/**
* @param pos1 - left most index
* @param pos2 - second to the left most index
* @param pos3 - third from left most index
* @return the value of the element in pos1th and
pos2th and pos3th in java numerical type float[].
*/
public float[] getfloat1(int pos1, int pos2, int pos3) {
int j;
int size4 = _data[0][0][0].length;
float[] tmp = new float[size4];
for (j=0; jpos1th and
pos2th and pos3th in java numerical type int[].
*/
public int[] getint1(int pos1, int pos2, int pos3) {
int j;
int size4 = _data[0][0][0].length;
int[] tmp = new int[size4];
for (j=0; jpos1th and
pos2th and pos3th and pos4th in java numerical type double.
*/
// override in NslDouble4 for better efficiency
public double getdouble(int pos1, int pos2, int pos3, int pos4) {
return _data[pos1][pos2][pos3][pos4];
}
/**
* @param pos1 - left most
* @param pos2 - second from left
* @param pos3 - third from left
* @param pos4 - fourth from left
* @return the value of the element in pos1th and
pos2th and pos3th and pos4th in java numerical type float.
*/
// override in NslFloat4 for better efficiency
public float getfloat(int pos1, int pos2, int pos3, int pos4) {
return (float)_data[pos1][pos2][pos3][pos4];
}
/**
* @param pos1 - left most
* @param pos2 - second from left
* @param pos3 - third from left
* @param pos4 - fourth from left
* @return the value of the element in pos1th and
pos2th and pos3th and pos4th in java numerical type int.
*/
public int getint(int pos1, int pos2, int pos3, int pos4) {
return (int)_data[pos1][pos2][pos3][pos4];
}
//------------------------------------------------------------------***----
/**
* get the value of this object in NslDouble4 form.
*/
public NslDouble4 getNslDouble4() {
return this;
}
/**
* get the value of this object in NslFloat4 form.
*/
public NslFloat4 getNslFloat4() {
return (new NslFloat4(getfloat4()));
}
/**
* get the value of this object in NslInt4 form.
*/
public NslInt4 getNslInt4() {
return (new NslInt4(getint4()));
}
//----------------------------------------------------
public double[][][][] getSector(int start1, int start2, int start3, int start4, int end1, int end2, int end3, int end4) {
int i1;
int i2;
int i3;
int i4;
int j1;
int j2;
int j3;
int j4;
int length1;
int length2;
int length3;
int length4;
double[][][][] doubledata;
if (start1 < 0)
start1 = 0;
if (start2 < 0)
start2 = 0;
if (start3 < 0)
start3 = 0;
if (start4 < 0)
start4 = 0;
if (end1 > _data.length)
end1 = _data.length;
if (end2 > _data[0].length)
end2 = _data[0].length;
if (end3 > _data[0][0].length)
end3 = _data[0][0].length;
if (end4 > _data[0][0][0].length)
end4 = _data[0][0][0].length;
length1 = end1-start1+1;
length2 = end2-start2+1;
length3 = end3-start3+1;
length4 = end4-start4+1;
doubledata = new double[length1][length2][length3][length4];
i1 = start1;
i2 = start2;
i3 = start3;
i4 = start4;
for (j1=0; j1 _data.length)
return;
if (startpos2 > _data[0].length)
return;
if (startpos3 > _data[0][0].length)
return;
if (startpos4 > _data[0][0][0].length)
return;
if (endpos1 > _data.length)
endpos1 = _data.length;
if (endpos2 > _data[0].length)
endpos2 = _data[0].length;
if (endpos3 > _data[0][0].length)
endpos3 = _data[0][0].length;
if (endpos4 > _data[0][0][0].length)
endpos4 = _data[0][0][0].length;
for (i1=startpos1, j1=0; i1value)
{
pos1 = i; pos2 = j; pos3 = k; pos4 = l;
value = _data[i][j][k][l];
}
}
}
}
}
max_elem_pos1.set(pos1);
max_elem_pos2.set(pos2);
max_elem_pos3.set(pos3);
max_elem_pos4.set(pos4);
return value;
}
public double max() {
return maxElem(new NslInt0(0), new NslInt0(0), new NslInt0(0), new NslInt0(0));
}
public double minElem(NslInt0 max_elem_pos1, NslInt0 max_elem_pos2, NslInt0 max_elem_pos3, NslInt0 max_elem_pos4) {
double value = java.lang.Double.POSITIVE_INFINITY;
int i, j, k, l;
int size1 = _data.length;
int size2 = _data[0].length;
int size3 = _data[0][0].length;
int size4 = _data[0][0][0].length;
int pos1 = -1;
int pos2 = -1;
int pos3 = -1;
int pos4 = -1;
for (i=0; i