
Hi, [crossposted to oo-numerics and boost-developers] About 20 months back, I asked if there was any interest in a geometric or Clifford algebra library written in C++. Despite some positive replies, I got the impression that there were not a lot of people in the Boost community who saw any practical uses for such library. Back then I had a rudimentary proof-of-concept for a Clifford algebra library that used meta-programming techniques to gain significant performance benefits over other existing libraries (Gaigen, nKlein, CLU, etcetera). Over the past few months I have put a lot more work into this library. The bulk of the work consisted of adding more unit-tests, proving many of the theorems in some of the papers by David Hestenes et al. I also added expression templates to improve performance. To give an idea of what the library is capable of: #include <boost/math/clifford/clifford.hpp> #include <boost/mpl/list_c.hpp> #include <cassert> using namespace boost::math::clifford; using namespace boost::mpl; typedef algebra<4, 1> conformal_model; typedef blade<float, 0, conformal_model> scalar; typedef blade<float, 1, conformal_model> vector; typedef blade<float, 5, conformal_model> pseudo_scalar; typedef blade<float, 2, conformal_model> bi_vector; // same as: // typedef element<float, list_c<int, 1>, conformal_model> bi_vector; typedef list_c<int, 0, 2> spinor_grades; typedef element<float, spinor_grades, conformal_model> spinor; typedef list_c<int, 0, 1, 2, 3, 4, 5> multi_vector_grades; typedef element<float, multi_vector_grades, conformal_model> multi_vector; int main() { assert(sizeof(scalar) == sizeof(float)); assert(sizeof(vector) == 5 * sizeof(float)); assert(sizeof(bi_vector) == 10 * sizeof(float)); assert(sizeof(pseudo_scalar) == sizeof(float)); assert(sizeof(spinor) == 11 * sizeof(float)); assert(sizeof(multi_vector) == 32 * sizeof(float)); vector e_plus; e_plus[3] = 1.0; vector e_min; e_min[4] = 1.0; e_star = e_min - e_plus; e_star *= -std::sqrt(2.0); e_star /= 2.0f; e [noalias] = e_plus * std::sqrt(2.0) - e_star; bi_vector E = outer_product(e, e_star); // geometric product between bi_vector and vector multi_vector v = E * e_star; // geometric product between two vectors, generating a spinor vector a, b; spinor s = a * b; // doing a spinor rotation vector c; c [noalias] = reverse(s) * a * s; } Each product always does the bare minimum of additions, multiplications and subtractions to calculate the result on the left-hand-side of an expression. Thus, if you do the full geometric product of two multi_vectors but assign it to a scalar, it will only do those calculations that are involved in grade 0. Also, unlike other existing libraries, no dynamic allocations are being done ever. Currently, the following operations are supported, between any two random elements of an algebra (blades and composite multi_vectors): geometric_product = operator * inner_product outer_product fat_dot_product left_contraction right_contraction scalar_product of course, all the normal operations (scalar multiplication, addition of elements, etcetera) are supported, as well as reversion, involution and conjugates. Adding more operators is trivial. They can either be implemented in terms of existing operators, or by implementing an appropriate grade-predicate. For example, this is what the implementation of the outer_product looks like: struct outer_product_predicate { template <class ResultGrade, class LhsGrade, class RhsGrade> struct apply { typedef typename mpl::if_ < typename mpl::equal_to < ResultGrade, typename mpl::plus<LhsGrade,RhsGrade>::type >::type, mpl::true_, mpl::false_ >::type type; }; }; BOOST_MATH_CLIFFORD_PRODUCT_IMPL( outer_product, impl::outer_product_predicate ) which for somebody that knows the definition of the outer_product is easy to understand. I have unit-tests for 2, 3 4 and 5 dimensional algebras, but more is possible if your compiler supports it. Currently I have only tested the library on MSVC 7.1. I tried 7.0 but couldn't get it to work (excessive use of MPL). GCC and Intel compiled it at one point, but because I only use MSVC I dropped support. Of course, if anybody is interested I'd be trying other compilers again. You will need a compiler that does aggresive inlining though. On MSVC I am using the force_inline feature to get the release performance I need. Anyway, let me know if anybody is interested, and I'll put together a package to upload somewhere. Cheers, Jaap

Jaap Suter wrote:
For a full geometric algebra, I suspect the target market is going to be limited to a few thousand people worldwide, most of whom have never heard of boost and are unwilling to learn C++. I wrote some GA classes for the 3D case about a decade ago, and I'm still using them, but they are a very minor part of my work and I've no reason to "upgrade" to a boost version, no matter how yummy it looks. I'd like to be more positive, but I have to be honest. However, you may be asking the wrong question. There are reasonable arguments for using only one library for all your geometric algebra and the demand for complex numbers is demonstrably large enough to justify including it in the language standard. The market for 3D geometry in video games is also fairly well established. Given that GA is a superset of these, could your library replace these two? It would need to be syntactically compatible, since we can't break existing clients of std::complex, but since all such libraries try to follow standard mathematical notation this might not be too difficult. The same probably applies to M. Holin's quaternions and octonions, already in boost, but I'm not familiar with those.

