Package jscicalc.complex

Examples of jscicalc.complex.Complex


     * @param x The first value (left of symbol)
     * @param y The second value (right of symbol)
     * @return The result of the operation
     */
    public OObject function( OObject x, OObject y ){
  return x.multiply( (y.multiply( (new Complex( base, 0 )).log()) ).exp() );
    }
View Full Code Here


      System.out.println( "length: " + i + " precision: " + d.precision( i )  );
      System.out.println( "length: " + i + " scientific precision: "
        + d.scientificPrecision( i )  );
  }
  */
  Complex c = new Complex( 4, 5 );
  Format f = new Format( c, Base.DECIMAL );
  System.out.println( "--------------------" );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 0, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 0, 1 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 1, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 0.002, -1 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( "--------------------" );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( -1, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( -12, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 123, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 1234, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 5, 20, true, true ) );
  c = new Complex( 12345, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 123456, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234567, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 12345678, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 123456789, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234567891.0, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 12345678912.0, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 123456789123.0, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234567891234.0, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 12345678912345.0, 0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234.0, -4321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234.0, -4321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 12345.0, -54321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 123456.0, -654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234567.0, -7654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 12345678.0, -87654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 123456789.0, -987654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 234567891.0, -1987654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234567891.0, -987654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
  c = new Complex( 1234567891.0, -1987654321.0 );
  f = new Format( c, Base.DECIMAL );
  System.out.println( f.formatStandard( Base.DECIMAL, 9, 20, true, true ) );
    }
View Full Code Here

     * @param x The value (right of symbol)
     * @return The result of the operation
     */
    public OObject function( OObject x ){
  if( x instanceof Complex ){
      Complex c = (Complex)x;
      if( scale != 1 && Math.abs( c.imaginary() ) > 1e-6 )
    throw new RuntimeException( "Error" );
      return c.scale( scale ).sin();
  } else {
      return x.sin( angleType );
  }
    }
View Full Code Here

    getApplet().setMode( 0 );
    getApplet().setShift( false );
      }
      getApplet().setOn( true );
      getApplet().clear();
      getApplet().setValue( new Complex( 0 ) );
      getApplet().updateDisplay( true, true );
      getApplet().requestFocusInWindow();
  }
    }
View Full Code Here

     * @param x The value (right of symbol)
     * @return The result of the operation
     */
    public OObject function( OObject x ){
  if( x instanceof Complex ){
      Complex c = (Complex)x;
      if( scale != 1 && StrictMath.abs( c.imaginary() ) > 1e-6 )
    throw new RuntimeException( "Error" );
      return c.scale( scale ).cos();
  } else {
      return x.cos( angleType );
  }
    }
View Full Code Here

     * @param x The value (right of symbol)
     * @return The result of the operation
     */
    public OObject function( OObject x ){
  if( x instanceof Complex ){
      Complex c = (Complex)x;
      if( scale != 1 && StrictMath.abs( c.imaginary() ) > 1e-6 )
    throw new RuntimeException( "Error" );
      return c.scale( scale ).tan();
  } else {
      return x.tan( angleType );
  }
    }
View Full Code Here

  /* intitially no attached component  and no graph */
  setTextComponent( null );
  graph = null;

  /* set initial value */
  setValue( new Complex() );

  /* set initial sizes */
  setSizes();
 
  /* set initial state */
  parser = new Parser();
  shift = false;
  angleType = AngleType.DEGREES;
  mode = 0;
  stat = false;
  notation = new Notation(); // set default of standard, rectangular, non-complex
  memory = new Complex();
  statMemory = new java.util.Vector<Complex>();
  statMemoryNeg = new java.util.Vector<Complex>();

  //listen for key presses
  addKeyListener( this );
  setFocusable( true );

        getContentPane().removeAll();
 
  /* set up initial objects */
  displayPanel = new DisplayPanel( this );
  displayPanel
      .setBorder( new javax.swing.border
      .BevelBorder( javax.swing.border.BevelBorder.LOWERED ) );
  setPanels();

  /* create a DataTransfer so we can copy to system clipboard */
  /* this code does not actually work -- I don't know why */
  dataTransfer = new DataTransfer( this );
  calculatorPanel.getInputMap()
      .put( javax.swing.KeyStroke
      .getKeyStroke( java.awt.event.KeyEvent.VK_COPY, 0), "copy" );
  calculatorPanel.getInputMap()
      .put( javax.swing.KeyStroke
      .getKeyStroke( java.awt.event.KeyEvent.VK_C,
         java.awt.event.ActionEvent.CTRL_MASK |
         java.awt.event.ActionEvent.SHIFT_MASK, false  ),
      "copy" );
  calculatorPanel.getActionMap().put( "copy", dataTransfer );
  dataTransfer.setEnabled( true );
 
  //set up history
 
  setBase( Base.DECIMAL );
  history = new java.util.Vector<HistoryItem>();
  tempParserList
      = new HistoryItem( null, getAngleType(), getBase(), getNotation() );
  historyPosition = -1;
  shiftDown = false;
  setOn( true );
  setValue( new Complex( 0 ) );
  updateDisplay( true, true );
  requestFocusInWindow();
    }
View Full Code Here

  if( historyPosition >= history.size() - 1 ) return;
  // save old buffer
  if( historyPosition == -1 ){
      // if error shown clear it.
      if( getValue() instanceof jscicalc.Error )
    setValue( new Complex() );
      // copy to temporary buffer
      tempParserList.list = parser.getList();
      tempParserList.angleType = getAngleType();
      tempParserList.base = getBase();
      tempParserList.notation = getNotation();
View Full Code Here

     * @param d The Complex to put into memory
     * @return The number of objects in statistical memory.
     */
    public Complex statAdd( Complex d ){
  statMemory.add( d );
  return new Complex( statSize() );
    }
View Full Code Here

     * @return The number of objects in statistcal memory.
     * @see #statAdd( Complex )
     */
    public Complex statSub( Complex d ){
  statMemoryNeg.add( d );
  return new Complex( statSize() );
    }
View Full Code Here

TOP

Related Classes of jscicalc.complex.Complex

Copyright © 2018 www.massapicom. 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.