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
@@ -9,42 +9,75 @@
9
9
  * NumPy array of shape (3,)*n in C order). Moved from birss-app (`tensorForms.ts`,
10
10
  * `tensorProjection.ts`, `linalg.ts`, revision 2be5fe3).
11
11
  */
12
+ import { SETTING_KEYS, TOLERANCE_KEYS, checkNumbers, checkOptions, shown } from '../checks.js';
12
13
  import { det } from '../linalg.js';
13
- import { checkOrthogonal, checkTimeReversal, closeGroup } from '../operations.js';
14
- import { operations, settings } from '../pointGroups/pointGroups.js';
14
+ import { checkCartesianOperations, checkOrthogonalWithin, checkTimeReversal, } from '../operations.js';
15
+ import { idealGroup } from '../closure.js';
16
+ import { operations, settingIndexOf, } from '../pointGroups/pointGroups.js';
15
17
  import { specOf } from './propertyTable.js';
16
- import { EPSILON, SNAP_EPSILON } from '../tolerances.js';
17
- import { rowEchelonWithPivots } from './rowEchelon.js';
18
+ import { EPSILON, MAX_PIVOT_THRESHOLD, SNAP_EPSILON, toleranceOf } from '../tolerances.js';
19
+ import { PIVOT_EPSILON, rowEchelonWithPivots } from './rowEchelon.js';
20
+ import { deepFreeze } from '../freeze.js';
18
21
  const RANKS = [0, 1, 2, 3, 4];
19
- /** Checks a specification and returns the index permutations that generate its intrinsic symmetry. */
22
+ /** The names of the fields and values up to 0.10, with those that replace them (#137 E1, E2). */
23
+ const RENAMED_INTRINSIC = {
24
+ ij: 'symmetric-first-pair',
25
+ jk: 'symmetric-last-pair',
26
+ ij_kl: 'symmetric-pairs',
27
+ voigt: 'symmetric-pairs-exchangeable',
28
+ };
29
+ const RENAMED_TIME_PARITY = { i: 'even', c: 'odd' };
30
+ /** Checks a specification and returns the signed index permutations that generate its intrinsic symmetry. */
20
31
  function checkSpec(spec) {
21
- const { rank, parity, timeParity, intrinsic } = spec;
32
+ const { rank, kind, timeParity, intrinsic } = spec;
33
+ if ('parity' in spec) {
34
+ throw new RangeError(`The field parity of a tensor specification is named kind since symcrys 0.11 ('polar' or 'axial')`);
35
+ }
22
36
  if (!RANKS.includes(rank))
23
- throw new RangeError(`Tensor rank must be 0 to 4, not ${JSON.stringify(rank)}`);
24
- if (parity !== 'polar' && parity !== 'axial')
25
- throw new RangeError(`Unknown tensor parity: ${JSON.stringify(parity)}`);
26
- if (timeParity !== 'i' && timeParity !== 'c')
27
- throw new RangeError(`Unknown time parity: ${JSON.stringify(timeParity)}`);
28
- const swap = (a, b) => {
29
- const p = Array.from({ length: rank }, (_, k) => k);
30
- [p[a], p[b]] = [p[b], p[a]];
31
- return p;
37
+ throw new RangeError(`Tensor rank must be 0 to 4, not ${shown(rank)}`);
38
+ if (kind !== 'polar' && kind !== 'axial') {
39
+ throw new RangeError(`The kind of a tensor is 'polar' or 'axial', not ${shown(kind)}`);
40
+ }
41
+ if (timeParity !== 'even' && timeParity !== 'odd') {
42
+ const renamed = typeof timeParity === 'string' ? RENAMED_TIME_PARITY[timeParity] : undefined;
43
+ throw new RangeError(`The time parity of a tensor is 'even' or 'odd', not ${shown(timeParity)}` +
44
+ (renamed ? ` ('${timeParity}' up to symcrys 0.10 is '${renamed}')` : ''));
45
+ }
46
+ const swap = (a, b, sign = 1) => {
47
+ const perm = Array.from({ length: rank }, (_, k) => k);
48
+ [perm[a], perm[b]] = [perm[b], perm[a]];
49
+ return { perm, sign };
50
+ };
51
+ const needs = (condition, what) => {
52
+ if (!condition)
53
+ throw new RangeError(`Intrinsic symmetry '${intrinsic}' needs ${what}, not rank ${rank}`);
32
54
  };
33
55
  switch (intrinsic) {
34
56
  case 'none':
35
57
  return [];
36
- case 'ij':
37
- case 'jk':
38
- if (rank < 2)
39
- throw new RangeError(`Intrinsic symmetry '${intrinsic}' needs rank 2 or more, not ${rank}`);
40
- return [intrinsic === 'ij' ? swap(0, 1) : swap(rank - 2, rank - 1)];
41
- case 'ij_kl':
42
- case 'voigt':
43
- if (rank !== 4)
44
- throw new RangeError(`Intrinsic symmetry '${intrinsic}' needs rank 4, not ${rank}`);
45
- return intrinsic === 'ij_kl' ? [swap(0, 1), swap(2, 3)] : [swap(0, 1), swap(2, 3), [2, 3, 0, 1]];
46
- default:
47
- throw new RangeError(`Unknown intrinsic symmetry: ${JSON.stringify(intrinsic)}`);
58
+ case 'symmetric-first-pair':
59
+ needs(rank >= 2, 'rank 2 or more');
60
+ return [swap(0, 1)];
61
+ case 'symmetric-last-pair':
62
+ needs(rank >= 2, 'rank 2 or more');
63
+ return [swap(rank - 2, rank - 1)];
64
+ case 'symmetric-pairs':
65
+ needs(rank === 4, 'rank 4');
66
+ return [swap(0, 1), swap(2, 3)];
67
+ case 'symmetric-pairs-exchangeable':
68
+ needs(rank === 4, 'rank 4');
69
+ return [swap(0, 1), swap(2, 3), { perm: [2, 3, 0, 1], sign: 1 }];
70
+ case 'antisymmetric':
71
+ needs(rank === 2, 'rank 2');
72
+ return [swap(0, 1, -1)];
73
+ case 'totally-symmetric':
74
+ needs(rank >= 2, 'rank 2 or more');
75
+ return Array.from({ length: rank - 1 }, (_, k) => swap(k, k + 1));
76
+ default: {
77
+ const renamed = typeof intrinsic === 'string' ? RENAMED_INTRINSIC[intrinsic] : undefined;
78
+ throw new RangeError(`Unknown intrinsic symmetry: ${shown(intrinsic)}` +
79
+ (renamed ? ` ('${intrinsic}' up to symcrys 0.10 is '${renamed}')` : ''));
80
+ }
48
81
  }
49
82
  }
50
83
  /** The indices (x, y, z = 0, 1, 2) of every flat index at a rank, first index first. */
@@ -57,24 +90,34 @@ function digits(rank) {
57
90
  }
58
91
  return table;
59
92
  }
