symcrys 0.10.0 → 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 +146 -118
  15. package/dist/crystalClasses.d.ts.map +1 -1
  16. package/dist/crystalClasses.js +163 -124
  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 +9 -17
  115. package/dist/siteSymmetry.d.ts.map +1 -1
  116. package/dist/siteSymmetry.js +62 -47
  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 +12 -4
  145. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  146. package/dist/tensors/rowEchelon.js +24 -11
  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 +173 -68
  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 +234 -160
  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 -69
  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 +71 -64
  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 +29 -17
  199. package/src/tensors/rowEchelon.ts +28 -9
  200. package/src/tensors/tensorForm.ts +260 -89
  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
@@ -1,61 +1,86 @@
1
1
  /**
2
2
  * Public API for the point groups: the 32 crystallographic point groups (crystal classes) and the
3
3
  * 90 magnetic point groups with time reversal (32 grey, 58 black-and-white). Lookup, settings,
4
- * operations, generators and symbols, in the ITC convention (default) or the Birss convention.
4
+ * operations, generators and symbols, as ITC gives them (CLAUDE.md, "Pure ITC").
5
5
  */
6
- import { INVERSION, det, matricesEqual } from '../linalg.js';
6
+ import { checkOptions, SETTING_KEYS, shown } from '../checks.js';
7
+ import { INVERSION, det, inverse, matricesEqual, multiply } from '../linalg.js';
7
8
  import { EPSILON } from '../tolerances.js';
8
- import { MAX_GROUP_ORDER, closeGroup, compose, operationsEqual, transformOperation, } from '../operations.js';
9
- import { inItaOrder, itaGeneratorOperations } from './itaOrder.js';
10
- import { POINT_GROUP_DATA, POINT_GROUP_KEYS } from './data.js';
11
- import { BLACK_WHITE_DATA, MAGNETIC_POINT_GROUP_KEYS, TIME_REVERSAL, greySchoenflies, } from './magneticData.js';
9
+ import { compactSymbol } from '../notation.js';
10
+ import { compose, operation, operationsEqual } from '../operations.js';
11
+ import { ITC_CLASSES, itcBasis, itcCartesianGenerators, itcCartesianOperations, itcClass, itcLatticeGenerators, itcLatticeOperations, itcSetting, } from './itcData.js';
12
+ import { ITC_BLACK_WHITE, itcBlackWhiteClassSetting, itcBlackWhiteOperations, itcBlackWhiteSetting, } from './itcMagneticData.js';
13
+ import { crystalFamily, latticeSystemsOfSystem } from '../lattice.js';
14
+ import { MAGNETIC_POINT_GROUP_KEYS, POINT_GROUP_KEYS, TIME_REVERSAL, greySchoenflies, } from './keys.js';
12
15
  import { primedSymbols } from './magneticSymbols.js';
13
- export { POINT_GROUP_KEYS } from './data.js';
14
- export { MAGNETIC_POINT_GROUP_KEYS } from './magneticData.js';
16
+ import { deepFreeze } from '../freeze.js';
17
+ export { MAGNETIC_POINT_GROUP_KEYS, POINT_GROUP_KEYS } from './keys.js';
18
+ /**
19
+ * The second argument of `findPointGroup`: the criteria, checked. A string is the convention that
20
+ * up to 0.10 came here (`findPointGroup(symbol, 'birss')`), a RangeError that names the change.
21
+ */
22
+ function criteriaArgument(arg) {
23
+ if (arg === undefined)
24
+ return undefined;
25
+ if (typeof arg === 'string')
26
+ rejectConventionArgument(2);
27
+ checkOptions(arg, ['axes', 'uniqueAxis'], 'findPointGroup');
28
+ // The values are checked here, before a group is found, so that a wrong value is an error also
29
+ // for a symbol that names no group.
30
+ const { axes, uniqueAxis } = arg;
31
+ if (axes !== undefined && axes !== 'hexagonal' && axes !== 'rhombohedral') {
32
+ throw new RangeError(`axes must be 'hexagonal' or 'rhombohedral', not ${shown(axes)}`);
33
+ }
34
+ if (uniqueAxis !== undefined && uniqueAxis !== 'a' && uniqueAxis !== 'b' && uniqueAxis !== 'c') {
35
+ throw new RangeError(`uniqueAxis must be 'a', 'b' or 'c', not ${shown(uniqueAxis)}`);
36
+ }
37
+ return arg;
38
+ }
39
+ /** The ITC default setting of a class, from the ITC class data (itcData.ts). */
40
+ function itcDefaultOf(key) {
41
+ return itcClass(key).settings.find((s) => s.isDefault).index;
42
+ }
43
+ // Built from the ITC data, in their order (that of POINT_GROUP_KEYS and
44
+ // BLACK_WHITE_POINT_GROUP_KEYS).
15
45
  const BY_KEY = new Map();
