symcrys 0.10.1 → 0.12.0
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/README.md +6 -6
- package/dist/cell.d.ts +19 -16
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +63 -35
- package/dist/cell.js.map +1 -1
- package/dist/checks.d.ts +29 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +79 -0
- package/dist/checks.js.map +1 -0
- package/dist/closure.d.ts +43 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +201 -0
- package/dist/closure.js.map +1 -0
- package/dist/coordinates.d.ts +143 -0
- package/dist/coordinates.d.ts.map +1 -0
- package/dist/coordinates.js +198 -0
- package/dist/coordinates.js.map +1 -0
- package/dist/crystalClasses.d.ts +170 -117
- package/dist/crystalClasses.d.ts.map +1 -1
- package/dist/crystalClasses.js +190 -121
- package/dist/crystalClasses.js.map +1 -1
- package/dist/freeze.d.ts +7 -0
- package/dist/freeze.d.ts.map +1 -0
- package/dist/freeze.js +15 -0
- package/dist/freeze.js.map +1 -0
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/indices.d.ts +30 -20
- package/dist/indices.d.ts.map +1 -1
- package/dist/indices.js +101 -31
- package/dist/indices.js.map +1 -1
- package/dist/lattice.d.ts +15 -1
- package/dist/lattice.d.ts.map +1 -1
- package/dist/lattice.js +30 -1
- package/dist/lattice.js.map +1 -1
- package/dist/linalg.d.ts +2 -2
- package/dist/linalg.d.ts.map +1 -1
- package/dist/linalg.js +3 -3
- package/dist/linalg.js.map +1 -1
- package/dist/magnetic.d.ts +14 -10
- package/dist/magnetic.d.ts.map +1 -1
- package/dist/magnetic.js +10 -6
- package/dist/magnetic.js.map +1 -1
- package/dist/notation.d.ts +16 -0
- package/dist/notation.d.ts.map +1 -0
- package/dist/notation.js +66 -0
- package/dist/notation.js.map +1 -0
- package/dist/operations.d.ts +40 -26
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +48 -60
- package/dist/operations.js.map +1 -1
- package/dist/plane.d.ts +297 -80
- package/dist/plane.d.ts.map +1 -1
- package/dist/plane.js +289 -94
- package/dist/plane.js.map +1 -1
- package/dist/pointGroups/crystalForms.d.ts +6 -21
- package/dist/pointGroups/crystalForms.d.ts.map +1 -1
- package/dist/pointGroups/crystalForms.js +9 -16
- package/dist/pointGroups/crystalForms.js.map +1 -1
- package/dist/pointGroups/crystalFormsData.d.ts +4 -1
- package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
- package/dist/pointGroups/crystalFormsData.js +64 -1
- package/dist/pointGroups/crystalFormsData.js.map +1 -1
- package/dist/pointGroups/elements.d.ts +19 -17
- package/dist/pointGroups/elements.d.ts.map +1 -1
- package/dist/pointGroups/elements.js +65 -83
- package/dist/pointGroups/elements.js.map +1 -1
- package/dist/pointGroups/identify.d.ts +10 -18
- package/dist/pointGroups/identify.d.ts.map +1 -1
- package/dist/pointGroups/identify.js +27 -79
- package/dist/pointGroups/identify.js.map +1 -1
- package/dist/pointGroups/itaOrder.d.ts +15 -14
- package/dist/pointGroups/itaOrder.d.ts.map +1 -1
- package/dist/pointGroups/itaOrder.js +116 -94
- package/dist/pointGroups/itaOrder.js.map +1 -1
- package/dist/pointGroups/itcData.d.ts +96 -0
- package/dist/pointGroups/itcData.d.ts.map +1 -0
- package/dist/pointGroups/itcData.js +336 -0
- package/dist/pointGroups/itcData.js.map +1 -0
- package/dist/pointGroups/itcMagneticData.d.ts +55 -0
- package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
- package/dist/pointGroups/itcMagneticData.js +172 -0
- package/dist/pointGroups/itcMagneticData.js.map +1 -0
- package/dist/pointGroups/keys.d.ts +32 -0
- package/dist/pointGroups/keys.d.ts.map +1 -0
- package/dist/pointGroups/keys.js +120 -0
- package/dist/pointGroups/keys.js.map +1 -0
- package/dist/pointGroups/magneticSymbols.d.ts +6 -5
- package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
- package/dist/pointGroups/magneticSymbols.js +15 -12
- package/dist/pointGroups/magneticSymbols.js.map +1 -1
- package/dist/pointGroups/orbits.d.ts +23 -42
- package/dist/pointGroups/orbits.d.ts.map +1 -1
- package/dist/pointGroups/orbits.js +20 -62
- package/dist/pointGroups/orbits.js.map +1 -1
- package/dist/pointGroups/pointGroups.d.ts +145 -68
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +455 -243
- package/dist/pointGroups/pointGroups.js.map +1 -1
- package/dist/pointGroups/properties.d.ts +21 -22
- package/dist/pointGroups/properties.d.ts.map +1 -1
- package/dist/pointGroups/properties.js +40 -37
- package/dist/pointGroups/properties.js.map +1 -1
- package/dist/pointGroups/seitzData.d.ts +26 -0
- package/dist/pointGroups/seitzData.d.ts.map +1 -0
- package/dist/pointGroups/seitzData.js +130 -0
- package/dist/pointGroups/seitzData.js.map +1 -0
- package/dist/pointGroups/shubnikovData.d.ts +11 -0
- package/dist/pointGroups/shubnikovData.d.ts.map +1 -0
- package/dist/pointGroups/shubnikovData.js +101 -0
- package/dist/pointGroups/shubnikovData.js.map +1 -0
- package/dist/pointGroups/wyckoff.d.ts +70 -40
- package/dist/pointGroups/wyckoff.d.ts.map +1 -1
- package/dist/pointGroups/wyckoff.js +98 -91
- package/dist/pointGroups/wyckoff.js.map +1 -1
- package/dist/pointGroups/wyckoffData.d.ts +7 -4
- package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
- package/dist/pointGroups/wyckoffData.js +789 -168
- package/dist/pointGroups/wyckoffData.js.map +1 -1
- package/dist/siteSymmetry.d.ts +8 -16
- package/dist/siteSymmetry.d.ts.map +1 -1
- package/dist/siteSymmetry.js +34 -24
- package/dist/siteSymmetry.js.map +1 -1
- package/dist/spaceGroups/affine.d.ts.map +1 -1
- package/dist/spaceGroups/affine.js +3 -2
- package/dist/spaceGroups/affine.js.map +1 -1
- package/dist/spaceGroups/cell.d.ts +43 -31
- package/dist/spaceGroups/cell.d.ts.map +1 -1
- package/dist/spaceGroups/cell.js +173 -85
- package/dist/spaceGroups/cell.js.map +1 -1
- package/dist/spaceGroups/describe.d.ts +13 -10
- package/dist/spaceGroups/describe.d.ts.map +1 -1
- package/dist/spaceGroups/describe.js +11 -10
- package/dist/spaceGroups/describe.js.map +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts +3 -1
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroupData.js +25 -8
- package/dist/spaceGroups/planeGroupData.js.map +1 -1
- package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroups.js +2 -1
- package/dist/spaceGroups/planeGroups.js.map +1 -1
- package/dist/spaceGroups/planeLattice.d.ts +78 -0
- package/dist/spaceGroups/planeLattice.d.ts.map +1 -0
- package/dist/spaceGroups/planeLattice.js +143 -0
- package/dist/spaceGroups/planeLattice.js.map +1 -0
- package/dist/spaceGroups/planePointGroups.d.ts +6 -2
- package/dist/spaceGroups/planePointGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planePointGroups.js +14 -2
- package/dist/spaceGroups/planePointGroups.js.map +1 -1
- package/dist/spaceGroups/positions.d.ts +48 -19
- package/dist/spaceGroups/positions.d.ts.map +1 -1
- package/dist/spaceGroups/positions.js +166 -67
- package/dist/spaceGroups/positions.js.map +1 -1
- package/dist/spaceGroups/rational.d.ts +18 -0
- package/dist/spaceGroups/rational.d.ts.map +1 -1
- package/dist/spaceGroups/rational.js +58 -0
- package/dist/spaceGroups/rational.js.map +1 -1
- package/dist/tensors/propertyTable.d.ts +3 -1
- package/dist/tensors/propertyTable.d.ts.map +1 -1
- package/dist/tensors/propertyTable.js +17 -10
- package/dist/tensors/propertyTable.js.map +1 -1
- package/dist/tensors/rowEchelon.d.ts +3 -3
- package/dist/tensors/rowEchelon.d.ts.map +1 -1
- package/dist/tensors/rowEchelon.js +4 -4
- package/dist/tensors/rowEchelon.js.map +1 -1
- package/dist/tensors/tensorForm.d.ts +75 -34
- package/dist/tensors/tensorForm.d.ts.map +1 -1
- package/dist/tensors/tensorForm.js +171 -67
- package/dist/tensors/tensorForm.js.map +1 -1
- package/dist/tensors/tensorProperties.d.ts +10 -9
- package/dist/tensors/tensorProperties.d.ts.map +1 -1
- package/dist/tensors/tensorProperties.js +22 -12
- package/dist/tensors/tensorProperties.js.map +1 -1
- package/dist/tensors/voigt.d.ts +56 -0
- package/dist/tensors/voigt.d.ts.map +1 -0
- package/dist/tensors/voigt.js +188 -0
- package/dist/tensors/voigt.js.map +1 -0
- package/dist/tolerances.d.ts +56 -1
- package/dist/tolerances.d.ts.map +1 -1
- package/dist/tolerances.js +51 -1
- package/dist/tolerances.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/cell.ts +78 -51
- package/src/checks.ts +84 -0
- package/src/closure.ts +214 -0
- package/src/coordinates.ts +370 -0
- package/src/crystalClasses.ts +271 -157
- package/src/freeze.ts +14 -0
- package/src/index.ts +33 -12
- package/src/indices.ts +102 -42
- package/src/lattice.ts +41 -1
- package/src/linalg.ts +3 -3
- package/src/magnetic.ts +24 -11
- package/src/notation.ts +73 -0
- package/src/operations.ts +78 -71
- package/src/plane.ts +531 -151
- package/src/pointGroups/crystalForms.ts +11 -44
- package/src/pointGroups/crystalFormsData.ts +66 -1
- package/src/pointGroups/elements.ts +82 -92
- package/src/pointGroups/identify.ts +38 -97
- package/src/pointGroups/itaOrder.ts +117 -101
- package/src/pointGroups/itcData.ts +404 -0
- package/src/pointGroups/itcMagneticData.ts +206 -0
- package/src/pointGroups/keys.ts +144 -0
- package/src/pointGroups/magneticSymbols.ts +18 -17
- package/src/pointGroups/orbits.ts +41 -89
- package/src/pointGroups/pointGroups.ts +593 -298
- package/src/pointGroups/properties.ts +44 -40
- package/src/pointGroups/seitzData.ts +147 -0
- package/src/pointGroups/shubnikovData.ts +103 -0
- package/src/pointGroups/wyckoff.ts +137 -112
- package/src/pointGroups/wyckoffData.ts +793 -170
- package/src/siteSymmetry.ts +43 -40
- package/src/spaceGroups/affine.ts +3 -2
- package/src/spaceGroups/cell.ts +227 -116
- package/src/spaceGroups/describe.ts +23 -19
- package/src/spaceGroups/planeGroupData.ts +28 -9
- package/src/spaceGroups/planeGroups.ts +2 -1
- package/src/spaceGroups/planeLattice.ts +208 -0
- package/src/spaceGroups/planePointGroups.ts +23 -3
- package/src/spaceGroups/positions.ts +202 -78
- package/src/spaceGroups/rational.ts +59 -0
- package/src/tensors/propertyTable.ts +26 -14
- package/src/tensors/rowEchelon.ts +4 -3
- package/src/tensors/tensorForm.ts +258 -88
- package/src/tensors/tensorProperties.ts +34 -14
- package/src/tensors/voigt.ts +268 -0
- package/src/tolerances.ts +66 -1
- package/src/version.ts +1 -1
- package/dist/pointGroups/data.d.ts +0 -75
- package/dist/pointGroups/data.d.ts.map +0 -1
- package/dist/pointGroups/data.js +0 -212
- package/dist/pointGroups/data.js.map +0 -1
- package/dist/pointGroups/magneticData.d.ts +0 -66
- package/dist/pointGroups/magneticData.d.ts.map +0 -1
- package/dist/pointGroups/magneticData.js +0 -184
- package/dist/pointGroups/magneticData.js.map +0 -1
- package/dist/spaceGroups/snap.d.ts +0 -20
- package/dist/spaceGroups/snap.d.ts.map +0 -1
- package/dist/spaceGroups/snap.js +0 -103
- package/dist/spaceGroups/snap.js.map +0 -1
- package/src/pointGroups/data.ts +0 -305
- package/src/pointGroups/magneticData.ts +0 -328
- package/src/spaceGroups/snap.ts +0 -121
package/src/operations.ts
CHANGED
|
@@ -1,116 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Point operations:
|
|
3
|
-
*
|
|
2
|
+
* Point operations: the record the API gives (the matrix W in the lattice basis and the Cartesian
|
|
3
|
+
* matrix, with time reversal), the Cartesian operation the calculations work with, and the closure
|
|
4
|
+
* of a set of generators into a group.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
import {
|
|
7
|
+
import { shown } from './checks.js';
|
|
8
|
+
import { matricesEqual, multiply, snap, type Mat3 } from './linalg.js';
|
|
7
9
|
import { EPSILON } from './tolerances.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
|
-
* A point operation:
|
|
11
|
-
* combined with time reversal if `timeReversal` is true (a primed
|
|
12
|
+
* A point operation as the calculations use it: its orthogonal Cartesian matrix (rotation,
|
|
13
|
+
* rotoinversion, mirror, inversion), combined with time reversal if `timeReversal` is `true` (a primed
|
|
14
|
+
* operation). Every function that takes operations from a caller and computes with Cartesian
|
|
15
|
+
* matrices reads these two fields (`residualOperations` reads `matrix` instead), so an `Operation`
|
|
16
|
+
* of the API can be passed as it is.
|
|
12
17
|
*/
|
|
13
|
-
export interface
|
|
18
|
+
export interface CartesianOperation {
|
|
14
19
|
/** The orthogonal Cartesian 3×3 matrix, rows first. */
|
|
15
|
-
readonly
|
|
16
|
-
/**
|
|
20
|
+
readonly cartesian: Mat3;
|
|
21
|
+
/** `true` if the operation is combined with time reversal (a primed operation). */
|
|
17
22
|
readonly timeReversal: boolean;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* A point operation of a magnetic point group in a setting: ITA's matrix W in the lattice basis of
|
|
27
|
+
* the setting (`matrix`, integer, acting on the coordinates of a lattice direction [uvw]; the
|
|
28
|
+
* coordinate triplets of ITA's general position are its rows) and the same operation as an
|
|
29
|
+
* orthogonal Cartesian matrix (`cartesian`, R = B·W·B⁻¹ with the basis B of the setting), combined
|
|
30
|
+
* with time reversal if `timeReversal` is `true` (a primed operation). docs/conventions.md,
|
|
31
|
+
* "Operations".
|
|
32
|
+
*/
|
|
33
|
+
export interface Operation extends CartesianOperation {
|
|
34
|
+
/** ITA's matrix W in the lattice basis of the setting, integer, rows first. */
|
|
35
|
+
readonly matrix: Mat3;
|
|
36
|
+
}
|
|
24
37
|
|
|
25
38
|
/** A unitary operation (no time reversal). */
|
|
26
|
-
export function operation(
|
|
27
|
-
return {
|
|
39
|
+
export function operation(cartesian: Mat3): CartesianOperation {
|
|
40
|
+
return { cartesian, timeReversal: false };
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
/** Throws unless `m` is orthogonal (mᵀm = 1 within `EPSILON`): the code assumes Cartesian matrices. */
|
|
43
|
+
/** Throws unless `m` is orthogonal (mᵀm = 1 within `EPSILON` per entry): the code assumes Cartesian matrices. */
|
|
31
44
|
export function checkOrthogonal(m: Mat3, what: string): void {
|
|
32
|
-
|
|
33
|
-
for (let j = 0; j < 3; j++) {
|
|
34
|
-
const dot = m[0][i] * m[0][j] + m[1][i] * m[1][j] + m[2][i] * m[2][j];
|
|
35
|
-
// A comparison that is false for NaN, so that a matrix with NaN is refused as well.
|
|
36
|
-
if (!(Math.abs(dot - (i === j ? 1 : 0)) <= EPSILON)) {
|
|
37
|
-
throw new RangeError(`${what} is not an orthogonal (Cartesian) matrix: ${JSON.stringify(m)}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
45
|
+
checkOrthogonalWithin(m, what, EPSILON);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
/**
|
|
44
|
-
* Throws unless mᵀm = 1 within the tolerance
|
|
45
|
-
*
|
|
46
|
-
*
|
|
49
|
+
* Throws unless mᵀm = 1 within the tolerance per entry, at least `EPSILON`, so that a matrix with
|
|
50
|
+
* rounding errors (e.g. rounded to 4 decimals) passes with a larger tolerance and a smaller one is
|
|
51
|
+
* never stricter than the default. A comparison that is false for NaN refuses a matrix with NaN.
|
|
47
52
|
*/
|
|
48
53
|
export function checkOrthogonalWithin(m: Mat3, what: string, tolerance: number): void {
|
|
49
|
-
|
|
50
|
-
checkOrthogonal(m, what);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
54
|
+
const t = Math.max(tolerance, EPSILON);
|
|
53
55
|
for (let i = 0; i < 3; i++) {
|
|
54
56
|
for (let j = 0; j < 3; j++) {
|
|
55
57
|
const d = m[0][i] * m[0][j] + m[1][i] * m[1][j] + m[2][i] * m[2][j];
|
|
56
|
-
if (!(Math.abs(d - (i === j ? 1 : 0)) <
|
|
57
|
-
throw new RangeError(`${what} is not an orthogonal (Cartesian) matrix: ${
|
|
58
|
+
if (!(Math.abs(d - (i === j ? 1 : 0)) < t)) {
|
|
59
|
+
throw new RangeError(`${what} is not an orthogonal (Cartesian) matrix: ${shown(m)}`);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
/** True for a 3×3 array of numbers (not checked for finiteness; the orthogonality check refuses NaN). */
|
|
66
|
+
function isMatrix3(m: unknown): m is Mat3 {
|
|
67
|
+
return (
|
|
68
|
+
Array.isArray(m) &&
|
|
69
|
+
m.length === 3 &&
|
|
70
|
+
m.every((row) => Array.isArray(row) && row.length === 3 && row.every((v) => typeof v === 'number'))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Checks the operations a caller passes in to a function that computes with Cartesian matrices:
|
|
76
|
+
* each must have `cartesian`, an orthogonal 3×3 matrix (within `tolerance`, at least `EPSILON`). A
|
|
77
|
+
* record without it is refused, so that the lattice matrix `matrix` cannot pass for a Cartesian one
|
|
78
|
+
* (docs/conventions.md, "Operations").
|
|
79
|
+
*/
|
|
80
|
+
export function checkCartesianOperations(
|
|
81
|
+
operations: readonly { readonly cartesian: Mat3 }[],
|
|
82
|
+
tolerance = EPSILON,
|
|
83
|
+
): void {
|
|
84
|
+
if (!Array.isArray(operations)) throw new RangeError('The operations must be an array');
|
|
85
|
+
operations.forEach((op, i) => {
|
|
86
|
+
const cartesian = (op as { readonly cartesian?: unknown } | null)?.cartesian;
|
|
87
|
+
if (!isMatrix3(cartesian)) {
|
|
88
|
+
const hasMatrix = (op as { readonly matrix?: unknown } | null)?.matrix !== undefined;
|
|
89
|
+
throw new RangeError(
|
|
90
|
+
`Operation ${i} has no Cartesian matrix (field cartesian, a 3×3 array of numbers)` +
|
|
91
|
+
(hasMatrix
|
|
92
|
+
? '; its field matrix is the matrix W in the lattice basis since symcrys 0.11.0, so pass the operations as operations() gives them, or the Cartesian matrix as cartesian'
|
|
93
|
+
: ''),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
checkOrthogonalWithin(cartesian, `Operation ${i}`, tolerance);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
63
100
|
/**
|
|
64
101
|
* Checks operations that a caller passes in: each must say whether it is combined with time
|
|
65
102
|
* reversal. Without this, an operation that lacks `timeReversal` (as the crystallographic API
|
|
66
103
|
* returns them) would be composed as if it had it in every second product.
|
|
67
104
|
*/
|
|
68
|
-
export function checkTimeReversal(operations: readonly
|
|
105
|
+
export function checkTimeReversal(operations: readonly CartesianOperation[]): void {
|
|
106
|
+
if (!Array.isArray(operations)) throw new RangeError('The operations must be an array');
|
|
69
107
|
operations.forEach((op, i) => {
|
|
70
|
-
if (typeof op
|
|
108
|
+
if (typeof (op as Partial<CartesianOperation> | null)?.timeReversal !== 'boolean') {
|
|
71
109
|
throw new RangeError(
|
|
72
|
-
`Operation ${i}: timeReversal must be true or false, not ${
|
|
110
|
+
`Operation ${i}: timeReversal must be true or false, not ${shown((op as Partial<CartesianOperation> | null)?.timeReversal)}; an operation of the magnetic API says whether it is combined with time reversal`,
|
|
73
111
|
);
|
|
74
112
|
}
|
|
75
113
|
});
|
|
76
114
|
}
|
|
77
115
|
|
|
78
116
|
/** The product a·b: first b, then a. */
|
|
79
|
-
export function compose(a:
|
|
80
|
-
return {
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function operationsEqual(a: Operation, b: Operation): boolean {
|
|
84
|
-
return a.timeReversal === b.timeReversal && matricesEqual(a.matrix, b.matrix);
|
|
117
|
+
export function compose(a: CartesianOperation, b: CartesianOperation): CartesianOperation {
|
|
118
|
+
return { cartesian: snap(multiply(a.cartesian, b.cartesian)), timeReversal: a.timeReversal !== b.timeReversal };
|
|
85
119
|
}
|
|
86
120
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return { matrix: snap(conjugate(op.matrix, s)), timeReversal: op.timeReversal };
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* The group generated by `generators`: the identity first, then the generators, then products in
|
|
94
|
-
* the order they are found. The order of the result is therefore fixed by the generators.
|
|
95
|
-
* Throws if the closure exceeds the order of any point group (a sign of wrong input data).
|
|
96
|
-
*/
|
|
97
|
-
export function closeGroup(generators: readonly Operation[]): Operation[] {
|
|
98
|
-
const group: Operation[] = [IDENTITY_OPERATION];
|
|
99
|
-
const add = (op: Operation): boolean => {
|
|
100
|
-
if (group.some((g) => operationsEqual(g, op))) return false;
|
|
101
|
-
if (group.length >= MAX_GROUP_ORDER)
|
|
102
|
-
throw new RangeError(
|
|
103
|
-
`The operations generate no finite point group (more than ${MAX_GROUP_ORDER} elements): a rotation by an angle that is not 360°/n, or matrices too far from exact`,
|
|
104
|
-
);
|
|
105
|
-
group.push(op);
|
|
106
|
-
return true;
|
|
107
|
-
};
|
|
108
|
-
for (const g of generators) add({ matrix: snap(g.matrix), timeReversal: g.timeReversal });
|
|
109
|
-
for (let i = 0; i < group.length; i++) {
|
|
110
|
-
for (let j = 0; j <= i; j++) {
|
|
111
|
-
add(compose(group[i], group[j]));
|
|
112
|
-
add(compose(group[j], group[i]));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return group;
|
|
121
|
+
export function operationsEqual(a: CartesianOperation, b: CartesianOperation): boolean {
|
|
122
|
+
return a.timeReversal === b.timeReversal && matricesEqual(a.cartesian, b.cartesian);
|
|
116
123
|
}
|