Jannis (0.1preAlpha) | ||
Frames | No Frames |
1: /* Pattern.java - Copyright (c) 2005 by Stefan Thesing 2: <p>This file is part of Jannis.</p> 3: <p>Jannis is free software; you can redistribute it and/or modify 4: it under the terms of the GNU General Public License as published by 5: the Free Software Foundation; either version 2 of the License, or 6: (at your option) any later version.</p> 7: <p>Jannis is distributed in the hope that it will be useful, 8: but WITHOUT ANY WARRANTY; without even the implied warranty of 9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10: GNU General Public License for more details.</p> 11: <p>You should have received a copy of the GNU General Public License 12: along with Jannis; if not, write to the<br> 13: Free Software Foundation, Inc.,<br> 14: 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br> 15: */ 16: package de.webdings.jannis.neuralnet; 17: 18: import de.webdings.jannis.exceptions.PatternCreateException; 19: 20: /** 21: * Pattern is used represent an input pattern or output 22: * pattern a neural net processes or produces. 23: * 24: * @author Stefan Thesing<br> 25: * Website: <a href="http://www.webdings.de">http://www.webdings.de</a> 26: * @version 0.1 10.08.2005 27: */ 28: public class Pattern { 29: // Attribute 30: /** 31: * The entries of the pattern. 32: */ 33: public boolean[] entries; 34: //Konstruktor 35: /** 36: * Constructs a Pattern from an array containing <code>true</code> or 37: * <code>false</code>, where <code>true</code> means the neuron is supposed to 38: * fire (for an input pattern) or it has fired (for an output pattern) and 39: * <code>false</code> means it is not supposed to fire or hasn't fired. 40: * @param entries 41: */ 42: public Pattern(boolean[] entries) { 43: this.entries = entries; 44: } 45: /** 46: * Counstructs a Pattern from a String containing <code>0</code>s and <code>1</code>s, 47: * where <code>1</code> corresponds to <code>true</code> and <code>0</code> to 48: * <code>false</code>. 49: * @param entries 50: * @throws PatternCreateException if the String contains characters other than 51: * <code>0</code> and <code>1</code> 52: */ 53: public Pattern(String entries) throws PatternCreateException { 54: this(entries.toCharArray()); 55: } 56: /** 57: * Counstructs a Pattern from an array containing <code>0</code>s and <code>1</code>s, 58: * where <code>1</code> corresponds to <code>true</code> and <code>0</code> to 59: * <code>false</code>. 60: * @param entries 61: * @throws PatternCreateException if the array contains characters other than 62: * <code>0</code> and <code>1</code> 63: */ 64: public Pattern(char[] entries) throws PatternCreateException { 65: boolean[] temp = new boolean[entries.length]; 66: for(int i=0;i<entries.length;++i){ 67: if(entries[i]=='0') { 68: temp[i] = false; 69: } else if(entries[i]=='1') { 70: temp[i] = true; 71: } else { 72: throw new PatternCreateException("Can't " + 73: "create pattern. Data contains " + 74: "characters other than 0 and 1"); 75: } 76: } 77: this.entries = temp; 78: } 79: }
Jannis (0.1preAlpha) |
© 2005 by Stefan Thesing;
Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.