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

Use vectorized operations to compute transformations #266

Merged
merged 2 commits into from Oct 14, 2015

Conversation

@oliverlee
Copy link
Contributor

oliverlee commented Oct 7, 2015

Use vectorized Numpy operation to compute visualization frame
transformation matrices as this is much faster than using a for loop.
Each element of the transformation matrix is lambdified and stored in a
list of numerical transformations.

Individual element transforms that do not contain dynamic variables nor
constant variables are not returned as functions by lambdify and
subsequent evaluation for these elements is skipped. Element transforms
that contain constant variables but not dynamic variables are lambdified
with only the constant variables as arguments. These are only evaluated
once and then repeated for create of the visualization matrix
trajectory.

This commit resolves issue #32

@oliverlee oliverlee force-pushed the oliverlee:speedup-frame-transformations branch from c89e7bf to ccc6478 Oct 7, 2015
@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Oct 12, 2015

Are there any tests for this code?

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Oct 13, 2015

Please update with master.

@oliverlee oliverlee force-pushed the oliverlee:speedup-frame-transformations branch from ccc6478 to d8c273b Oct 13, 2015
oliverlee added 2 commits Oct 7, 2015
Use vectorized Numpy operation to compute visualization frame
transformation matrices as this is much faster than using a for loop.
Each element of the transformation matrix is lambdified and stored in a
list of numerical transformations.

Individual element transforms that do not contain dynamic variables nor
constant variables are not returned as functions by lambdify and
subsequent evaluation for these elements is skipped. Element transforms
that contain constant variables but not dynamic variables are lambdified
with only the constant variables as arguments. These are only evaluated
once and then repeated for create of the visualization matrix
trajectory.

This commit resolves issue #32.
@oliverlee

This comment has been minimized.

Copy link
Contributor Author

oliverlee commented Oct 14, 2015

It looks like there are no tests for the calculation of the transform matrices.

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Oct 14, 2015

Would you be willing to create a regression test? You could run the code from master on an example and pull out some values and then make the test against them.

@oliverlee

This comment has been minimized.

Copy link
Contributor Author

oliverlee commented Oct 14, 2015

No problem I'm already doing that now.

@oliverlee

This comment has been minimized.

Copy link
Contributor Author

oliverlee commented Oct 14, 2015

Actually, there is already a regression test:

def test_numeric_transform(self):
self.list1 = [[0.5000000000000001, 0.5, \
-0.7071067811865475, 0.0, \
-0.14644660940672627, 0.8535533905932737, \
0.5, 0.0, \
0.8535533905932737, -0.14644660940672627, \
0.5000000000000001, 0.0, \
10.0, 10.0, 10.0, 1.0]]
self.list2 = [[-0.11518993731879767, 0.8178227645734215, \
-0.563823734943801, 0.0, \
0.1332055011661179, 0.5751927992738988, \
0.8070994598700584, 0.0, \
0.984371663956036, 0.017865313009926137, \
-0.17519491371464685, 0.0, \
20.0, 20.0, 20.0, 1.0]]
self.global_frame1.generate_transformation_matrix(self.I, self.O)
self.global_frame1.generate_numeric_transform_function(self.dynamic, \
self.parameters)
assert_allclose(self.global_frame1.\
evaluate_transformation_matrix(self.states, \
self.param_vals), self.list1)
self.global_frame2.generate_transformation_matrix(self.I, self.O)
self.global_frame2.generate_numeric_transform_function(self.dynamic, \
self.parameters)
assert_allclose(self.global_frame2.\
evaluate_transformation_matrix(self.states, \
self.param_vals), self.list2)

so I think we can merge this unless you have any other issues.

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Oct 14, 2015

Sweet. Merging.

moorepants added a commit that referenced this pull request Oct 14, 2015
Use vectorized operations to compute transformations
@moorepants moorepants merged commit 42aae29 into pydy:master Oct 14, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@oliverlee oliverlee deleted the oliverlee:speedup-frame-transformations branch Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.