symcrys 0.10.1 → 0.11.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.
Files changed (218) hide show
  1. package/README.md +6 -6
  2. package/dist/cell.d.ts +19 -16
  3. package/dist/cell.d.ts.map +1 -1
  4. package/dist/cell.js +63 -35
  5. package/dist/cell.js.map +1 -1
  6. package/dist/checks.d.ts +29 -0
  7. package/dist/checks.d.ts.map +1 -0
  8. package/dist/checks.js +79 -0
  9. package/dist/checks.js.map +1 -0
  10. package/dist/closure.d.ts +43 -0
  11. package/dist/closure.d.ts.map +1 -0
  12. package/dist/closure.js +201 -0
  13. package/dist/closure.js.map +1 -0
  14. package/dist/crystalClasses.d.ts +145 -117
  15. package/dist/crystalClasses.d.ts.map +1 -1
  16. package/dist/crystalClasses.js +161 -121
  17. package/dist/crystalClasses.js.map +1 -1
  18. package/dist/freeze.d.ts +7 -0
  19. package/dist/freeze.d.ts.map +1 -0
  20. package/dist/freeze.js +15 -0
  21. package/dist/freeze.js.map +1 -0
  22. package/dist/index.d.ts +11 -10
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/indices.d.ts +31 -5
  27. package/dist/indices.d.ts.map +1 -1
  28. package/dist/indices.js +104 -13
  29. package/dist/indices.js.map +1 -1
  30. package/dist/lattice.d.ts +15 -1
  31. package/dist/lattice.d.ts.map +1 -1
  32. package/dist/lattice.js +30 -1
  33. package/dist/lattice.js.map +1 -1
  34. package/dist/linalg.d.ts +2 -2
  35. package/dist/linalg.d.ts.map +1 -1
  36. package/dist/linalg.js +3 -3
  37. package/dist/linalg.js.map +1 -1
  38. package/dist/magnetic.d.ts +12 -10
  39. package/dist/magnetic.d.ts.map +1 -1
  40. package/dist/magnetic.js +8 -6
  41. package/dist/magnetic.js.map +1 -1
  42. package/dist/notation.d.ts +16 -0
  43. package/dist/notation.d.ts.map +1 -0
  44. package/dist/notation.js +66 -0
  45. package/dist/notation.js.map +1 -0
  46. package/dist/operations.d.ts +40 -26
  47. package/dist/operations.d.ts.map +1 -1
  48. package/dist/operations.js +48 -60
  49. package/dist/operations.js.map +1 -1
  50. package/dist/plane.d.ts +141 -79
  51. package/dist/plane.d.ts.map +1 -1
  52. package/dist/plane.js +147 -77
  53. package/dist/plane.js.map +1 -1
  54. package/dist/pointGroups/crystalForms.d.ts +6 -21
  55. package/dist/pointGroups/crystalForms.d.ts.map +1 -1
  56. package/dist/pointGroups/crystalForms.js +9 -16
  57. package/dist/pointGroups/crystalForms.js.map +1 -1
  58. package/dist/pointGroups/crystalFormsData.d.ts +4 -1
  59. package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
  60. package/dist/pointGroups/crystalFormsData.js +64 -1
  61. package/dist/pointGroups/crystalFormsData.js.map +1 -1
  62. package/dist/pointGroups/elements.d.ts +19 -17
  63. package/dist/pointGroups/elements.d.ts.map +1 -1
  64. package/dist/pointGroups/elements.js +65 -83
  65. package/dist/pointGroups/elements.js.map +1 -1
  66. package/dist/pointGroups/identify.d.ts +10 -18
  67. package/dist/pointGroups/identify.d.ts.map +1 -1
  68. package/dist/pointGroups/identify.js +27 -79
  69. package/dist/pointGroups/identify.js.map +1 -1
  70. package/dist/pointGroups/itaOrder.d.ts +15 -14
  71. package/dist/pointGroups/itaOrder.d.ts.map +1 -1
  72. package/dist/pointGroups/itaOrder.js +116 -94
  73. package/dist/pointGroups/itaOrder.js.map +1 -1
  74. package/dist/pointGroups/itcData.d.ts +96 -0
  75. package/dist/pointGroups/itcData.d.ts.map +1 -0
  76. package/dist/pointGroups/itcData.js +336 -0
  77. package/dist/pointGroups/itcData.js.map +1 -0
  78. package/dist/pointGroups/itcMagneticData.d.ts +55 -0
  79. package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
  80. package/dist/pointGroups/itcMagneticData.js +172 -0
  81. package/dist/pointGroups/itcMagneticData.js.map +1 -0
  82. package/dist/pointGroups/keys.d.ts +32 -0
  83. package/dist/pointGroups/keys.d.ts.map +1 -0
  84. package/dist/pointGroups/keys.js +120 -0
  85. package/dist/pointGroups/keys.js.map +1 -0
  86. package/dist/pointGroups/magneticSymbols.d.ts +6 -5
  87. package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
  88. package/dist/pointGroups/magneticSymbols.js +15 -12
  89. package/dist/pointGroups/magneticSymbols.js.map +1 -1
  90. package/dist/pointGroups/orbits.d.ts +23 -42
  91. package/dist/pointGroups/orbits.d.ts.map +1 -1
  92. package/dist/pointGroups/orbits.js +20 -62
  93. package/dist/pointGroups/orbits.js.map +1 -1
  94. package/dist/pointGroups/pointGroups.d.ts +135 -67
  95. package/dist/pointGroups/pointGroups.d.ts.map +1 -1
  96. package/dist/pointGroups/pointGroups.js +409 -244
  97. package/dist/pointGroups/pointGroups.js.map +1 -1
  98. package/dist/pointGroups/properties.d.ts +21 -22
  99. package/dist/pointGroups/properties.d.ts.map +1 -1
  100. package/dist/pointGroups/properties.js +40 -37
  101. package/dist/pointGroups/properties.js.map +1 -1
  102. package/dist/pointGroups/seitzData.d.ts +26 -0
  103. package/dist/pointGroups/seitzData.d.ts.map +1 -0
  104. package/dist/pointGroups/seitzData.js +130 -0
  105. package/dist/pointGroups/seitzData.js.map +1 -0
  106. package/dist/pointGroups/wyckoff.d.ts +70 -40
  107. package/dist/pointGroups/wyckoff.d.ts.map +1 -1
  108. package/dist/pointGroups/wyckoff.js +98 -91
  109. package/dist/pointGroups/wyckoff.js.map +1 -1
  110. package/dist/pointGroups/wyckoffData.d.ts +7 -4
  111. package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
  112. package/dist/pointGroups/wyckoffData.js +789 -168
  113. package/dist/pointGroups/wyckoffData.js.map +1 -1
  114. package/dist/siteSymmetry.d.ts +8 -16
  115. package/dist/siteSymmetry.d.ts.map +1 -1
  116. package/dist/siteSymmetry.js +34 -24
  117. package/dist/siteSymmetry.js.map +1 -1
  118. package/dist/spaceGroups/affine.d.ts.map +1 -1
  119. package/dist/spaceGroups/affine.js +3 -2
  120. package/dist/spaceGroups/affine.js.map +1 -1
  121. package/dist/spaceGroups/cell.d.ts +43 -31
  122. package/dist/spaceGroups/cell.d.ts.map +1 -1
  123. package/dist/spaceGroups/cell.js +173 -85
  124. package/dist/spaceGroups/cell.js.map +1 -1
  125. package/dist/spaceGroups/describe.d.ts +12 -10
  126. package/dist/spaceGroups/describe.d.ts.map +1 -1
  127. package/dist/spaceGroups/describe.js +11 -10
  128. package/dist/spaceGroups/describe.js.map +1 -1
  129. package/dist/spaceGroups/planeGroupData.d.ts +1 -1
  130. package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
  131. package/dist/spaceGroups/planeGroupData.js +8 -8
  132. package/dist/spaceGroups/planeGroupData.js.map +1 -1
  133. package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
  134. package/dist/spaceGroups/planeGroups.js +2 -1
  135. package/dist/spaceGroups/planeGroups.js.map +1 -1
  136. package/dist/spaceGroups/positions.d.ts +48 -19
  137. package/dist/spaceGroups/positions.d.ts.map +1 -1
  138. package/dist/spaceGroups/positions.js +166 -67
  139. package/dist/spaceGroups/positions.js.map +1 -1
  140. package/dist/tensors/propertyTable.d.ts +3 -1
  141. package/dist/tensors/propertyTable.d.ts.map +1 -1
  142. package/dist/tensors/propertyTable.js +17 -10
  143. package/dist/tensors/propertyTable.js.map +1 -1
  144. package/dist/tensors/rowEchelon.d.ts +3 -3
  145. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  146. package/dist/tensors/rowEchelon.js +4 -4
  147. package/dist/tensors/rowEchelon.js.map +1 -1
  148. package/dist/tensors/tensorForm.d.ts +75 -34
  149. package/dist/tensors/tensorForm.d.ts.map +1 -1
  150. package/dist/tensors/tensorForm.js +171 -67
  151. package/dist/tensors/tensorForm.js.map +1 -1
  152. package/dist/tensors/tensorProperties.d.ts +10 -9
  153. package/dist/tensors/tensorProperties.d.ts.map +1 -1
  154. package/dist/tensors/tensorProperties.js +22 -12
  155. package/dist/tensors/tensorProperties.js.map +1 -1
  156. package/dist/tolerances.d.ts +56 -1
  157. package/dist/tolerances.d.ts.map +1 -1
  158. package/dist/tolerances.js +51 -1
  159. package/dist/tolerances.js.map +1 -1
  160. package/dist/version.d.ts +1 -1
  161. package/dist/version.js +1 -1
  162. package/package.json +1 -1
  163. package/src/cell.ts +78 -51
  164. package/src/checks.ts +84 -0
  165. package/src/closure.ts +214 -0
  166. package/src/crystalClasses.ts +232 -157
  167. package/src/freeze.ts +14 -0
  168. package/src/index.ts +21 -10
  169. package/src/indices.ts +108 -18
  170. package/src/lattice.ts +41 -1
  171. package/src/linalg.ts +3 -3
  172. package/src/magnetic.ts +14 -9
  173. package/src/notation.ts +73 -0
  174. package/src/operations.ts +78 -71
  175. package/src/plane.ts +253 -127
  176. package/src/pointGroups/crystalForms.ts +11 -44
  177. package/src/pointGroups/crystalFormsData.ts +66 -1
  178. package/src/pointGroups/elements.ts +82 -92
  179. package/src/pointGroups/identify.ts +38 -97
  180. package/src/pointGroups/itaOrder.ts +117 -101
  181. package/src/pointGroups/itcData.ts +404 -0
  182. package/src/pointGroups/itcMagneticData.ts +206 -0
  183. package/src/pointGroups/keys.ts +144 -0
  184. package/src/pointGroups/magneticSymbols.ts +18 -17
  185. package/src/pointGroups/orbits.ts +41 -89
  186. package/src/pointGroups/pointGroups.ts +540 -297
  187. package/src/pointGroups/properties.ts +44 -40
  188. package/src/pointGroups/seitzData.ts +147 -0
  189. package/src/pointGroups/wyckoff.ts +137 -112
  190. package/src/pointGroups/wyckoffData.ts +793 -170
  191. package/src/siteSymmetry.ts +43 -40
  192. package/src/spaceGroups/affine.ts +3 -2
  193. package/src/spaceGroups/cell.ts +227 -116
  194. package/src/spaceGroups/describe.ts +22 -19
  195. package/src/spaceGroups/planeGroupData.ts +9 -9
  196. package/src/spaceGroups/planeGroups.ts +2 -1
  197. package/src/spaceGroups/positions.ts +202 -78
  198. package/src/tensors/propertyTable.ts +26 -14
  199. package/src/tensors/rowEchelon.ts +4 -3
  200. package/src/tensors/tensorForm.ts +258 -88
  201. package/src/tensors/tensorProperties.ts +34 -14
  202. package/src/tolerances.ts +66 -1
  203. package/src/version.ts +1 -1
  204. package/dist/pointGroups/data.d.ts +0 -75
  205. package/dist/pointGroups/data.d.ts.map +0 -1
  206. package/dist/pointGroups/data.js +0 -212
  207. package/dist/pointGroups/data.js.map +0 -1
  208. package/dist/pointGroups/magneticData.d.ts +0 -66
  209. package/dist/pointGroups/magneticData.d.ts.map +0 -1
  210. package/dist/pointGroups/magneticData.js +0 -184
  211. package/dist/pointGroups/magneticData.js.map +0 -1
  212. package/dist/spaceGroups/snap.d.ts +0 -20
  213. package/dist/spaceGroups/snap.d.ts.map +0 -1
  214. package/dist/spaceGroups/snap.js +0 -103
  215. package/dist/spaceGroups/snap.js.map +0 -1
  216. package/src/pointGroups/data.ts +0 -305
  217. package/src/pointGroups/magneticData.ts +0 -328
  218. package/src/spaceGroups/snap.ts +0 -121