60
- /** The flat indices reached from `flat` by the index permutations (`out[k] = in[perm[k]]`). */
93
+ /**
94
+ * The flat indices reached from `flat` by the signed index permutations (`out[k] = in[perm[k]]`),
95
+ * each with the product of the signs on the way; undefined if one is reached with both signs (the
96
+ * seed of an antisymmetric tensor with two equal indices, which vanishes).
97
+ */
61
98
  function orbit(flat, rank, perms) {
62
99
  const d = digits(rank);
63
- const seen = new Set([flat]);
100
+ const seen = new Map([[flat, 1]]);
64
101
  const stack = [flat];
65
102
  while (stack.length > 0) {
66
103
  const cur = stack.pop();
67
- for (const p of perms) {
104
+ const curSign = seen.get(cur);
105
+ for (const { perm, sign } of perms) {
68
106
  let next = 0;
69
107
  for (let k = 0; k < rank; k++)
70
- next = next * 3 + d[cur][p[k]];
71
- if (!seen.has(next)) {
72
- seen.add(next);
108
+ next = next * 3 + d[cur][perm[k]];
109
+ const nextSign = (curSign * sign);
110
+ const known = seen.get(next);
111
+ if (known === undefined) {
112
+ seen.set(next, nextSign);
73
113
  stack.push(next);
74
114
  }
115
+ else if (known !== nextSign) {
116
+ return undefined;
117
+ }
75
118
  }
76
119
  }
77
- return [...seen];
120
+ return [...seen].map(([f, sign]) => ({ flat: f, sign }));
78
121
  }
79
122
  function freezeRows(rows) {
80
123
  return Object.freeze(rows.map((r) => Object.freeze([...r])));
@@ -84,18 +127,23 @@ function freezeRows(rows) {
84
127
  * (a unit tensor on one orbit of the intrinsic symmetry) projects it onto the invariant subspace;
85
128
  * the projections span it, and the reduced row echelon form makes the basis minimal and canonical.
86
129
  */
87
- function project(group, spec, perms) {
130
+ function project(group, spec, perms, deviation = 0) {
88
131
  const { rank } = spec;
89
132
  const dim = 3 ** rank;
90
133
  const d = digits(rank);
91
134
  const ops = group.map((op) => ({
92
- m: op.matrix.flat(),
93
- sign: (spec.parity === 'axial' ? Math.sign(det(op.matrix)) : 1) * (spec.timeParity === 'c' && op.timeReversal ? -1 : 1),
135
+ m: op.cartesian.flat(),
136
+ sign: (spec.kind === 'axial' ? Math.sign(det(op.cartesian)) : 1) *
137
+ (spec.timeParity === 'odd' && op.timeReversal ? -1 : 1),
94
138
  }));
95
139
  const spanning = [];
140
+ // The trace of the group average on the tensors of this index symmetry: the dimension of the
141
+ // invariant subspace, since the average is an orthogonal projector for orthogonal operations. The
142
+ // sums over the orbits of the index symmetry are an orthogonal basis of those tensors.
143
+ let trace = 0;
96
144
  for (let seed = 0; seed < dim; seed++) {
97
145
  const members = orbit(seed, rank, perms);
98
- if (seed !== Math.min(...members))
146
+ if (!members || seed !== Math.min(...members.map((m) => m.flat)))
99
147
  continue;
100
148
  const averaged = new Array(dim).fill(0);
101
149
  for (const { m, sign } of ops) {
@@ -103,8 +151,8 @@ function project(group, spec, perms) {
103
151
  const o = d[out];
104
152
  let acc = 0;
105
153
  for (const s of members) {
106
- const i = d[s];
107
- let p = 1;
154
+ const i = d[s.flat];
155
+ let p = s.sign;
108
156
  for (let r = 0; r < rank; r++)
109
157
  p *= m[o[r] * 3 + i[r]];
110
158
  acc += p;
@@ -114,10 +162,11 @@ function project(group, spec, perms) {
114
162
  }
115
163
  for (let k = 0; k < dim; k++)
116
164
  averaged[k] /= ops.length;
165
+ trace += members.reduce((sum, s) => sum + s.sign * averaged[s.flat], 0) / members.length;
117
166
  if (averaged.some((x) => Math.abs(x) >= EPSILON))
118
167
  spanning.push(averaged);
119
168
  }
120
- const reduced = rowEchelonWithPivots(spanning, dim);
169
+ const reduced = reduce(spanning, dim, deviation, Math.round(trace));
121
170
  const basis = reduced.rows.map((row) => row.map(snapEntry));
122
171
  const { pivots } = reduced;
123
172
  const relations = [];
@@ -139,6 +188,31 @@ function project(group, spec, perms) {
139
188
  relations: freezeRows(relations),
140
189
  });
141
190
  }
191
+ /**
192
+ * The reduced row echelon form of the projections, with as many pivots as the invariant subspace
193
+ * has dimensions (`rank`, the trace of the group average, exact for an exact group in any frame).
194
+ * For a group made exact from operations of a caller (`idealGroup`), which lies `deviation` from
195
+ * them, a component smaller than about that is not known to be independent: the pivots are first
196
+ * sought at 10 × `deviation` (at least `PIVOT_EPSILON`) and the threshold is lowered tenfold until
197
+ * the pivots reach the rank, so that the free parameters are those of the exact form unless one of
198
+ * its pivots is itself of the order of the deviation (#89). Should the pivots exceed the rank even
199
+ * at `PIVOT_EPSILON` (a component of the order of 10⁻⁷ in a general orientation), the threshold is
200
+ * raised instead until they reach it.
201
+ */
202
+ function reduce(spanning, dim, deviation, rank) {
203
+ const start = Math.max(10 * deviation, PIVOT_EPSILON);
204
+ for (let threshold = start; threshold >= PIVOT_EPSILON * 0.999; threshold /= 10) {
205
+ const reduced = rowEchelonWithPivots(spanning, dim, threshold);
206
+ if (reduced.pivots.length === rank)
207
+ return reduced;
208
+ }
209
+ for (let threshold = start * 10; threshold <= MAX_PIVOT_THRESHOLD; threshold *= 10) {
210
+ const reduced = rowEchelonWithPivots(spanning, dim, threshold);
211
+ if (reduced.pivots.length === rank)
212
+ return reduced;
213
+ }
214
+ throw new Error(`The projections of a tensor form give no ${rank} independent components`);
215
+ }
142
216
  /**
143
217
  * An entry within 10⁻⁹ of a multiple of 1/12 is set to it, so that the exact values of the
144
218
  * crystallographic forms (0, ±1/2, ±1, ±2 for the 32 classes in all settings) come out exact instead
@@ -149,21 +223,21 @@ function snapEntry(x) {
149
223
  return Math.abs(x - r) < SNAP_EPSILON ? r + 0 : x;
150
224
  }
151
225
  function specKey(spec) {
152
- return `${spec.rank}:${spec.parity}:${spec.timeParity}:${spec.intrinsic}`;
226
+ return `${spec.rank}:${spec.kind}:${spec.timeParity}:${spec.intrinsic}`;
153
227
  }
154
228
  const formCache = new Map();
155
229
  /**
156
230
  * The form of a tensor under a point group, a crystal class or a magnetic point group, in the
157
- * requested setting (default: the default setting of the convention, `'itc'` unless given). The
158
- * tensor is given by its specification or by the name of a property in `TENSOR_PROPERTIES`
159
- * (`'piezoelectric'`). The convention matters only through the setting: the same setting index
160
- * gives the same form in both conventions (docs/conventions.md, "Tensors").
231
+ * requested setting (default: the ITC default setting). The tensor is given by its specification
232
+ * or by the name of a property in `TENSOR_PROPERTIES` (`'piezoelectric'`; docs/conventions.md,
233
+ * "Tensors").
161
234
  */
162
235
  export function tensorForm(key, spec, options) {
236
+ checkOptions(options, SETTING_KEYS, 'tensorForm');
163
237
  const resolved = specOf(spec);
164
238
  const perms = checkSpec(resolved);
165
- const ops = operations(key, options); // checks key, convention and setting
166
- const index = options?.setting ?? settings(key, options?.convention).find((s) => s.isDefault).index;
239
+ const ops = operations(key, options); // checks key and setting
240
+ const index = settingIndexOf(key, options);
167
241
  const cacheKey = `${key}#${index}#${specKey(resolved)}`;
168
242
  let form = formCache.get(cacheKey);
169
243
  if (!form) {
@@ -175,37 +249,67 @@ export function tensorForm(key, spec, options) {
175
249
  /**
176
250
  * The form of a tensor under the group generated by `operations`, e.g. the site symmetry of a
177
251
  * surface normal (`siteSymmetry`) or the operations of a distorted crystal. The tensor is given by
178
- * its specification or by the name of a property in `TENSOR_PROPERTIES`. The operations are
179
- * Cartesian and orthogonal, and each says whether it is combined with time reversal
180
- * (`timeReversal`, `true` or `false`); a list that is not closed is closed first. Throws a
181
- * RangeError for a matrix that is not orthogonal and for an operation that does not say whether it
182
- * is combined with time reversal.
252
+ * its specification or by the name of a property in `TENSOR_PROPERTIES`. Each operation is read by
253
+ * its Cartesian matrix (`cartesian`), which must be orthogonal, and each says whether it is
254
+ * combined with time reversal (`timeReversal`, `true` or `false`). The list is closed into a group
255
+ * within the tolerance, and that group is made exact before the form is computed, so that matrices
256
+ * with rounding errors (e.g. rounded to 6 decimals) give the form of the exact group, with its
257
+ * number of free parameters (docs/conventions.md, "Tolerances"). Throws a RangeError for an
258
+ * operation without an orthogonal Cartesian matrix (`cartesian`; within the tolerance), for an
259
+ * operation that does not say whether it is combined with time reversal, and for operations that
260
+ * generate no finite group within the tolerance.
183
261
  */
184
- export function tensorFormOf(operations, spec) {
262
+ export function tensorFormOf(operations, spec, options) {
263
+ checkOptions(options, TOLERANCE_KEYS, 'tensorFormOf');
185
264
  const resolved = specOf(spec);
186
265
  const perms = checkSpec(resolved);
187
- operations.forEach((op, i) => checkOrthogonal(op.matrix, `Operation ${i}`));
266
+ return formOfGroup(callerGroup(operations, options), resolved, perms);
267
+ }
268
+ /**
269
+ * The operations of a caller, checked (orthogonal within the tolerance, time reversal given),
270
+ * closed within the tolerance and made exact: the group the functions for a list of operations
271
+ * compute with.
272
+ */
273
+ export function callerGroup(operations, options) {
274
+ const tolerance = toleranceOf(options, 'operations');
275
+ checkCartesianOperations(operations, tolerance);
188
276
  checkTimeReversal(operations);
189
- return project(closeGroup(operations), resolved, perms);
277
+ return idealGroup(operations, tolerance);
278
+ }
279
+ /** The form of a tensor (checked specification and its permutations) under a group made exact. */
280
+ export function formOfGroup(group, spec, perms) {
281
+ return project(group.operations, spec, perms, group.deviation);
282
+ }
283
+ /** The specification of a tensor given by its specification or name, checked, with its permutations. */
284
+ export function checkedSpec(spec) {
285
+ const resolved = specOf(spec);
286
+ return { spec: resolved, perms: checkSpec(resolved) };
190
287
  }
191
288
  /**
192
- * The components of `tensor` (length 3^rank, flat index) in a frame rotated by the orthogonal
289
+ * The tensor `tensor` in a frame rotated by the orthogonal
193
290
  * matrix `rotation`: t′_{i…} = f·Σ R_{ia}…R_{…}·t_{a…}, with f = det(R) for an axial tensor and 1
194
291
  * for a polar one. To express a tensor in the frame of a surface, pass the matrix whose rows are
195
292
  * the new axes in the old frame. Time parity plays no part. The kind of tensor is given by its
196
- * specification or by the name of a property in `TENSOR_PROPERTIES`.
293
+ * specification or by the name of a property in `TENSOR_PROPERTIES`. Throws a RangeError for a
294
+ * rotation that is not orthogonal within the tolerance (per matrix entry of RᵀR).
197
295
  */
198
- export function rotateTensor(tensor, rotation, specOrName) {
199
- const spec = specOf(specOrName);
200
- checkSpec(spec);
201
- checkOrthogonal(rotation, 'The rotation');
202
- const { rank } = spec;
296
+ export function rotateTensor(tensor, rotation, spec, options) {
297
+ checkOptions(options, TOLERANCE_KEYS, 'rotateTensor');
298
+ const resolved = specOf(spec);
299
+ checkSpec(resolved);
300
+ if (!Array.isArray(rotation) || rotation.length !== 3) {
301
+ throw new RangeError(`The rotation must be a 3 × 3 matrix, not ${shown(rotation)}`);
302
+ }
303
+ rotation.forEach((row, i) => checkNumbers(row, 3, `Row ${i} of the rotation`));
304
+ checkOrthogonalWithin(rotation, 'The rotation', toleranceOf(options, 'operations'));
305
+ const { rank } = resolved;
203
306
  const dim = 3 ** rank;
204
- if (tensor.length !== dim)
205
- throw new RangeError(`A tensor of rank ${rank} has ${dim} components, not ${tensor.length}`);
307
+ if (!Array.isArray(tensor) || tensor.length !== dim)
308
+ throw new RangeError(`A tensor of rank ${rank} has ${dim} components, not ${shown(tensor)}`);
309
+ checkNumbers(tensor, dim, 'The tensor');
206
310
  const d = digits(rank);
207
311
  const m = rotation.flat();
208
- const f = spec.parity === 'axial' ? Math.sign(det(rotation)) : 1;
312
+ const f = resolved.kind === 'axial' ? Math.sign(det(rotation)) : 1;
209
313
  const out = new Array(dim).fill(0);
210
314
  for (let o = 0; o < dim; o++) {
211
315
  let acc = 0;
@@ -219,6 +323,6 @@ export function rotateTensor(tensor, rotation, specOrName) {
219
323
  }
220
324
  out[o] = f * acc;
221
325
  }
222
- return out;
326
+ return deepFreeze(out);
223
327
  }
224
328
  //# sourceMappingURL=tensorForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tensorForm.js","sourceRoot":"","sources":["../../src/tensors/tensorForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAa,MAAM,cAAc,CAAC;AAC9C,OAAO,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,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,GAAG,IAAI,CAAC,CAAC;QACX,CAAC;QACD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACnB,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
@@ -10,23 +10,24 @@
10
10
  * The crystallographic API (`crystalClasses.ts`) knows the time-even properties only
11
11
  * (docs/conventions.md, "Two entry points").
12
12
  */
13
- import type { Operation } from '../operations.js';
13
+ import type { CartesianOperation } from '../operations.js';
14
14
  import type { MagneticPointGroupKey } from '../pointGroups/pointGroups.js';
15
15
  import { type TensorPropertyName } from './propertyTable.js';
16
+ import type { ToleranceOptions } from '../tolerances.js';
16
17
  /**
17
18
  * True if the point group allows the named property, e.g. `allowsProperty('-6m2', 'piezoelectric')`.
18
- * It does not depend on setting or convention. Throws a RangeError for an unknown key or name.
19
+ * It does not depend on the setting. Throws a RangeError for an unknown key or name.
19
20
  */
20
21
  export declare function allowsProperty(key: MagneticPointGroupKey, name: TensorPropertyName): boolean;
21
22
  /** The named properties the point group allows, in the order of `TENSOR_PROPERTIES`. */
22
- export declare function allowedProperties(key: MagneticPointGroupKey): TensorPropertyName[];
23
+ export declare function allowedProperties(key: MagneticPointGroupKey): readonly TensorPropertyName[];
23
24
  /**
24
25
  * True if the group generated by `operations` allows the named property, e.g. for the site
25
- * symmetry of a surface normal or the operations of a distorted crystal. The matrices must be
26
- * Cartesian and orthogonal; a list that is not closed is closed first. Throws a RangeError for a matrix that is not
27
- * orthogonal and for an operation that does not say whether it is combined with time reversal.
26
+ * symmetry of a surface normal or the operations of a distorted crystal. The operations are read
27
+ * and closed as `tensorFormOf` reads them, within the tolerance, and it throws a RangeError as
28
+ * `tensorFormOf` does.
28
29
  */
29
- export declare function allowsPropertyOf(operations: readonly Operation[], name: TensorPropertyName): boolean;
30
- /** The named properties the group generated by `operations` allows. Checks the operations as `allowsPropertyOf`. */
31
- export declare function allowedPropertiesOf(operations: readonly Operation[]): TensorPropertyName[];
30
+ export declare function allowsPropertyOf(operations: readonly CartesianOperation[], name: TensorPropertyName, options?: ToleranceOptions): boolean;
31
+ /** The named properties the group generated by `operations` allows. Reads the operations as `allowsPropertyOf`. */
32
+ export declare function allowedPropertiesOf(operations: readonly CartesianOperation[], options?: ToleranceOptions): readonly TensorPropertyName[];
32
33
  //# sourceMappingURL=tensorProperties.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tensorProperties.d.ts","sourceRoot":"","sources":["../../src/tensors/tensorProperties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAiC,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAU5F;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,qBAAqB,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAE5F;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,GAAG,kBAAkB,EAAE,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAEpG;AAED,oHAAoH;AACpH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,kBAAkB,EAAE,CAE1F"}
1
+ {"version":3,"file":"tensorProperties.d.ts","sourceRoot":"","sources":["../../src/tensors/tensorProperties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAiC,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAWzD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,qBAAqB,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAE5F;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,qBAAqB,GAAG,SAAS,kBAAkB,EAAE,CAE3F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,SAAS,kBAAkB,EAAE,EACzC,IAAI,EAAE,kBAAkB,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAIT;AAED,mHAAmH;AACnH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,SAAS,kBAAkB,EAAE,EACzC,OAAO,CAAC,EAAE,gBAAgB,GACzB,SAAS,kBAAkB,EAAE,CAI/B"}
@@ -10,37 +10,47 @@
10
10
  * The crystallographic API (`crystalClasses.ts`) knows the time-even properties only
11
11
  * (docs/conventions.md, "Two entry points").
12
12
  */
13
+ import { checkOptions, shown, TOLERANCE_KEYS } from '../checks.js';
13
14
  import { TENSOR_PROPERTY_NAMES, specOf } from './propertyTable.js';
14
- import { tensorForm, tensorFormOf } from './tensorForm.js';
15
+ import { callerGroup, checkedSpec, formOfGroup, tensorForm } from './tensorForm.js';
16
+ import { deepFreeze } from '../freeze.js';
15
17
  /** A name of the table; anything else, a specification included, is an error here. */
16
18
  function named(name) {
17
19
  if (typeof name !== 'string')
18
- throw new RangeError(`Unknown tensor property: ${JSON.stringify(name)}`);
20
+ throw new RangeError(`Unknown tensor property: ${shown(name)}`);
19
21
  specOf(name);
20
22
  return name;
21
23
  }
22
24
  /**
23
25
  * True if the point group allows the named property, e.g. `allowsProperty('-6m2', 'piezoelectric')`.
24
- * It does not depend on setting or convention. Throws a RangeError for an unknown key or name.
26
+ * It does not depend on the setting. Throws a RangeError for an unknown key or name.
25
27
  */
26
28
  export function allowsProperty(key, name) {
27
29
  return tensorForm(key, named(name), { setting: 1 }).basis.length > 0;
28
30
  }
29
31
  /** The named properties the point group allows, in the order of `TENSOR_PROPERTIES`. */
30
32
  export function allowedProperties(key) {
31
- return TENSOR_PROPERTY_NAMES.filter((name) => allowsProperty(key, name));
33
+ return deepFreeze(TENSOR_PROPERTY_NAMES.filter((name) => allowsProperty(key, name)));
32
34
  }
33
35
  /**
34
36
  * True if the group generated by `operations` allows the named property, e.g. for the site
35
- * symmetry of a surface normal or the operations of a distorted crystal. The matrices must be
36
- * Cartesian and orthogonal; a list that is not closed is closed first. Throws a RangeError for a matrix that is not
37
- * orthogonal and for an operation that does not say whether it is combined with time reversal.
37
+ * symmetry of a surface normal or the operations of a distorted crystal. The operations are read
38
+ * and closed as `tensorFormOf` reads them, within the tolerance, and it throws a RangeError as
39
+ * `tensorFormOf` does.
38
40
  */
39
- export function allowsPropertyOf(operations, name) {
40
- return tensorFormOf(operations, named(name)).basis.length > 0;
41
+ export function allowsPropertyOf(operations, name, options) {
42
+ checkOptions(options, TOLERANCE_KEYS, 'allowsPropertyOf');
43
+ const checked = named(name);
44
+ return allows(callerGroup(operations, options), checked);
41
45
  }
42
- /** The named properties the group generated by `operations` allows. Checks the operations as `allowsPropertyOf`. */
43
- export function allowedPropertiesOf(operations) {
44
- return TENSOR_PROPERTY_NAMES.filter((name) => allowsPropertyOf(operations, name));
46
+ /** The named properties the group generated by `operations` allows. Reads the operations as `allowsPropertyOf`. */
47
+ export function allowedPropertiesOf(operations, options) {
48
+ checkOptions(options, TOLERANCE_KEYS, 'allowedPropertiesOf');
49
+ const group = callerGroup(operations, options);
50
+ return deepFreeze(TENSOR_PROPERTY_NAMES.filter((name) => allows(group, name)));
51
+ }
52
+ function allows(group, name) {
53
+ const { spec, perms } = checkedSpec(name);
54
+ return formOfGroup(group, spec, perms).basis.length > 0;
45
55
  }
46
56
  //# sourceMappingURL=tensorProperties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tensorProperties.js","sourceRoot":"","sources":["../../src/tensors/tensorProperties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAA2B,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3D,sFAAsF;AACtF,SAAS,KAAK,CAAC,IAAwB;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,MAAM,IAAI,UAAU,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvG,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,GAA0B,EAAE,IAAwB;IACjF,OAAO,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvE,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,iBAAiB,CAAC,GAA0B;IAC1D,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAgC,EAAE,IAAwB;IACzF,OAAO,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,mBAAmB,CAAC,UAAgC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IAAwB,EACxB,OAA0B;IAE1B,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,mBAAmB,CACjC,UAAyC,EACzC,OAA0B;IAE1B,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,qBAAqB,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,MAAM,CAAC,KAAiB,EAAE,IAAwB;IACzD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1D,CAAC"}
@@ -1,11 +1,66 @@
1
1
  /**
2
2
  * Numeric tolerances, in one place. The values differ on purpose: each gates a different quantity.
3
+ * The tolerance a caller passes is one contract for every function (docs/conventions.md,
4
+ * "Tolerances"): one option, one metric per kind of object, one check.
5
+ */
6
+ /**
7
+ * The default tolerance of every function that compares numbers a caller passes in (operations,
8
+ * directions, points): two numbers closer than this count as equal, in the metric of their kind
9
+ * (docs/conventions.md, "Tolerances").
3
10
  */
4
- /** Two matrix entries (or vector components) closer than this are equal. */
5
11
  export declare const EPSILON = 0.000001;
6
12
  /**
7
13
  * During group closure, an entry closer than this to one of the exact values in `SNAP_VALUES`
8
14
  * (linalg.ts) is replaced by it, so rounding errors cannot accumulate over repeated products.
9
15
  */
10
16
  export declare const SNAP_EPSILON = 1e-9;
17
+ /** The tolerance of a function that compares numbers a caller passes in. */
18
+ export interface ToleranceOptions {
19
+ /**
20
+ * Two numbers closer than this count as equal; default `EPSILON` (10⁻⁶). It is measured per
21
+ * matrix entry for operations, as the distance of unit vectors for directions and per coordinate
22
+ * modulo the lattice for points (docs/conventions.md, "Tolerances").
23
+ */
24
+ readonly tolerance?: number;
25
+ }
26
+ /**
27
+ * The upper bound of the tolerance per kind of object, above which it says nothing: two distinct
28
+ * operations A, B of a crystallographic point group differ in some entry by at least √2/3 ≈ 0.47 in
29
+ * any orthonormal frame (‖A − B‖ = ‖1 − A⁻¹B‖ ≥ √2 in the Frobenius norm, the least for a sixfold
30
+ * rotation), so 0.1 keeps them apart; two unit vectors are at most 2 apart; two points modulo the
31
+ * lattice at most 1/2 per coordinate; a relative deviation of the metric tensor is at most of the
32
+ * order of 1.
33
+ */
34
+ export declare const TOLERANCE_BOUND: Readonly<{
35
+ operations: 0.1;
36
+ directions: 1;
37
+ points: 0.5;
38
+ metric: 1;
39
+ }>;
40
+ /**
41
+ * The tolerance of the options, checked: a finite number above 0 and below the bound of the kind
42
+ * of object it measures; the default `EPSILON`.
43
+ */
44
+ export declare function toleranceOf(options: ToleranceOptions | undefined, kind: keyof typeof TOLERANCE_BOUND): number;
45
+ /**
46
+ * Making a group of a caller exact (`idealGroup`, closure.ts): a product is matched to the nearest
47
+ * element of the group, which must lie closer than `PRODUCT_MATCH` per entry (distinct operations
48
+ * of a point group differ by at least √2/3 ≈ 0.47 in some entry, so a nearer one is the product);
49
+ * the averaging has settled when no entry changes by `IDEAL_SETTLED` or more in a pass, and fails
50
+ * if after `IDEAL_PASSES` passes an entry still changes by `IDEAL_UNSETTLED` (it settles in one to
51
+ * six passes for every point group, exact or rounded); entries within `IDEAL_SNAP` of an exact value
52
+ * are set to it, which catches the rounding of the last bits but not a group turned by a small
53
+ * angle.
54
+ */
55
+ export declare const PRODUCT_MATCH = 0.25;
56
+ export declare const IDEAL_SETTLED = 1e-15;
57
+ export declare const IDEAL_UNSETTLED = 1e-12;
58
+ export declare const IDEAL_PASSES = 50;
59
+ export declare const IDEAL_SNAP = 1e-12;
60
+ /**
61
+ * The largest pivot threshold of a tensor form (tensorForm.ts, `reduce`): the threshold is raised
62
+ * up to this only in a general orientation, when components of the order of 10⁻⁷ would otherwise be
63
+ * taken for independent ones; a genuine pivot of a form of a point group is far larger.
64
+ */
65
+ export declare const MAX_PIVOT_THRESHOLD = 0.01;
11
66
  //# sourceMappingURL=tolerances.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tolerances.d.ts","sourceRoot":"","sources":["../src/tolerances.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,OAAO,WAAO,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC"}
1
+ {"version":3,"file":"tolerances.d.ts","sourceRoot":"","sources":["../src/tolerances.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAO,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;;;EAA4E,CAAC;AAEzG;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,OAAO,eAAe,GAAG,MAAM,CAQ7G;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC"}