/*
 This is a proprietary part of DataMelt package.
 License: the Creative Commons Attribution-Share Alike License; either version 3.0 of the License, 
 or any later version.
 http://creativecommons.org/licenses/by-sa/3.0/
 

Redistributions of the source code, or parts of the source codes, must retain the copyright notice, this list of conditions and the following disclaimer (all at the top of each source code) and requires the written permission from DataMelt.

Redistribution in binary form of all or parts of a class must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution and requires the written permission of ScaVis

Details about license agreement or commercial use are: http://jwork.org/scavis/ */ package jhpro.nnet; import java.util.ArrayList; import jhplot.P1D; import jhplot.P2D; /** * Input matrix. * * @author Jochen Fröhlich and S.Chekanov * */ public class InputMatrix { /** * Creates an instance of InputMatrix. This is the only constructor of the * class and has the following arguments: size: the number of input values * (1...N) dim: the dimension of this matrix (1...3) * * @param i * @param j */ public InputMatrix(int i, int j) { value = new InputValue[i]; dimension = j <= 0 || j >= 4 ? 3 : j; for (int k = 0; k < i; k++) value[k] = new InputValue(); } /** * Sets input values for each dimension to this matrix. These methods can be * used sequentially, if you want an input matrix with 1, 2, or 3 * dimensions. The arguments x, y, and z are arrays of type int. To define a * 3-dimensional input matrix, you may use the setInputValues(x,y,z) method. * * @param ai */ public void setInputX(int ai[]) { if (ai.length <= value.length) { for (int i = 0; i < ai.length; i++) value[i].setX(ai[i]); } } public void setInputX(ArrayList ai) { if (ai.size() <= value.length) { for (int i = 0; i < ai.size(); i++) value[i].setX(ai.get(i)); } } /** * Set X and Y in one method. * @param ai * @param aj */ public void setInputXY(ArrayList ai, ArrayList aj) { if (ai.size() <= value.length) { for (int i = 0; i < ai.size(); i++) { value[i].setX(ai.get(i)); value[i].setY(aj.get(i)); } } } /** * Sets input values for Y. * @param ai */ public void setInputY(int ai[]) { if (ai.length <= value.length) { for (int i = 0; i < ai.length; i++) value[i].setY(ai[i]); } } /** * Set Y values * @param ai */ public void setInputY(ArrayList ai) { if (ai.size() <= value.length) { for (int i = 0; i < ai.size(); i++) value[i].setY(ai.get(i)); } } /** * Sets input values for Z. * @param ai */ public void setInputZ(int ai[]) { if (ai.length <= value.length) { for (int i = 0; i < ai.length; i++) value[i].setZ(ai[i]); } } /** * Set Z values. * @param ai */ public void setInputZ(ArrayList ai) { if (ai.size() <= value.length) { for (int i = 0; i < ai.size(); i++) value[i].setZ(ai.get(i)); } } /** * Sets input values for X,Y * @param ai */ public void setInputXY(P1D ai) { if (ai.size() <= value.length) { for (int i = 0; i < ai.size(); i++) { value[i].setX(ai.getX(i)); value[i].setY(ai.getY(i)); } } } /** * Sets input values for X,Y * @param ai */ public void setInputXYZ(P2D ai) { if (ai.size() <= value.length) { for (int i = 0; i < ai.size(); i++) { value[i].setX(ai.getX(i)); value[i].setY(ai.getY(i)); value[i].setZ(ai.getZ(i)); } } } /** * Sets input values for all three dimensions to this matrix. This method is * used, when you want an input matrix with three dimensions. The arguments * x, y, and z are arrays of type int. * * @param ai * @param ai1 * @param ai2 */ public void setInputValues(int ai[], int ai1[], int ai2[]) { setInputX(ai); setInputY(ai1); setInputZ(ai2); } /** * Returns the dimension of this input matrix. * @return */ public int getDimension() { return dimension; } public InputValue[] getInputValues() { return value; } public InputValue getRandomInput() { return value[(int) (Math.random() * (double) value.length)]; } /** * Returns the number of input values in this input matrix. * @return */ public int size() { return value.length; } InputValue value[]; int dimension; }

Ads help maintain this website.