Somewhere in the E.U., le 15/06/2004 Bonjour In article <ca9aqo$a6a$1@sea.gmane.org>, "Ken Hagan" <K.Hagan@thermoteknix.co.uk> wrote:
I was in Limbo at the time, sorry (still spend most of my time there now, unfortunately...). Otherwise, I would have said that, yes, there is interest for such a library, and that it would be nice that it were in boost. I think this is still the case today, even perhaps more so as an increased interest in math within Boost is manifest.
I agree that the number of potential users at any one time is bound to be limited. However, for those who are indeed interested, such a library would be a godsend. Furthermore, its very existence might prompt more interest (the first step along a path is always the most difficult, even if the path is later left). It is not merely "Develop it and they will come", it is that when one has to face a severely complex problem, the lack of all appropriate tools is an open invitation to do something else... In other words, such a library would severely lessen the access difficulty for a whole category of problems. Therefore, for those who would be considering C++ to solve their problem in that domain, that library would be invaluable. As far as the potential users being unwilling to use C++, if there are no C++ tools for the problem domain, then indeed nobody dealing with that domain will be inclined to learn C++ to solve their specific problems. This aspect is the classical chicken-and-egg dilemma. A tool is always worthwhile to consider, even if it is ultimately rejected for a particular use.
Well, you already have your tools. The vast majority of other potential users do not (at least as far as C++ is considered), so they would benefit from that library.
It would not be necessary to replace the complex numbers. There is value in specialization. There is even greater value in interoperability, and in this respect it is a strong argument for having that library within Boost, along with proper bridges with the other libraries (and possibly factorization of commonality).
Yes these two libraries work nicely with the standard's complex numbers. Regards, Hubert Holin

On Thursday, 10. of June. 2004 07:26, Jaap Suter wrote:
Anyway, let me know if anybody is interested, and I'll put together a package to upload somewhere.
Some time ago, I had an idea of using geometric algebra for implementing exotic kinds of logics would dramatically change possible uses of logic programming. But I didn't find a suitable GA library that time. Since currently I am using gcc only, I would gladly help porting your library as well. Petr Kocmid

Dear Jaap Suter, Your library is more than interesting, actually (at least, for me). I was browsing for its source recently and with no success. It's a very good news to hear that GA library (apparently) will be available in public domain (whether this would be boost or oo-numerics, I don't really care, although I believe that this library should find its place among other boost libraries. After all, quaternions and octonions are already there and one could arguably tell that the use of GA lib would be far more substantial). Sound YES. This library is interesting. Would you be so kind to upload it somewhere? I just cannot wait to see what it contains and how applicable it is for some problems I'm currently working on. Kind regards, Justinas Vygintas D.

Jaap, Reply below. Best regards On Thursday 10 June 2004 15:26, Jaap Suter wrote: [...]
On the OON list I said I would be very interested to see what you have done with your library, and also said that "Boostify GluCat" is on my TODO list. I am still swamped with Math PhD work, but I would at least like to understand how much work would be needed to get GluCat into shape for Boost. I posted the following to boost-users on 12 May but had no reply: http://lists.boost.org/MailArchives/boost-users/msg06695.php Back in January last year, I asked if there was any documentation which could help me to Boostify GluCat: http://lists.boost.org/MailArchives/boost-users/msg02787.php Since then I have been very busy, but in the next few months I may be able to find the time to get this done right, so I'm asking again: GluCat is a new numeric template class library, hopefully destined for promotion to Boost. I would like to know where there is some documentation on how to: 1. Add concepts. Is there such a thing as a non-commutative multiplication concept? How do I check concepts? 2. Add numeric limits. Limits of U<T> would default to limits of T. 3. Add numeric promotion_traits. What are promotion_traits ? There is a discussion on ublas-dev mailing list about promotion_traits within uBLAS. 4. Add numeric type_traits. Also, is there a set of documented procedures which explain what is required for a library to be included in Boost?

"Paul C. Leopardi" <leopardi@bigpond.net.au> wrote in message news:200406161025.16589.leopardi@bigpond.net.au...
There is as soon as you write one. ;)
How do I check concepts?
You could check out the Boost.ConceptCheck library: http://www.boost.org/libs/concept_check/concept_check.htm
2. Add numeric limits. Limits of U<T> would default to limits of T.
I'm not sure about this, but I vaguely recall some discussion about a numeric limits library. I'm not sure if it's complete or what, but a search of the list archives would probably reveal something interesting.
3. Add numeric promotion_traits. What are promotion_traits?
Not entirely sure, but I suspect they tell you when you can promote say an int to a double, and things like that.
http://www.boost.org/more/lib_guide.htm Dave --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.701 / Virus Database: 458 - Release Date: 6/7/2004
participants (7)
-
David B. Held
-
Hubert Holin
-
Jaap Suter
-
Justinas V.D.
-
Ken Hagan
-
Paul C. Leopardi
-
Petr Kočmíd