function m = addOne2Two(m,  from, to1, to2, fwd)
% ADDONE2ONE adds an x(1) --> x(2) + x(3) reaction to the model.
%
% m = addOne2Two(m,  from, to1, to2, fwd) adds a reaction to the model m of the 
% form:
% 
%         p(fwd)
% x(from) ------> x(to1) + x(to2)
% 
%
% See also
%   addTwo2One
%   addTwo2OneRev
%   addOne2One
%   addInputTwo2One

% This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative 
% Works 3.0 United States License. To view a copy of this license, visit 
% http://creativecommons.org/licenses/by-nc-nd/3.0/us/ or send a letter to Creative Commons,
% 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

    m = a1add(m, from,  to1,  fwd,  1);
    m = a1add(m, from,  to2,  fwd,  1);        
    m = a1add(m, from, from,  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, from, m.nR, -1);
end