@@ -11,38 +11,47 @@
11
11
  * comes in and leaves time reversal out of what goes back.
12
12
  */
13
13
 
14
- import type { CrystalSystem } from './lattice.js';
14
+ import { checkOptions, shown, TOLERANCE_KEYS } from './checks.js';
15
+ import type { CrystalSystem, LatticeSystem } from './lattice.js';
15
16
  import type { Mat3, Vec3 } from './linalg.js';
16
- import type { Operation as MagneticOperation } from './operations.js';
17
+ import type { CartesianOperation as MagneticOperation, Operation as MagneticRecord } from './operations.js';
17
18
  import * as elements from './pointGroups/elements.js';
18
19
  import * as groups from './pointGroups/pointGroups.js';
19
- import type { Convention, PointGroupKey, Setting, SettingOptions, SymbolOptions } from './pointGroups/pointGroups.js';
20
+ import type { PointGroupKey, Setting, SettingOptions, SymbolOptions } from './pointGroups/pointGroups.js';
20
21
  import * as properties from './pointGroups/properties.js';
21
22
  import * as forms from './pointGroups/crystalForms.js';
22
23
  import * as identify from './pointGroups/identify.js';
23
24
  import * as orbits from './pointGroups/orbits.js';
24
25
  import * as wyckoff from './pointGroups/wyckoff.js';
25
- import type { Hkl } from './pointGroups/wyckoff.js';
26
26
  import * as cell from './cell.js';
27
27
  import * as site from './siteSymmetry.js';
28
- import type { Uvw } from './symmetryDirections.js';
29
28
  import { TENSOR_PROPERTIES as ALL_TENSOR_PROPERTIES } from './tensors/propertyTable.js';
30
29
  import type { TensorPropertyName as MagneticTensorPropertyName } from './tensors/propertyTable.js';
31
30
  import * as tensors from './tensors/tensorForm.js';
32
- import type { IntrinsicSymmetry, TensorForm, TensorParity, TensorRank } from './tensors/tensorForm.js';
31
+ import type { IntrinsicSymmetry, TensorForm, TensorKind, TensorRank } from './tensors/tensorForm.js';
32
+ import { deepFreeze } from './freeze.js';
33
+ import type { ToleranceOptions } from './tolerances.js';
33
34
 
