* @see ca.nengo.model.ExpandableNode#addTermination(java.lang.String, float[][], float, boolean)
*/
public synchronized Termination addTermination(String name, float[][] weights, PDF tauPSC, PDF delays, boolean modulatory) throws StructuralException {
for(Termination t : getTerminations()) {
if(t.getName().equals(name))
throw new StructuralException("The ensemble already contains a termination named " + name);
}
if (myExpandableNodes.length != weights.length) {
throw new StructuralException(weights.length + " sets of weights given for "
+ myExpandableNodes.length + " expandable nodes");
}
int dimension = weights[0].length;
Termination[] components = new Termination[myExpandableNodes.length];
for (int i = 0; i < myExpandableNodes.length; i++) {
if (weights[i].length != dimension) {
throw new StructuralException("Equal numbers of weights are needed for termination onto each node");
}
if(delays == null)
components[i] = myExpandableNodes[i].addTermination(name, new float[][]{weights[i]}, tauPSC.sample()[0], modulatory);
else {
if(myExpandableNodes[i] instanceof ExpandableSpikingNeuron)
components[i] = ((ExpandableSpikingNeuron)myExpandableNodes[i]).addDelayedTermination(name,
new float[][]{weights[i]}, tauPSC.sample()[0], delays.sample()[0], modulatory);
else
throw new StructuralException("Cannot specify delays for non-ExpandableSpikingNeuron");
}
}
EnsembleTermination result = new EnsembleTermination(this, name, components);
myExpandedTerminations.put(name, result);