- Timestamp:
- 08/14/10 06:43:05 (3 years ago)
- Files:
-
- 1 modified
-
lang/javascript/math-complex/trunk/complex.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/math-complex/trunk/complex.js
r38266 r38267 1 1 /* 2 * $Id: complex.js,v 0. 5 2010/08/13 19:59:24dankogai Exp dankogai $2 * $Id: complex.js,v 0.6 2010/08/13 21:39:40 dankogai Exp dankogai $ 3 3 */ 4 4 … … 6 6 if (Math.Complex) return; 7 7 Math.Complex = function(re, im){ 8 this.re = re ? re : 0;9 this.im = im ? im : 0;8 this.re = re ? re : 0; 9 this.im = im ? im : 0; 10 10 }; 11 11 Math.Complex.prototype = { … … 52 52 if (that.constructor === this.constructor){ 53 53 var d = that.re * that.re + that.im * that.im; 54 if (d === 0) return new Math.Complex(this.re/0, this.im/0);54 if (d === 0) return new Math.Complex(this.re/0, this.im/0); 55 55 return new Math.Complex( 56 56 (this.re * that.re + this.im * that.im) / d, … … 59 59 }else{ 60 60 return new Math.Complex( 61 this.re / (that*1), this.im / (that*1)62 );61 this.re / (that*1), this.im / (that*1) 62 ); 63 63 } 64 64 }, … … 66 66 var abs = Math.exp(this.re); 67 67 var arg = this.im; 68 return new Math.Complex(abs*Math.cos(arg), abs*Math.sin(arg));68 return new Math.Complex(abs*Math.cos(arg), abs*Math.sin(arg)); 69 69 }, 70 70 log:function(){ … … 94 94 } 95 95 }, 96 ne:function(that){97 return ! this.eq(that);98 }96 ne:function(that){ 97 return ! this.eq(that); 98 } 99 99 }; 100 100 /* functions exported for convenience */
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)