34
35
  const USE_MAGNETIC =
35
36
  "the crystallographic API has no time reversal; use the magnetic API ('symcrys/magnetic', in Python symcrys.magnetic)";
36
37
 
37
- /** A point operation: an orthogonal Cartesian matrix (rotation, rotoinversion, mirror, inversion). */
38
+ /**
39
+ * A point operation of a crystal class in a setting: ITA's matrix W in the lattice basis of the
40
+ * setting (`matrix`, integer, acting on the coordinates of a lattice direction [uvw]; the coordinate
41
+ * triplets of ITA's general position are its rows) and the same operation as an orthogonal Cartesian
42
+ * matrix (`cartesian`: rotation, rotoinversion, mirror, inversion; R = B·W·B⁻¹ with the basis B of
43
+ * the setting). docs/conventions.md, "Operations".
44
+ */
38
45
  export interface Operation {
39
- /** The orthogonal Cartesian 3×3 matrix, rows first. */
46
+ /** ITA's matrix W in the lattice basis of the setting, integer, rows first. */
40
47
  readonly matrix: Mat3;
48
+ /** The orthogonal Cartesian 3×3 matrix, rows first. */
49
+ readonly cartesian: Mat3;
41
50
  }
42
51
 
43
52
  /**
44
53
  * A crystal class with the properties that are fixed by its operations. None of them depends on
45
- * the setting or the convention (docs/conventions.md, "Properties").
54
+ * the setting (docs/conventions.md, "Properties").
46
55
  */
