if (newChildPipe.size() <= 1) { LinearPrinter.println("  " + ((newChildPipe.size()==0)? "(no children)" : "(one child)"));
if (newChildPipe.size() == 0) { LinearPrinter.println("  (no children)"); return; } else if (newChildPipe.size() == 1) { LinearPrinter.println("  (one child)"); LinearPrinter.println("  resetting parent pointer for " + newChildPipe.get(0)); newChildPipe.get(0).setParent(parentPipe);
    private static void doPipelineAdd(SIRPipeline parentPipe,				      SIRPipeline newChildPipe,				      HashMap linearRepMap) {	LinearPrinter.println(" new child pipe: ");	Iterator newKidIter = newChildPipe.getChildren().iterator();	while(newKidIter.hasNext()) {LinearPrinter.println("  " + newKidIter.next());}		// if the new child pipe has 0-1 children, we are done	if (newChildPipe.size() <= 1) {	    LinearPrinter.println("  " + ((newChildPipe.size()==0)? "(no children)" : "(one child)"));	    return;	}		// if the newChild pipeline contains all of the children of	// the parent pipe, there is no need to do any replacing	// (we would just be adding a pipeline with its only child a pipeline).	if (parentPipe.size() != newChildPipe.size()) {	    // set the parent field of the child pipe to be the parent (duh)	    newChildPipe.setParent(parentPipe);	    newChildPipe.setInit(SIRStream.makeEmptyInit()); // set to empty init method	    // remember the location of the first wrapper pipe's child	    // in the original parent pipeline (so we can insert the wrapper	    // pipe at the appropriate place.	    int newPipeIndex = parentPipe.indexOf(newChildPipe.get(0));	    if (newPipeIndex == -1) {throw new RuntimeException("unknown child in wrapper pipe");}	    // now, remove all of the streams that appear in the new child wrapper pipeline	    Iterator wrappedChildIter = newChildPipe.getChildren().iterator();	    while(wrappedChildIter.hasNext()) {		SIRStream removeKid = (SIRStream)wrappedChildIter.next() ;		parentPipe.remove(removeKid);	    }	    // now, add the new child pipeline to the parent at the index of first wrapped child	    parentPipe.add(newPipeIndex,newChildPipe);	} else {	    // no need to do wrap all of the children again.	    newChildPipe = parentPipe;	}			// now, calculate the overall linear rep of the child pipeline	List repList = getLinearRepList(linearRepMap, newChildPipe.getChildren()); // list of linear reps	LinearTransform pipeTransform = LinearTransformPipeline.calculate(repList);	try {	    LinearFilterRepresentation newRep = pipeTransform.transform();	    // add a mapping from child pipe to the new linear form.	    linearRepMap.put(newChildPipe, newRep);	    // write output for output parsing scripts (check output mode	    // because printing this takes a loooooong time for big matrices) 	    if (LinearPrinter.getOutput()) {		LinearPrinter.println("Linear pipeline found: " + newChildPipe +				      "\n-->Matrix:\n" + newRep.getA() +				      "\n-->Constant Vector:\n" + newRep.getb());	    }		} catch (NoTransformPossibleException e) {	    // otherwise something bad happened in the combination process.	    LinearPrinter.println(" can't combine transform reps: " + e.getMessage());	    //throw new RuntimeException("Error combining pipeline!");	}	return;    }