Skip to content

Commit

Permalink
Simplify linear quantities in parallelotope
Browse files Browse the repository at this point in the history
ref #344
  • Loading branch information
frostburn committed Jun 9, 2024
1 parent a840fc8 commit 62b7145
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/parser/__tests__/stdlib.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1576,4 +1576,22 @@ describe('SonicWeave standard library', () => {
'2 blue',
]);
});

it('has reasonable default formatting for a parallellotope', () => {
const scale = expand('parallelotope([3/2, 7/81], [5, 1], [0, 0], 2/1)');
expect(scale).toEqual([
'28/27',
'9/8',
'7/6',
'81/64',
'21/16',
'112/81',
'3/2',
'14/9',
'27/16',
'7/4',
'243/128',
'2/1',
]);
});
});
6 changes: 6 additions & 0 deletions src/stdlib/prelude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ riff parallelotope(basis, ups = niente, downs = niente, equave = 2, basisSizeHin
axis ~tns~ ££;
}
(* It's too hard to keep track of good formatting during tensoring. Simplify non-unison linears. *)
const l = isLinear($)
if (l)
l[0] = false
$[l] = simplify $[l]
if (basisSizeHints == niente and equaveSizeHint == niente)
return sort($ ~rdc equave);
Expand Down

0 comments on commit 62b7145

Please sign in to comment.