In [1]:
!pip install pyprof2calltree


Requirement already satisfied: pyprof2calltree in /Users/utensil/.julia/conda/3/lib/python3.7/site-packages (1.4.4)

In [2]:
!brew install qcachegrind


Warning: qcachegrind 18.04.3_1 is already installed and up-to-date
To reinstall 18.04.3_1, run `brew reinstall qcachegrind`

In [3]:
%%writefile test_41.py
from galgebra.ga import Ga

GA = Ga('e*1|2|3')
a = GA.mv('a', 'vector')
b = GA.mv('b', 'vector')
c = GA.mv('c', 'vector')

def cross(x, y):
    return (x ^ y).dual()

xx = cross(a, cross(b, c))


Overwriting test_41.py

In [4]:
!python -m cProfile -o test_41.cprof test_41.py

In [5]:
!python -m pyprof2calltree -i test_41.cprof -k


launching kcachegrind
Selected  "Function cross"
CallGraphView::refresh
CallGraphView::refresh: Starting process 0x7fd353f8f380, 'dot -Tplain'
CallGraphView::readDotOutput: QProcess 0x7fd353f8f380
CallGraphView::dotExited: QProcess 0x7fd353f8f380

With View options set to:

The profiling result is like:


In [6]:
%%writefile test_41.py
from galgebra.ga import Ga

GA = Ga('e*1|2|3', norm=False)
a = GA.mv('a', 'vector')
b = GA.mv('b', 'vector')
c = GA.mv('c', 'vector')

def cross(x, y):
    return (x ^ y).dual()

xx = cross(a, cross(b, c))


Overwriting test_41.py

In [7]:
!python -m cProfile -o test_41.cprof test_41.py

In [8]:
!python -m pyprof2calltree -i test_41.cprof -k


launching kcachegrind
Selected  "Function cross"
CallGraphView::refresh
CallGraphView::refresh: Starting process 0x7f97aede0940, 'dot -Tplain'
CallGraphView::readDotOutput: QProcess 0x7f97aede0940
CallGraphView::dotExited: QProcess 0x7f97aede0940


In [14]:
from galgebra.ga import Ga

GA = Ga('e*1|2|3')
a = GA.mv('a', 'vector')
b = GA.mv('b', 'vector')
c = GA.mv('c', 'vector')

def cross(x, y):
    return (x ^ y).dual()

xx = cross(a, cross(b, c))
xx


Out[14]:
\begin{equation*} \left ( \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{1} c^{2} - \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{2} c^{1} + \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{1} c^{3} - \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{3} c^{1} + \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{1} c^{2} - \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{2} c^{1} + \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{1} c^{3} - \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{3} c^{1} + \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{1} c^{2} - \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{2} c^{1} + \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{1} c^{3} - \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{3} c^{1}\right ) \boldsymbol{e}_{1} + \left ( - \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{1} c^{2} + \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{2} c^{1} - \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{1} c^{2} + \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{2} c^{1} + \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{2} c^{3} - \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{3} c^{2} - \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{1} c^{2} + \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{2} c^{1} + \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{2} c^{3} - \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{3} c^{2} + \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{2} c^{3} - \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{3} c^{2}\right ) \boldsymbol{e}_{2} + \left ( - \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{1} c^{3} + \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{3} c^{1} - \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{2} c^{3} + \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{3} c^{2} - \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{1} c^{3} + \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{3} c^{1} - \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{1} c^{3} + \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{3} c^{1} - \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{2} c^{3} + \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{3} c^{2} - \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{2} c^{3} + \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{3} c^{2}\right ) \boldsymbol{e}_{3} \end{equation*}

In [15]:
GA.E()


Out[15]:
\begin{equation*} \boldsymbol{e}_{1}\wedge \boldsymbol{e}_{2}\wedge \boldsymbol{e}_{3} \end{equation*}

In [16]:
GA.I()


