Blame view

Giac_maj/giac-1.4.9/src/runme.java 1.85 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  package javagiac;
  // -*- compile-command: "javac *.java" -*-
  // This example illustrates how giac can be used from Java using SWIG.
  // On linux type java runme, on mac os x with giac 32 bits, java -d32 runme
  
  import java.io.*;
  
  public class runme {
    static {
      try {
  	System.out.println("Loading giac java interface");
          //System.load("/usr/local/lib/libgiacjava.so");
          System.loadLibrary("javagiac");
      } catch (UnsatisfiedLinkError e) {
        System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
        System.exit(1);
      }
    }
  
    public static void main(String argv[]) 
    {
      context C=new context();
      String s=new String("");
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      System.out.print( "Enter an expression :" );
      try {
  	s = br.readLine();
      } catch (IOException ioe) {
  	System.out.println("IO error trying to read your name!");
  	System.exit(1);
      }
      gen g=new gen(s,C);
      // gen g=new gen(10,12);
      // gen g=new gen("x**4-1",C);
      System.out.println( "Created gen of type : "+g.getType());
      if (g.getType()==gen_unary_types._SYMB.swigValue()){
  	System.out.println( "g operator is "+g.operator_at(0,C).print(C));
  	System.out.println( "g has "+giac._size(g,C).getVal()+" arguments");
  	System.out.println( "First argument of g is "+g.operator_at(1,C).print(C));
      }
      gen h=giac._factor(g,C);
  
      System.out.println( "Value of h: " + h.print(C) );
  
      h=giac.add(g,g);
      h=giac._simplify(h,C);
  
      System.out.println( "Value of h: " + h.print(C) );
      // h=new gen(giac.makevecteur(h,new gen(2)),(short)1);
      h=new gen(giac.makevecteur(h,new gen(2),h),(short)gen_comp_subtypes._SEQ__VECT.swigValue());
      System.out.println( "Value of h: " + h.print(C) );
  
      System.out.println( "Goodbye" );
    }
  }