// Path: src/main/java/de/jannlab/misc/IntTools.java
// public final class IntTools {
//     
//     public static void shuffle(
//             final int[] data, 
//             final Random rnd
//     ) {
//        //
//        final int size = data.length;
//        //
//        for (int i = size; i > 1; i--) {
//            final int ii = i - 1;
//            final int r  = rnd.nextInt(i);
//            //
//            final int temp = data[ii];
//            data[ii] = data[r];
//            data[r] = temp;
//        }
//     }
// 
//     public static String asString(final int[] data) {
//         return asString(data, 0, data.length);
//     }
//     
//     public static String asString(final int[] data, final int offset, final int size) {
//         StringWriter out = new StringWriter();
//             
//         int o = offset;
//         for (int i = 0; i < size; i++) {
//             if (i > 0) out.append(", ");
//             out.append(Integer.toString(data[o]));
//             o++;
//         }
//         return out.toString();
//     }
//     
// }


import java.io.Serializable;
import de.jannlab.misc.IntTools;
/*******************************************************************************
 * JANNLab Neural Network Framework for Java
 * Copyright (C) 2012-2013 Sebastian Otte
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

package de.jannlab.core;



/**
 * An instance of this class defines a Layer in ANN. It contains some information
 * on the CellArray corresponding to this layer and some other computational
 * specification (e.g. the computational dependencies of the containing CellArrays). 
 * <br></br>
 * @author Sebastian Otte
 */
public final class Layer implements Serializable{
    private static final long serialVersionUID = 52359162370719687L;

    public static final int NO_LAYER = -1;
    
    //-------------------------------------------------------------------------
    
    /**
     * Gives the lower bound of the cells contained by this layer.
     */
    public int cellslbd = 0;
    /**
     * Gives the upper bound of the cells contained by this layer.
     */
    public int cellsubd = -1;
    /**
     * Gives the number of the cells contained by this layer.
     */
    public int cellsnum = 0;
    /**
     * Gives the lower bound of the arrays contained by this layer.
     */
    public int arrayslbd = 0;
    /**
     * Gives the upper bound of the arrays contained by this layer.
     */
    public int arraysubd = -1;
    /**
     * Gives the number of the arrays contained by this layer.
     */
    public int arraysnum = 0;
    /**
     * Gives the lower bounds of the packages of computational independent
     * arrays. Arrays with the same computation index are computed at the same
     * time.
     */
    public int[] complbds = null;
    /**
     * Gives the uppder bounds of the packages of computational independent
     * arrays. Arrays with the same computation index are computed at the same
     * time.
     */
    public int[] compubds = null;
    /**
     * Gives the number of the packages of computational independent
     * arrays. 
     */    
    public int compwidth = 0;
    /**
     * Gives the degree of incoming connections to all cells contained by all
     * array in this layer.
     */
    public int indeg = 0;
    /**
     * Gives the degree of outgoing connections of all cells contained by all
     * array in this layer.
     */
    public int outdeg = 0;
    /**
     * Gives the tag of the layer, which contains information of its
     * computational behavior.
     */
    public int tag = LayerTag.REGULAR;
    
    //-------------------------------------------------------------------------
    
    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        StringBuilder w = new StringBuilder();
        //
        w.append("cellslbd  : " + this.cellslbd + "\n");
        w.append("cellsubd  : " + this.cellsubd + "\n");
        w.append("cellsnum  : " + this.cellsnum + "\n");
        w.append("arrayslbd : " + this.arrayslbd + "\n");
        w.append("arraysubd : " + this.arraysubd + "\n");
        w.append("arraysnum : " + this.arraysnum + "\n");
        w.append("compwidth : " + this.compwidth + "\n");
        w.append("complbds  : " + "(" + IntTools.asString(this.complbds) + ")\n");
// Path: src/main/java/de/jannlab/misc/IntTools.java
// public final class IntTools {
//     
//     public static void shuffle(
//             final int[] data, 
//             final Random rnd
//     ) {
//        //
//        final int size = data.length;
//        //
//        for (int i = size; i > 1; i--) {
//            final int ii = i - 1;
//            final int r  = rnd.nextInt(i);
//            //
//            final int temp = data[ii];
//            data[ii] = data[r];
//            data[r] = temp;
//        }
//     }
// 
//     public static String asString(final int[] data) {
//         return asString(data, 0, data.length);
//     }
//     
//     public static String asString(final int[] data, final int offset, final int size) {
//         StringWriter out = new StringWriter();
//             
//         int o = offset;
//         for (int i = 0; i < size; i++) {
//             if (i > 0) out.append(", ");
//             out.append(Integer.toString(data[o]));
//             o++;
//         }
//         return out.toString();
//     }
//     
// }


// Path: src/main/java/de/jannlab/core/Layer.java
import java.io.Serializable;
import de.jannlab.misc.IntTools;

/*******************************************************************************
 * JANNLab Neural Network Framework for Java
 * Copyright (C) 2012-2013 Sebastian Otte
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

package de.jannlab.core;



/**
 * An instance of this class defines a Layer in ANN. It contains some information
 * on the CellArray corresponding to this layer and some other computational
 * specification (e.g. the computational dependencies of the containing CellArrays). 
 * <br></br>
 * @author Sebastian Otte
 */
public final class Layer implements Serializable{
    private static final long serialVersionUID = 52359162370719687L;

    public static final int NO_LAYER = -1;
    
    //-------------------------------------------------------------------------
    
    /**
     * Gives the lower bound of the cells contained by this layer.
     */
    public int cellslbd = 0;
    /**
     * Gives the upper bound of the cells contained by this layer.
     */
    public int cellsubd = -1;
    /**
     * Gives the number of the cells contained by this layer.
     */
    public int cellsnum = 0;
    /**
     * Gives the lower bound of the arrays contained by this layer.
     */
    public int arrayslbd = 0;
    /**
     * Gives the upper bound of the arrays contained by this layer.
     */
    public int arraysubd = -1;
    /**
     * Gives the number of the arrays contained by this layer.
     */
    public int arraysnum = 0;
    /**
     * Gives the lower bounds of the packages of computational independent
     * arrays. Arrays with the same computation index are computed at the same
     * time.
     */
    public int[] complbds = null;
    /**
     * Gives the uppder bounds of the packages of computational independent
     * arrays. Arrays with the same computation index are computed at the same
     * time.
     */
    public int[] compubds = null;
    /**
     * Gives the number of the packages of computational independent
     * arrays. 
     */    
    public int compwidth = 0;
    /**
     * Gives the degree of incoming connections to all cells contained by all
     * array in this layer.
     */
    public int indeg = 0;
    /**
     * Gives the degree of outgoing connections of all cells contained by all
     * array in this layer.
     */
    public int outdeg = 0;
    /**
     * Gives the tag of the layer, which contains information of its
     * computational behavior.
     */
    public int tag = LayerTag.REGULAR;
    
    //-------------------------------------------------------------------------
    
    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        StringBuilder w = new StringBuilder();
        //
        w.append("cellslbd  : " + this.cellslbd + "\n");
        w.append("cellsubd  : " + this.cellsubd + "\n");
        w.append("cellsnum  : " + this.cellsnum + "\n");
        w.append("arrayslbd : " + this.arrayslbd + "\n");
        w.append("arraysubd : " + this.arraysubd + "\n");
        w.append("arraysnum : " + this.arraysnum + "\n");
        w.append("compwidth : " + this.compwidth + "\n");
        w.append("complbds  : " + "(" + IntTools.asString(this.complbds) + ")\n");
        w.append("compubds  : " + "(" + IntTools.asString(this.compubds) + ")\n");