Out[16]:
\begin{equation*} \frac{1}{\sqrt{\left ( e_{1}\cdot e_{1}\right ) \left ( e_{2}\cdot e_{2}\right ) \left ( e_{3}\cdot e_{3}\right ) - \left ( e_{1}\cdot e_{1}\right ) \left ( e_{2}\cdot e_{3}\right ) ^{2} - \left ( e_{1}\cdot e_{2}\right ) ^{2} \left ( e_{3}\cdot e_{3}\right ) + 2 \left ( e_{1}\cdot e_{2}\right ) \left ( e_{1}\cdot e_{3}\right ) \left ( e_{2}\cdot e_{3}\right ) - \left ( e_{1}\cdot e_{3}\right ) ^{2} \left ( e_{2}\cdot e_{2}\right ) }} \boldsymbol{e}_{1}\wedge \boldsymbol{e}_{2}\wedge \boldsymbol{e}_{3} \end{equation*}

In [12]:
from galgebra.ga import Ga

GA = Ga('e*1|2|3', norm=False)
a = GA.mv('a', 'vector')
b = GA.mv('b', 'vector')
c = GA.mv('c', 'vector')

def cross(x, y):
    return (x ^ y).dual()

xx = cross(a, cross(b, c))
xx


Out[12]:
\begin{equation*} \left ( \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{1} c^{2} - \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{2} c^{1} + \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{1} c^{3} - \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{3} c^{1} + \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{1} c^{2} - \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{2} c^{1} + \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{1} c^{3} - \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{3} c^{1} + \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{1} c^{2} - \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{2} c^{1} + \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{1} c^{3} - \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{3} c^{1}\right ) \boldsymbol{e}_{1} + \left ( - \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{1} c^{2} + \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{2} c^{1} - \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{1} c^{2} + \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{2} c^{1} + \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{2} c^{3} - \left ( e_{1}\cdot e_{3}\right ) a^{1} b^{3} c^{2} - \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{1} c^{2} + \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{2} c^{1} + \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{2} c^{3} - \left ( e_{2}\cdot e_{3}\right ) a^{2} b^{3} c^{2} + \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{2} c^{3} - \left ( e_{3}\cdot e_{3}\right ) a^{3} b^{3} c^{2}\right ) \boldsymbol{e}_{2} + \left ( - \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{1} c^{3} + \left ( e_{1}\cdot e_{1}\right ) a^{1} b^{3} c^{1} - \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{2} c^{3} + \left ( e_{1}\cdot e_{2}\right ) a^{1} b^{3} c^{2} - \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{1} c^{3} + \left ( e_{1}\cdot e_{2}\right ) a^{2} b^{3} c^{1} - \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{1} c^{3} + \left ( e_{1}\cdot e_{3}\right ) a^{3} b^{3} c^{1} - \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{2} c^{3} + \left ( e_{2}\cdot e_{2}\right ) a^{2} b^{3} c^{2} - \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{2} c^{3} + \left ( e_{2}\cdot e_{3}\right ) a^{3} b^{3} c^{2}\right ) \boldsymbol{e}_{3} \end{equation*}

In [11]:
GA.E()


Out[11]:
\begin{equation*} \boldsymbol{e}_{1}\wedge \boldsymbol{e}_{2}\wedge \boldsymbol{e}_{3} \end{equation*}

In [17]:
GA.I()


Out[17]:
\begin{equation*} \frac{1}{\sqrt{\left ( e_{1}\cdot e_{1}\right ) \left ( e_{2}\cdot e_{2}\right ) \left ( e_{3}\cdot e_{3}\right ) - \left ( e_{1}\cdot e_{1}\right ) \left ( e_{2}\cdot e_{3}\right ) ^{2} - \left ( e_{1}\cdot e_{2}\right ) ^{2} \left ( e_{3}\cdot e_{3}\right ) + 2 \left ( e_{1}\cdot e_{2}\right ) \left ( e_{1}\cdot e_{3}\right ) \left ( e_{2}\cdot e_{3}\right ) - \left ( e_{1}\cdot e_{3}\right ) ^{2} \left ( e_{2}\cdot e_{2}\right ) }} \boldsymbol{e}_{1}\wedge \boldsymbol{e}_{2}\wedge \boldsymbol{e}_{3} \end{equation*}

In [ ]: