View Javadoc
1   /*
2    * Copyright 2009 Ange Optimization ApS
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package eu.simuline.octave.examples;
17  
18  import junit.framework.TestCase;
19  
20  import eu.simuline.octave.OctaveEngine;
21  import eu.simuline.octave.OctaveEngineFactory;
22  import eu.simuline.octave.type.OctaveDouble;
23  
24  /**
25   * http://kenai.com/projects/javaoctave/pages/SimpleExampleOfSolvingAnODE
26   */
27  public class OdeExampleTest extends TestCase {
28  
29      /** Test */
30      public void test() {
31          // Begin web text
32          final OctaveEngine octave = new OctaveEngineFactory().getScriptEngine();
33          octave.eval("x = 0:0.01:1;");
34          octave.eval("t = lsode(@(x,t) x**2+t**2, 0, x);");
35          final OctaveDouble t = octave.get(OctaveDouble.class, "t");
36          octave.close();
37          // End web text
38          assertEquals(101, t.dataSize());
39      }
40  
41  }