001// import org.apache.commons.math.ode.*; 002import org.apache.commons.math3.ode.*; 003 004/** Retrieves the solution from a {@link ContinuousOutputModel}.<br> 005 * <br> 006 * See <a target="_top" href="../0_CommonsMath_README.html#examples">CommonsMath_ODE_Lotka_Volterra~Test.jxn</a> 007 * for an example. 008 */ 009public class JxnCOMAnalyzer 010{ 011 private JxnCOMAnalyzer() 012 { 013 } 014 015 /** Returns an array of state values <code>y<sub>iState</sub>(t<sub>k</sub>)</code> for <code> t<sub>k</sub> </code> values 016 * given in the array {@code t}. 017 * @param com model available from the integrator. See {@link ODEIntegrator#addStepHandler ODEIntegrator.addStepHandler(...)} 018 * and {@link ContinuousOutputModel} 019 * @param t array of points in time where output is desired 020 * @param iState state for which output is desired 021 * @return values of a state variable at given points in time 022 */ 023 public static double [] analyze( ContinuousOutputModel com, double [] t, int iState ) // throws DerivativeException 024 { 025 double [] yt = new double[ t.length ]; 026 027 for( int i = 0; i < t.length; i++ ) 028 { 029 com.setInterpolatedTime( t[i] ); 030 double [] y = com.getInterpolatedState(); 031 yt[i] = y[iState]; 032 } 033 034 return yt; 035 } 036}