16
- for (const d of POINT_GROUP_DATA) {
46
+ for (const c of ITC_CLASSES) {
17
47
  const self = {
18
- key: d.key,
48
+ key: c.key,
19
49
  type: 'I',
20
50
  get crystalClass() {
21
51
  return self;
22
52
  },
23
- crystalSystem: d.crystalSystem,
24
- schoenflies: d.schoenflies,
25
- generators: d.generators,
26
- settings: d.settings,
27
- itcDefault: d.itcDefault,
28
- symbols: d.settings,
53
+ crystalSystem: c.crystalSystem,
54
+ schoenflies: c.schoenflies,
55
+ itcDefault: itcDefaultOf(c.key),
56
+ settingCount: c.settings.length,
29
57
  };
30
- BY_KEY.set(d.key, self);
58
+ BY_KEY.set(c.key, self);
31
59
  }
32
- // Grey groups: the class and time reversal (ITC Vol. D, eq. (1.5.2.1)). birss-app generates them
33
- // from the generators of the class followed by 1', without the identity generator of class 1.
34
- for (const d of POINT_GROUP_DATA) {
35
- const crystalClass = BY_KEY.get(d.key);
36
- const key = `${d.key}1'`;
60
+ // Grey groups: the class and time reversal (ITC Vol. D, eq. (1.5.2.1)).
61
+ for (const c of ITC_CLASSES) {
62
+ const crystalClass = BY_KEY.get(c.key);
63
+ const key = `${c.key}1'`;
37
64
  BY_KEY.set(key, {
38
65
  key,
39
66
  type: 'II',
40
67
  crystalClass,
41
- crystalSystem: d.crystalSystem,
42
- schoenflies: greySchoenflies(d.schoenflies),
43
- generators: [...(d.key === '1' ? [] : d.generators), TIME_REVERSAL],
44
- settings: d.settings,
45
- itcDefault: d.itcDefault,
68
+ crystalSystem: c.crystalSystem,
69
+ schoenflies: greySchoenflies(c.schoenflies),
70
+ itcDefault: crystalClass.itcDefault,
71
+ settingCount: crystalClass.settingCount,
46
72
  });
47
73
  }
48
- for (const d of BLACK_WHITE_DATA) {
49
- const crystalClass = BY_KEY.get(d.crystalClass);
50
- BY_KEY.set(d.key, {
51
- key: d.key,
74
+ for (const g of ITC_BLACK_WHITE) {
75
+ const crystalClass = BY_KEY.get(g.crystalClass);
76
+ BY_KEY.set(g.key, {
77
+ key: g.key,
52
78
  type: 'III',
53
79
  crystalClass,
54
80
  crystalSystem: crystalClass.crystalSystem,
55
- schoenflies: d.schoenflies,
56
- generators: d.generators,
57
- settings: d.settings,
58
- itcDefault: d.itcDefault,
81
+ schoenflies: g.schoenflies,
82
+ itcDefault: g.settings.find((s) => s.isDefault).index,
83
+ settingCount: g.settings.length,
59
84
  });
60
85
  }
61
86
  /** True if `key` is the key of one of the 32 crystal classes. */
@@ -69,84 +94,173 @@ export function isMagneticPointGroupKey(key) {
69
94
  function data(key) {
70
95
  const d = BY_KEY.get(key);
71
96
  if (!d)
72
- throw new RangeError(`Unknown point group key: ${JSON.stringify(key)}`);
97
+ throw new RangeError(`Unknown point group key: ${shown(key)}`);
73
98
  return d;
74
99
  }
75
- function convention(options) {
76
- const c = options?.convention ?? 'itc';
77
- if (c !== 'itc' && c !== 'birss')
78
- throw new RangeError(`Unknown convention: ${JSON.stringify(c)}`);
79
- return c;
100
+ /**
101
+ * Throws for a second argument of `settings` or `findPointGroup`, which took a convention up to
102
+ * 0.10 (`settings('32', 'birss')`): TypeScript refuses it, plain JavaScript would ignore it and
103
+ * answer for the ITC frame. Internal.
104
+ */
105
+ export function rejectConventionArgument(argumentCount) {
106
+ if (argumentCount > 1) {
107
+ throw new RangeError('The convention argument was removed in symcrys 0.11.0: symcrys follows ITC only (CHANGELOG.md, 0.11.0)');
108
+ }
80
109
  }
81
- function defaultSetting(d, c) {
82
- return c === 'itc' ? d.itcDefault : 1;
110
+ /** The settings a symbol names, spaces ignored: by its key, its short or full symbol, or Birss's cubic form. */
111
+ function settingsNamed(d, text) {
112
+ const compactText = compact(text);
113
+ const target = birssCubic(compactText) === d.key ? d.key : compactText;
114
+ return allSettings(d).filter((i) => {
115
+ if (target === d.key && i === d.itcDefault)
116
+ return true;
117
+ const s = settingSymbols(d, i);
118
+ return compact(s.short) === target || compact(derivedSymbols(d, i).short) === target || compact(s.full) === target;
119
+ });
83
120
  }
84
- /** The requested setting index, checked; the convention's default if none is given. */
121
+ const allSettings = (d) => Array.from({ length: d.settingCount }, (_, i) => i + 1);
122
+ /** The settings of `d`, listed for an error message. */
123
+ function listSettings(d, indices) {
124
+ return indices
125
+ .map((i) => {
126
+ const axes = settingAxes(d, i);
127
+ const unique = settingUniqueAxis(d, i);
128
+ const note = axes ? `, ${axes} axes` : unique ? `, unique axis ${unique}` : '';
129
+ return `${i}: ${settingSymbols(d, i).short} (${settingSymbols(d, i).full}${note})`;
130
+ })
131
+ .join(', ');
132
+ }
133
+ /** `axes` and `uniqueAxis` of the options, checked against the family of the group. */
134
+ function criteriaOf(d, options) {
135
+ const axes = options?.axes;
136
+ const uniqueAxis = options?.uniqueAxis;
137
+ if (axes !== undefined) {
138
+ if (axes !== 'hexagonal' && axes !== 'rhombohedral') {
139
+ throw new RangeError(`axes must be 'hexagonal' or 'rhombohedral', not ${shown(axes)}`);
140
+ }
141
+ if (crystalFamily(d.crystalSystem) !== 'hexagonal') {
142
+ throw new RangeError(`Point group ${d.key} (${d.crystalSystem}): axes applies to the trigonal and hexagonal groups`);
143
+ }
144
+ }
145
+ if (uniqueAxis !== undefined) {
146
+ if (uniqueAxis !== 'a' && uniqueAxis !== 'b' && uniqueAxis !== 'c') {
147
+ throw new RangeError(`uniqueAxis must be 'a', 'b' or 'c', not ${shown(uniqueAxis)}`);
148
+ }
149
+ if (d.crystalSystem !== 'monoclinic') {
150
+ throw new RangeError(`Point group ${d.key} (${d.crystalSystem}): uniqueAxis applies to the monoclinic groups`);
151
+ }
152
+ }
153
+ return { ...(axes ? { axes } : {}), ...(uniqueAxis ? { uniqueAxis } : {}) };
154
+ }
155
+ /** Whether setting `i` meets the criteria (`axes: 'hexagonal'` holds for every hexagonal group). */
156
+ function meets(d, i, c) {
157
+ if (c.axes && (settingAxes(d, i) ?? 'hexagonal') !== c.axes)
158
+ return false;
159
+ if (c.uniqueAxis && settingUniqueAxis(d, i) !== c.uniqueAxis)
160
+ return false;
161
+ return true;
162
+ }
163
+ /**
164
+ * The setting among `candidates` that meets the criteria: the only one, or the standard (ITC
165
+ * default) where it is one of several, as a name without a criterion means the standard (Thomas,
166
+ * 2026-11-23, #96). None, or several without the standard, is a RangeError that lists them.
167
+ */
168
+ function choose(d, candidates, criteria, what) {
169
+ const met = candidates.filter((i) => meets(d, i, criteria));
170
+ if (met.length === 1)
171
+ return met[0];
172
+ if (met.includes(d.itcDefault))
173
+ return d.itcDefault;
174
+ const crit = [criteria.axes && `${criteria.axes} axes`, criteria.uniqueAxis && `unique axis ${criteria.uniqueAxis}`]
175
+ .filter(Boolean)
176
+ .join(', ');
177
+ const asked = what ? [what, crit].filter(Boolean).join(', ') : `with ${crit}`;
178
+ throw new RangeError(met.length === 0
179
+ ? `Point group ${d.key} has no setting ${asked} (settings ${listSettings(d, allSettings(d))})`
180
+ : `Point group ${d.key}: ${asked} names ${met.length} settings; give the index (${listSettings(d, met)})`);
181
+ }
182
+ /** The requested setting index, checked; the ITC default if none is given. */
85
183
  function settingIndex(d, options) {
86
- const c = convention(options);
87
- const index = options?.setting ?? defaultSetting(d, c);
88
- if (!Number.isInteger(index) || index < 1 || index > d.settings.length) {
89
- throw new RangeError(`Point group ${d.key} has no setting ${String(index)} (settings 1 to ${d.settings.length})`);
184
+ const criteria = criteriaOf(d, options);
185
+ const requested = options?.setting;
186
+ if (requested !== undefined && requested !== null && typeof requested !== 'number' && typeof requested !== 'string') {
187
+ throw new RangeError(`The setting must be an index or a symbol, not ${shown(requested)}`);
188
+ }
189
+ if (typeof requested === 'string') {
190
+ const named = settingsNamed(d, requested);
191
+ if (named.length === 0) {
192
+ throw new RangeError(`Point group ${d.key} has no setting ${shown(requested)} (settings ${listSettings(d, allSettings(d))})`);
193
+ }
194
+ return choose(d, named, criteria, shown(requested));
90
195
  }
91
- return index;
196
+ if (requested === undefined || requested === null)
197
+ return choose(d, allSettings(d), criteria, '');
198
+ const count = d.settingCount;
199
+ if (!Number.isInteger(requested) || requested < 1 || requested > count) {
200
+ throw new RangeError(`Point group ${d.key} has no setting ${String(requested)} (settings 1 to ${count})`);
201
+ }
202
+ if (!meets(d, requested, criteria)) {
203
+ throw new RangeError(`Point group ${d.key}: setting ${requested} does not have the ${[criteria.axes && `${criteria.axes} axes`, criteria.uniqueAxis && `unique axis ${criteria.uniqueAxis}`].filter(Boolean).join(', ')} (settings ${listSettings(d, allSettings(d))})`);
204
+ }
205
+ return requested;
206
+ }
207
+ /**
208
+ * The index of the requested setting (an index or a symbol; the ITC default if none), checked.
209
+ * Internal: for the modules that cache by setting.
210
+ */
211
+ export function settingIndexOf(key, options) {
212
+ return settingIndex(data(key), options);
92
213
  }
93
214
  function freezeOperation(op) {
94
- const [r0, r1, r2] = op.matrix;
215
+ const [r0, r1, r2] = op.cartesian;
95
216
  return Object.freeze({
96
- matrix: Object.freeze([Object.freeze([...r0]), Object.freeze([...r1]), Object.freeze([...r2])]),
217
+ cartesian: Object.freeze([Object.freeze([...r0]), Object.freeze([...r1]), Object.freeze([...r2])]),
97
218
  timeReversal: op.timeReversal,
98
219
  });
99
220
  }
100
- const generatorCache = new Map();
101
221
  const operationCache = new Map();
102
- /** The stored generators carried into the frame of a setting: the generators of the Birss convention. */
103
- function settingGenerators(d, index) {
104
- const cacheKey = `${d.key}#${index}`;
105
- let result = generatorCache.get(cacheKey);
106
- if (!result) {
107
- const frame = d.settings[index - 1].frame;
108
- result = Object.freeze(d.generators.map((g) => freezeOperation(transformOperation(g, frame))));
109
- generatorCache.set(cacheKey, result);
110
- }
111
- return result;
112
- }
113
222
  /** The operation of `ops` with the matrix of `op`, whatever its time reversal. */
114
223
  function withMatrix(ops, op) {
115
- const found = ops.find((x) => matricesEqual(x.matrix, op.matrix));
224
+ const found = ops.find((x) => matricesEqual(x.cartesian, op.cartesian));
116
225
  if (!found)
117
226
  throw new Error('Operation of the crystal class missing in the magnetic group');
118
227
  return found;
119
228
  }
120
- const classSettingCache = new Map();
121
229
  /**
122
230
  * The setting of the crystal class whose frame is that of setting `index` of the group: the one
123
231
  * in which the class has the operations of the group without their time reversal. For a class and
124
- * a grey group it is `index` itself. A black-and-white group may have its settings in another
125
- * order than its class, and settings its class does not tell apart (docs/conventions.md,
232
+ * a grey group it is `index` itself; for a black-and-white group, the class setting named by its
233
+ * ITC symbol without primes (itcMagneticData.ts). A black-and-white group may have its settings in
234
+ * another order than its class, and settings its class does not tell apart (docs/conventions.md,
126
235
  * "Settings").
127
236
  */
128
237
  function classSetting(d, index) {
129
- if (d.type !== 'III')
130
- return index;
131
- const cacheKey = `${d.key}#${index}`;
132
- let result = classSettingCache.get(cacheKey);
133
- if (!result) {
134
- const ops = closeGroup(settingGenerators(d, index));
135
- const c = d.crystalClass;
136
- result =
137
- c.settings.findIndex((_, i) => {
138
- const classOps = settingOperations(c, i + 1);
139
- return (classOps.length === ops.length && classOps.every((x) => ops.some((y) => matricesEqual(x.matrix, y.matrix))));
140
- }) + 1;
141
- if (!result)
142
- throw new Error(`Point group ${d.key}, setting ${index}: no setting of class ${c.key} has this frame`);
143
- classSettingCache.set(cacheKey, result);
144
- }
145
- return result;
238
+ return d.type === 'III' ? itcBlackWhiteClassSetting(d.key, index) : index;
239
+ }
240
+ /** The unique axis of a monoclinic setting; undefined in other systems. */
241
+ function settingUniqueAxis(d, index) {
242
+ return d.type === 'III'
243
+ ? itcBlackWhiteSetting(d.key, index).uniqueAxis
244
+ : itcSetting(d.crystalClass.key, index).uniqueAxis;
245
+ }
246
+ /** The axes of a trigonal setting, `'hexagonal'` or `'rhombohedral'`; undefined in other systems. */
247
+ function settingAxes(d, index) {
248
+ return d.type === 'III'
249
+ ? itcBlackWhiteSetting(d.key, index).axes
250
+ : itcSetting(d.crystalClass.key, index).axes;
251
+ }
252
+ /**
253
+ * The crystal class of a group and the setting of the class whose frame and basis the requested
254
+ * setting of the group has. Internal: for the modules that need the basis or the symmetry
255
+ * directions of a setting.
256
+ */
257
+ export function classSettingOf(key, options) {
258
+ const d = data(key);
259
+ return { key: d.crystalClass.key, index: classSetting(d, settingIndex(d, options)) };
146
260
  }
147
261
  const itaGeneratorCache = new Map();
148
262
  /**
149
- * ITA's generators of a setting (see `generators`); throws if setting 1 of a class has none. For a
263
+ * ITA's generators of a setting (see `generators`); for a class from the ITC class data. For a
150
264
  * magnetic group: ITA's generators of its class in the same frame, each with the time reversal it
151
265
  * has in the group; for a grey group followed by time reversal 1'.
152
266
  */
@@ -156,14 +270,7 @@ function settingItaGenerators(d, index) {
156
270
  if (!result) {
157
271
  let gens;
158
272
  if (d.type === 'I') {
159
- const ita = itaGeneratorOperations(d.key, index, d.crystalSystem);
160
- if (ita)
161
- gens = ita;
162
- else {
163
- if (index === 1)
164
- throw new Error(`Point group ${d.key}: no ITA generators for setting 1`);
165
- gens = settingItaGenerators(d, 1).map((op) => transformOperation(op, d.settings[index - 1].frame));
166
- }
273
+ gens = itcCartesianGenerators(d.key, index).map((m) => operation(m));
167
274
  }
168
275
  else {
169
276
  const classGens = settingItaGenerators(d.crystalClass, classSetting(d, index));
@@ -177,108 +284,71 @@ function settingItaGenerators(d, index) {
177
284
  }
178
285
  return result;
179
286
  }
180
- const birssOperationCache = new Map();
181
- /**
182
- * The operations of a setting in the Birss convention, in birss-app's order (docs/conventions.md,
183
- * "Birss convention and birss-app"): the generators of the setting first, then repeated passes
184
- * that append every new product g·h of two operations found before the pass, in the order of g,
185
- * then h, until a pass adds nothing.
186
- */
187
- function birssOperations(d, index) {
188
- const cacheKey = `${d.key}#${index}`;
189
- let result = birssOperationCache.get(cacheKey);
190
- if (!result) {
191
- const group = [...settingGenerators(d, index)];
192
- for (let changed = true; changed;) {
193
- changed = false;
194
- const size = group.length;
195
- for (let i = 0; i < size; i++) {
196
- for (let j = 0; j < size; j++) {
197
- const product = compose(group[i], group[j]);
198
- if (!group.some((g) => operationsEqual(g, product))) {
199
- if (group.length >= MAX_GROUP_ORDER)
200
- throw new Error(`Point group ${d.key}: closure does not terminate`);
201
- group.push(product);
202
- changed = true;
203
- }
204
- }
205
- }
206
- }
207
- if (!sameSet(group, settingOperations(d, index))) {
208
- throw new Error(`Point group ${d.key}, setting ${index}: Birss operations differ from the closure`);
209
- }
210
- result = Object.freeze(group.map(freezeOperation));
211
- birssOperationCache.set(cacheKey, result);
212
- }
213
- return result;
214
- }
215
287
  /**
216
288
  * The operations of a setting in ITA's order (docs/conventions.md, "Order of the operations"). A
217
- * crystal class: for a setting ITA lists, coset by coset from ITA's generators; for a setting ITA
218
- * does not list (today `mm2` settings 2 and 3), the order of setting 1, carried into the frame of
219
- * the setting. Setting 1 is always one ITA lists; throws if its generators are missing or do not
220
- * give the closure. A black-and-white group: the operations of its class in the same frame, in
221
- * that order, each with the time reversal it has in the group. A grey group: the operations of its
222
- * class, then the same sequence combined with time reversal.
289
+ * crystal class: from the ITC class data (itcData.ts), built coset by coset from ITA's generators.
290
+ * A black-and-white group: the operations of its class in the setting its ITC symbol names, in
291
+ * that order, each with the time reversal its symbol gives (itcMagneticData.ts). A grey group: the
292
+ * operations of its class, then the same sequence combined with time reversal.
223
293
  */
224
294
  function settingOperations(d, index) {
225
295
  const cacheKey = `${d.key}#${index}`;
226
296
  let result = operationCache.get(cacheKey);
227
297
  if (!result) {
228
- const closed = closeGroup(settingGenerators(d, index));
229
298
  let ordered;
230
299
  if (d.type === 'I') {
231
- ordered = inItaOrder(d.key, index, d.crystalSystem, closed);
232
- if (!ordered) {
233
- if (index === 1)
234
- throw new Error(`Point group ${d.key}: no ITA generators for setting 1`);
235
- ordered = settingOperations(d, 1).map((op) => transformOperation(op, d.settings[index - 1].frame));
236
- }
300
+ ordered = itcCartesianOperations(d.key, index).map((m) => operation(m));
237
301
  }
238
- else {
239
- const classOps = settingOperations(d.crystalClass, classSetting(d, index));
240
- ordered =
241
- d.type === 'II'
242
- ? [...classOps, ...classOps.map((op) => compose(TIME_REVERSAL, op))]
243
- : classOps.map((op) => withMatrix(closed, op));
302
+ else if (d.type === 'II') {
303
+ const classOps = settingOperations(d.crystalClass, index);
304
+ ordered = [...classOps, ...classOps.map((op) => compose(TIME_REVERSAL, op))];
244
305
  }
245
- if (!sameSet(ordered, closed)) {
246
- throw new Error(`Point group ${d.key}, setting ${index}: ordered operations differ from the closure`);
306
+ else {
307
+ ordered = [...itcBlackWhiteOperations(d.key, index)];
247
308
  }
248
309
  result = Object.freeze(ordered.map(freezeOperation));
249
310
  operationCache.set(cacheKey, result);
250
311
  }
251
312
  return result;
252
313
  }
253
- /** True if `a` is `b` in some order: equal length, no operation twice in `a`, every one of `a` in `b`. */
254
- function sameSet(a, b) {
255
- return (a.length === b.length &&
256
- a.every((op, i) => b.some((x) => operationsEqual(x, op)) && !a.slice(0, i).some((x) => operationsEqual(x, op))));
257
- }
258
314
  const symbolCache = new Map();
259
315
  /**
260
- * Short and full symbol of a setting in a convention. A crystal class: as stored. A grey group:
261
- * the symbols of its class followed by `1'`. A black-and-white group: the symbols of its class in
262
- * the same frame, with the primes of its operations (magneticSymbols.ts).
316
+ * Short and full symbol of a setting as symcrys gives them (#137 B2): those of `derivedSymbols`,
317
+ * except that the default setting of a grey or black-and-white group has its key as short symbol:
318
+ * that of ITC Vol. D Table 1.5.2.3 for a black-and-white group (`32'`, not `32'1`), the class key
319
+ * followed by `1'` for a grey group (`321'`, not `3211'`). A crystal class keeps
320
+ * ITA's symbol (`321`) in both entry points.
263
321
  */
264
- function settingSymbols(d, index, c) {
265
- if (d.symbols)
266
- return d.symbols[index - 1][c];
267
- const cacheKey = `${d.key}#${index}#${c}`;
322
+ function settingSymbols(d, index) {
323
+ const derived = derivedSymbols(d, index);
324
+ return d.type !== 'I' && index === d.itcDefault ? { short: d.key, full: derived.full } : derived;
325
+ }
326
+ /**
327
+ * Short and full symbol of a setting by the rule. A crystal class: from the ITC class data
328
+ * (itcData.ts). A grey group: the symbols of its class followed by `1'`. A black-and-white group:
329
+ * the symbols of its class in the same frame, with the primes of its operations
330
+ * (magneticSymbols.ts).
331
+ */
332
+ function derivedSymbols(d, index) {
333
+ if (d.type === 'I') {
334
+ const s = itcSetting(d.key, index);
335
+ return Object.freeze({ short: s.short, full: s.full });
336
+ }
337
+ const cacheKey = `${d.key}#${index}`;
268
338
  let result = symbolCache.get(cacheKey);
269
339
  if (!result) {
270
- const classSymbols = settingSymbols(d.crystalClass, classSetting(d, index), c);
340
+ const classSymbols = derivedSymbols(d.crystalClass, classSetting(d, index));
271
341
  result = Object.freeze(d.type === 'II'
272
342
  ? { short: `${classSymbols.short}1'`, full: `${classSymbols.full} 1'` }
273
- : primedSymbols(classSymbols, d.crystalSystem, c, settingOperations(d, index)));
343
+ : primedSymbols(classSymbols, d.crystalSystem, settingOperations(d, index)));
274
344
  symbolCache.set(cacheKey, result);
275
345
  }
276
346
  return result;
277
347
  }
278
- // --- properties fixed by the operations (setting 1, the frame all stored data share) ---------------
348
+ // --- properties fixed by the operations (setting 1; a class and its Laue class share its frame) ----
279
349
  /** Contains the inversion, not combined with time reversal. */
280
350
  function hasInversion(ops) {
281
- return ops.some((op) => !op.timeReversal && matricesEqual(op.matrix, INVERSION));
351
+ return ops.some((op) => !op.timeReversal && matricesEqual(op.cartesian, INVERSION));
282
352
  }
283
353
  /**
284
354
  * Some direction is left unchanged by every operation: the group average of the matrices, which
@@ -289,7 +359,7 @@ function hasFixedDirection(ops) {
289
359
  for (let j = 0; j < 3; j++) {
290
360
  let sum = 0;
291
361
  for (const op of ops)
292
- sum += op.matrix[i][j];
362
+ sum += op.cartesian[i][j];
293
363
  if (Math.abs(sum / ops.length) > EPSILON)
294
364
  return true;
295
365
  }
@@ -303,7 +373,7 @@ function laueClassOf(crystalClass) {
303
373
  if (cached)
304
374
  return cached;
305
375
  const ops = settingOperations(crystalClass, 1);
306
- const inversion = { matrix: INVERSION, timeReversal: false };
376
+ const inversion = { cartesian: INVERSION, timeReversal: false };
307
377
  const withInversion = [...ops];
308
378
  for (const op of ops) {
309
379
  const product = compose(inversion, op);
@@ -335,7 +405,7 @@ export function pointGroup(key) {
335
405
  order: ops.length,
336
406
  centrosymmetric: hasInversion(ops),
337
407
  polar: hasFixedDirection(ops),
338
- chiral: ops.every((op) => det(op.matrix) > 0),
408
+ enantiomorphic: ops.every((op) => det(op.cartesian) > 0),
339
409
  laueClass: laueClassOf(d.crystalClass),
340
410
  });
341
411
  groupCache.set(d.key, g);
@@ -344,7 +414,7 @@ export function pointGroup(key) {
344
414
  }
345
415
  /** All 32 crystal classes, in the order of `POINT_GROUP_KEYS` (by crystal system, as in ITA). */
346
416
  export function pointGroups() {
347
- return POINT_GROUP_KEYS.map((key) => pointGroup(key));
417
+ return deepFreeze(POINT_GROUP_KEYS.map((key) => pointGroup(key)));
348
418
  }
349
419
  /**
350
420
  * All 122 magnetic point groups, in the order of `POINT_GROUP_KEYS` of the magnetic API: the 32 crystal
@@ -352,7 +422,7 @@ export function pointGroups() {
352
422
  * groups (type III) in the order of ITC Vol. D Table 1.5.2.3.
353
423
  */
354
424
  export function magneticPointGroups() {
355
- return MAGNETIC_POINT_GROUP_KEYS.map((key) => pointGroup(key));
425
+ return deepFreeze(MAGNETIC_POINT_GROUP_KEYS.map((key) => pointGroup(key)));
356
426
  }
357
427
  /**
358
428
  * The key of the crystal class of a point group: the group itself for a class, otherwise the class
@@ -362,114 +432,209 @@ export function magneticPointGroups() {
362
432
  export function crystalClassOf(key) {
363
433
  return data(key).crystalClass.key;
364
434
  }
365
- /** The settings of a point group, with symbols and the default of the given convention (default `'itc'`). */
366
- export function settings(key, conventionName = 'itc') {
435
+ /**
436
+ * The lattice systems of a point group: those whose lattices its crystal class can act on (ITA
437
+ * § 1.3.4.4.2 and Table 1.3.4.1, p. 39). One for every class but the trigonal ones, which belong to
438
+ * the hexagonal (hP) or the rhombohedral (hR) lattice system depending on the basis, so they give
439
+ * both, `['hexagonal', 'rhombohedral']`. The holohedry of each is `holohedry(latticeSystem)`. Throws a
440
+ * RangeError for an unknown key.
441
+ */
442
+ export function latticeSystems(key) {
443
+ return latticeSystemsOfSystem(pointGroup(key).crystalSystem);
444
+ }
445
+ /** The settings of a point group, with their symbols and the ITC default. */
446
+ export function settings(key) {
447
+ rejectConventionArgument(arguments.length);
367
448
  const d = data(key);
368
- const c = convention({ convention: conventionName });
369
- const def = defaultSetting(d, c);
370
- return d.settings.map((s, i) => {
371
- const symbols = settingSymbols(d, i + 1, c);
449
+ return deepFreeze(Array.from({ length: d.settingCount }, (_, i) => {
450
+ const symbols = settingSymbols(d, i + 1);
451
+ const data = d.type === 'III'
452
+ ? itcBlackWhiteSetting(d.key, i + 1)
453
+ : itcSetting(d.crystalClass.key, i + 1);
372
454
  return Object.freeze({
373
455
  index: i + 1,
374
456
  symbol: symbols.short,
375
457
  fullSymbol: symbols.full,
376
- ...(s.uniqueAxis ? { uniqueAxis: s.uniqueAxis } : {}),
377
- isDefault: i + 1 === def,
458
+ ...(data.uniqueAxis ? { uniqueAxis: data.uniqueAxis } : {}),
459
+ ...(data.axes ? { axes: data.axes } : {}),
460
+ isDefault: i + 1 === d.itcDefault,
378
461
  });
379
- });
462
+ }));
463
+ }
464
+ const frozenMatrix = (m) => Object.freeze(m.map((row) => Object.freeze(row.map((v) => v + 0))));
465
+ /** An integer matrix from one that should be one; throws if it is not (a data error). Internal. */
466
+ export function integer(m, what) {
467
+ const r = m.map((row) => row.map((v) => Math.round(v) + 0));
468
+ if (!m.every((row, i) => row.every((v, j) => Math.abs(v - r[i][j]) < 1e-9))) {
469
+ throw new Error(`${what} is not an integer matrix in the lattice basis: ${shown(m)}`);
470
+ }
471
+ return r;
380
472
  }
381
473
  /**
382
- * All operations of the point group in the requested setting (default: the convention's default
383
- * setting). ITC convention: in ITA's order, identity first, then as ITA numbers the general
384
- * position of the crystal class; an operation of a magnetic group has the number it has in the
385
- * class, and a grey group lists the class first, then the same sequence with time reversal. Birss
386
- * convention: in birss-app's order (docs/conventions.md, "Order of the operations"). The matrices
387
- * are Cartesian (docs/conventions.md, "Cartesian frame").
474
+ * The records of the API for Cartesian operations of a setting: each with its matrix W in the
475
+ * lattice basis of the setting. A crystal class takes W from the exact ITC class data (`exact`, in
476
+ * the same order); a magnetic group computes W = B⁻¹·R·B in the basis B of the setting of its class
477
+ * (itcData.ts, `itcBasis`), which is exact after rounding, since W is an integer matrix.
478
+ */
479
+ function records(d, index, ops, exact) {
480
+ const classKey = d.crystalClass.key;
481
+ const b = itcBasis(classKey, classSetting(d, index));
482
+ const bInv = inverse(b);
483
+ return Object.freeze(ops.map((op, i) => Object.freeze({
484
+ matrix: frozenMatrix(exact ? exact[i] : integer(multiply(multiply(bInv, op.cartesian), b), `Operation ${i} of ${d.key}`)),
485
+ cartesian: op.cartesian,
486
+ timeReversal: op.timeReversal,
487
+ })));
488
+ }
489
+ const recordCache = new Map();
490
+ /**
491
+ * All operations of the point group in the requested setting (default: the ITC default setting),
492
+ * in ITA's order: identity first, then as ITA numbers the general position of the crystal class; an
493
+ * operation of a magnetic group has the number it has in the class, and a grey group lists the
494
+ * class first, then the same sequence with time reversal (docs/conventions.md, "Order of the
495
+ * operations"). Each operation is ITA's matrix W in the lattice basis of the setting (`matrix`) with
496
+ * the same operation as a Cartesian matrix (`cartesian`) and its time reversal (docs/conventions.md,
497
+ * "Operations").
388
498
  */
389
499
  export function operations(key, options) {
500
+ checkOptions(options, SETTING_KEYS, 'operations');
390
501
  const d = data(key);
391
502
  const index = settingIndex(d, options);
392
- return convention(options) === 'birss' ? birssOperations(d, index) : settingOperations(d, index);
503
+ const cacheKey = `${d.key}#${index}`;
504
+ let result = recordCache.get(cacheKey);
505
+ if (!result) {
506
+ const exact = d.type === 'I' ? itcLatticeOperations(d.key, index) : undefined;
507
+ result = records(d, index, settingOperations(d, index), exact);
508
+ recordCache.set(cacheKey, result);
509
+ }
510
+ return result;
393
511
  }
394
512
  /**
395
- * Generators of the point group in the requested setting (docs/conventions.md, "Generators"). ITC
396
- * convention: ITA's selected generators in printed order, without the identity and ITA's lattice
397
- * translations, so the list is empty for `1`; for `mm2` settings 2 and 3, which ITA does not list,
398
- * those of setting 1 carried into their frame; for a magnetic group, those of its class with the
399
- * time reversal they have in the group, for a grey group followed by `1'`. Birss convention:
400
- * birss-app's generators (for `1` the identity, as in birss-app).
513
+ * Generators of the point group in the requested setting (docs/conventions.md, "Generators"): ITA's
514
+ * selected generators in printed order, without the identity and ITA's lattice translations, so
515
+ * 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 carried
516
+ * into their frame; for a magnetic group, those of its class with the time reversal they
517
+ * have in the group, for a grey group followed by `1'`.
401
518
  */
402
519
  export function generators(key, options) {
520
+ checkOptions(options, SETTING_KEYS, 'generators');
403
521
  const d = data(key);
404
522
  const index = settingIndex(d, options);
405
- return convention(options) === 'birss' ? settingGenerators(d, index) : settingItaGenerators(d, index);
523
+ const cacheKey = `${d.key}#${index}#generators`;
524
+ let result = recordCache.get(cacheKey);
525
+ if (!result) {
526
+ const exact = d.type === 'I' ? itcLatticeGenerators(d.key, index) : undefined;
527
+ result = records(d, index, settingItaGenerators(d, index), exact);
528
+ recordCache.set(cacheKey, result);
529
+ }
530
+ return result;
531
+ }
532
+ /**
533
+ * A Schoenflies symbol as ITC Vol. D writes it (#137 B3): `S6` for the class -3, where ITA writes
534
+ * `C3i` (Table 3.2.1.2), as the crystallographic API does, and so `S6R` for its grey group. The
535
+ * black-and-white groups store their symbols as Vol. D prints them (`S6(C3)`, `D3d(S6)`,
536
+ * `C6h(S6)`; itcMagneticData.ts).
537
+ */
538
+ const volDSchoenflies = (s) => s.replace(/C3i/g, 'S6');
539
+ /** The Schoenflies symbol of a crystal class as ITA writes it (`C3i`). Internal: for the crystallographic API. */
540
+ export function itaSchoenflies(key) {
541
+ return data(key).schoenflies;
406
542
  }
407
- /** A symbol of the point group in the requested convention and setting. */
543
+ /**
544
+ * A symbol of the point group in the requested setting. The default setting of a grey or
545
+ * black-and-white group has its key as short symbol (`32'`, as ITC Vol. D Table 1.5.2.3 prints it;
546
+ * `321'`), a crystal class ITA's symbol (`321`), and the Schoenflies symbols follow ITC Vol. D
547
+ * (`S6`, `D3d(S6)`; docs/conventions.md, "Symbols").
548
+ */
408
549
  export function symbol(key, options) {
550
+ checkOptions(options, [...SETTING_KEYS, 'form'], 'symbol');
409
551
  const d = data(key);
410
552
  const form = options?.form ?? 'short';
411
- const s = settingSymbols(d, settingIndex(d, options), convention(options));
553
+ const s = settingSymbols(d, settingIndex(d, options));
412
554
  if (form === 'schoenflies')
413
- return d.schoenflies;
555
+ return volDSchoenflies(d.schoenflies);
414
556
  if (form === 'short')
415
557
  return s.short;
416
558
  if (form === 'full')
417
559
  return s.full;
418
- throw new RangeError(`Unknown symbol form: ${JSON.stringify(form)}`);
419
- }
420
- const compact = (s) => s.replace(/\s+/g, '');
421
- function find(hm, conventionName, classesOnly) {
422
- const c = convention({ convention: conventionName });
423
- if (typeof hm !== 'string')
424
- return undefined;
425
- const target = compact(hm);
560
+ throw new RangeError(`Unknown symbol form: ${shown(form)}`);
561
+ }
562
+ /** A symbol in the spelling of this library without spaces (notation.ts). */
563
+ const compact = compactSymbol;
564
+ function find(symbol, classesOnly, options) {
565
+ // A symbol that names no group is not found; a value that is no symbol at all is wrong input.
566
+ if (typeof symbol !== 'string')
567
+ throw new RangeError(`findPointGroup takes a symbol (a string), not ${shown(symbol)}`);
568
+ const target = compact(symbol);
426
569
  const candidates = [...BY_KEY.values()].filter((d) => !classesOnly || d.type === 'I');
427
- /** The settings of `d` whose symbol of this form is the target. */
428
- const named = (d, form) => d.settings.map((_, j) => j + 1).filter((i) => compact(settingSymbols(d, i, c)[form]) === target);
429
- /** One setting named: that one. Several (a monoclinic short symbol) or none (a key): the default. */
430
- const pick = (d, settingsNamed) => ({
431
- key: d.key,
432
- setting: settingsNamed.length === 1 ? settingsNamed[0] : defaultSetting(d, c),
433
- });
434
- const byKey = candidates.find((d) => d.key === target);
435
- if (byKey)
436
- return pick(byKey, named(byKey, 'short'));
437
- for (const form of ['short', 'full']) {
438
- for (const d of candidates) {
439
- const settingsNamed = named(d, form);
440
- if (settingsNamed.length > 0)
441
- return pick(d, settingsNamed);
442
- }
570
+ // The key, a short or full symbol of a setting (spaces ignored), Birss's cubic form; then a
571
+ // Schoenflies symbol, ITA's `C3i` or ITC Vol. D's `S6` alike, which names the group and not an
572
+ // orientation (Thomas, 2026-11-23, #96). A symbol of several groups is an error.
573
+ let found = candidates.map((d) => ({ d, named: settingsNamed(d, symbol) })).filter((m) => m.named.length > 0);
574
+ if (found.length === 0) {
575
+ const inVolD = volDSchoenflies(target);
576
+ found = candidates
577
+ .filter((d) => volDSchoenflies(d.schoenflies) === inVolD)
578
+ .map((d) => ({ d, named: allSettings(d) }));
443
579
  }
444
- return undefined;
580
+ if (found.length > 1) {
581
+ throw new RangeError(`The symbol ${shown(symbol)} names several point groups: ${found.map((m) => m.d.key).join(', ')}`);
582
+ }
583
+ if (found.length === 0)
584
+ return undefined;
585
+ const { d, named } = found[0];
586
+ // A name that several settings share gives the standard, unless axes or uniqueAxis chooses another.
587
+ return { key: d.key, setting: choose(d, named, criteriaOf(d, options), shown(symbol)) };
588
+ }
589
+ /**
590
+ * Birss prints the cubic groups without the overbar on the 3, which takes the prime of the mirror
591
+ * before it (Birss Tables 3 and 6: `m3m`, `m'3` for `m-3m`, `m'-3'`): the symbol with the overbar,
592
+ * which the caller looks up as a key (the cubic groups have one setting); undefined for any other
593
+ * symbol.
594
+ */
595
+ function birssCubic(compactTarget) {
596
+ const m = /^m('?)3(?!')(.*)$/.exec(compactTarget);
597
+ return m ? `m${m[1]}-3${m[1]}${m[2]}` : undefined;
445
598
  }
446
599
  /**
447
- * Finds a crystal class by a Hermann–Mauguin symbol in the given convention (default `'itc'`): the
448
- * short symbol of a setting, a full symbol, or the key (spaces are ignored). A symbol that names
449
- * one setting gives that setting; the key, and a short symbol that several settings share (the
450
- * monoclinic ones: `2` for unique axis b and c), give the default setting of the convention.
451
- * Returns undefined if nothing matches, also for a value that is not a string and for the
452
- * symbol of a magnetic group with time reversal (`findMagneticPointGroup`). Symbols are written as
453
- * in this library: `-` for the overbar, also in the Birss convention (`m-3m`, where Birss prints
454
- * `m3m`; docs/conventions.md, "Where ITC and Birss differ").
600
+ * Finds a crystal class by a symbol, read tolerantly.
601
+ * It reads, spaces ignored (#96; docs/conventions.md, "Reading symbols"): the key; the short or
602
+ * full symbol of a setting (`312`, `1 1 2`); a Schoenflies symbol, ITA's or ITC Vol. D's (`D3`,
603
+ * `C3i`, `S6`); Birss's cubic symbols without the overbar on the 3 (`m3m`). A symbol that names
604
+ * several settings (the key `32`, which is also the symbol of the setting with rhombohedral axes;
605
+ * `2` for unique axis b, c and a; any Schoenflies symbol) gives the standard (ITC default) setting,
606
+ * unless the options `axes` or `uniqueAxis` choose another, as the headlines of ITA name the
607
+ * settings (the option `axes` set to `'rhombohedral'` for the key `32`).
608
+ *
609
+ * Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
610
+ * Schoenflies subscripts also as Unicode or LaTeX subscripts (`C₃ᵥ`, `C_{3v}`). Returns undefined if nothing matches,
611
+ * also for a value that is not a string and for the symbol of a magnetic group with time reversal
612
+ * (`findMagneticPointGroup`); a symbol that names several groups is a RangeError that lists them.
455
613
  */
456
- export function findPointGroup(hm, conventionName = 'itc') {
457
- return find(hm, conventionName, true);
614
+ export function findPointGroup(symbol, options) {
615
+ if (arguments.length > 2)
616
+ rejectConventionArgument(arguments.length);
617
+ return deepFreeze(find(symbol, true, criteriaArgument(options)));
458
618
  }
459
619
  /**
460
- * Finds one of the 122 magnetic point groups (the 32 crystal classes included) by a symbol in the
461
- * given convention (default `'itc'`): the short symbol of a setting, a full symbol, or the key
462
- * (spaces are ignored). A prime `'` marks time reversal: `4'/mmm'`, `2221'`. A symbol that names
463
- * one setting gives that setting; the key, and a short symbol that several settings share (the
464
- * monoclinic ones: `2'` for unique axis b and c), give the default setting of the convention. In
465
- * the Birss convention two keys are the Birss symbol of a setting that is not the default
466
- * (`mm'm'` and `6'/mmm'`, setting 2; Birss prints `m'm'm` and `6'/mm'm` for these groups) and give
467
- * that setting, like any symbol. Returns undefined if nothing matches, also for a value that is
468
- * not a string. Symbols are written as in this library: `-` for the overbar, also in the Birss
469
- * convention (`m'-3'm`, where Birss prints `m'3m`; docs/conventions.md, "Where ITC and Birss
470
- * differ").
620
+ * Finds one of the 122 magnetic point groups (the 32 crystal classes included) by a symbol, read
621
+ * tolerantly. A prime marks time reversal: `4'/mmm'`, `2221'`.
622
+ * It reads, spaces ignored (#96; docs/conventions.md, "Reading symbols"): the key; the short or
623
+ * full symbol of a setting (`312`, `1 1 2`); a Schoenflies symbol, ITA's or ITC Vol. D's (`D3`,
624
+ * `C3i`, `S6`); Birss's cubic symbols without the overbar on the 3 (`m3m`). A symbol that names
625
+ * several settings (the key `32`, which is also the symbol of the setting with rhombohedral axes;
626
+ * `2` for unique axis b, c and a; any Schoenflies symbol) gives the standard (ITC default) setting,
627
+ * unless the options `axes` or `uniqueAxis` choose another, as the headlines of ITA name the
628
+ * settings (the option `axes` set to `'rhombohedral'` for the key `32`).
629
+ *
630
+ * Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
631
+ * the prime as `'`, `′`, `ʹ` or `’`; Schoenflies subscripts also as Unicode or LaTeX subscripts (`D₃d(S₆)`, `D_{3d}`).
632
+ * Returns undefined if nothing matches, also for a value that is not a string; a symbol that names
633
+ * several groups is a RangeError that lists them.
471
634
  */
472
- export function findMagneticPointGroup(hm, conventionName = 'itc') {
473
- return find(hm, conventionName, false);
635
+ export function findMagneticPointGroup(symbol, options) {
636
+ if (arguments.length > 2)
637
+ rejectConventionArgument(arguments.length);
638
+ return deepFreeze(find(symbol, false, criteriaArgument(options)));
474
639
  }
475
640
  //# sourceMappingURL=pointGroups.js.map