API Docs for: 1.0.0
Show:

File: src/gallery-mathcanvas/js/RealPart.js

  1. /**
  2. * @module gallery-mathcanvas
  3. */
  4.  
  5. /**********************************************************************
  6. * <p>Real part of a complex number.</p>
  7. *
  8. * @namespace MathFunction
  9. * @class RealPart
  10. * @extends MathFunction.FunctionWithArgs
  11. * @constructor
  12. * @param f {MathFunction}
  13. */
  14.  
  15. function MathRealPart(
  16. /* MathFunction */ f)
  17. {
  18. MathRealPart.superclass.constructor.call(this, MathRealPart.NAME, f);
  19. }
  20.  
  21. MathRealPart.NAME = 're';
  22.  
  23. Y.extend(MathRealPart, MathFunctionWithArgs,
  24. {
  25. /**
  26. * @method evaluate
  27. * @param var_list {Object} map of variable names to values or MathFunctions
  28. * @return the value of the function
  29. */
  30. evaluate: function(
  31. /* map */ var_list)
  32. {
  33. var value = this.args[0].evaluate(var_list);
  34. return Y.ComplexMath.isComplexNumber(value) ? value.real() : value;
  35. }
  36. });
  37.  
  38. MathFunction.RealPart = MathRealPart;
  39.  
  40. MathFunction.name_map[ MathRealPart.NAME ] =
  41. {
  42. applyTo: function(f)
  43. {
  44. return new MathRealPart(f);
  45. }
  46. };
  47.