Examples of OObject


Examples of jscicalc.OObject

      if( getApplet().getMode() != 0 ){
    getApplet().setMode( pobject );
    getApplet().requestFocusInWindow();
    return;
      }
      OObject m = getApplet().getMemory();
      getApplet().pushHistory();
      OObject o = getApplet().getValue();
      if( !getApplet().getParser().isEmpty() ){
    //System.out.println( "__________" );
    PObject p = getApplet().getParser().getLast();
    if( !(o instanceof jscicalc.Error) && ( p instanceof RFunction ||
              p instanceof DFunction ||
              p instanceof MFunction ||
              p instanceof AFunction ) ){
        Ans ans = new Ans();
        ans.setValue( o );
        getApplet().insert( ans );
        getApplet().updateDisplay( true, true );
    }
      } else {
    //System.out.println( "**********" );
    Ans ans = new Ans();
    ans.setValue( o );
    getApplet().insert( ans );
    getApplet().updateDisplay( true, true );
      }
      o = getApplet().getParser().evaluate( getApplet().getAngleType() );
      if( !(o instanceof jscicalc.Error) ){
    OObject q =  m.subtract( o );
    if( !(q instanceof jscicalc.Error) )
        getApplet().setMemory( q );
    getApplet().setValue( o );
    getApplet().updateDisplay( false, true );
      }
View Full Code Here

