ootk 4.0.0-1 → 4.0.0-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,15 @@
3
3
  This is an automatic changelog that automatically records all changes made to the project. Generated from Git commit
4
4
  messages, it details updates like bug fixes and new features, providing a clear history of the project's development.
5
5
 
6
- #### [4.0.0-1](https://github.com/thkruz/ootk/compare/v4.0.0-0...4.0.0-1)
6
+ #### [4.0.0-2](https://github.com/thkruz/ootk/compare/v4.0.0-1...4.0.0-2)
7
+
8
+ - refactor: :recycle: move derivative from ootk-core [`9a9b50d`](https://github.com/thkruz/ootk/commit/9a9b50d4402b24398d920ae4ef0a76a7d19edabf)
9
+ - build: :arrow_up: bump ootk-core [`efc4aa0`](https://github.com/thkruz/ootk/commit/efc4aa0caf7182afd9fbba7e29a50a8defd16ebe)
10
+ - test: :white_check_mark: update snapshots [`ca95ad6`](https://github.com/thkruz/ootk/commit/ca95ad65be2de3f818390585a7bc1749ca7bf918)
11
+
12
+ #### [v4.0.0-1](https://github.com/thkruz/ootk/compare/v4.0.0-0...v4.0.0-1)
13
+
14
+ > 17 January 2024
7
15
 
8
16
  - feat: :sparkles: integrate ootk-core v1.0.7 [`101eeb6`](https://github.com/thkruz/ootk/commit/101eeb6a21008ce198832818154fa0442691e4ad)
9
17
  - refactor: :recycle: refactor to match latest ootk-core [`ae37922`](https://github.com/thkruz/ootk/commit/ae3792283571c69ff0d6406188d0c7219215c56f)
@@ -0,0 +1,8 @@
1
+ import { DifferentiableFunction } from '../main';
2
+ /**
3
+ * Calculates the derivative of a differentiable function.
4
+ * @param f The differentiable function.
5
+ * @param h The step size for numerical differentiation. Default value is 1e-3.
6
+ * @returns The derivative function.
7
+ */
8
+ export declare function derivative(f: DifferentiableFunction, h?: number): DifferentiableFunction;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Calculates the derivative of a differentiable function.
3
+ * @param f The differentiable function.
4
+ * @param h The step size for numerical differentiation. Default value is 1e-3.
5
+ * @returns The derivative function.
6
+ */
7
+ export function derivative(f, h = 1e-3) {
8
+ /**
9
+ * @param x The value at which to calculate the derivative.
10
+ * @returns The derivative of the function at the given value.
11
+ */
12
+ function df(x) {
13
+ const hh = h * 0.5;
14
+ return (f(x + hh) - f(x - hh)) / h;
15
+ }
16
+ return df;
17
+ }
18
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/utils/functions.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAAyB,EAAE,CAAC,GAAG,IAAI;IAC5D;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAS;QACnB,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;QAEnB,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './jacobian';
2
+ export * from './functions';
@@ -1,2 +1,3 @@
1
1
  export * from './jacobian';
2
+ export * from './functions';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -8,4 +8,4 @@ import { JacobianFunction } from '../types/types';
8
8
  * @param step The step size for numerical differentiation (default: 1e-5).
9
9
  * @returns The Jacobian matrix.
10
10
  */
11
- export declare function jacobian(f: JacobianFunction, m: number, x0: Float64Array, step?: number): Matrix;
11
+ export declare const jacobian: (f: JacobianFunction, m: number, x0: Float64Array, step?: number) => Matrix;
@@ -8,7 +8,7 @@ import { array2d, Matrix, Vector } from 'ootk-core';
8
8
  * @param step The step size for numerical differentiation (default: 1e-5).
9
9
  * @returns The Jacobian matrix.
10
10
  */
11
- export function jacobian(f, m, x0, step = 0.00001) {
11
+ export const jacobian = (f, m, x0, step = 0.00001) => {
12
12
  const n = x0.length;
13
13
  const j = array2d(m, n, 0);
14
14
  const h = 0.5 * step;
@@ -25,5 +25,5 @@ export function jacobian(f, m, x0, step = 0.00001) {
25
25
  }
26
26
  }
27
27
  return new Matrix(j);
28
- }
28
+ };
29
29
  //# sourceMappingURL=jacobian.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jacobian.js","sourceRoot":"","sources":["../../src/utils/jacobian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGpD,uDAAuD;AAEvD;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAmB,EAAE,CAAS,EAAE,EAAgB,EAAE,IAAI,GAAG,OAAO;IACvF,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACpB,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;QAEtB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACX,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7B,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;QAEtB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,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E,CAAC;QAEtB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACX,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7B,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC1B;KACF;IAED,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ootk",
3
- "version": "4.0.0-1",
3
+ "version": "4.0.0-2",
4
4
  "type": "module",
5
5
  "module": "dist/main.js",
6
6
  "description": "Orbital Object Toolkit including Multiple Propagators, Initial Orbit Determination, and Maneuver Calculations.",
@@ -53,7 +53,7 @@
53
53
  "typescript": "^4.9.5"
54
54
  },
55
55
  "dependencies": {
56
- "ootk-core": "^1.0.7"
56
+ "ootk-core": "^1.0.8"
57
57
  },
58
58
  "homepage": "https://github.com/thkruz/ootk"
59
59
  }
@@ -0,0 +1,21 @@
1
+ import { DifferentiableFunction } from '../main';
2
+
3
+ /**
4
+ * Calculates the derivative of a differentiable function.
5
+ * @param f The differentiable function.
6
+ * @param h The step size for numerical differentiation. Default value is 1e-3.
7
+ * @returns The derivative function.
8
+ */
9
+ export function derivative(f: DifferentiableFunction, h = 1e-3): DifferentiableFunction {
10
+ /**
11
+ * @param x The value at which to calculate the derivative.
12
+ * @returns The derivative of the function at the given value.
13
+ */
14
+ function df(x: number): number {
15
+ const hh = h * 0.5;
16
+
17
+ return (f(x + hh) - f(x - hh)) / h;
18
+ }
19
+
20
+ return df;
21
+ }
@@ -1 +1,2 @@
1
1
  export * from './jacobian';
2
+ export * from './functions';
@@ -11,7 +11,7 @@ import { JacobianFunction } from '../types/types';
11
11
  * @param step The step size for numerical differentiation (default: 1e-5).
12
12
  * @returns The Jacobian matrix.
13
13
  */
14
- export function jacobian(f: JacobianFunction, m: number, x0: Float64Array, step = 0.00001): Matrix {
14
+ export const jacobian = (f: JacobianFunction, m: number, x0: Float64Array, step = 0.00001): Matrix => {
15
15
  const n = x0.length;
16
16
  const j = array2d(m, n, 0);
17
17
  const h = 0.5 * step;
@@ -35,4 +35,4 @@ export function jacobian(f: JacobianFunction, m: number, x0: Float64Array, step
35
35
  }
36
36
 
37
37
  return new Matrix(j);
38
- }
38
+ };