On Friday, 9 February 2018 at 17:10:11 UTC, Simen Kjærås wrote:
On Friday, 9 February 2018 at 15:45:11 UTC, Amorphorious wrote:
On Friday, 9 February 2018 at 02:40:06 UTC, Nick Sabalausky (Abscissa) wrote:
Well, that's the difference between a formal library package release vs sharing a working proof of concept jotted down to pass time ;)


Yes, but he can go back an add some friendly text at some point... He knows most about it so it is much easier and shouldn't take more than a few mins.

Indeed I can, and I have:

https://gist.github.com/Biotronic/833680b37d4afe774c8562fd21554c6b

Doing so after a long, tiring day at work for something I just did to pass the time, though - not worth it when I wanted a shower and some sleep. Luckily, today was just as boring, so I cleaned up the syntax a bit, added more sensible error messages, and even made it do the right thing by default when you leave out a rule:

alias complex = Algebra!(
        float,
        "1,i",
        "i" * "i".op = -1);
alias dual = Algebra!(
        float,
        "1,e",
        "e" * "e".op = 0);
alias splitComplex = Algebra!(
        float,
        "1,j",
        "j" * "j".op = 1
        );
alias quaternion = Algebra!(
        float,
        "1,i,j,k",
        "i,j,k" * "i,j,k".op = -1,
        "i,j,k" * "j,k,i".op = "k,i,j".antiCommutative
        );

--
  Simen

Lol, thanks, but that wasn't much. What I was thinking is a sort of paragraph of text at the top that sorta describes the overall conceptualization/overview. One still has to understand how all the pieces fit and the only way to learn that is by learning the pieces. And English equivalent of D code isn't really all that useful because anyone that knows D can understand the D code.

E.g.,

// Create a canonical list of rules from compound rules.
template Canonicalize(string units, Rules...)

is not really all that useful

rather, which I'm making up some type of overview:

"Creates algebraic structures[Algebra!(base type, relators/varables, relations...)] using composition rules(relations) to define the structure. To define an algebra type, say, the quaternions of base type float,

 alias quaternion = Algebra!(
         float,
         "1,i,j,k",
         "i,j,k" * "i,j,k".op = -1,
         "i,j,k" * "j,k,i".op = "k,i,j".antiCommutative
         );

which can be used a type:

quaternion(a,b,c,d) q; // Defines the quaternion q = a + bi + cj + dk.

--

the main bulk of defining an algebra as the relations. Each relation consists of a string expressions sk involving the realtors expressing the relation equation as

f(s1,..,fn).op = s0

where f is an algebraic function and s0 is a the special relator(whatever). relators can be used as a csl.

e.g., for quats,

"i,j,k" * "i,j,k".op = -1

says that i*i = -1, j*j = -1, k*k = -1. Each of the rules could have been specified individually:

"i" * "i".op = -1
"j" * "j".op = -1
"k" * "k".op = -1

One can append a string expression using "property syntax":

"i,j,k" * "j,k,i".op = "k,i,j".antiCommutative

.antiCommutative states that the relator is anti commutative. Other properties are:

........
........
........ (no others?)

Once and algebra is established it can then act as any complex type and used as a functioning algebra.
"

etc.

The idea here is that to write a few paragraphs of English text so that one can read from the start to finish and understanding the general idea of what is going on without having to read through the entire code(which is much longer) and try to put the pieces together. The code I presented is what gleaned from what you are trying to accomplish and my knowledge of abstract algebra(which most don't have).

What's important is that the average person shouldn't have to learn your code to know how to use it. It is not important of the details(of which I haven't looked at) but just how to use them. While you give examples, which is good, the only problem is one can't necessarily glean from those examples how to create their own algebras. e.g., what about the GL(n,Z)? Is it possible?


 alias GLnZ = Algebra!(
         Matrix!(n,Z),
         "e_i_j" = 1,
         );

Obviously I doubt this would work, but it would be cool if it did, but the only way I could know is if I learned your code and tried to figure out how to massage it to work, if it could.. and that may take up more time than it would be to do my own implementation which I would understand better.

Hence adding clarifications to the code then help one make better decisions:

e.g.,

"Base Type must be a D primitive".

(again, the only way one can know if your code supports a general type is to learn the code, which may require one to learn all the code).


I'm not saying you have to do this, of course... just saying it would be more more helpful. I'm not sure how general your code is but if one could basically make arbitrary algebraic types, it would be very cool indeed and probably be pretty useful when people learned where to use it.




Reply via email to