47
56
  export interface PointGroup {
48
57
  /** The key (docs/conventions.md, "Keys"). */
@@ -55,8 +64,12 @@ export interface PointGroup {
55
64
  readonly centrosymmetric: boolean;
56
65
  /** Polar (pyroelectric class): some direction is left unchanged by every operation. */
57
66
  readonly polar: boolean;
58
- /** Chiral (enantiomorphic class): proper rotations only. */
59
- readonly chiral: boolean;
67
+ /**
68
+ * Enantiomorphic: proper rotations only. ITA § 3.2.2.1.3 (p. 738): "All these terms
69
+ * [enantiomorphism, enantiomerism, chirality, dissymmetry] refer to the same symmetry restriction,
70
+ * the absence of improper rotations (rotoinversions, rotoreflections)".
71
+ */
72
+ readonly enantiomorphic: boolean;
60
73
  /** The Laue class: the centrosymmetric crystal class generated by the class and the inversion. */
61
74
  readonly laueClass: PointGroupKey;
62
75
  }
@@ -77,25 +90,35 @@ export interface TensorSpec {
77
90
  /** Number of indices, 0 to 4. */
78
91
  readonly rank: TensorRank;
79
92
  /** `'polar'` or `'axial'`: whether an improper operation changes the sign (factor det R). */
80
- readonly parity: TensorParity;
93
+ readonly kind: TensorKind;
81
94
  /** The index symmetry of the tensor. */
82
95
  readonly intrinsic: IntrinsicSymmetry;
83
96
  }
84
97
 
85
98
  /**
86
- * An operation as a caller may pass it: its matrix. `timeReversal: false` is accepted, so that an
87
- * operation of the magnetic API without time reversal can be handed on from plain JavaScript; with
88
- * `timeReversal: true` it is refused, at compile time and at run time.
99
+ * An operation as a caller may pass it to a function that computes with Cartesian matrices: its
100
+ * Cartesian matrix (`cartesian`; other fields, such as `matrix`, are not read), so that the
101
+ * operations of `operations` can be passed as they are. `timeReversal: false` is accepted, so that
102
+ * an operation of the magnetic API without time reversal can be handed on from plain JavaScript;
103
+ * with `timeReversal: true` it is refused, at compile time and at run time.
89
104
  */
90
- type OperationArgument = Operation & {
105
+ type OperationArgument = {
106
+ /** The orthogonal Cartesian 3×3 matrix, rows first. */
107
+ readonly cartesian: Mat3;
91
108
  /** Accepted if false; an operation with time reversal belongs to the magnetic API. */
92
109
  readonly timeReversal?: false;
93
110
  };
94
111
 
95
- /** A tensor specification as a caller may pass it; `timeParity: 'i'` is accepted, `'c'` refused. */
112
+ /** An operation as a caller may pass it to `residualOperations`: its matrix W in the lattice basis. */
113
+ type CellOperationArgument = cell.CellOperation & {
114
+ /** Accepted if false; an operation with time reversal belongs to the magnetic API. */
115
+ readonly timeReversal?: false;
116
+ };
117
+
118
+ /** A tensor specification as a caller may pass it; `timeParity: 'even'` is accepted, `'odd'` refused. */
96
119
  type TensorSpecArgument = TensorSpec & {
97
- /** Accepted if `'i'`; a time-odd tensor belongs to the magnetic API. */
98
- readonly timeParity?: 'i';
120
+ /** Accepted if `'even'`; a time-odd tensor belongs to the magnetic API. */
121
+ readonly timeParity?: 'even';
99
122
  };
100
123
 
101
124
  /** A named property: the tensor that describes it, what it is and where it is defined. */
@@ -122,11 +145,11 @@ export type TensorPropertyName = Extract<
122
145
  export const TENSOR_PROPERTIES = Object.freeze(
123
146
  Object.fromEntries(
124
147
  Object.entries(ALL_TENSOR_PROPERTIES)
125
- .filter(([, p]) => p.spec.timeParity === 'i')
148
+ .filter(([, p]) => p.spec.timeParity === 'even')
126
149
  .map(([name, { spec, description, source }]) => [
127
150
  name,
128
151
  Object.freeze({
129
- spec: Object.freeze({ rank: spec.rank, parity: spec.parity, intrinsic: spec.intrinsic }),
152
+ spec: Object.freeze({ rank: spec.rank, kind: spec.kind, intrinsic: spec.intrinsic }),
130
153
  description,
131
154
  source,
132
155
  }),
@@ -142,9 +165,9 @@ const TENSOR_PROPERTY_NAMES = Object.freeze(Object.keys(TENSOR_PROPERTIES)) as r
142
165
  function classKey(key: PointGroupKey): PointGroupKey {
143
166
  if (groups.isPointGroupKey(key)) return key;
144
167
  if (groups.isMagneticPointGroupKey(key)) {
145
- throw new RangeError(`${JSON.stringify(key)} is a magnetic point group, not a crystal class: ${USE_MAGNETIC}`);
168
+ throw new RangeError(`${shown(key)} is a magnetic point group, not a crystal class: ${USE_MAGNETIC}`);
146
169
  }
147
- throw new RangeError(`Unknown point group key: ${JSON.stringify(key)}`);
170
+ throw new RangeError(`Unknown point group key: ${shown(key)}`);
148
171
  }
149
172
 
150
173
  /** A name of the table of this API, checked. */
@@ -152,35 +175,41 @@ function propertyName(name: TensorPropertyName): TensorPropertyName {
152
175
  if (typeof name === 'string') {
153
176
  if (Object.hasOwn(TENSOR_PROPERTIES, name)) return name;
154
177
  if (Object.hasOwn(ALL_TENSOR_PROPERTIES, name)) {
155
- throw new RangeError(`${JSON.stringify(name)} is the property of a time-odd tensor: ${USE_MAGNETIC}`);
178
+ throw new RangeError(`${shown(name)} is the property of a time-odd tensor: ${USE_MAGNETIC}`);
156
179
  }
157
180
  }
158
- throw new RangeError(`Unknown tensor property: ${JSON.stringify(name)} (known: ${TENSOR_PROPERTY_NAMES.join(', ')})`);
181
+ throw new RangeError(`Unknown tensor property: ${shown(name)} (known: ${TENSOR_PROPERTY_NAMES.join(', ')})`);
159
182
  }
160
183
 
161
184
  /** The time-even tensor of a specification or of a property name, as the shared modules take it. */
162
185
  function timeEven(specOrName: TensorSpecArgument | TensorPropertyName): tensors.TensorSpec | TensorPropertyName {
163
186
  if (typeof specOrName === 'string') return propertyName(specOrName);
164
187
  if (typeof specOrName !== 'object' || specOrName === null) {
165
- throw new RangeError(`Not a tensor specification: ${JSON.stringify(specOrName)}`);
188
+ throw new RangeError(`Not a tensor specification: ${shown(specOrName)}`);
166
189
  }
167
190
  const timeParity = (specOrName as { readonly timeParity?: unknown }).timeParity;
168
- if (timeParity === 'c') throw new RangeError(`A time-odd tensor (timeParity 'c'): ${USE_MAGNETIC}`);
169
- if (timeParity !== undefined && timeParity !== 'i') {
170
- throw new RangeError(`Unknown time parity: ${JSON.stringify(timeParity)}`);
191
+ if (timeParity === 'odd' || timeParity === 'c') {
192
+ throw new RangeError(`A time-odd tensor (timeParity '${timeParity}'): ${USE_MAGNETIC}`);
193
+ }
194
+ if (timeParity !== undefined && timeParity !== 'even') {
195
+ // The shared check names the values and the names up to 0.10 ('i', 'c').
196
+ return { ...specOrName, timeParity: timeParity as never };
171
197
  }
172
- return { rank: specOrName.rank, parity: specOrName.parity, timeParity: 'i', intrinsic: specOrName.intrinsic };
198
+ // The other fields are passed on as they are, so that the shared check reports a field of 0.10 (parity).
199
+ return { ...specOrName, timeParity: 'even' };
173
200
  }
174
201
 
175
202
  /** Checks a list of operations of a caller: an operation with time reversal is an error. */
176
- function checkUnitary(operations: readonly OperationArgument[]): void {
203
+ function checkUnitary(operations: readonly { readonly timeReversal?: false }[]): void {
204
+ if (!Array.isArray(operations)) throw new RangeError('The operations must be an array');
177
205
  operations.forEach((op, i) => {
206
+ if (typeof op !== 'object' || op === null) throw new RangeError(`Operation ${i} is not an object`);
178
207
  const timeReversal = (op as { readonly timeReversal?: unknown }).timeReversal;
179
208
  if (timeReversal === true) {
180
209
  throw new RangeError(`Operation ${i} is combined with time reversal: ${USE_MAGNETIC}`);
181
210
  }
182
211
  if (timeReversal !== undefined && timeReversal !== false) {
183
- throw new RangeError(`Operation ${i}: timeReversal must be false or absent, not ${JSON.stringify(timeReversal)}`);
212
+ throw new RangeError(`Operation ${i}: timeReversal must be false or absent, not ${shown(timeReversal)}`);
184
213
  }
185
214
  });
186
215
  }
@@ -188,18 +217,20 @@ function checkUnitary(operations: readonly OperationArgument[]): void {
188
217
  /** A list of operations as the shared modules take it. */
189
218
  function unitary(operations: readonly OperationArgument[]): MagneticOperation[] {
190
219
  checkUnitary(operations);
191
- return operations.map((op) => ({ matrix: op.matrix, timeReversal: false }));
220
+ // The other fields are kept for the checks of the shared modules (a record with `matrix` only
221
+ // is refused there with a hint).
222
+ return operations.map((op) => ({ ...op, timeReversal: false }));
192
223
  }
193
224
 
194
225
  // --- what goes back --------------------------------------------------------------------------------
195
226
 
196
- const withoutTimeCache = new WeakMap<readonly MagneticOperation[], readonly Operation[]>();
227
+ const withoutTimeCache = new WeakMap<readonly MagneticRecord[], readonly Operation[]>();
197
228
 
198
- /** The operations as their matrices; the shared modules return the same frozen list for the same call. */
199
- function matricesOnly(ops: readonly MagneticOperation[]): readonly Operation[] {
229
+ /** The operations without time reversal; the shared modules return the same frozen list for the same call. */
230
+ function withoutTime(ops: readonly MagneticRecord[]): readonly Operation[] {
200
231
  let result = withoutTimeCache.get(ops);
201
232
  if (!result) {
202
- result = Object.freeze(ops.map((op) => Object.freeze({ matrix: op.matrix })));
233
+ result = Object.freeze(ops.map((op) => Object.freeze({ matrix: op.matrix, cartesian: op.cartesian })));
203
234
  withoutTimeCache.set(ops, result);
204
235
  }
205
236
  return result;
@@ -222,8 +253,8 @@ const groupCache = new Map<PointGroupKey, PointGroup>();
222
253
  export function pointGroup(key: PointGroupKey): PointGroup {
223
254
  let g = groupCache.get(classKey(key));
224
255
  if (!g) {
225
- const { crystalSystem, order, centrosymmetric, polar, chiral, laueClass } = groups.pointGroup(key);
226
- g = Object.freeze({ key, crystalSystem, order, centrosymmetric, polar, chiral, laueClass });
256
+ const { crystalSystem, order, centrosymmetric, polar, enantiomorphic, laueClass } = groups.pointGroup(key);
257
+ g = Object.freeze({ key, crystalSystem, order, centrosymmetric, polar, enantiomorphic, laueClass });
227
258
  groupCache.set(key, g);
228
259
  }
229
260
  return g;
@@ -231,74 +262,99 @@ export function pointGroup(key: PointGroupKey): PointGroup {
231
262
 
232
263
  /** All 32 crystal classes, in the order of `POINT_GROUP_KEYS` (by crystal system, as in ITA). */
233
264
  export function pointGroups(): readonly PointGroup[] {
234
- return groups.POINT_GROUP_KEYS.map((key) => pointGroup(key));
265
+ return deepFreeze(groups.POINT_GROUP_KEYS.map((key) => pointGroup(key)));
235
266
  }
236
267
 
237
268
  /**
238
- * Finds a crystal class by a Hermann–Mauguin symbol in the given convention (default `'itc'`): the
239
- * short symbol of a setting, a full symbol, or the key (spaces are ignored). A symbol that names
240
- * one setting gives that setting; the key, and a short symbol that several settings share (the
241
- * monoclinic ones: `2` for unique axis b and c), give the default setting of the convention.
242
- * Returns undefined if nothing matches, also for a value that is not a string and for the
243
- * symbol of a magnetic group with time reversal. Symbols are written as in this library: `-` for
244
- * the overbar, also in the Birss convention (`m-3m`, where Birss prints `m3m`; docs/conventions.md,
245
- * "Where ITC and Birss differ").
269
+ * Finds a crystal class by a symbol, read tolerantly.
270
+ * It reads, spaces ignored (#96; docs/conventions.md, "Reading symbols"): the key; the short or
271
+ * full symbol of a setting (`312`, `1 1 2`); a Schoenflies symbol, ITA's or ITC Vol. D's (`D3`,
272
+ * `C3i`, `S6`); Birss's cubic symbols without the overbar on the 3 (`m3m`). A symbol that names
273
+ * several settings (the key `32`, which is also the symbol of the setting with rhombohedral axes;
274
+ * `2` for unique axis b, c and a; any Schoenflies symbol) gives the standard (ITC default) setting,
275
+ * unless the options `axes` or `uniqueAxis` choose another, as the headlines of ITA name the
276
+ * settings (the option `axes` set to `'rhombohedral'` for the key `32`).
277
+ *
278
+ * Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
279
+ * Schoenflies subscripts also as Unicode or LaTeX subscripts (`C₃ᵥ`, `C_{3v}`). Returns undefined if nothing matches,
280
+ * also for a value that is not a string and for the symbol of a magnetic group with time reversal; a
281
+ * symbol that names several groups is a RangeError that lists them.
246
282
  */
247
- export function findPointGroup(hm: string, conventionName: Convention = 'itc'): PointGroupInSetting | undefined {
248
- return groups.findPointGroup(hm, conventionName);
283
+ export function findPointGroup(symbol: string, options?: groups.AxesOptions): PointGroupInSetting | undefined {
284
+ if (arguments.length > 2) groups.rejectConventionArgument(arguments.length);
285
+ return deepFreeze(groups.findPointGroup(symbol, options));
249
286
  }
250
287
 
251
- /** The settings of a crystal class, with symbols and the default of the given convention (default `'itc'`). */
252
- export function settings(key: PointGroupKey, conventionName: Convention = 'itc'): readonly Setting[] {
253
- return groups.settings(classKey(key), conventionName);
288
+ /** The settings of a crystal class, with their symbols and the ITC default. */
289
+ export function settings(key: PointGroupKey): readonly Setting[] {
290
+ groups.rejectConventionArgument(arguments.length);
291
+ return deepFreeze(groups.settings(classKey(key)));
254
292
  }
255
293
 
256
294
  /**
257
- * All operations of the crystal class in the requested setting (default: the convention's default
258
- * setting). ITC convention: in ITA's order, identity first, then as ITA numbers the general
259
- * position. Birss convention: in birss-app's order (docs/conventions.md, "Order of the
260
- * operations"). The matrices are Cartesian (docs/conventions.md, "Cartesian frame").
295
+ * All operations of the crystal class in the requested setting (default: the ITC default setting),
296
+ * in ITA's order: identity first, then as ITA numbers the general position (docs/conventions.md,
297
+ * "Order of the operations"). Each operation is ITA's matrix W in the lattice basis of the setting
298
+ * (`matrix`) with the same operation as a Cartesian matrix (`cartesian`; docs/conventions.md,
299
+ * "Operations").
261
300
  */
262
301
  export function operations(key: PointGroupKey, options?: SettingOptions): readonly Operation[] {
263
- return matricesOnly(groups.operations(classKey(key), options));
302
+ return withoutTime(groups.operations(classKey(key), options));
264
303
  }
265
304
 
266
305
  /**
267
- * Generators of the crystal class in the requested setting (docs/conventions.md, "Generators"). ITC
268
- * convention: ITA's selected generators in printed order, without the identity and ITA's lattice
269
- * translations, so the list is empty for `1`; for `mm2` settings 2 and 3, which ITA does not list,
270
- * those of setting 1 carried into their frame. Birss convention: birss-app's generators (for `1`
271
- * the identity, as in birss-app).
306
+ * Generators of the crystal class in the requested setting (docs/conventions.md, "Generators"):
307
+ * ITA's selected generators in printed order, without the identity and ITA's lattice translations,
308
+ * so the list is empty for `1`; for the settings ITA does not print (`mm2` settings 2 and 3, monoclinic unique axis a), those of setting 1
309
+ * carried into their frame.
272
310
  */
273
311
  export function generators(key: PointGroupKey, options?: SettingOptions): readonly Operation[] {
274
- return matricesOnly(groups.generators(classKey(key), options));
312
+ return withoutTime(groups.generators(classKey(key), options));
275
313
  }
276
314
 
277
- /** A symbol of the crystal class in the requested convention and setting. */
315
+ /**
316
+ * A symbol of the crystal class in the requested setting, as ITA writes it (Tables 3.2.1.2 and
317
+ * 3.2.3.2: `321`, `C3i`; docs/conventions.md, "Symbols").
318
+ */
278
319
  export function symbol(key: PointGroupKey, options?: SymbolOptions): string {
279
- return groups.symbol(classKey(key), options);
320
+ const result = groups.symbol(classKey(key), options);
321
+ // The Schoenflies symbol as ITA writes it (`C3i`); the magnetic API follows ITC Vol. D (`S6`).
322
+ return options?.form === 'schoenflies' ? groups.itaSchoenflies(key) : result;
280
323
  }
281
324
 
282
325
  // --- properties that follow from operations ---------------------------------------------------------
283
326
 
284
327
  export { holohedry } from './pointGroups/properties.js';
285
328
 
329
+ /**
330
+ * The lattice systems of a crystal class: those whose lattices it can act on (ITA § 1.3.4.4.2 and
331
+ * Table 1.3.4.1, p. 39). One for every class but the trigonal ones, which belong to the hexagonal
332
+ * (hP) or the rhombohedral (hR) lattice system depending on the basis, so they give both,
333
+ * `['hexagonal', 'rhombohedral']`. The holohedry of each is `holohedry(latticeSystem)`. Throws a
334
+ * RangeError for an unknown key.
335
+ */
336
+ export function latticeSystems(key: PointGroupKey): readonly LatticeSystem[] {
337
+ return groups.latticeSystems(classKey(key));
338
+ }
339
+
286
340
  /**
287
341
  * True if the group generated by `operations` contains the inversion, e.g. for the operations of a
288
- * distorted crystal. A list that is not closed is closed first. For a crystal class, read
289
- * `pointGroup(key).centrosymmetric`. Throws a RangeError for a matrix that is not orthogonal.
342
+ * distorted crystal. The list is closed into a group within the tolerance and made exact first, as
343
+ * `tensorFormOf` does. For a crystal class, read `pointGroup(key).centrosymmetric`. Throws a
344
+ * RangeError as `tensorFormOf`.
290
345
  */
291
- export function isCentrosymmetricOf(operations: readonly OperationArgument[]): boolean {
292
- return properties.isCentrosymmetricOf(unitary(operations));
346
+ export function isCentrosymmetricOf(operations: readonly OperationArgument[], options?: ToleranceOptions): boolean {
347
+ return properties.isCentrosymmetricOf(unitary(operations), options);
293
348
  }
294
349
 
295
350
  /**
296
- * True if the group generated by `operations` is chiral: proper rotations only. For a crystal
297
- * class, read `pointGroup(key).chiral`. Polar is the named property `'pyroelectric'`:
298
- * `allowsPropertyOf(operations, 'pyroelectric')`. Throws a RangeError for a matrix that is not orthogonal.
351
+ * True if the group generated by `operations` is enantiomorphic: proper rotations only (ITA
352
+ * § 3.2.2.1.3). For a crystal class, read `pointGroup(key).enantiomorphic`. Polar is the named property `'pyroelectric'`:
353
+ * `allowsPropertyOf(operations, 'pyroelectric')`. Throws a RangeError for an operation without an
354
+ * orthogonal Cartesian matrix (`cartesian`; within the tolerance).
299
355
  */
300
- export function isChiralOf(operations: readonly OperationArgument[]): boolean {
301
- return properties.isChiralOf(unitary(operations));
356
+ export function isEnantiomorphicOf(operations: readonly OperationArgument[], options?: ToleranceOptions): boolean {
357
+ return properties.isEnantiomorphicOf(unitary(operations), options);
302
358
  }
303
359
 
304
360
  // --- the point group of a list of operations -------------------------------------------------------
@@ -323,14 +379,13 @@ export type CartesianOperationDescription = Omit<identify.CartesianOperationDesc
323
379
  * (absent if the group is the class in another orientation, e.g. a threefold axis along [111]). The
324
380
  * list is closed into a group first, two matrices being equal when no entry differs by `tolerance`
325
381
  * (default `EPSILON`) or more. Returns undefined if the operations generate no crystal class (an
326
- * operation of order 5, a group larger than 48). Throws a RangeError for a matrix that is not
327
- * orthogonal (within `tolerance`, at least `EPSILON`). The classes `1` and `-1` have no
382
+ * operation of order 5, a group larger than 48). Throws a RangeError for an operation without an orthogonal Cartesian matrix (`cartesian`; within `tolerance`, at least `EPSILON`). The classes `1` and `-1` have no
328
383
  * orientation, so they always have setting 1. The first call builds a table of the groups (about
329
384
  * 0.1 s; docs/conventions.md, "Point group of a list of operations").
330
385
  */
331
386
  export function pointGroupOf(
332
387
  operations: readonly OperationArgument[],
333
- options?: identify.PointGroupOfOptions,
388
+ options?: ToleranceOptions,
334
389
  ): IdentifiedPointGroup | undefined {
335
390
  return identify.pointGroupOf(unitary(operations), options) as IdentifiedPointGroup | undefined;
336
391
  }
@@ -340,13 +395,13 @@ export function pointGroupOf(
340
395
  * Cartesian axis (rotation or rotoinversion axis, mirror normal) with its first non-zero component,
341
396
  * in the order x, y, z, positive, and for n ≥ 3 the sense about that axis. The axes are not named
342
397
  * by lattice directions, since the list need not belong to a setting; for a crystal class given by
343
- * its key, `describeOperations` names them. Throws a RangeError for a matrix that is not orthogonal
398
+ * its key, `describeOperations` names them. Throws a RangeError for an operation without an orthogonal Cartesian matrix (`cartesian`)
344
399
  * or not a crystallographic operation (a rotation part by an angle other than 360°/n, n = 1, 2, 3,
345
400
  * 4, 6), both within `tolerance` (default `EPSILON`, as for `pointGroupOf`).
346
401
  */
347
402
  export function describeOperationsOf(
348
403
  operations: readonly OperationArgument[],
349
- options?: identify.PointGroupOfOptions,
404
+ options?: ToleranceOptions,
350
405
  ): readonly CartesianOperationDescription[] {
351
406
  return Object.freeze(
352
407
  identify.describeOperationsOf(unitary(operations), options).map((d) => {
@@ -360,17 +415,18 @@ export function describeOperationsOf(
360
415
 
361
416
  /**
362
417
  * Each operation of the crystal class described geometrically, in the order of `operations` for
363
- * the same key and options. Axes are named by the symmetry direction they lie along: in the ITC
364
- * convention with the sign of ITA Table 2.1.3.1, in the Birss convention signed as birss-app signs
365
- * them (first non-zero Cartesian component positive); the sign fixes what the sense refers to.
418
+ * the same key and options. An axis lies along a symmetry direction and has the sign of the
419
+ * operation's Seitz symbol (ITA 6th ed., Tables 1.4.2.1–1.4.2.3, p. 52), e.g. [1, 1, 0] for 2₁₁₀ in
420
+ * the hexagonal family, where ITA Table 2.1.3.1 lists [1̄, 1̄, 0]; for n ≥ 3 the sign fixes what the
421
+ * sense refers to.
366
422
  */
367
423
  export function describeOperations(key: PointGroupKey, options?: SettingOptions): readonly OperationDescription[] {
368
424
  const described = elements.describeOperations(classKey(key), options);
369
425
  let result = descriptionCache.get(described);
370
426
  if (!result) {
371
427
  result = Object.freeze(
372
- described.map(({ kind, order, axis, sense }) =>
373
- Object.freeze({ kind, order, ...(axis ? { axis } : {}), ...(sense ? { sense } : {}) }),
428
+ described.map(({ kind, n, axis, sense }) =>
429
+ Object.freeze({ kind, n, ...(axis ? { axis } : {}), ...(sense ? { sense } : {}) }),
374
430
  ),
375
431
  );
376
432
  descriptionCache.set(described, result);
@@ -379,12 +435,12 @@ export function describeOperations(key: PointGroupKey, options?: SettingOptions)
379
435
  }
380
436
 
381
437
  /**
382
- * The positions of the full Hermann–Mauguin symbol in the requested convention and setting, each
383
- * with its symmetry directions (ITA Table 2.1.3.1) and the symmetry elements along them. All
384
- * positions of the crystal family are listed, also those the symbol of the class leaves out (then
385
- * without `symbol`); the triclinic family has none. The directions keep the sign of Table 2.1.3.1
386
- * in both conventions; in the Birss convention an axis of `describeOperations` may be reversed, so
387
- * match it to a direction whose dot product with it is ±1, not by identity.
438
+ * The positions of the full Hermann–Mauguin symbol in the requested setting, each with its
439
+ * symmetry directions (ITA Table 2.1.3.1) and the symmetry elements along them. All positions of the
440
+ * crystal family are listed (for rhombohedral axes the two of that row of the table), also those the
441
+ * symbol of the class leaves out (then without `symbol`); the triclinic family has none. A direction
442
+ * has the sign of ITA Table 2.1.3.1, the axis of an operation along it that of its Seitz symbol, so
443
+ * the two are parallel and may be opposite: match them by direction, up to sign.
388
444
  */
389
445
  export function symmetryDirections(
390
446
  key: PointGroupKey,
@@ -401,24 +457,37 @@ export function symmetryDirections(
401
457
  * fixing the direction within the tolerance are closed under the products found in the list and
402
458
  * the direction is set onto their fixed space, repeated until stable, so that for a group the
403
459
  * result is a subgroup and the set direction lies exactly on its elements. For a list that is not a
404
- * group, `multiplicity` may not be an integer. The matrices must be Cartesian and orthogonal (not
405
- * those of `latticeOperations`). Throws a RangeError for a matrix that is not orthogonal (within
460
+ * group, `multiplicity` may not be an integer. Each operation is read by its Cartesian matrix
461
+ * (`cartesian`). Throws a RangeError for an operation without an orthogonal Cartesian matrix (`cartesian`; within
406
462
  * `tolerance`, at least `EPSILON`), for a zero vector, and if the closed operations fix no common
407
463
  * direction or do not settle into a group (a tolerance far too large, e.g. 0.5).
408
464
  */
409
- export function siteSymmetry(
465
+ export function siteSymmetryOf(
410
466
  operations: readonly OperationArgument[],
411
467
  direction: Vec3,
412
- options?: site.SiteSymmetryOptions,
468
+ options?: ToleranceOptions,
413
469
  ): site.SiteSymmetry {
414
470
  checkUnitary(operations);
415
471
  // The shared function reads the matrices only, so the list of the caller is passed on as it is.
416
- return site.siteSymmetry(operations as readonly MagneticOperation[], direction, options);
472
+ return site.siteSymmetryOf(operations as readonly MagneticOperation[], direction, options);
473
+ }
474
+
475
+ /**
476
+ * The site symmetry of a direction (any non-zero Cartesian vector) under a crystal class in a
477
+ * setting: `siteSymmetryOf` applied to `operations(key, options)`, so the indices refer to those
478
+ * operations (#137 C1). Throws a RangeError as `siteSymmetryOf` does.
479
+ */
480
+ export function siteSymmetry(
481
+ key: PointGroupKey,
482
+ direction: Vec3,
483
+ options?: SettingOptions & ToleranceOptions,
484
+ ): site.SiteSymmetry {
485
+ return wyckoff.siteSymmetry(classKey(key), direction, options);
417
486
  }
418
487
 
419
488
  /**
420
489
  * The Wyckoff positions of a crystal class for directions, as ITA tabulates them (general position
421
- * first), in the ITC convention only (docs/conventions.md, "Site symmetry and Wyckoff positions").
490
+ * first) (docs/conventions.md, "Site symmetry and Wyckoff positions").
422
491
  */
423
492
  export function wyckoffPositions(key: PointGroupKey, options?: SettingOptions): readonly wyckoff.WyckoffPosition[] {
424
493
  return wyckoff.wyckoffPositions(classKey(key), options);
@@ -427,53 +496,38 @@ export function wyckoffPositions(key: PointGroupKey, options?: SettingOptions):
427
496
  /**
428
497
  * The Wyckoff position of a direction (Cartesian) in a crystal class: the position whose site
429
498
  * symmetry is conjugate to that of the direction (ITA's definition). `tolerance` as for
430
- * `siteSymmetry`.
499
+ * `siteSymmetryOf`.
431
500
  */
432
- export function wyckoffPositionOf(
501
+ export function wyckoffPosition(
433
502
  key: PointGroupKey,
434
503
  direction: Vec3,
435
- options?: wyckoff.WyckoffOptions,
504
+ options?: SettingOptions & ToleranceOptions,
436
505
  ): wyckoff.WyckoffPosition {
437
- return wyckoff.wyckoffPositionOf(classKey(key), direction, options);
506
+ return wyckoff.wyckoffPosition(classKey(key), direction, options);
438
507
  }
439
508
 
440
509
  // --- lattice basis and orbits ---------------------------------------------------------------------
441
510
 
442
511
  /**
443
512
  * The operations of a list that keep the metric of a cell: W with WᵀGW = G, G the metric tensor
444
- * of `basis`. The operations are integer matrices on lattice coordinates, as `latticeOperations`
445
- * gives them; the list is taken as it is and the kept operations are the ones of the list, in its
513
+ * of `basis`. The operations are read by `matrix`, the integer matrix W on lattice coordinates, as
514
+ * `operations` gives them; the list is taken as it is and the kept operations are the ones of the list, in its
446
515
  * order. The deviation counts relative to the largest entry of G (`tolerance`, default
447
516
  * `EPSILON`). An operation combined with time reversal belongs to the magnetic API.
448
517
  */
449
- export function residualOperations<T extends OperationArgument>(
518
+ export function residualOperations<T extends CellOperationArgument>(
450
519
  operations: readonly T[],
451
520
  basis: Mat3,
452
- options?: cell.ResidualOperationsOptions,
453
- ): T[] {
521
+ options?: ToleranceOptions,
522
+ ): readonly T[] {
454
523
  checkUnitary(operations);
455
524
  return cell.residualOperations(operations, basis, options);
456
525
  }
457
526
 
458
- /**
459
- * The operations of the crystal class in the conventional lattice basis (a, b, c; for the trigonal
460
- * classes the hexagonal axes), in the order of `operations` for the same setting and convention:
461
- * integer matrices W acting on the coordinates of a lattice direction [uvw], W = B⁻¹·R·B with the
462
- * basis B of `latticeBasis` and the Cartesian matrix R of `operations`. They do not depend on the
463
- * cell angles, so they exist for every family; for the monoclinic and triclinic families a, b, c
464
- * are taken along x, y, z, as for the Wyckoff positions. In the ITC convention they are the
465
- * matrices of ITA's general position (6th ed., Table 3.2.3.2). Not orthogonal in general: pass
466
- * them to no function that takes Cartesian operations (docs/conventions.md, "Lattice basis and
467
- * orbits").
468
- */
469
- export function latticeOperations(key: PointGroupKey, options?: SettingOptions): readonly Operation[] {
470
- return matricesOnly(orbits.latticeOperations(classKey(key), options));
471
- }
472
-
473
527
  /**
474
528
  * The orbit of a face (hkl) or of a lattice direction [uvw] under a crystal class, exactly, in the
475
529
  * lattice basis: the distinct faces (directions), in the order in which the operations reach them
476
- * (so in the ITC convention the given face first), each with the indices of the operations that map
530
+ * (so the given face first), each with the indices of the operations that map
477
531
  * the given one onto it. A face transforms with the inverse transpose of a lattice operation,
478
532
  * h' = W⁻ᵀ·h, a direction with the operation itself, u' = W·u. The number of entries is the
479
533
  * multiplicity of the face (direction). Throws a RangeError unless exactly one of `hkl` and `uvw` is
@@ -481,40 +535,40 @@ export function latticeOperations(key: PointGroupKey, options?: SettingOptions):
481
535
  */
482
536
  export function orbit(
483
537
  key: PointGroupKey,
484
- indices: { readonly hkl: Hkl },
538
+ indices: orbits.FaceIndices,
485
539
  options?: SettingOptions,
486
540
  ): readonly orbits.FaceOrbitEntry[];
487
541
  export function orbit(
488
542
  key: PointGroupKey,
489
- indices: { readonly uvw: Uvw },
543
+ indices: orbits.DirectionIndices,
490
544
  options?: SettingOptions,
491
545
  ): readonly orbits.DirectionOrbitEntry[];
492
546
  export function orbit(
493
547
  key: PointGroupKey,
494
- indices: { readonly hkl: Hkl } | { readonly uvw: Uvw },
548
+ indices: orbits.FaceIndices | orbits.DirectionIndices,
495
549
  options?: SettingOptions,
496
550
  ): readonly orbits.FaceOrbitEntry[] | readonly orbits.DirectionOrbitEntry[];
497
551
  export function orbit(
498
552
  key: PointGroupKey,
499
- indices: { readonly hkl: Hkl } | { readonly uvw: Uvw },
553
+ indices: orbits.FaceIndices | orbits.DirectionIndices,
500
554
  options?: SettingOptions,
501
555
  ): readonly orbits.FaceOrbitEntry[] | readonly orbits.DirectionOrbitEntry[] {
502
- return orbits.orbit(classKey(key), indices as { readonly hkl: Hkl }, options);
556
+ return orbits.orbit(classKey(key), indices as orbits.FaceIndices, options);
503
557
  }
504
558
 
505
559
  /**
506
560
  * The orbit of a direction (any non-zero vector, Cartesian, e.g. a face normal) under a list of
507
561
  * operations, for instance those of a distorted crystal: the images of its unit vector under each
508
562
  * operation, coinciding images merged (closer than `tolerance`, default `EPSILON`, as for
509
- * `siteSymmetry`), in the order in which the operations reach them, each with the indices of the
563
+ * `siteSymmetryOf`), in the order in which the operations reach them, each with the indices of the
510
564
  * operations that map the direction there. The list is taken as it is, not closed into a group.
511
- * Throws a RangeError for a zero vector and for a matrix that is not orthogonal (within
565
+ * Throws a RangeError for a zero vector and for an operation without an orthogonal Cartesian matrix (`cartesian`; within
512
566
  * `tolerance`, at least `EPSILON`).
513
567
  */
514
568
  export function orbitOf(
515
569
  operations: readonly OperationArgument[],
516
570
  direction: Vec3,
517
- options?: orbits.OrbitOptions,
571
+ options?: ToleranceOptions,
518
572
  ): readonly orbits.OrbitPole[] {
519
573
  checkUnitary(operations);
520
574
  return orbits.orbitOf(operations, direction, options);
@@ -533,8 +587,7 @@ export const CRYSTAL_FORM_TYPES: readonly forms.CrystalFormType[] = forms.CRYSTA
533
587
  /**
534
588
  * The crystal forms of a crystal class, as ITA 6th ed. Table 3.2.3.2 prints them: for each Wyckoff
535
589
  * position (general position first) its basic form (two for the cubic faces (hhl) of -43m and
536
- * m-3m), then its limiting forms. In the ITC convention
537
- * only, like the Wyckoff positions (docs/conventions.md, "Crystal forms").
590
+ * m-3m), then its limiting forms (docs/conventions.md, "Crystal forms").
538
591
  */
539
592
  export function crystalForms(key: PointGroupKey, options?: SettingOptions): readonly forms.CrystalForm[] {
540
593
  return forms.crystalForms(classKey(key), options);
@@ -543,11 +596,9 @@ export function crystalForms(key: PointGroupKey, options?: SettingOptions): read
543
596
  // --- tensors ---------------------------------------------------------------------------------------
544
597
 
545
598
  /**
546
- * The form of a tensor under a crystal class in the requested setting (default: the default
547
- * setting of the convention, `'itc'` unless given). The tensor is given by its specification or by
548
- * the name of a property in `TENSOR_PROPERTIES` (`'piezoelectric'`). The convention matters only
549
- * through the setting: the same setting index gives the same form in both conventions
550
- * (docs/conventions.md, "Tensors").
599
+ * The form of a tensor under a crystal class in the requested setting (default: the ITC default
600
+ * setting). The tensor is given by its specification or by the name of a property in
601
+ * `TENSOR_PROPERTIES` (`'piezoelectric'`; docs/conventions.md, "Tensors").
551
602
  */
552
603
  export function tensorForm(
553
604
  key: PointGroupKey,
@@ -560,37 +611,44 @@ export function tensorForm(
560
611
  /**
561
612
  * The form of a tensor under the group generated by `operations`, e.g. the site symmetry of a
562
613
  * surface normal (`siteSymmetry`) or the operations of a distorted crystal. The tensor is given by
563
- * its specification or by the name of a property in `TENSOR_PROPERTIES`. The operations are
564
- * Cartesian and orthogonal; a list that is not closed is closed first. Throws a RangeError for a
565
- * matrix that is not orthogonal.
614
+ * its specification or by the name of a property in `TENSOR_PROPERTIES`. Each operation is read by
615
+ * its Cartesian matrix (`cartesian`), which must be orthogonal. The list is closed into a group
616
+ * within the tolerance, and that group is made exact before the form is computed, so that matrices
617
+ * with rounding errors (e.g. rounded to 6 decimals) give the form of the exact group, with its
618
+ * number of free parameters (docs/conventions.md, "Tolerances"). Throws a RangeError for an
619
+ * operation without an orthogonal Cartesian matrix (`cartesian`; within the tolerance) and for
620
+ * operations that generate no finite group within the tolerance.
566
621
  */
567
622
  export function tensorFormOf(
568
623
  operations: readonly OperationArgument[],
569
624
  spec: TensorSpecArgument | TensorPropertyName,
625
+ options?: ToleranceOptions,
570
626
  ): TensorForm {
571
- return tensors.tensorFormOf(unitary(operations), timeEven(spec));
627
+ return tensors.tensorFormOf(unitary(operations), timeEven(spec), options);
572
628
  }
573
629
 
574
630
  /**
575
- * The components of `tensor` (length 3^rank, flat index) in a frame rotated by the orthogonal
631
+ * The tensor `tensor` in a frame rotated by the orthogonal
576
632
  * matrix `rotation`: t′_{i…} = f·Σ R_{ia}…R_{…}·t_{a…}, with f = det(R) for an axial tensor and 1
577
633
  * for a polar one. To express a tensor in the frame of a surface, pass the matrix whose rows are
578
634
  * the new axes in the old frame. The kind of tensor is given by its specification or by the name
579
- * of a property in `TENSOR_PROPERTIES`.
635
+ * of a property in `TENSOR_PROPERTIES`. Throws a RangeError for a rotation that is not orthogonal
636
+ * within the tolerance (per matrix entry of RᵀR).
580
637
  */
581
638
  export function rotateTensor(
582
639
  tensor: readonly number[],
583
640
  rotation: Mat3,
584
- specOrName: TensorSpecArgument | TensorPropertyName,
585
- ): number[] {
586
- return tensors.rotateTensor(tensor, rotation, timeEven(specOrName));
641
+ spec: TensorSpecArgument | TensorPropertyName,
642
+ options?: ToleranceOptions,
643
+ ): readonly number[] {
644
+ return tensors.rotateTensor(tensor, rotation, timeEven(spec), options);
587
645
  }
588
646
 
589
647
  /**
590
648
  * True if the crystal class allows the named property, e.g. `allowsProperty('-6m2',
591
649
  * 'piezoelectric')`: the tensor that describes it (`TENSOR_PROPERTIES`) has a non-zero form under
592
650
  * the class. Symmetry only allows a property; whether a crystal shows it is a question of the
593
- * material. It does not depend on setting or convention. Throws a RangeError for an unknown key or
651
+ * material. It does not depend on the setting. Throws a RangeError for an unknown key or
594
652
  * name.
595
653
  */
596
654
  export function allowsProperty(key: PointGroupKey, name: TensorPropertyName): boolean {
@@ -598,21 +656,38 @@ export function allowsProperty(key: PointGroupKey, name: TensorPropertyName): bo
598
656
  }
599
657
 
600
658
  /** The named properties the crystal class allows, in the order of `TENSOR_PROPERTIES`. */
601
- export function allowedProperties(key: PointGroupKey): TensorPropertyName[] {
602
- return TENSOR_PROPERTY_NAMES.filter((name) => allowsProperty(key, name));
659
+ export function allowedProperties(key: PointGroupKey): readonly TensorPropertyName[] {
660
+ return deepFreeze(TENSOR_PROPERTY_NAMES.filter((name) => allowsProperty(key, name)));
603
661
  }
604
662
 
605
663
  /**
606
664
  * True if the group generated by `operations` allows the named property, e.g. for the site
607
- * symmetry of a surface normal or the operations of a distorted crystal. The matrices must be
608
- * Cartesian and orthogonal; a list that is not closed is closed first. Throws a RangeError for a matrix that is not orthogonal.
665
+ * symmetry of a surface normal or the operations of a distorted crystal. The operations are read
666
+ * and closed as `tensorFormOf` reads them, within the tolerance, and it throws a RangeError as
667
+ * `tensorFormOf` does.
609
668
  */
610
- export function allowsPropertyOf(operations: readonly OperationArgument[], name: TensorPropertyName): boolean {
611
- return tensors.tensorFormOf(unitary(operations), propertyName(name)).basis.length > 0;
669
+ export function allowsPropertyOf(
670
+ operations: readonly OperationArgument[],
671
+ name: TensorPropertyName,
672
+ options?: ToleranceOptions,
673
+ ): boolean {
674
+ checkOptions(options, TOLERANCE_KEYS, 'allowsPropertyOf');
675
+ const checked = propertyName(name);
676
+ const { spec, perms } = tensors.checkedSpec(checked);
677
+ return tensors.formOfGroup(tensors.callerGroup(unitary(operations), options), spec, perms).basis.length > 0;
612
678
  }
613
679
 
614
- /** The named properties the group generated by `operations` allows. Checks the operations as `allowsPropertyOf`. */
615
- export function allowedPropertiesOf(operations: readonly OperationArgument[]): TensorPropertyName[] {
616
- const ops = unitary(operations);
617
- return TENSOR_PROPERTY_NAMES.filter((name) => tensors.tensorFormOf(ops, name).basis.length > 0);
680
+ /** The named properties the group generated by `operations` allows. Reads the operations as `allowsPropertyOf`. */
681
+ export function allowedPropertiesOf(
682
+ operations: readonly OperationArgument[],
683
+ options?: ToleranceOptions,
684
+ ): readonly TensorPropertyName[] {
685
+ checkOptions(options, TOLERANCE_KEYS, 'allowedPropertiesOf');
686
+ const group = tensors.callerGroup(unitary(operations), options);
687
+ return deepFreeze(
688
+ TENSOR_PROPERTY_NAMES.filter((name) => {
689
+ const { spec, perms } = tensors.checkedSpec(name);
690
+ return tensors.formOfGroup(group, spec, perms).basis.length > 0;
691
+ }),
692
+ );
618
693
  }