コード例 #1
0
ファイル: testReadWrite.java プロジェクト: rfabbri/scilab
  @Test()
  public void putAndGetPolynomialTest() throws NullPointerException, JavasciException {
    double[][][] a = {{{1, 2, 3}, {2}, {0, 0, 0, -4}}, {{-1, 0, 2}, {0, 2, 0, 0, 3}, {0}}};
    ScilabPolynomial aOriginal = new ScilabPolynomial(a, "X");
    sci.put("a", aOriginal);
    assertTrue(sci.exec("somme = sum(a);"));

    ScilabPolynomial aFromScilab = (ScilabPolynomial) sci.get("a");

    assertTrue(aFromScilab.equals(aOriginal));
  }
コード例 #2
0
 /** @see org.scilab.modules.types.ScilabType#equals(Object) */
 @Override
 public boolean equals(Object obj) {
   if (obj instanceof ScilabPolynomial) {
     ScilabPolynomial sciPoly = ((ScilabPolynomial) obj);
     if (sciPoly.getPolyVarName().equals(getPolyVarName())) {
       if (this.isReal() && sciPoly.isReal()) {
         return Arrays.deepEquals(this.getRealPart(), sciPoly.getRealPart());
       } else {
         /* Complex */
         return Arrays.deepEquals(this.getRealPart(), sciPoly.getRealPart())
             && Arrays.deepEquals(this.getImaginaryPart(), sciPoly.getImaginaryPart());
       }
     } else {
       return false;
     }
   } else {
     return false;
   }
 }