mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #29028 from pavasich/master
[@types/complex] Include Complex.real & Complex.im on Complex instance
This commit is contained in:
@@ -1,42 +1,44 @@
|
||||
import Complex from 'complex';
|
||||
|
||||
var z: Complex = new Complex(2, 3);
|
||||
var z: Complex = Complex.from(2, 3);
|
||||
var z: Complex = Complex.from(2, 4);
|
||||
var z: Complex = Complex.from(5);
|
||||
var z: Complex = Complex.from('2+5i');
|
||||
var z: Complex = Complex.fromPolar(3, Math.PI);
|
||||
var z: Complex = Complex.i;
|
||||
var z: Complex = Complex.one;
|
||||
var z: Complex = z.fromRect(2, 3);
|
||||
var z: Complex = z.fromPolar(3, Math.PI);
|
||||
var z: Complex = z.toPrecision(3);
|
||||
var z: Complex = z.toFixed(3);
|
||||
var z: Complex = z.finalize();
|
||||
var x: number = z.magnitude();
|
||||
var x: number = z.abs();
|
||||
var x: number = z.angle();
|
||||
var x: number = z.arg();
|
||||
var x: number = z.phase();
|
||||
var z: Complex = z.conjugate();
|
||||
var z: Complex = z.negate();
|
||||
var z: Complex = z.multiply(z);
|
||||
var z: Complex = z.mult(3);
|
||||
var z: Complex = z.divide(z);
|
||||
var z: Complex = z.div(3);
|
||||
var z: Complex = z.add(z);
|
||||
var z: Complex = z.subtract(z);
|
||||
var z: Complex = z.sub(3);
|
||||
var z: Complex = z.pow(z);
|
||||
var z: Complex = z.sqrt();
|
||||
var z: Complex = z.log(2);
|
||||
var z: Complex = z.exp();
|
||||
var z: Complex = z.sin();
|
||||
var z: Complex = z.cos();
|
||||
var z: Complex = z.tan();
|
||||
var z: Complex = z.sinh();
|
||||
var z: Complex = z.cosh();
|
||||
var z: Complex = z.tanh();
|
||||
var z: Complex = z.clone();
|
||||
var s: string = z.toString();
|
||||
var b: boolean = z.equals(z);
|
||||
let z: Complex = new Complex(2, 3);
|
||||
z = Complex.from(2, 3);
|
||||
z = Complex.from(2, 4);
|
||||
z = Complex.from(5);
|
||||
z = Complex.from('2+5i');
|
||||
z = Complex.fromPolar(3, Math.PI);
|
||||
z = Complex.i;
|
||||
z = Complex.one;
|
||||
z = z.fromRect(2, 3);
|
||||
z = z.fromPolar(3, Math.PI);
|
||||
z = z.toPrecision(3);
|
||||
z = z.toFixed(3);
|
||||
z = z.finalize();
|
||||
let x: number = z.magnitude();
|
||||
x = z.abs();
|
||||
x = z.angle();
|
||||
x = z.arg();
|
||||
x = z.phase();
|
||||
z = z.conjugate();
|
||||
z = z.negate();
|
||||
z = z.multiply(z);
|
||||
z = z.mult(3);
|
||||
z = z.divide(z);
|
||||
z = z.div(3);
|
||||
z = z.add(z);
|
||||
z = z.subtract(z);
|
||||
z = z.sub(3);
|
||||
z = z.pow(z);
|
||||
z = z.sqrt();
|
||||
z = z.log(2);
|
||||
z = z.exp();
|
||||
z = z.sin();
|
||||
z = z.cos();
|
||||
z = z.tan();
|
||||
z = z.sinh();
|
||||
z = z.cosh();
|
||||
z = z.tanh();
|
||||
z = z.clone();
|
||||
const s: string = z.toString();
|
||||
const b: boolean = z.equals(z);
|
||||
const n: number = z.real;
|
||||
const i: number = z.im;
|
||||
|
||||
Vendored
+27
-9
@@ -1,6 +1,7 @@
|
||||
// Type definitions for Complex 3.0.1
|
||||
// Type definitions for Complex 3.0
|
||||
// Project: https://github.com/arian/Complex
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Paul Vasich <https://github.com/pavasich>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export default class Complex {
|
||||
@@ -46,6 +47,16 @@ export default class Complex {
|
||||
*/
|
||||
static one: Complex;
|
||||
|
||||
/**
|
||||
* The Complex number's real component
|
||||
*/
|
||||
real: number;
|
||||
|
||||
/**
|
||||
* The Complex number's imaginary component
|
||||
*/
|
||||
im: number;
|
||||
|
||||
/**
|
||||
* Set the real and imaginary properties a and b from a + bi.
|
||||
* @param real The real part of the number
|
||||
@@ -61,19 +72,25 @@ export default class Complex {
|
||||
fromPolar(r: number, phi: number): Complex;
|
||||
|
||||
/**
|
||||
* Set the precision of the numbers. Similar to Number.prototype.toPrecision. Useful before printing the number with the toString method.
|
||||
* Set the precision of the numbers. Similar to Number.prototype.toPrecision.
|
||||
* Useful before printing the number with the toString method.
|
||||
* @param k An integer specifying the number of significant digits
|
||||
*/
|
||||
toPrecision(k: number): Complex;
|
||||
|
||||
/**
|
||||
* Format a number using fixed-point notation. Similar to Number.prototype.toFixed. Useful before printing the number with the toString method.
|
||||
* @param k The number of digits to appear after the decimal point; this may be a value between 0 and 20, inclusive, and implementations may optionally support a larger range of values. If this argument is omitted, it is treated as 0.
|
||||
* Format a number using fixed-point notation. Similar to Number.prototype.toFixed.
|
||||
* Useful before printing the number with the toString method.
|
||||
* @param k The number of digits to appear after the decimal point [0 - 20].
|
||||
* Implementations may optionally support a larger range of values.
|
||||
* If this argument is omitted, it is treated as 0.
|
||||
*/
|
||||
toFixed(k: number): Complex;
|
||||
|
||||
/**
|
||||
* Finalize the instance. The number will not change and any other method call will return a new instance. Very useful when a complex instance should stay constant. For example the Complex.i variable is a finalized instance.
|
||||
* Finalize the instance. The number will not change and any other method call will return a new instance.
|
||||
* Very useful when a complex instance should stay constant.
|
||||
* For example the Complex.i variable is a finalized instance.
|
||||
*/
|
||||
finalize(): Complex;
|
||||
|
||||
@@ -167,7 +184,8 @@ export default class Complex {
|
||||
|
||||
/**
|
||||
* Return the natural logarithm (base E)
|
||||
* @param k The actual answer has a multiplicity (ln(z) = ln|z| + arg(z)) where arg(z) can return the same for different angles (every 2*pi), with this argument you can define which answer is required
|
||||
* @param k The actual answer has a multiplicity (ln(z) = ln|z| + arg(z)) where arg(z) can return the same for
|
||||
* different angles (every 2*pi), with this argument you can define which answer is required
|
||||
*/
|
||||
log(k?: number): Complex;
|
||||
|
||||
@@ -194,17 +212,17 @@ export default class Complex {
|
||||
/**
|
||||
* Calculate the hyperbolic sine of the complex number
|
||||
*/
|
||||
sinh(): Complex
|
||||
sinh(): Complex;
|
||||
|
||||
/**
|
||||
* Calculate the hyperbolic cosine of the complex number
|
||||
*/
|
||||
cosh(): Complex
|
||||
cosh(): Complex;
|
||||
|
||||
/**
|
||||
* Calculate the hyperbolic tangent of the complex number
|
||||
*/
|
||||
tanh(): Complex
|
||||
tanh(): Complex;
|
||||
|
||||
/**
|
||||
* Return a new Complex instance with the same real and imaginary properties
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"complex-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
Reference in New Issue
Block a user