Examples of jscicalc.OObject

    // Complex values of expression1 should be dealt with separately
    if( n == 0 ) return new Complex( 1 );
    else if( n == 1 ) return expression1;
    else if( expression1 instanceof Power ){
        Power q = (Power)expression1;
        OObject o = null;
        if( q.expression2 instanceof Expression ){
      Product p = new Product( (Expression)(q.expression2), false );
      o = p.multiply( new Complex( n ) );
        } else if( q.expression2 instanceof Complex ){
      o = q.expression2.multiply( new Complex( n ) );
View Full Code Here

Examples of jscicalc.OObject

     */
    protected void add( PObject p ){
  // FIXME: this is probably not quite right
  if( !(getApplet().getValue() instanceof OObject) )
      return;
  OObject value = getApplet().getValue();
  if( getApplet().getParser().isEmpty()
      && !(p instanceof Numeral)
      && !(p instanceof Variable)
      && !(p instanceof AFunction)
      && !(p instanceof RFunction)
View Full Code Here

Examples of jscicalc.OObject

    getApplet().requestFocusInWindow();
    return;
      }
      if( !getApplet().getParser().isEmpty() ){
    PObject p = getApplet().getParser().getLast();
    OObject o = getApplet().getValue();
    if( !(o instanceof jscicalc.Error) && ( p instanceof RFunction ||
              p instanceof DFunction ||
              p instanceof MFunction ||
              p instanceof AFunction ) ){
        Ans ans = new Ans();
        ans.setValue( o );
        getApplet().insert( ans );
        getApplet().updateDisplay( true, true );
    }
    getApplet().pushHistory();
    OObject value = getApplet().getParser()
        .evaluate( getApplet().getAngleType() );
    getApplet().setValue( value );
      }
      getApplet().setShift( false );
      getApplet().newExpression();
View Full Code Here

Examples of jscicalc.OObject

    getApplet().setMode( pobject );
    getApplet().requestFocusInWindow();
    return;
      }
      getApplet().pushHistory();
      OObject o = getApplet().getValue();
      if( !getApplet().getParser().isEmpty() ){
    //System.out.println( "__________" );
    PObject p = getApplet().getParser().getLast();
    if( o instanceof Complex && ( p instanceof RFunction ||
                p instanceof DFunction ||
View Full Code Here

Examples of jscicalc.OObject

    getApplet().setMode( pobject );
    getApplet().requestFocusInWindow();
    return;
      }
      getApplet().pushHistory();
      OObject o = getApplet().getValue();
      if( !getApplet().getParser().isEmpty() ){
    //System.out.println( "__________" );
    PObject p = getApplet().getParser().getLast();
    if( o instanceof Complex && ( p instanceof RFunction ||
                p instanceof DFunction ||
View Full Code Here

Examples of jscicalc.OObject

     * @param x The value to be substituted
     * @return A substitued object
     */
    protected OObject substitute( double x ){
  substitution.add( variable, new Complex( x ) );
  OObject result = oobject.substitute( substitution ).auto_simplify();
//   System.out.print( "Locus.substitute(): " );
//   final int maxLength = 120;
//   final int sigDigits = 32;
//   jscicalc.Base base = jscicalc.Base.DECIMAL;
//   jscicalc.Notation notation = new jscicalc.Notation();
View Full Code Here

Examples of jscicalc.OObject

     */
    protected double function( double x, Transformation t ){
  System.out.print( "[function( " );
  System.out.print( t.toModelX( x ) );
  System.out.print( " ) = " );
  OObject p = substitute( t.toModelX( x ) );
  if( p instanceof Complex ){
      Complex z = (Complex)p;
      if( Math.abs( z.imaginary() ) < epsilon ){
    double y = z.real();
    System.out.print( y );
View Full Code Here

Examples of jscicalc.OObject

    public OObject auto_simplify(){
  // first remove quotients
  for( java.util.ListIterator<Expression> i = divisorList.listIterator();
       i.hasNext(); ){
      Expression e = i.next();
      OObject o = new Power( e, new Complex( -1 ) ).auto_simplify();
      if( o instanceof Complex ){
    complex = complex.divide( (Complex)o );
      } else if( o instanceof Expression ){
    expressionList.add( (Expression)o );
      } else {
    return new jscicalc.Error( "Product.auto_simplify() error" );
      }
  }
  divisorList.clear();
  // simplify remaining expressions
  for( java.util.ListIterator<Expression> i = expressionList.listIterator();
       i.hasNext(); ){
      OObject o = i.next().auto_simplify();
      if( o instanceof Complex ){
    complex = complex.multiply( (Complex)o );
    i.remove();
      } else if( o instanceof Expression ){
    i.set( (Expression)o );
      } else {
    return new jscicalc.Error( "Product.auto_simplify() error" );
      }
  }
  sort();
  if( expressionList.isEmpty() ) return unBox(); // should be a Complex
  // now work through expressions in product
  java.util.ListIterator<Expression> i = expressionList.listIterator();
  Expression f = null; // initialise for loop
  for( Expression e = i.next(); i.hasNext(); e = f ){
      OObject base_e = e;
      OObject exponent_e = new Complex( 1 );
      if( e instanceof Power ){
    base_e = ((Power)e).base();
    exponent_e = ((Power)e).exponent();
      }
      f = i.next();
      OObject base_f = f;
      OObject exponent_f = new Complex( 1 );
      if( f instanceof Power ){
    base_f = ((Power)f).base();
    exponent_f = ((Power)f).exponent();
      }
      if( base_e.compareTo( base_f ) == 0 ){
    OObject exponent = exponent_e.add( exponent_f );
    if( exponent instanceof Expression )
        exponent = ((Expression)exponent).auto_simplify();
    OObject expression = new Power( base_e, exponent ).auto_simplify();
    if( expression instanceof Complex ){
        complex = complex.multiply( (Complex)expression );
        i.remove(); // remove f
        i.previous();
        i.remove(); // remove e
View Full Code Here

Examples of jscicalc.OObject

    public OObject substitute( jscicalc.Substitution substitution ){
  Product s = clone();
  for( java.util.ListIterator<Expression>
     i = s.expressionList.listIterator(); i.hasNext(); ){
      Expression expression = i.next();
      OObject o = expression.substitute( substitution );
      if( o instanceof Complex ){
    i.remove();
    s.complex = s.complex.multiply( (Complex)o );
      } else if( o instanceof Expression ) {
    i.set( (Expression)o );
      } else {
    return new jscicalc.Error( "Product.substitution() Error" );
      }
  }
  for( java.util.ListIterator<Expression> i = s.divisorList.listIterator();
       i.hasNext(); ){
      Expression expression = i.next();
      OObject o = expression.substitute( substitution );
      if( o instanceof Complex ){
    i.remove();
    s.complex = s.complex.divide( (Complex)o );
      } else if( o instanceof Expression ) {
    i.set( (Expression)o );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.