Package jscicalc.complex

Examples of jscicalc.complex.Complex


  return statMemory.size() - statMemoryNeg.size();
    }

    public Mean statMean(){
  Mean mean = new Mean();
  Complex d = new Complex();
  for( Complex o : statMemory ){
      d = d.add( o );
  }
  for( Complex o : statMemoryNeg ){
      d = d.subtract( o );
  }
  if( statSize() > 0 ){
     mean.setValue( d.divide( new Complex( statSize(), 0 ) ) );
  } else {
      mean.setError( true );
   }
  return mean;
    }
View Full Code Here


   
    public Complex statSumSquares(){
  Mean m = statMean();
  if( m.error() || !(m.value() instanceof Complex) )
      throw new RuntimeException( "Stat Error" );
  Complex e = (Complex)(m.value());
  Complex d = new Complex();
  for( Complex o : statMemory ){
      Complex c = o.subtract( e );
      d = d.add( c.square() );
  }
  for( Complex o : statMemoryNeg ){
      Complex c = o.subtract( e );
      d = d.subtract( c.square() );
  }
  return d;
    }
View Full Code Here

    }

    public StDev statSampleStDev(){
  StDev stDev = new StDev();
  try {
      Complex d = statSumSquares();
      //if( d < 0 || statSize() < 2 ){
      if( statSize() < 2 ){
    stDev.setError( true );
    return stDev;
      } else {
    stDev.setValue( d.divide( new Complex( statSize() - 1, 0 ) ).sqrt() );
    return stDev;
      }
  } catch( Exception e ){
      stDev.setError( true );
      return stDev;
View Full Code Here

    }

    public PopStDev statPopulationStDev(){
  PopStDev stDev = new PopStDev();
  try {
      Complex d = statSumSquares();
      //if( d < 0 || statSize() < 1 ){
      if( statSize() < 1 ){
    stDev.setError( true );
    return stDev;
      } else {
    stDev.setValue( d.divide( new Complex( statSize(), 0 ) ).sqrt() );
    return stDev;
      }
  } catch( Exception e ){
      stDev.setError( true );
      return stDev;
View Full Code Here

  if( (expression1 instanceof jscicalc.Error) ||
      (expression2 instanceof jscicalc.Error) ){
      return new jscicalc.Error( "Power error" );
  }
  if( expression1 instanceof Complex ){
      Complex v = (Complex)expression1;
      if( expression2 instanceof Complex ){
    Complex w = (Complex)expression2;
    return v.pow( w ); // Complex power of Complex
      }
      Long l = v.isInteger();
      if( l != null ){
    long i = l;
    if( i == 0 ){
        return new jscicalc.Error( "Power error" );
    } else if( i == 1 ){
        return new Complex( 1 );
    } else {
        // integer expression1 as i
    }
      }
  }
  if( expression2 instanceof Complex ){
      Complex w = (Complex)expression2;
      Long m = w.isInteger();
      if( m != null ){
    long n = m;
    // An integer power.
    // 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 ) );
        } else
      return new jscicalc.Error( "Power error" );
        return new Power( q.expression1, o );
    } else if( expression1 instanceof Product ){
        Product p =(Product)expression1;
View Full Code Here

     */
    public void copy(){
  Object value = calculatorApplet.getValue();
  if( !(value instanceof Complex ) )
      return;
  Complex d = (Complex)value;
  /* get values from CalculatorApplet */
  Base base = calculatorApplet.getBase();
  Notation notation = new Notation();
  double factor = 1;
  if( calculatorApplet.getAngleType() == AngleType.DEGREES )
      factor = 1;//180 / StrictMath.PI;
  String string = d.toHTMLString( maxLength, sigDigits, base, notation, factor );
  /* String now needs formatting */
  java.util.regex.Matcher matcher = html.matcher( string );
  string = matcher.replaceAll( "" );
  matcher = htmlend.matcher( string );
  string = matcher.replaceAll( "" );
View Full Code Here

      if( o instanceof PObject ){
    PObject p = (PObject)o;
    for( String s : p.name_array() )
        c.add( s );
      } else if( o instanceof Complex ){
    Complex z = (Complex)o;
    String s = Double.toString( z.real() )
        + "+i" + Double.toString( z.imaginary() );
    c.add( s );
      } else ifo instanceof Double ){
    Double d = (Double)o;
    c.add( d.toString() );
      }
View Full Code Here

     * Calculate the inverse.
     * @return The result of the operation
     */
    public OObject inverse(){
  if( this instanceof Expression ){
      return new jscicalc.expression.Power( (Expression)this, new Complex( -1 ) );
  }
  return new Error( "OObject inverse( x ) error" );
    }
View Full Code Here

     * Calculate the square.
     * @return The result of the operation
     */
    public OObject square(){
  if( this instanceof Expression ){
      return new jscicalc.expression.Power( (Expression)this, new Complex( 2 ) );
  }
  return new Error( "OObject square( x ) error" );
    }
View Full Code Here

     * Calculate the cube.
     * @return The result of the operation
     */
    public OObject cube(){
  if( this instanceof Expression ){
      return new jscicalc.expression.Power( (Expression)this, new Complex( 3 ) );
  }
  return new Error( "OObject cube( x ) error" );
    }
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.