public void removeArgFromFunction ( String varName , DifferentialFunction function ) { val args = function . args ( ) ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( args [ i ] . getVarName ( ) . equals ( varName ) ) { /** * Since we are removing the variable reference * from the arguments we need to update both * the reverse and forward arguments. */ List < String > reverseArgs = ops . get ( function . getOwnName ( ) ) . getInputsToOp ( ) ; val newArgs = new ArrayList < String > ( args . length - 1 ) ; for ( int arg = 0 ; arg < args . length ; arg ++ ) { if ( ! reverseArgs . get ( arg ) . equals ( varName ) ) { newArgs . add ( reverseArgs . get ( arg ) ) ; } } ops . get ( function . getOwnName ( ) ) . setInputsToOp ( newArgs ) ; break ; } } }
Remove an argument for a function . Note that if this function does not contain the argument it will just be a no op .