return new Error( "OObject add( x ) error" );
else if( this instanceof Complex ){
if( x instanceof Complex ){
return ((Complex)this).add( (Complex)x );
} else if( x instanceof Variable ){
Sum s = new Sum( (Variable)x );
return s.add( (Complex)this );
} else if( x instanceof Sum ){
return ((Sum)x).add( (Complex)this );
} else if( x instanceof Product ){
Sum s = new Sum( (Product)x );
return s.add( (Complex)this );
} else if( x instanceof Expression ){
Sum s = new Sum( (Expression)x );
return s.add( (Complex)this );
}
} else if( this instanceof Variable ){
if( x instanceof Complex ){
Sum s = new Sum( (Variable)this );
return s.add( (Complex)x );
} else if( x instanceof Variable ){
Sum s = new Sum( (Variable)this );
return s.add( x );
} else if( x instanceof Sum ){
Sum s = new Sum( (Variable)this );
return s.add( (Sum)x );
} else if( x instanceof Product ){
Sum s = new Sum( (Variable)this );
return s.add( (Product)x );
} else if( x instanceof Expression ){
Sum s = new Sum( (Variable)this );
return s.add( new Product( (Expression)x, false ) );
}
} else if( this instanceof Sum ){
if( x instanceof Complex ){
return ((Sum)this).add( (Complex)x );
} else if( x instanceof Variable ){
Product s = new Product( (Variable)x, false );
return ((Sum)this).add( s );
} else if( x instanceof Product ){
return ((Sum)this).add( (Product)x );
} else if( x instanceof Sum ){
return ((Sum)this).add( (Sum)x );
} else if( x instanceof Expression ){
return ((Sum)this).add( new Product( (Expression)x, false ) );
}
} else if( this instanceof Product ){
if( x instanceof Complex ){
Sum s = new Sum( (Product)this );
return s.add( (Complex)x );
} else if( x instanceof Variable ){
Sum s = new Sum( (Product)this );
Product p = new Product( (Variable)x, false );
return s.add( p );
} else if( x instanceof Sum ){
Sum s = new Sum( (Product)this );
return s.add( (Sum)x );
} else if( x instanceof Product ){
Sum s = new Sum( (Product)this );
return s.add( (Product)x );
} else if( x instanceof Expression ){
Sum s = new Sum( (Product)this );
return s.add( new Product( (Expression)x, false ) );
}
} else if( this instanceof Expression ){
Sum s = new Sum( new Product( (Expression)this, false ) );
if( x instanceof Complex ){
return s.add( (Complex)x );
} else if( x instanceof Sum ){
return s.add( (Sum)x );
} else if( x instanceof Product ){
return s.add( (Product)x );
} else if( x instanceof Expression ){
return s.add( new Product( (Expression)x, false ) );
}
}
// default
return new Error( "OObject add( x ) error" );
}