Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onBasis gets the matrix equivalent of the Transformation #36

Merged
merged 2 commits into from
Mar 22, 2013
Merged

onBasis gets the matrix equivalent of the Transformation #36

merged 2 commits into from
Mar 22, 2013

Conversation

bergey
Copy link
Member

@bergey bergey commented Mar 22, 2013

closes #22

This is a helper function to avoid writing the same code for every backend and every vector space. It makes a couple of assumptions about HasBasis implementations, which are true of the instances in Data.Basis and Diagrams, but might not be true in general:

  • that decompose returns all basis functions, not just those with non-zero coefficients
  • that the basis functions are returned in a meaningful order

The new function onBasis returns a list of vectors. The length of the list should be the same as the number of components in each vector, but that is not explicit in the type. The specialized version in TwoD.Transform returns a pair of vectors, instead of a list. (See next pull request, against diagrams-lib.)

This code ended up being identical to that in Diagrams.Backend.Show renderTransf. The diagrams-lib pull request modifies that function to use the new onBasis function.

@@ -179,6 +181,20 @@ papply (Transformation t _ v) (P p) = P $ lapp t p ^+^ v
fromLinear :: AdditiveGroup v => (v :-: v) -> (v :-: v) -> Transformation v
fromLinear l1 l2 = Transformation l1 l2 zeroV

-- | Get the matrix equivalent of the linear transform,
-- (as a list of rows) and the translation vector. This
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be "list of columns" rather than "list of rows"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that!

@byorgey
Copy link
Member

byorgey commented Mar 22, 2013

Looks good, thanks!

byorgey added a commit that referenced this pull request Mar 22, 2013
onBasis gets the matrix equivalent of the Transformation
@byorgey byorgey merged commit c7c69b8 into diagrams:master Mar 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function to extract matrix coefficients from a Transformation
2 participants