function m = addInputTwo2Two(m, inFrom, stateFrom, to1, to2, fwd)
%ADDINPUTTWO2TWO adds an u(1) + x(1) --> x(1) + x(2) reaction to the model
%
% m = addInputTwo2Two(m, to1, to2, fwd) adds a reaction to the model m of the 
% form:
% 
%                      p(fwd)
% u(inFrom) + x(stateFrom) ------> x(to1) + x(to2)
% 

% (c) 2010 David R Hagen & Bruce Tidor
% This work is released under the MIT license.

m = b2add(m, inFrom, stateFrom,   to1, fwd,  1);
m = b2add(m, inFrom, stateFrom,   to2, fwd,  1);
m = b2add(m, inFrom, stateFrom, stateFrom, fwd, -1);

% add term to stoichiometry matrix
m.nR            = m.nR+1;
[m.spinds.i_S, m.spinds.j_S, m.spinds.x_S, m.spinds.n_S] = ...
    sparse_vec(m.spinds.i_S, m.spinds.j_S, m.spinds.x_S, m.spinds.n_S, to1, m.nR, 1);
[m.spinds.i_S, m.spinds.j_S, m.spinds.x_S, m.spinds.n_S] = ...
    sparse_vec(m.spinds.i_S, m.spinds.j_S, m.spinds.x_S, m.spinds.n_S, to2, m.nR, 1);
[m.spinds.i_S, m.spinds.j_S, m.spinds.x_S, m.spinds.n_S] = ...
    sparse_vec(m.spinds.i_S, m.spinds.j_S, m.spinds.x_S, m.spinds.n_S, stateFrom, m.nR, -1);
