This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, I have written some software to do simple tensor algebra, that you may want for the GSL. For the moment it is only complete in its C++ implementation, though. It is not finished in its C & GSL-style incarnation, and maybe someone out there would like to finish it before I do it myself. More on that at the end, first let me say: What you can do with it ----------------------- * Define real and complex tensors of any rank and dimension (of the associated vectorial space), assign and retrieve the values of its individual components. * Add and substract tensors of the same rank and with the same underlying vectorial space (same dimension). * Do the tensorial product of any two tensors when it makes sense. * Contract two indices of a tensor * Swap two indices of a tensor Note that the matrix product is the same as the tensorial product of rank-2 tensors followed by an index contraction (of the middle indices), that is, m1_ij * m2_jk = contract(m1_ij x m2_kl, 1,2) where "*" is the matrix product, "x" is the tensorial product, "contract(tensor, i,j)" is the contraction of indices i,j (I start counting on 0), and m1, m2 are to be interpreted as either squared matrices or rank-2 tensors depending on the context (yes, I used a sloppy notation). Also note that the matrix transposition (of a squared matrix) is a particular case of tensor index-swapping for rank-2 tensors. And of course a scalar product of two vectors is the contraction of their tensorial product ( a·b = cont(axb,0,1) ), and their vectorial product is their tensorial product with the totally-antisymmetric tensor and a double contraction of the appropiate indices (a^b = cont(cont(e x a x b, 2,4), 1,3)). Why it is not finished in C (and why you may want to finish it before I do) --------------------------------------------------------------------------- I started it on last february, out of curiosity about tensors, and used C++ for the operator overloading and many other goodies. Then I saw that the GSL didn't have such a thing, and also read some interest in the list. NAG and others don't have it either, by the way. So I started translating it to C for the GSL following the example of the directory matrix/ . For one thing or another I couldn't find enough time to finish it. The C++ version is finished and works, and can be used as a reference to do the gslization. I am attaching it as tensor-cpp.tar.gz . Try to compile with the makefile and run the examples if you like, it should be easy. At this moment there is some code that may or may not be a good starting point to do the GSL version (in case anyone wants it for the GSL, that is!), that I am attaching as tensor.tar.gz and should be "tar -xzf" in your gsl/ directory. Instead of lagging more, and because I don't foresee to have much time in the near future, I let you know about all this now. In case you are interested, go ahead and add it to the GSL. Finally, and again only in case it is interesting, I will be happy to answer questions about the code, explain the algorithms and/or comment about some things that I think can be done in some other way. Best regards, Jordi
Attachment:
tensor-cpp.tar.gz
Description: application/tgz
Attachment:
tensor.tar.gz
Description: application/tgz
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |