From 2217c59e61a4e9389ad341d54752faee19127d07 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 4 Jul 2014 14:13:09 -0500 Subject: [PATCH] Add MultiVector.project_{min,max}_grade, shuffle MV docs --- doc/geometric-algebra.rst | 44 ------------------------- pymbolic/geometric_algebra.py | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/doc/geometric-algebra.rst b/doc/geometric-algebra.rst index cdece82..9179498 100644 --- a/doc/geometric-algebra.rst +++ b/doc/geometric-algebra.rst @@ -21,50 +21,6 @@ Multivectors .. autoclass:: MultiVector - .. autoattribute:: mapper_method - - .. rubric:: More products - - .. automethod:: scalar_product - .. automethod:: x - .. automethod:: __pow__ - - .. rubric:: Unary operators - - .. automethod:: inv - .. automethod:: rev - .. automethod:: invol - .. automethod:: dual - .. automethod:: __inv__ - .. automethod:: norm_squared - .. automethod:: __abs__ - .. autoattribute:: I - - .. rubric:: Comparisons - - :class:`MultiVector` objects have a truth value corresponding to whether - they have any blades with non-zero coefficients. They support testing - for (exact) equality. - - .. automethod:: zap_near_zeros - .. automethod:: close_to - - .. rubric:: Grade manipulation - - .. automethod:: gen_blades - .. automethod:: project - .. automethod:: xproject - .. automethod:: all_grades - .. automethod:: get_pure_grade - .. automethod:: odd - .. automethod:: even - .. automethod:: as_scalar - .. automethod:: as_vector - - .. rubric:: Helper functions - - .. automethod:: map - .. _ga-examples: Example usage diff --git a/pymbolic/geometric_algebra.py b/pymbolic/geometric_algebra.py index 6b12a92..7eb2b91 100644 --- a/pymbolic/geometric_algebra.py +++ b/pymbolic/geometric_algebra.py @@ -352,6 +352,54 @@ class MultiVector(object): and then geometric. In other words: Use parentheses everywhere. + + .. autoattribute:: mapper_method + + .. rubric:: More products + + .. automethod:: scalar_product + .. automethod:: x + .. automethod:: __pow__ + + .. rubric:: Unary operators + + .. automethod:: inv + .. automethod:: rev + .. automethod:: invol + .. automethod:: dual + .. automethod:: __inv__ + .. automethod:: norm_squared + .. automethod:: __abs__ + .. autoattribute:: I + + .. rubric:: Comparisons + + :class:`MultiVector` objects have a truth value corresponding to whether + they have any blades with non-zero coefficients. They support testing + for (exact) equality. + + .. automethod:: zap_near_zeros + .. automethod:: close_to + + .. rubric:: Grade manipulation + + .. automethod:: gen_blades + .. automethod:: project + .. automethod:: xproject + .. automethod:: all_grades + .. automethod:: get_pure_grade + .. automethod:: odd + .. automethod:: even + .. automethod:: project_min_grade + .. automethod:: project_max_grade + + .. automethod:: as_scalar + .. automethod:: as_vector + + .. rubric:: Helper functions + + .. automethod:: map + """ # {{{ construction @@ -862,6 +910,20 @@ class MultiVector(object): return MultiVector(new_data, self.space) + def project_min_grade(self): + """ + .. versionadded:: 2014.2 + """ + + return self.project(min(self.all_grades())) + + def project_max_grade(self): + """ + .. versionadded:: 2014.2 + """ + + return self.project(max(self.all_grades())) + def as_scalar(self): result = 0 for bits, coeff in self.data.iteritems(): -- GitLab