Small vector and matrix proposed for phobos2 now on github

2010-04-25 Thread Gareth Charnock
I've put the beginnings of my matrix-vector library up on github (between swizzling, generalising to N dimensions and making use of static foreach this project quickly turned from a cleanup to a rewrite). You can find it here. http://github.com/gcharnock/phoboslinalgebra Some highlights so fa

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-25 Thread Robert Jacques
On Sun, 25 Apr 2010 23:17:10 -0300, Gareth Charnock wrote: I've put the beginnings of my matrix-vector library up on github (between swizzling, generalising to N dimensions and making use of static foreach this project quickly turned from a cleanup to a rewrite). You can find it here. ht

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-25 Thread Gareth Charnock
Thanks. To quickly answer this: > - The version I'm seeing on github doesn't seem to have all the features > you're referencing (i.e. v*v). Why are some ops limited to */ and other +-? It was quite late (3am) when I typed up that email. I'm sorry if I got the ops wrong. v*v was actually rejec

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread bearophile
Gareth Charnock: >http://github.com/gcharnock/phoboslinalgebra I think that a single module is better. If seen fitting, some functionality can be moved inside other already present modules of Phobos. The module will need a good amount of unit tests. In the code I see no point in calling functio

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread bearophile
You can do performance benchmarks compared to the tinyvector module here, for D1: http://www.fantascienza.net/leonardo/so/libs_d.zip It comes from a performance tuning for DMD. Bye, bearophile

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread #ponce
> The semantics of transpose/transposed can be like in Python: the transpose > works in-place, transposed creates a new matrix. That's what I do, with normalize/normalized too.

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread #ponce
I'm not sure how your static foreach is actually static. I think static foreach is a very good idea to minimize speed difference between debug and release versions (i know one shouldn't ship debug version, but sometimes you have to)... > //Single element access does not require opDispatch > wr

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread bearophile
#ponce: > I'm not sure how your static foreach is actually static. It's a foreach on: template TypeNuple(T, size_t n) { static if(n == 0) { alias TypeTuple!() TypeNuple; } else { alias TypeTuple!(T,TypeNuple!(T, n-1)) TypeNuple; } } So with the current D it's a s

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread Gareth Charnock
I need a better name for ArgList. It originally made sense because because I assumed I be using the tuple like this: this(ArgList argList) But then I ended up using it in a load of static foreaches. I think it would be useful to actually be able to say "static foreach" so that readers (and wri

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread bearophile
Gareth Charnock: > I think it would be useful to actually be able to say "static foreach" > so that readers (and writers) of the code know for sure what's going on. > I seem to remember you starting a thread on that very matter. http://d.puremagic.com/issues/show_bug.cgi?id=4085 Bye, bearophil

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread Robert Jacques
On Mon, 26 Apr 2010 03:46:47 -0300, Gareth Charnock wrote: Thanks. To quickly answer this: > - The version I'm seeing on github doesn't seem to have all the features > you're referencing (i.e. v*v). Why are some ops limited to */ and other +-? It was quite late (3am) when I typed up

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread bearophile
Robert Jacques: > - Element wise *, etc are important operators that you need to cleanly > support. Design-wise, since we can't do Matlab style operators, I prefer > */+- to be element wise, But keep in mind in D the built-in array ops always require the []. Bye, bearophile

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread Robert Jacques
On Mon, 26 Apr 2010 13:16:02 -0300, bearophile wrote: Robert Jacques: - Element wise *, etc are important operators that you need to cleanly support. Design-wise, since we can't do Matlab style operators, I prefer */+- to be element wise, But keep in mind in D the built-in array ops always

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread bearophile
Robert Jacques: > Yes, but emulating that behavior is difficult. And array ops are still > buggy and broken to the degree of not being usable. In theory you > shouldn't need to define a small vector or matrix in D: fixed size arrays > are value types, array op support and free functions as me

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread Gareth Charnock
- Element wise *, etc are important operators that you need to cleanly support. Design-wise, since we can't do Matlab style operators, I prefer */+- to be element wise, and then use dot/cross/solve for matrix ops. This seems to avoid the confusion of as having some ops be matrix style and some

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread Gareth Charnock
bearophile wrote: Gareth Charnock: http://github.com/gcharnock/phoboslinalgebra I think that a single module is better. If seen fitting, some functionality can be moved inside other already present modules of Phobos. The module will need a good amount of unit tests. In the code I see no poi

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-26 Thread Robert Jacques
On Mon, 26 Apr 2010 18:02:53 -0300, Gareth Charnock wrote: - Element wise *, etc are important operators that you need to cleanly support. Design-wise, since we can't do Matlab style operators, I prefer */+- to be element wise, and then use dot/cross/solve for matrix ops. This seems to avo

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-27 Thread Jérôme M. Berger
Gareth Charnock wrote: > PS: Okay so I just had a looked at the matrix and vector classes in > Ogre3D and irrlicht. Looks like they both define v*v as element wise > multiplication but m*m is matrix multiplication. That just seems even > more inconsistent. Eigen (http://eigen.tuxfamily.org

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-27 Thread #ponce
> As for principal of least surprise, lots of libraries op > for using array-wise * and v.dot(v), including (IIRC) all of the various > GPU shading/compute languages. In GLSL, vector * vector is component-wise but matrix * vector is not matrix * matrix is not, and it fee

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-29 Thread Gareth Charnock
Jérôme M. Berger wrote: Gareth Charnock wrote: PS: Okay so I just had a looked at the matrix and vector classes in Ogre3D and irrlicht. Looks like they both define v*v as element wise multiplication but m*m is matrix multiplication. That just seems even more inconsistent. Eigen (http:/

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-29 Thread Robert Jacques
On Thu, 29 Apr 2010 19:16:49 -0400, Gareth Charnock wrote: Jérôme M. Berger wrote: Gareth Charnock wrote: PS: Okay so I just had a looked at the matrix and vector classes in Ogre3D and irrlicht. Looks like they both define v*v as element wise multiplication but m*m is matrix multiplication.

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-30 Thread Jérôme M. Berger
Robert Jacques wrote: > On Thu, 29 Apr 2010 19:16:49 -0400, Gareth Charnock > wrote: > >> Jérôme M. Berger wrote: >>> Gareth Charnock wrote: PS: Okay so I just had a looked at the matrix and vector classes in Ogre3D and irrlicht. Looks like they both define v*v as element wise mult

Re: Small vector and matrix proposed for phobos2 now on github

2010-04-30 Thread Robert Jacques
On Fri, 30 Apr 2010 17:23:33 -0400, Jérôme M. Berger wrote: Robert Jacques wrote: On Thu, 29 Apr 2010 19:16:49 -0400, Gareth Charnock wrote: Jérôme M. Berger wrote: Gareth Charnock wrote: PS: Okay so I just had a looked at the matrix and vector classes in Ogre3D and irrlicht. Looks like t