Skip to content

Commit 1f9f62b

Browse files
Added real operator counterparts and converted javascript to strict mode
1 parent bb793e5 commit 1f9f62b

File tree

3 files changed

+328
-121
lines changed

3 files changed

+328
-121
lines changed

README.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ they must be called by an instance of `Complex`. For example, to raise
6161
1+5i to the power of 3 e^((2/3)pi i), do the following:
6262

6363
```js
64-
console.log(Complex(1,5).cPow(Complex.Polar(3,2/3*Math.PI)));
64+
console.log(Complex(1,5).pow(Complex.Polar(3,2/3*Math.PI)));
6565
```
6666

67-
Notice how `cPow` is a method of a `Complex` instance, and not of the
67+
Notice how `pow` is a method of a `Complex` instance, and not of the
6868
namespace Complex. That's because it is an operator rather than a
6969
function. Non-static methods are denoted as
7070
`Complex.prototype.nonStaticMethod`.
@@ -153,7 +153,7 @@ input.addEventListener('change', function(){
153153
//if the parser throws an error, clear outputs and alert error
154154
cart.innerHTML = "";
155155
expo.innerHTML = "";
156-
alert(error);
156+
alert(error.message);
157157
}
158158
});
159159
```
@@ -211,13 +211,18 @@ console.log(Complex(5,1).equals(five_plus_i));
211211
* [`im`](#p-im)
212212
* [`abs`](#p-abs)
213213
* [`arg`](#p-arg)
214+
* [`rAdd`](#r-add)
214215
* [`add`](#add)
216+
* [`rSub`](#r-sub)
215217
* [`sub`](#sub)
218+
* [`rMult`](#r-mult)
216219
* [`mult`](#mult)
220+
* [`rDivBy`](#r-div-by)
217221
* [`divBy`](#div-by)
222+
* [`rMod`](#r-mod)
218223
* [`mod`](#mod)
224+
* [`rPow`](#r-pow)
219225
* [`pow`](#pow)
220-
* [`cPow`](#c-pow)
221226

222227
### [Static Methods](#static)
223228

@@ -266,7 +271,7 @@ console.log(Complex(5,1).equals(five_plus_i));
266271
* [`arccsch`](#arccsch)
267272
* [`arccoth`](#arccoth)
268273

269-
### [Misc. Static Methods](#misc)
274+
### [Misc. Methods](#misc)
270275

271276
* [`min`](#min)
272277
* [`max`](#max)
@@ -403,6 +408,16 @@ Returns the magnitude as a `Number`.
403408
Returns the argument as a `Number`.
404409

405410

411+
<a name="r-add"></a>
412+
### Complex.prototype.rAdd(real)
413+
414+
Adds a Complex number and a `Number`.
415+
416+
__Arguments__
417+
418+
* `real` - A `Number` to add.
419+
420+
406421
<a name="add"></a>
407422
### Complex.prototype.add(complex)
408423

@@ -413,6 +428,16 @@ __Arguments__
413428
* `complex` - An instance of the `Complex` class to add.
414429

415430

431+
<a name="r-sub"></a>
432+
### Complex.prototype.rSub(real)
433+
434+
Subtracts a `Number` from a Complex number.
435+
436+
__Arguments__
437+
438+
* `real` - A `Number` to subtract.
439+
440+
416441
<a name="sub"></a>
417442
### Complex.prototype.sub(complex)
418443

@@ -423,6 +448,16 @@ __Arguments__
423448
* `complex` - An instance of the `Complex` class to subtract.
424449

425450

451+
<a name="r-mult"></a>
452+
### Complex.prototype.rMult(real)
453+
454+
Multiplies a Complex number and a `Number`.
455+
456+
__Arguments__
457+
458+
* `real` - A `Number` to multiply.
459+
460+
426461
<a name="mult"></a>
427462
### Complex.prototype.mult(complex)
428463

@@ -433,16 +468,36 @@ __Arguments__
433468
* `complex` - An instance of the `Complex` class to multiply.
434469

435470

471+
<a name="r-div-by"></a>
472+
### Complex.prototype.rDivBy(real)
473+
474+
Divides a Complex number by a `Number`.
475+
476+
__Arguments__
477+
478+
* `real` - A `Number` by which to divide.
479+
480+
436481
<a name="div-by"></a>
437482
### Complex.prototype.divBy(complex)
438483

439-
Divides a Complex number from another.
484+
Divides a Complex number by another.
440485

441486
__Arguments__
442487

443488
* `complex` - An instance of the `Complex` class by which to divide.
444489

445490

491+
<a name="r-mod"></a>
492+
### Complex.prototype.rMod(real)
493+
494+
Applies a Real Modulus to a Complex number by cartesian coordinates.
495+
496+
__Arguments__
497+
498+
* `real` - A `Number` to for the modulus.
499+
500+
446501
<a name="mod"></a>
447502
### Complex.prototype.mod(complex)
448503

@@ -453,25 +508,26 @@ __Arguments__
453508
* `complex` - An instance of the `Complex` class for the modulus.
454509

455510

456-
<a name="pow"></a>
457-
### Complex.prototype.pow(number)
511+
<a name="r-pow"></a>
512+
### Complex.prototype.rPow(real)
458513

459-
Raises a Complex number to a real power.
514+
Raises a Complex number to a Real power.
460515

461516
__Arguments__
462517

463-
* `number` - A `Number` to which to raise the Complex number.
518+
* `real` - A `Number` by which to raise.
464519

465520

466-
<a name="c-pow"></a>
467-
### Complex.prototype.cPow(complex)
521+
<a name="pow"></a>
522+
### Complex.prototype.pow(complex)
468523

469524
Raises a Complex number to a Complex power.
470525

471526
__Arguments__
472527

473528
* `complex` - An instance of the `Complex` class by which to raise.
474529

530+
475531
<a name="static"></a>
476532
## Static Methods
477533

0 commit comments

Comments
 (0)