pygae / galgebra Goto Github PK
View Code? Open in Web Editor NEWSymbolic Geometric Algebra/Calculus package for SymPy :crystal_ball:
Home Page: https://galgebra.rtfd.io/
License: BSD 3-Clause "New" or "Revised" License
Symbolic Geometric Algebra/Calculus package for SymPy :crystal_ball:
Home Page: https://galgebra.rtfd.io/
License: BSD 3-Clause "New" or "Revised" License
Opening this as a tracking issue so that I can reference it in the source code
@chaowenGUO commented on Mar 9, 2016
I use the following code to produce reciprocal frame
import ga
base=ga.Ga('a b')
a,b=base.mv()
ar,br=base.mvr()
but ar|a does not return 1Moreover, I try to output base.E() after base.mvr(), it does not output a^b. Instead, it outputs a scalar.
Later, I try to use base.ReciprocalFrame(base.mv()) to get the reciprocal frame, then the answer is correct. So why the answers from ga.Ga.mvr and ga.Ga.ReciprocalFrame are different? It seems that mvr() does not return the reciprocal frame, what does it actually do?
@brombo commented on Mar 10, 2016
mvr is also messing up base.E(). I am working to fix this. Thank you
for breaking the code it really helps me.
@brombo commented on Mar 10, 2016
Pushed correction to galgebra on github. In future if you have code in
notebook please attach as ipynb file.
@chaowenGUO commented on Mar 11, 2016
Thank you, now mvr works ok. But you seems to forget to remove line 343 in ga.py
print 'self.e =', self.e
So when I call ga.Ga, it will automatically print the pseudoscalar
@brombo commented on Mar 11, 2016
Will fix it. What are you using GA for?
@chaowenGUO commented on Mar 11, 2016
Before the fix, the following code is working:
import ga,sympy
u,v=sympy.symbols('u,v',real=True)
x,y,z=sympy.symbols('x,y,z',Function=True)
surface=ga.Ga('e1 e2',coords=(u,v),X=[x(u,v),y(u,v),z(u,v)])
print surface.mv()But now:
It produces the following error:
Traceback (most recent call last):
File "test.py", line 4, in
surface=ga.Ga('e1 e2',coords=(u,v),X=[x(u,v),y(u,v),z(u,v)])
File "/home/ken/Downloads/galgebra-master/galgebra/ga.py", line 327, in init
self.build_reciprocal_basis(self.gsym)
File "/home/ken/Downloads/galgebra-master/galgebra/ga.py", line 1386, in build_reciprocal_basis
self.e_obj = self.e.obj
AttributeError: 'Ga' object has no attribute 'e'Well, actually I do not quite understand the advanced properties of GA. But I find GA is very useful to deal with a lot of stuffs that can not be handled by linear algebra, say oblique coordinates in crystallography, rotation and reflection of rigid body, analytic geometry in dimension bigger than 3, definition of volume of subspace. Moreover, use it to deduce formula in electrodynamics and hydrodynamics(geometric derivative operator). Now, I am still learning field on manifold, it maybe can help me to define correct quantum potential in phase space.
@brombo commented on Mar 11, 2016
Fixed problem with vector manifold input and pushed to github. Try the
following code -import ga,sympy
coords = u,v =sympy.symbols('u,v',real=True)
#x,y,z=sympy.symbols('x,y,z',Function=True)x = sympy.Function('x')(_coords)
y = sympy.Function('y')(_coords)
z = sympy.Function('z')(*coords)#surface=ga.Ga('e1 e2',coords=(u,v),X=[x(u,v),y(u,v),z(u,v)])
surface=ga.Ga('e1 e2',coords=(u,v),X=[x,y,z])
print surface.g
eu,ev = surface.mv()
eur,evr = surface.mvr()
print (eu|eur).simplify()
print (eu|evr).simplify()
print (ev|eur).simplify()
print (ev|evr).simplify()I could not get you sympy function definition to work for me.
Note that code took awhile to run on my machine (10 sec)
@chaowenGUO closed this on May 27, 2016
From http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/5
@chaowenGUO commented on Mar 18, 2016
import ga,sympy
base=ga.Ga('a b',g=[1,1],coords=sympy.symbols('x,y',real=True))
a,b=base.mv()
A=base.lt([a+b,a-b])
print A
print A.matrix()output is:
Lt(a) = a + b
Lt(b) = a - b
Traceback (most recent call last):
File "test.py", line 6, in
print A.matrix()
File "/home/ken/galgebra-master/galgebra/lt.py", line 476, in matrix
self.mat = Dictionary_to_Matrix(self.lt_dict, self.Ga) * self.Ga.g
File "/home/ken/galgebra-master/galgebra/lt.py", line 102, in Dictionary_to_Matrix
(coefs,bases) = metric.linear_expand(dict_rep[e_row])
File "/home/ken/galgebra-master/galgebra/metric.py", line 62, in linear_expand
if expr.is_commutative:
AttributeError: 'Mv' object has no attribute 'is_commutative'that means it construct linear transformation correctly, but can not convert to sympy matrix
From http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/10
There're some nice work in other forks of brombo/galgebra, here's a summary:
Has some interesting changes:
setup.py
)No particular interesting changes:
I believe the intent of 'odd'
is for usage like:
>>> g, *a = Ga.build('e*1|2|3|4')
>>> g.mv('A', 'odd')
A__1*e_1 + A__2*e_2 + A__3*e_3 + A__4*e_4 + A__5*e_5 + A__123*e_1^e_2^e_3 + A__124*e_1^e_2^e_4 + A__125*e_1^e_2^e_5 + A__134*e_1^e_3^e_4 + A__135*e_1^e_3^e_5 + A__145*e_1^e_4^e_5 + A__234*e_2^e_3^e_4 + A__235*e_2^e_3^e_5 + A__245*e_2^e_4^e_5 + A__345*e_3^e_4^e_5 + A__12345*e_1^e_2^e_3^e_4^e_5
However, it can be also use as
>>> g, *a = Ga.build('e*1|2|3|4')
>>> g.mv([2], 'odd')
2*e_1 + 2*e_1^e_2^e_3 + 2*e_1^e_2^e_3^e_4^e_5
>>> g.mv([2, 3], 'odd')
ValueError: Too many coefficients
This doesn't seem remotely useful - I'd propose we deprecate or outright remove it. 'even'
already forbids this usage.
test
in https://github.com/pygae/cliffordComments welcome 😃
Thank you for picking up the torch with regard to galgebra. I just did not have enough time to work on it as required. I have a question about your conversion to python 3. I am trying to use your version and it looks like the python 3 print function is not overloaded. That is if A is a multivector or other object in galgebra the statement "print(A)" does not work. Is this correct?
Misc bugs that need some time to fix:
@utensil commented on May 8, 2016 •
edited
- write a
setup.py
so it can be installed bypython setup.py install
- add
.gitignore
and remove.pyc
files- add option
--noconflict
to usegalgebra
as namespace- fix tests
- register
galgebra
on PyPIThis issue is opened to track the work discussed in #12 (comment)
The work would be done according to the instructions in the following documents:
@utensil commented on May 8, 2016
Work would begin at https://github.com/utensil-contrib/galgebra/tree/14-pip . A PR would be created when 1-3 tasks have been completed.
@utensil commented on May 8, 2016 •
edited
A minimal
setup.py
is written as in commit utensil-contrib@2d6606e .But it introduced a problem, these module names would be exposed in the global(just the same as the old Ga.pth approach). Should we put them into the namespace
galgebra
? Then we would useimport galgebra.ga
instead ofimport ga
. Less global namespace pollution.
@brombo commented on May 8, 2016
You are afraid that there is some other python library that could expose
the same module names globally? The only one I would be worried about
is "printer." Could we have an user option to do it either way since
everyone now using galgebra is doing it with ga.pth?
@utensil commented on May 8, 2016 •
edited
Could we have an user option to do it either way since
everyone now using galgebra is doing it with ga.pth?Yes, we could. After I implemented it, users can use
python setup.py install --noconflict
.And in the
setup.py
, we could just use this option to choose frompackage_dir={'galgebra':'galgebra'},
andpackage_dir={'':'galgebra'}
.
@brombo commented on May 8, 2016
Let's do it that way then.
@utensil commented on May 8, 2016
Implemented in utensil-contrib@7ec591e
@brombo commented on May 8, 2016
I see you are at Texas Tech. I tracked gcwenken to Texas Tech and
Chaowen Guo is that who you are? I live in Silver Spring Maryland. If
you ever wish to talk in real time my phone number is 301-625-5951. My
main interest in GA is for physics. If you want the GA notes I wrote
(based on Doran and Lasenby's book) I will put them on Google drive. We
have a study group of physicists, mathematician, and astronomers (most
are retired) that meets on most Friday evenings at the Montgomery
College planetarium. We also have two participants that attend remotely
via Teamviewer. We are currently covering Lagrangian field theory. If
you are interested let me know.
@utensil commented on May 9, 2016
Oh, I'm not at Texas Tech. I'm a senior software engineer at Tencent in China, mainly focused on back-end server development for online payment, using C++/Java/Python/Node.js. So my work is not related to GA in any way, Physics and GA are my personal interest.
I'm a reader of "Geometric Algebra for Physicists", and came across your work when looking for previous efforts on combining symbolic programming and GA. My main interest in GA is also for physics. To me, GA is a brand new way to look at the math we used in Physics, with the power of simplicity, the ability to connect/unite different areas or aspects, and the potential to further reveal the nature of physics.
Personally, I'm using spare time to digest what I've learned from the book and related materials, and planning to implement a GA library in Julia(a very expressive and effective language) as a better way to learn it.
Sorry, due to time zone reason, I might not be able to attend the study group meetings, but I'll really benefit from and appreciate your notes. And I'm also reading your book. It's really very nice of you to share all these.
I haven't been able to find too much progress of GA, especially the applications in Physics. It seems that computer graphics did show some interest in GA, for a possibly more effective way to do rotations than quaternions, and there are some papers to introduce GA to their specific areas in Physics, but not much fruit yet. Do you have a better list of papers regarding this? In other words, do you have a clear roadmap of the latest development of GA? It looks like that, GA is still at a stage to reinterpret established Physics, am I missing something?
@utensil closed this on May 9, 2016
@utensil reopened this on May 9, 2016
@utensil commented on May 9, 2016 •
edited
The last paragraph of my last comment may seem a little doubtful about GA. Actually, I was trying to neutralize my more enthusiastic and radical view: The current math used in physics is not only inefficient but also wrong. By "wrong", I mean that the inefficiency of the current math leads to misleading puzzles. The learning curve of GA is smooth, the time-consuming part is mapping them back to old-fashion math and explain the differences or even seemingly contradictions. I do understand the importance to review all "established" physics, the meaning can be explained by a quote from An Introduction to Geometric Algebra with some Preliminary Thoughts on the Geometric Meaning of Quantum Mechanics :
- Geometric Algebra provides a unified language for the whole of physics that is conceptually and
computationally superior to alternative mathematical systems in every application domain- Reforming the mathematical language of physics is the single most essential step toward
simplifying physics education at all levels from high school to graduate schoolBut what I was looking for, was the breadcrumb of serious adoption of GA in edge theoretical physics research and their findings.
@brombo commented on May 9, 2016
The version of BookGA.pdf on Google drive is the latest version. As the
Cliffhangers cover material on Friday evenings corrections and additions
are suggested that I perform during the following week.
@utensil commented on May 10, 2016
The version of BookGA.pdf on Google drive is the latest version.
Sorry, I can't find your Google Drive.
As the
Cliffhangers cover material on Friday evenings corrections and additions
are suggested that I perform during the following week.I can't quite follow you on this.
@utensil commented on May 15, 2016
Progress update: I'll start to work on fixing the tests in the coming week.
@utensil commented on May 15, 2016
I'm currently converting test cases one by one. The assertions are usually valid, but there're edge cases with slight differences, correcting the assertions with my own eyes.
There's one problematic:
# FIXME failed with value: (a.b)*c - (b.c)*a - ((a.b)*c - (b.c)*a) assert str((a|(b^c))+(c|(a^b))+(b|(c^a))) == '0'It's obvious the output is 0, but not simplified to 0. @brombo , do you know what caused this? This seems to be a problem of the implmentation, not the assertion.
@utensil commented on May 15, 2016 •
edited
An extra
.simplify()
turn it into 0, see utensil-contrib@7b9425eIs this intentional?
@brombo commented on May 15, 2016
Simplify can be costly in time so it is not automatically applied after
each operation. It is always a good idea to simplify if testing an
expression to be zero.
@utensil commented on May 15, 2016
Yeah, I also thought that the reason would be for performance.
@micahscopes commented on Apr 24, 2017 •
edited
I have a glsl generator that relies on sage's Clifford Algebra tools to generate high dimensional rotation functions. (I used to rely on sympy.galgebra, until it got spun off into this project). Anyhow, I really would love to be able to switch back to this library so I can publish my project, but I'm using setup.py/pip for dependency management... And pip has removed support for external dependencies.
So I'm kinda at a loss! I don't want to use requirements.txt, cause I want to publish my library.
So I'm wondering about what's holding up this ticket and if there anything I can do to help? Maybe you are waiting to do a stable release?
@utensil commented on Apr 29, 2017
My plan was add some code to make the project pip-compatible, improve the unit tests and assist in the registering process. The first part is completed, the second part(almost completed) lead me to find a few bugs and I fixed them in my way and presented the codes to be reviewed in #20 . Then, my work on it has stopped after some frustrating communication experience and @brombo kept working on the project and the PR became obsolete. After that, my life took a dramatic turn so I haven't been using or concerning this project ever since.
Personally I can update #20 to match the status of the master branch, but the final part relies heavily on @brombo 's own willing and efforts, along with an open communication channel. The work has paused due to the lack of both.
Hope the information helps. I'm always willing to continue the work on this issue.
@utensil commented on Sep 21, 2018
I'll close this issue as pygae#2 is now merged.
@utensil closed this on Sep 21, 2018
Found at http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/14
>>> ga, e1, e2, e3, ep, en = galgebra.ga.Ga.build('e_1 e_2 e_3 e_{+} e_{-}',g=[1,1,1, 1, -1])
>>> sympy.simplify(e1)
RecursionError: maximum recursion depth exceeded while calling a Python object
>>> list(e1)
RecursionError: maximum recursion depth exceeded while calling a Python object
This is because:
sympy.simplify
and list
calls iter(e1)
Mv.__iter__
is not defined, so it defaults to:
def __iter__(self):
i = 0
while True:
try:
yield self[i]
except IndexError:
break
i += 1
```
Mv.__getitem__
will return 0 forever, as it implies grade selectionPossible fixes:
Mv.__iter__
raise TypeErrorMv.__iter__
iterate only up to the highest grade presentWhen first converting GAlgebra from Python 2 to 3, I was not aware of sympy.core.compatibility and didn't wish to add a dependency like six
so some compatibility issues are handled in utils.py
which should actually be named compat
or something but kept utils
as its name so it may also used to put other utility functions.
So it's preferred to use sympy.core.compatibility
to handle such issues in the future but the entry point could still be kept in utils
if appropriate.
I do not worry that sympy.core.compatibility
might go away one day, even this happens it will be after SymPy also drops support for Python 2.7 when past its EOL( https://pythonclock.org/ ), we can deal with the situation by cleaning up the remnants of python 2 support in a new release.
The background of this is that @abrombo 's new work on GAlgebra is no longer considering Python 2 support and I intend to keep the support for 2.7 for a while longer to consolidate its ground for the still-fresh Python 3 support.
We should put out a python3 compatible release and bump the version in pypi to give people access to the nnice work of @utensil
This issue is to track references to GAlgebra in literature and other Web resources. The goal is:
Here are these references:
GAlgebra is an implementation of a geometric algebra module in python that utilizes the sympy symbolic algebra library. The python module GA has been developed for coordinate free calculations using the operations (geometric, outer, and inner products etc.) of geometric algebra. The operations can be defined using a completely arbitrary metric defined by the inner products of a set of arbitrary vectors or the metric can be restricted to enforce orthogonality and signature constraints on the set of vectors. In addition the module includes the geometric, outer (curl) and inner (div) derivatives and the ability to define a curvilinear coordinate system. The module requires the numpy and the sympy modules.
Comments welcome.
If use something like
symbols(r'{\color{airforceblue}\theta} {\color{applegreen}\phi}', real = True)
will produce invalid LaTeX output caused by double escaping:
! Missing } inserted.
<inserted text>
}
l.61 ...\ 0 & {\sin{\left ({\color{airforceblue}\\
theta } \right )}}^{2} \e...
If use something like
symbols(r'{\color{airforceblue}theta} {\color{applegreen}phi}', real = True)
to avoid double escaping, then the result is partially theta
/phi
and partially \theta
/\phi
:
The expected result is:
See #31 (comment) and sympy/sympy#8365 (comment) .
@utensil commented on May 1, 2016
Enviroment
- MacBook Pro (Retina, 13-inch, Mid 2014)
- OSX 10.11.2
- Python 2.7.11
- numpy 1.9.2
- sympy 1.0
Steps
git clone https://github.com/brombo/galgebra.git cd galgebra python setup.py install python setup.py test
import galgebra galgebra.Ga
Error
Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'Ga'
If I
import ga
instead, gotTraceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named ga
I looked into examples and tests, and can't figure out what went wrong.
@brombo commented on May 1, 2016
"python setup.py test" not implemented (I don't really know hot to write
a setup.py file). You would need to run tests and examples manually
(one at a time). Also "test_test.py" uses old GA format and was not
converted when I left sympy distribution. There is no more module MV to
import. Will fix
test_test.py when I get time. In examples Terminal/terminal_check.py
and LaTeX/latex_check.py run same tests and more without asserts
(answers printed out).
@utensil commented on May 1, 2016 •
edited
Oh it's not about the tests. I saw 0 tests were run.
Just that I can't use any classes in "ga" or "galgebra" after importing either of them in REPL.
@utensil commented on May 1, 2016
Let's use exact code from "Terminal/terminal_check.py":
$ python Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:57:58) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type "help", "copyright", "credits" or "license" for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org >>> from ga import Ga, one, zero Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named ga >>> from galgebra import Ga, one, zero Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name Ga
@brombo commented on May 1, 2016
To install use the instructions starting on page 5 of galgebra.pdf in
the doc directory (specifically section 1.3 in the doc) not setup.py.
Note that the Ipython notebook install section is dated.
@utensil commented on May 2, 2016
I followed the instructions in galgebra.pdf, still no luck:
galgebra $ pwd /Users/utensil/experiments/galgebra/galgebra galgebra $ ls __init__.py __init__.pyc ga.py lt.py metric.py mv.py printer.py setgapth.py galgebra $ python setgapth.py Traceback (most recent call last): File "setgapth.py", line 28, in <module> pth_file = open(pth_name,'w') IOError: [Errno 2] No such file or directory: '/Users/utensil/miniconda2/lib/site-python/Ga.pth' galgebra $ ls /Users/utensil/miniconda2/lib/site-python/ ls: /Users/utensil/miniconda2/lib/site-python/: No such file or directory galgebra $ ls /Users/utensil/miniconda2/lib/ Tk.icns libQtScript.4.dylib libmkl_avx2.dylib Tk.tiff libQtScript.dylib libmkl_avx512.dylib engines libQtScript.la libmkl_core.dylib libQtCLucene.4.8.7.dylib libQtScript.prl libmkl_intel.dylib
@utensil commented on May 2, 2016
After manually created the directory:
mkdir '/Users/utensil/miniconda2/lib/site-python' galgebra $ python setgapth.py os name: posix site-packages directory: /Users/utensil/miniconda2/lib/site-python/Ga.pth Ga.pth: #Path of Ga module /Users/utensil/experiments/galgebra/galgebra 0Python pth file Ga.pth for all modules of galgebra has been created and
placed in directory appropriate for Linux, Windows, or OSX. Note that
if Ga.pth already exists the old version will be deleted.>>> import ga >>> ga.Ga <class 'ga.Ga'>Succeed.
@utensil commented on May 2, 2016
I'll send a PR to correct instructions in INSTALL .
@brombo commented on May 2, 2016
Thanks for your feedback. I think on OSX the directory where the python
path files reside is not created when python is installed. Are you
using the default python that come with OSX or are your using another
distribution, if so what distribution?
@utensil commented on May 2, 2016
I'm using MiniConda which is a minimal distribution of Anaconda which is widely used.
@utensil commented on May 2, 2016
PR sent.
@utensil commented on May 2, 2016 •
edited
Though not related to this issue, I did notice something wrong in
terminal_check.py
:print '-I*(grad^A) =', -o3d.E() * (grad ^ A)It should be
.I()
if I'm understanding it correctly.
@utensil commented on May 7, 2016
"python setup.py test" not implemented (I don't really know hot to write
a setup.py file). You would need to run tests and examples manually
(one at a time). Also "test_test.py" uses old GA format and was not
converted when I left sympy distribution. There is no more module MV to
import. Will fix
test_test.py when I get time.I'm interested in writing a
setup.py
forgalgebra
, and add other essential parts to getgalgebra
into PyPI so it can be installed withpip install galgebra
. Also I do have some time to fix the issues you mentioned above. Would you like it to be done? Because I thinkgalgebra
is a great library.
@brombo commented on May 7, 2016
I would greatly appreciate you doing such a thing. Thank you very much.
@utensil commented on May 8, 2016
Great, then I would get started.
@brombo closed this in brombo/galgebra#13 on May 11, 2016
From http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/12
As reported by @FreddyBaudine here and discussed here, it seems that the usages of StringIO
should be replaced by BytesIO
.
The work needs to be done:
test_py2_compat.py
since most tests are written in Python 3 flavorContinuing from discussions on Slack with @abrombo and @hugohadfield :
Alan Bromborsky:
I think the biggest deficiency of galgebra is that it can only reduce multivector expressions in one direction. All results are in terms of the multivector basis. It would be useful to be able to go in the other direction and rewrite multivector expressions in terms of other multivector expressions.
utensil:
I have the same feeling. Actually I think as a symbolic library, GAlgebra should be able to manipulate GA expression without concerning the basis and simplify GA expressions using predefined rewrite rules. For that, I studied the internal of a few rule-based symbolic rewrite library and wish to be able to implement as such.
As for the rewrite rule list, I find Eric Chisolm's https://arxiv.org/pdf/1205.5935.pdf is pretty good at listing the identities in GA exhaustively in Appendix A Summary of definitions and formulas. I also have verified many of them with GAlgebra.jl (for syntax sugar) at https://github.com/pygae/GAlgebra.jl/blob/master/test/runtests.jl#L67 .
Some of the rule-based symbolic rewrite library/code that I've noticed:
From https://codebeat.co/projects/github-com-pygae-galgebra-master/pull_requests/292313 .
See also the discussion in #80 (comment) .
Creating a tracking issue for this, not advocating we do it immediately
Since Python 2.7 is EOL on 2020-01-01, we could consider dropping support for python 2.7 on the same date, in line with https://python3statement.org/ (which notably includes SymPy).
Realistically, that would probably make 0.4.5 the last release to support python 2.
First discussed in #19 (comment) .
eval()
usagesystem()
usagepdflatex
stops and asks for inputDear All,
Galgebra does not seem to obtain the correct Christoffel symbols of the first kind; at least the values printed out indicate a skew symmetry, which is strange.
Starting with the metric tensor relating to a two dimensional manifold, the unit sphere, viz.,
galgebra yields the following components for the Christoffel symbols of the first kind,
when, in fact, the correct values are
As is well known, these symbols are symmetrical in the indices alpha and beta.
As for the Christoffel symbols of the second kind they are not calculated, an error is returned instead:
“
C:\Users\Freddy\Desktop\Issues\Christoffel>C:\Anaconda3\python "Christoffel_symbols_checking.py"
Traceback (most recent call last):
File "Christoffel_symbols_checking.py", line 47, in
Cf2 = sp2.Christoffel_symbols(mode=2)
File "C:\Anaconda3\lib\site-packages\galgebra\metric.py", line 490, in Christoffel_symbols
Gamma_ijk += Gijl * self.g(l,)
TypeError: 'MutableDenseMatrix' object is not callable
C:\Users\Freddy\Desktop\Issues\Christoffel>pause
Press any key to continue . . .
“
It is not at all clear how the differential operators can be properly computed (see zip file enclosed)
when it is explicitly stated in Section 2.3.1 of Galgebra: a Geometric Algebra Module for Sympy (October 8, 2016) that the Christoffel symbols of the first kind are made use of to perform a number of calculations, notably to obtain the derivatives of the basis vectors (footnote on page 17). Unless the Christoffel symbols are not actually used at all! This would explain that, but I can be totally wrong on this.
Look forward to receiving any views on all this.
Kind regards,
FB
[email protected]
Christoffel.zip
Due to my commit Remove circular dependencies , module mv
no longer depends on module ga
, but currently MV still lives in mv
and calls ga
.
So any examples using class MV, particularly the ones in examples/Old Format
won't work and that includes some references to class MV in the new README. (My mistake......)
I have no intention to reintroduce circular dependencies or to drop support for class MV, so here's the work needed to be done:
ga
and mv
to put class MV and possibly the widely used com()
, could name it legacy
or deprecated
(related to a179957)This issue tracks some PRs merged with pending work:
or they will be buried in the pile of merged PRs.
As discussed here: #9 (comment) , there should be a way to maintain the version number without redundancies.
Also we need to decide a release cycle, a few milestones and decide when can we send PRs to change sympy to point to pygae/galgebra as discussed here: https://github.com/brombo/galgebra/pull/42#issuecomment-464703367 as well as to change the wiki url: https://en.wikipedia.org/wiki/Geometric_algebra#Actively_developed_open_source_projects
P.S. I'm starting this issue to combine some potential lost discussions and to remove the TODO item from README.md to make it more user-friendly.
Hi,
I was trying this version of galgebra and I found Mv.dual method is very slow for low dimension geometric algebras. I hoped the issue was fixed there (This issue is reproducible with brombo version).
A short snippet :
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()
I only profile :
xx = cross(a, cross(b, c))
cProfile reports :
16807237 function calls (15373382 primitive calls) in 5.316 seconds
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
2 0.000 0.000 5.316 2.658 /home/sylvain/Documents/pygae/tests/test_dual.py:41(cross)
63300/1661 0.047 0.000 5.200 0.003 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/cache.py:91(wrapper)
2 0.000 0.000 5.106 2.553 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:1050(dual)
2 0.000 0.000 5.039 2.520 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:506(__mul__)
5864/5592 0.037 0.000 4.517 0.001 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/operations.py:28(__new__)
1789/1582 0.001 0.000 3.483 0.002 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/decorators.py:84(__sympifyit_wrapper)
1602/1579 0.001 0.000 3.481 0.002 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/decorators.py:122(binary_op_wrapper)
62 0.003 0.000 3.371 0.054 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/ga.py:103(nc_subs)
22 0.000 0.000 3.136 0.143 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/ga.py:1137(base_to_blade_rep)
927 0.001 0.000 3.058 0.003 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/expr.py:117(__add__)
1045 0.130 0.000 3.054 0.003 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/add.py:78(flatten)
10 0.000 0.000 2.956 0.296 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:383(blade_rep)
5787 0.053 0.000 2.443 0.000 {method 'sort' of 'list' objects}
507395/196716 0.766 0.000 2.390 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/basic.py:170(compare)
1046 0.000 0.000 2.091 0.002 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/add.py:19(_addsort)
82 0.000 0.000 1.722 0.021 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/function.py:1982(expand)
33 0.001 0.000 1.721 0.052 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/expr.py:3071(expand)
246474/297 0.329 0.000 1.720 0.006 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/expr.py:3041(_expand_hint)
6 0.000 0.000 1.464 0.244 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:287(__init__)
6 0.000 0.000 1.464 0.244 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:124(characterise_Mv)
8886 0.025 0.000 1.146 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:854(_eval_expand_mul)
4744/4487 0.126 0.000 1.083 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:97(flatten)
262792 0.194 0.000 1.050 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/symbol.py:250(_hashable_content)
262792 0.363 0.000 0.633 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/symbol.py:254(assumptions0)
77094 0.037 0.000 0.621 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/operations.py:68(_new_rawargs)
84366 0.154 0.000 0.600 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/operations.py:54(_from_args)
4 0.000 0.000 0.502 0.125 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/ga.py:66(update_and_substitute)
604605/508233 0.121 0.000 0.444 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/assumptions.py:242(getit)
662/646 0.001 0.000 0.421 0.001 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/expr.py:137(__mul__)
2 0.000 0.000 0.418 0.209 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/ga.py:1170(mul)
72928 0.117 0.000 0.382 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/logic.py:112(fuzzy_and)
71594 0.058 0.000 0.374 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:768(as_coeff_Mul)
211/133 0.000 0.000 0.365 0.003 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:835(_expandsums)
8 0.001 0.000 0.360 0.045 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/metric.py:42(linear_expand)
4737 0.002 0.000 0.354 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:32(_mulsort)
17861/654 0.051 0.000 0.342 0.001 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/assumptions.py:254(_ask)
5796 0.104 0.000 0.303 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/basic.py:1695(_exec_constructor_postprocessors)
39 0.001 0.000 0.273 0.007 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:850(<listcomp>)
648176 0.188 0.000 0.269 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/core.py:73(__cmp__)
2338243 0.261 0.000 0.261 0.000 {built-in method builtins.isinstance}
1732062 0.251 0.000 0.251 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/symbol.py:256(<genexpr>)
8886 0.038 0.000 0.250 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/simplify/radsimp.py:930(fraction)
1018718/360300 0.130 0.000 0.238 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/basic.py:121(__hash__)
28 0.000 0.000 0.231 0.008 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/ga.py:1145(blade_to_base_rep)
4 0.000 0.000 0.228 0.057 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:375(base_rep)
324088 0.081 0.000 0.224 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/core.py:101(__gt__)
9486 0.073 0.000 0.212 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:380(_gather)
2 0.000 0.000 0.210 0.105 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:769(__xor__)
262825 0.205 0.000 0.205 0.000 {built-in method builtins.sorted}
1052/902 0.001 0.000 0.200 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/mul.py:1160(_eval_is_integer)
324088 0.073 0.000 0.199 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/core.py:96(__lt__)
647160 0.105 0.000 0.179 0.000 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/sympy/core/operations.py:64(<genexpr>)
4 0.000 0.000 0.167 0.042 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/mv.py:922(is_scalar)
4 0.000 0.000 0.167 0.042 /home/sylvain/Documents/pygae/venv/lib/python3.6/site-packages/galgebra/ga.py:1333(grades)
15832 0.052 0.000 0.159 0.000 /usr/lib/python3.6/random.py:263(shuffle)
Regards
It should return the same thing as Mv(name, 'scalar')
:
>>> g.mv('A', 'grade', 0)
0
>>> g.mv('A', 'scalar')
A
As brought up by @FreddyBaudine here, @brombe originally described a way to implement the overdot notation in Python as Split Differential Operator which is described in 2.3.4 of GAlgebra: a Geometric Algebra Module for Sympy by Alan Bromborsky .
The overdot notation is used for describing the scope of ∇ which has been used in Geometric Algebra for Physicists by Chris Doran; Anthony Lasenby and many other books and papers. A very brief definition would be
( a snapshot taken from hout07.pdf in Course materials of Physical Applications of Geometric Algebra
on http://geometry.mrao.cam.ac.uk/home/teaching-resources/ )
This issue does not mean there is a development plan for implementing overdot notation as either Split Differential Operator or other forms but a place to discuss it.
This issue is a placeholder for my original plan for 0.4.5, which will be postponed to later versions, but useful as a reference for forming a roadmap.
Moved from #17 (comment):
I think I'll be working on the following features in 0.4.5:
- Performance: GAlgebra is extremely slow for certain coordinates and metrics, primarily caused by eagerness in the calculus stuff and simplification, so the main idea is laziness, so higher dimensions can be supported
- Better support for FGA and CGA: it's already partially supported but I need to extensively verify them and some complications are expected
- SymPy 1.4 support: I need to reimplement
collect
in SymPy for non-commutative symbols, that's quite some work, see #31- Doc improvements: I want to write a true tutorial, weaving the examples together; also the docstring in Python code are mostly ill formated;
- Examples fixing: examples in
doc/python
are not verified; some of them have serious correctness issues yet to be fixed.
I am working through all the examples with the new python 3 printer module. When I finish I will send them to you. I see the collect
problem you mentioned in several examples (I am using sympy 1.4). Here is the custom collect
I wrote to solve the problem -
def Collect(A, exp_lst):
(coefs,bases) = linear_expand(A)
C = S(0)
for x in exp_lst:
if x in bases:
i = bases.index(x)
C += coefs[i]*x
return C
I placed it in metric.py just after linear_expand.
I have replaced the collect
call in ga.py but not in mv.py yet. Are there examples where calling collect
is a problem in mv.py that I can use to test. I am only using your galgebra for coding now. Would the best thing for me to do is just put a link to your github site in my github site and tell everone that your is the supported version of galgebra.
Mirroring a slack post here for public discussion:
I did some experimentation regarding tighter sympy integration: https://gist.github.com/eric-wieser/823a115df88b6e96e21fdedebbdfa9c0
The eventual idea here would be to eliminate Mv in favor of a subclass of GaExpr. It also opens the door for working symbolically without having to do so one basis blade at a time.
I'll expand on this idea in future.
Hi,
Here's another slow snippet (291s) :
from galgebra.ga import Ga
from sympy import Symbol
GA, e_0, e_1, e_2, e_3 = Ga.build("e*0|1|2|3", g='-1 0 0 0, 0 1 0 0, 0 0 1 0, 0 0 0 1')
e_0_inv = e_0.inv()
p = GA.mv((1, Symbol('p1'), Symbol('p2'), Symbol('p3')), 'vector')
q = GA.mv((0, Symbol('q1'), Symbol('q2'), Symbol('q3')), 'vector')
r = GA.mv((0, Symbol('r1'), Symbol('r2'), Symbol('r3')), 'vector')
A = q ^ r
X = (p ^ A) # A plane
d = (e_0_inv < (e_0 ^ X)) / (e_0_inv < X) # Support vector from plane
Very slow :
d_inv = d.inv()
d
doesn't seem to complex :
(p1*q2**2*r3**2 - 2*p1*q2*q3*r2*r3 + p1*q3**2*r2**2 - p2*q1*q2*r3**2 + p2*q1*q3*r2*r3 + p2*q2*q3*r1*r3 - p2*q3**2*r1*r2 + p3*q1*q2*r2*r3 - p3*q1*q3*r2**2 - p3*q2**2*r1*r3 + p3*q2*q3*r1*r2)*e_1/(q1**2*r2**2 + q1**2*r3**2 - 2*q1*q2*r1*r2 - 2*q1*q3*r1*r3 + q2**2*r1**2 + q2**2*r3**2 - 2*q2*q3*r2*r3 + q3**2*r1**2 + q3**2*r2**2) + (-p1*q1*q2*r3**2 + p1*q1*q3*r2*r3 + p1*q2*q3*r1*r3 - p1*q3**2*r1*r2 + p2*q1**2*r3**2 - 2*p2*q1*q3*r1*r3 + p2*q3**2*r1**2 - p3*q1**2*r2*r3 + p3*q1*q2*r1*r3 + p3*q1*q3*r1*r2 - p3*q2*q3*r1**2)*e_2/(q1**2*r2**2 + q1**2*r3**2 - 2*q1*q2*r1*r2 - 2*q1*q3*r1*r3 + q2**2*r1**2 + q2**2*r3**2 - 2*q2*q3*r2*r3 + q3**2*r1**2 + q3**2*r2**2) + (p1*q1*q2*r2*r3 - p1*q1*q3*r2**2 - p1*q2**2*r1*r3 + p1*q2*q3*r1*r2 - p2*q1**2*r2*r3 + p2*q1*q2*r1*r3 + p2*q1*q3*r1*r2 - p2*q2*q3*r1**2 + p3*q1**2*r2**2 - 2*p3*q1*q2*r1*r2 + p3*q2**2*r1**2)*e_3/(q1**2*r2**2 + q1**2*r3**2 - 2*q1*q2*r1*r2 - 2*q1*q3*r1*r3 + q2**2*r1**2 + q2**2*r3**2 - 2*q2*q3*r2*r3 + q3**2*r1**2 + q3**2*r2**2)
d_inv
will be used later for computing the dual of X. I can provide more information if that matters.
Regards
Just found sphinx-math-dollar
from this post: https://www.asmeurer.com/blog/posts/quansight-labs-work-update-for-september-2019/ .
Currently, the API documentation of GAlgebra splits into two scattered pieces:
1 is at https://galgebra.readthedocs.io/en/latest/galgebra_guide.html#Module-Components
2 is at https://galgebra.readthedocs.io/en/latest/api.html .
The scenario causes maintenance burden and one of the reasons why @abrombo preferred to work on a separate repo is that it's difficult to maintain LaTeX doc and Sphinx doc (but there wasn't such an automatic API doc back then) at the same time.
By ill-formatted, I mean:
It's still parseable but cumbersome. I was aware of this situation but I felt unwilling to rewrite them in the verbose syntax of reStructuredText so I left them there and treated them like plain text.
Now, with the help of sphinx-math-dollar
which SymPy is also using, the situation can be fixed. So I opened this issue to add this work to the backlog.
However, this does not solve the maintenance burden issue which I only mentioned it as a context and comments and suggestions are welcome @abrombo @hugohadfield @eric-wieser .
The setup for upstream lies in https://github.com/pygae/galgebra/tree/upstream_gitpod .
The WIP setup for upstream lies in https://github.com/pygae/galgebra/tree/gitpod .
Sometimes plain text is printed with or instead of LaTeX in Jupyter Notebooks.
The "with" case:
The "instead of" case:
When blaming the source of galgebra, most lines ends up at a commit fab9012 on 13 Nov 2015
, before that, it's lost to us.
But somehow the history is preserved at the following places:
Dear all,
Galgebra does not seem to be able to print out quantities such as the following:
Products (inner, left contraction, right contraction or geometric) of a (multi)vector with itself, e.g., a * a. It should be noted that the product of a vector with a different one is OK, e.g., a * b is printed out correctly.
By the same token, no inverse of an invertible multi(vector) is printed out.
It looks as if squares of the components of (multi)vectors were the culprits, as these appear in the above calculations.
Python (3.4 and 3.7):
The computer hangs. Here’s a print screen
“
C:\Users\Freddy\Desktop\Python\programs>C:\Python34-37\python "spacetimePython3.py"
latex file = spacetimePython3.tex
pdflatex path = C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe
“
Here’s the message returned to the console after exiting with a ctrl-C:
“
Traceback (most recent call last):
File "spacetimePython3.py", line 65, in
xpdf(paper=(8,9),crop=True)
File "C:\Python34-37\lib\site-packages\galgebra\printer.py", line 1165, in xpdf
os.system(latex_str + ' ' + filename[:-4] + sys_cmd['null'])
KeyboardInterrupt
Terminate batch job (Y/N)?
“
I tried IPython (notebook), i.e. Jupyter (with both browsers, viz., Firefox and Chrome).
In this case, the unevaluated latex code is returned and the computer does not hang.
Is there any workaround available?
Kind regards,
Freddy Baudine
This is currently tracked by #62 and #39 .
Mirroring a slack discussion:
To name a few changes I noticed:
- The new printer (do you wish to stop supporting Python 2.7?)
- Odot (Have you noticed the discussion and my proposal of design which is less invasive?)
- xtex (Have you noticed the xpdf function I modified to support not running pdflatex only generating .tex?)
- convert strings to raw strings to avoid escaping (it’s preferable to be on a separate commit)
- replace operators like I < > in print manually with their LaTeX correspondence (do you wish to stop support the automatic replacement?)
- Lots of space or tab changes
- new examples/ipython/tutorial_algebra.ipynb
- new examples/ipython/tutorial_calculus.ipynb
- your new colllect adapter to solve the SymPy 1.4 compatibility issue
- LaTeX changes such as align* to aligned
Regressions I noticed:
- Installation instructions;
- files that should be ignored using .gitignore;
- you seem to be using an old version of Jupyter so some fields in .ipynb are obsolete
- setgapth.py is back, it’s already replaced by pip install
- tests are failing miserably
- Circular dependencies are back
@abrombo replied:
- I don't see any point in supporting 2.7 since sympy will not.
- Odot is on the back burner for now. Needs much more discussion before doing anything
- The default for xtex is what you have xpdf doing now.
- I try to always use r'\something' instead of '\something'.
- Please explain this better.
- Do you mean in the source code?
- & 8. I need to go through all the examples
- What is the question.
- Did I miss some?
Regressions
- My bad.
- Not familiar with .gitignore.
- Will update.
- Should not have included it. I use it so my changes to code locally (not in sitepackages) take effect for any executable code py or ipynb.
- How do you run tests. I will not push in future until code passes.
- My bad again.
galgebra uses a < b
to mean left_contract(a, b)
. I'm worried that this doesn't work properly:
Quoting the python docs about the comparison ops:
There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, lt()` and gt() are each other’s reflection
If the operands are of different types, and right operand’s type is a direct or indirect subclass of the left operand’s type, the reflected method of the right operand has priority, otherwise the left operand’s method has priority.
What this means is that obj < mv
and mv > obj
are indistinguishable if obj
does not take part in the comparison.
From dorst, the rule for converting a left to right contraction is:
So by identity, left_contract(obj, mv) == right_contract(mv.rev(), obj.rev()).rev()
However, the python rules allow the rewrite left_contract(obj, mv) == right_contract(mv, obj)
.
Can we guarantee this is always true?
For example, in https://galgebra.readthedocs.io/en/latest/galgebra_guide.html the edit link at the top right points to
https://github.com/pygae/galgebra/blob/origin/master/doc/galgebra_guide.ipynb
...which yields a 404 error page. Instead, it should point to
https://github.com/pygae/galgebra/blob/master/doc/galgebra_guide.ipynb
Note the extraneous origin/
in the URL.
Hi everybody,
I tried using galgebra in pygae but the following code, viz.,
from sympy import symbols, sin, cos, pi
from ga import Ga
from printer import Forma,
Format(Fmode = True, Dmode = True)
coords = (r, th, phi) = symbols('r, theta, phi', real = True)
sp3d = Ga('e_r e_th e_ph',g=[1, r**2, r**2*sin(th)**2], coords = coords, norm = True)
lead to the following error
ValueError
Traceback (most recent call last)
<ipython-input-1-aa02a2b2e6ee> in <module>()
1 from sympy import symbols, sin, cos, pi
----> 2 from ga import Ga
3 from printer import Format
4 Format(Fmode = True, Dmode = True)
5
C:\Documents and Settings\freddy baudine\Desktop\CliffordAlgebraPython\galgebra-master\galgebra\ga.py in <module>()
10 #from sympy.core.compatibility import combinations
11 from itertools import combinations
---> 12 from . import printer
13 from . import metric
14 from . import mv
ValueError: Attempted relative import in non-package
This piece of code did not give any error in the past
Many thanks in advance for any help.
Kind regards,
Freddy Baudine
Extremely slow Ga initialization in derivatives_in_elliptic_cylindrical_coordinates()
a = symbols('a', real=True)
coords = (u,v,z) = symbols('u v z', real=True)
(elip3d,er,eth,ephi) = Ga.build('e_u e_v e_z',X=[a*cosh(u)*cos(v),a*sinh(u)*sin(v),z],coords=coords,norm=True)
grad = elip3d.grad
The code above takes 500~600 seconds for the Ga.build
call.
After some profiling/debugging I found it spent most of the time in simplify
and trigsimp
(both take ~50%) and every call to them cost ~16s of 100% CPU and there's approximately 27 calls to them, 27 * 16s = 513s, it explains the total time.
So which step is calling simplify
and trigsimp
? It turns out to be metric.Simp.apply()
in build_reciprocal_basis()
:
# Replace reciprocal basis vectors with expansion in terms of
# basis vectors in derivatives of basis vectors
if self.connect_flg:
for x_i in self.n_range:
for jb in self.n_range:
if not self.is_ortho:
self.de[x_i][jb] = metric.Simp.apply(self.de[x_i][jb].subs(self.r_basis_dict) / self.e_sq)
else:
self.de[x_i][jb] = metric.Simp.apply(self.de[x_i][jb].subs(self.r_basis_dict))
# Christoffel symbols of the first kind, \Gamma_{ijk}
for i in n_range:
de_row = []
for j in n_range:
Gamma = []
for k in n_range:
gamma = half * (dg[j][k][i] + dg[i][k][j] - dg[i][j][k])
Gamma.append(Simp.apply(gamma))
de_row.append(sum([gamma * base for (gamma, base) in zip(Gamma, self.r_symbols)]))
de.append(de_row)
Mostly the former.
SymPy 1.4 has just released and some tests are broken for SymPy 1.4, see build https://circleci.com/workflow-run/dcbd3c98-45c3-4c89-abd6-2ea97fa07b2c .
Freeze SymPy version to 1.3 to keep CI green for now.
Tasks:
See discussion in https://github.com/pygae/galgebra/pull/48/files#r336069520
@rbeaster commented on Jan 30, 2016
I am trying to get the grade of blade A as
A.grade()
or
grade(A)
but neither is working. They both return zero. I think this used to work, but then I upgraded the GAlgebra module to get the >> commutator and << anticommutator. I did not try to use grade() in a long time. Does anyone else have this problem with grade(A)==0 ?
@brombo commented on Jan 30, 2016
Both A.grade(r=0) and grade(A,r=0) are grade projection operators. Both
A.grade(r) and grade(A,r) returns the r^{th} grade of the multivector
A. If you want to determine the whether a mulitvector is a pure grade
and what that grade is use the multivector member data A.i_grade (this
is not a function) If A is not a pure grade multivector A.i_grade is
"None" otherwise it is the grade of the multivector. Give me a day or
two and I will add a member function called pure_grade() (usage
A.pure_grade()) so you do not have to use member data (I will make the
interface consistent).
@rbeaster commented on Jan 31, 2016
Thanks for the quick response :)
As you say, A.grade(r)=grade(A,r) returns the grade r part of A. Yet, A.grade() with no grade number given did not return any error and just gives the grade 0 part A.grade(0)=grade(A,0). It seems to replace null with zero, like A.grade(null)=grade(A,null)=A.grade(0)=grade(A,0). I was expecting the function signature "A.grade()" to mean the grade number, and the signature "A.grade(r)" to be the grade r part. In other programming languages, as I understand, functions with different parameter count or types (signature) are different functions. So, I was thinking it would often be possible to define A.grade()=grade(A) to return the grade number, and A.grade(r)=grade(A,r) to return the grade-r part. The member functions of A always implicitly take A as the first param, I guess, and then differ by names and the other params.
Anyhow, I don't understand python well, and I'll like A.pure_grade() if that is how it should be done. :)
I'm using GAlgebra a lot to study some stuff, so I really appreciate this software. It works well for what I am playing around with. If python could run on multiple cores / threads, it might run faster. As I study some stuff, I'm writing a research paper/monograph that seems interesting. I will eventually post it on vixra.org. I cite you and your GAlgebra module with a bibtex I made, and give a url to this github site. I plan to have a large section of the monograph give GAlgebra code listings and some example computations that I can figure out clearly without taking too long.
@rbeaster commented on Jan 31, 2016
I was also thinking... a multivector A is a sum of k-blades that can be of different grades k. The highest grade term (blade) of the multivector is grade r>=k (for all terms) and r is what I'd call the grade of the multivector. If the multivector A is pure grade r as an r-vector or an r-blade, then the grade of A is simply r. But if A is not pure grade, not an r-vector or r-blade, then the highest grade r in A can be returned as the negative -r to indicate that r is the impure highest grade in A. The negative grade is like a flag that says the multivector A is not pure grade, but +r is the largest grade in A.
This is a quick, rough idea. There could be issues I have not thought of. This is probably discussed in some paper or book because this sounds like something I came across before somewhere.
@brombo commented on Jan 31, 2016
When the member function grade(r=0) of multivector is defined r=0
defines the default value of r. Thus A.grade() returns the scalar part
of the multivector A. Actually A.grade() returns a scalar multivector
(as opposed to a sympy scalar which is not a multivector) equal to the
scalar part of A.
@brombo commented on Feb 3, 2016
New function "pure_grade(self)" added to git-hub distribution. If A is
pure grade multivector A.pure_grade() returns the grade value of the
multivector. If A is not pure grade A.pure_grade() returns the negative
of the grade value of the highest non-zero grade of the multivector.
@rbeaster commented on Feb 16, 2016
Thanks for the pure_grade function. I used it for something I was testing and got it to work good.
Using your GAlgebra module again, I studied and tested another geometric algebra and wrote a paper on it. The paper cites your software.
The paper includes code listings of how I used the GAlgebra module in a simple way to test the algebra. The paper is a first draft v1 and has some mistakes, but it is not that bad and is here:
http://vixra.org/abs/1602.0114
Thanks again.
Restored from http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/1
The calculation of reciprocal basis for non-orthogonal basis in GAlgebra deviate from standard definition and caused a bug when calculating inverse metric.
See https://nbviewer.jupyter.org/github/utensil/julia-playground/blob/master/py/galgebra_reciprocal_basis.ipynb for step-by-step investigation.
@chaowenGUO commented on Mar 14, 2016
example:
import ga,sympy
base=ga.Ga('e0 e1',g=[1,1],coords=sympy.symbols('x,y',real=True))
M=[[1,2],[3,4]]
A=base.lt(M)
print A
print A.matrix()and the ouput is:
Lt(e0) = e0 + 2_e1
Lt(e1) = 3_e0 + 4*e1
Matrix([
[3, 4],
[1, 2]])According to the definition in page 62 of galgebra.pdf
Lt.matrix()
Returns the matrix representation (sympy Matrix) of the linear transformation, L defined by L (e i ) = L ij e j where L ij is the matrix representation.the answer of A.matrix() should be
Matrix([
[1, 2],
[3, 4]])
However, the answer is correct in sympy0.7.6.1
@brombo commented on Mar 17, 2016
Fixed Lt Matrix function problem and pushed to github -
import ga,sympy
coords=sympy.symbols('x,y,z',real=True)
base=ga.Ga('e0 e1 e2',g=[1,1,1],coords=coords)
M=[[1,2,3],[4,5,6],[7,8,9]]
A=base.lt(M)
print A
print A.lt_dict
print A.matrix()
v = base.mv('v','vector')
print v
print A(v)Lt(e0) = e0 + 2_e1 + 3_e2
Lt(e1) = 4_e0 + 5_e1 + 6_e2
Lt(e2) = 7_e0 + 8_e1 + 9_e2
{e2: 7_e0 + 8_e1 + 9_e2, e1: 4_e0 + 5_e1 + 6_e2, e0: e0 + 2_e1 + 3_e2}
Matrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
v__x_e0 + v__y_e1 + v__z_e2
(v__x + 4_v__y + 7_v__z)_e0 + (2_v__x + 5_v__y + 8_v__z)_e1 + (3_v__x +
6_v__y + 9_v__z)_e2
From http://webcache.googleusercontent.com/search?q=cache:https://github.com/brombo/galgebra/issues/9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.