www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Matrix Class

reply Pedro Ferreira <checkmail file.attached> writes:
This is a templatized matrix class coded for the lastest DMD (using const
correctness). Everytime I used a Phobos functions I enclosed it with
version(Phobos), so adding support for another library (read: Tango) shouldn't
be too difficult.
There are a few edges left to be tackled, but this class was meant to be an
exercise of D templates and operator overloading (there was a thread in which I
talked about this class).
Not too long ago, I found out that there was already a Matrix class available,
but this one is not based on such other class. I don't really care which you
prefer.
The class was coded using D standards with some changes to suit my own
prefereces (tabs instead of spaces, opening bracket on new line, single space
seperating functions...).
This class does not rely on automatic garbage collection (except the right
shift operator), so you'll see some scope(failure) to prevent action from the
GC. This is, again, personal preference (I like to clean up after myself).
It is heavily documented and uses no "language arcana" (quoting Mr. Bright) or
obscure tricks, so even though I did not make as many comments as one would
like, it is still readable.
It is still incomplete. There are loads of functions I wanted to add, namely
matrix reduction (.reduce()), equation solving (from previous function),
derivated triangle matrix class (speedup on certain functions, such as
.determinant()), different storage schemes, Hamming Matrix calculus, rank()
(from Gaussian Elimination), rowReduce() (usefull to invert matrices),
characteristic polynomial... Some may be partially implemented by the time I
submit this message (I don't have permanent internet access). I will also write
some guidelines on how to derivate the class (which methods should be
overloaded, standards and so on).
This class should compile without warnings (-w flag).
No testing has been done with complex types (several warnings and errors show
up).
Matrix multiplication used to work. Now, it seems that "static if( is(T :
Matrix) )" no longer works.

On a side note, I am not an experienced programmer, so you may think "why the
heck he did this that way?!". If so, let me know :D Also, I am not english, so
spelling mistakes are probable as well as some comments/var names written in
portuguese.

The class itself features some bugs from DMD (just search for "bug" on the
file).
Speaking of bugs, on std.math, the documentation isn't complete for bool
approxEqual(T,U)(T lhs, U rhs); It just reads "Returns ."
I am forced to use offline documentation (c:\dmd\html\index.html). Usually, the
docs appear fine, but when I go to the Phobos section, it gets weird, in the
sense that I no longer have an index on the left. Just open it offline to see
what I mean.
Dec 04 2007
next sibling parent reply Pedro Ferreira <checkmail file.attached> writes:
i dont know why this didn't go through:

http://dpaste.com/hold/26749/
Dec 04 2007
parent reply BCS <ao pathlink.com> writes:
Reply to Pedro,

 i dont know why this didn't go through:
 
 http://dpaste.com/hold/26749/
 
If you have a dsource account, I'd be willing to let you put this in scrapple. All I'd need is your user name.
Dec 04 2007
parent reply Pedro Ferreira <reply this.post> writes:
BCS Wrote:

 Reply to Pedro,
 
 i dont know why this didn't go through:
 
 http://dpaste.com/hold/26749/
 
If you have a dsource account, I'd be willing to let you put this in scrapple. All I'd need is your user name.
My username in dsource is QueChatosComRegistos
Dec 04 2007
next sibling parent reply BCS <ao pathlink.com> writes:
Reply to Pedro,

that doesn't seem to work.

 QueChatosComRegisto
 
Dec 04 2007
parent reply pedro ferreira <saqa asdf.cas> writes:
BCS Wrote:

 Reply to Pedro,
 
 that doesn't seem to work.
 
 QueChatosComRegisto
 
Sorry, missed an "s": "QueChatosComRegistos"
Dec 06 2007
parent BCS <ao pathlink.com> writes:
Reply to Pedro,

 QueChatosComRegistos
 
your in
Dec 06 2007
prev sibling parent Bruno Medeiros <brunodomedeiros+spam com.gmail> writes:
Pedro Ferreira wrote:
 
 My username in dsource is QueChatosComRegistos
Where are you from Pedro Ferreira? From Portugal perhaps? -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Dec 05 2007
prev sibling next sibling parent Extrawurst <spam extrawurst.org> writes:
Pedro Ferreira schrieb:
 This is a templatized matrix class coded for the lastest DMD (using const
correctness). Everytime I used a Phobos functions I enclosed it with
version(Phobos), so adding support for another library (read: Tango) shouldn't
be too difficult.
 There are a few edges left to be tackled, but this class was meant to be an
exercise of D templates and operator overloading (there was a thread in which I
talked about this class).
 Not too long ago, I found out that there was already a Matrix class available,
but this one is not based on such other class. I don't really care which you
prefer.
 The class was coded using D standards with some changes to suit my own
prefereces (tabs instead of spaces, opening bracket on new line, single space
seperating functions...).
 This class does not rely on automatic garbage collection (except the right
shift operator), so you'll see some scope(failure) to prevent action from the
GC. This is, again, personal preference (I like to clean up after myself).
 It is heavily documented and uses no "language arcana" (quoting Mr. Bright) or
obscure tricks, so even though I did not make as many comments as one would
like, it is still readable.
 It is still incomplete. There are loads of functions I wanted to add, namely
matrix reduction (.reduce()), equation solving (from previous function),
derivated triangle matrix class (speedup on certain functions, such as
.determinant()), different storage schemes, Hamming Matrix calculus, rank()
(from Gaussian Elimination), rowReduce() (usefull to invert matrices),
characteristic polynomial... Some may be partially implemented by the time I
submit this message (I don't have permanent internet access). I will also write
some guidelines on how to derivate the class (which methods should be
overloaded, standards and so on).
 This class should compile without warnings (-w flag).
 No testing has been done with complex types (several warnings and errors show
up).
 Matrix multiplication used to work. Now, it seems that "static if( is(T :
Matrix) )" no longer works.

 On a side note, I am not an experienced programmer, so you may think "why the
heck he did this that way?!". If so, let me know :D Also, I am not english, so
spelling mistakes are probable as well as some comments/var names written in
portuguese.

 The class itself features some bugs from DMD (just search for "bug" on the
file).
 Speaking of bugs, on std.math, the documentation isn't complete for bool
approxEqual(T,U)(T lhs, U rhs); It just reads "Returns ."
 I am forced to use offline documentation (c:\dmd\html\index.html). Usually,
the docs appear fine, but when I go to the Phobos section, it gets weird, in
the sense that I no longer have an index on the left. Just open it offline to
see what I mean.
   
Line 84: /+DMD BUG: Altough it is documented at www.digitalmars.com/d/arrays.html under "Array Setting" neither of the following lines work: (at leat the first one should) * foreach(ref Type[] row; data) row=fill; * data[][]=fill; +/ possibility one is actually working as it is documented: void main() { byte[][] arr; arr = new byte[][](2,2); foreach(ref e; arr) e[] = 1; } ~Extrawurst
Dec 04 2007
prev sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Pedro Ferreira wrote:
 This is a templatized matrix class coded for the lastest DMD (using const
correctness). Everytime I used a Phobos functions I enclosed it with
version(Phobos), so adding support for another library (read: Tango) shouldn't
be too difficult.
 There are a few edges left to be tackled, but this class was meant to be an
exercise of D templates and operator overloading (there was a thread in which I
talked about this class).
 Not too long ago, I found out that there was already a Matrix class available,
but this one is not based on such other class. I don't really care which you
prefer.
 The class was coded using D standards with some changes to suit my own
prefereces (tabs instead of spaces, opening bracket on new line, single space
seperating functions...).
 This class does not rely on automatic garbage collection (except the right
shift operator), so you'll see some scope(failure) to prevent action from the
GC. This is, again, personal preference (I like to clean up after myself).
 It is heavily documented and uses no "language arcana" (quoting Mr. Bright) or
obscure tricks, so even though I did not make as many comments as one would
like, it is still readable.
 It is still incomplete. There are loads of functions I wanted to add, namely
matrix reduction (.reduce()), equation solving (from previous function),
derivated triangle matrix class (speedup on certain functions, such as
.determinant()), different storage schemes, Hamming Matrix calculus, rank()
(from Gaussian Elimination), rowReduce() (usefull to invert matrices),
characteristic polynomial... Some may be partially implemented by the time I
submit this message (I don't have permanent internet access). I will also write
some guidelines on how to derivate the class (which methods should be
overloaded, standards and so on).
 This class should compile without warnings (-w flag).
 No testing has been done with complex types (several warnings and errors show
up).
 Matrix multiplication used to work. Now, it seems that "static if( is(T :
Matrix) )" no longer works.
 
 On a side note, I am not an experienced programmer, so you may think "why the
heck he did this that way?!". If so, let me know :D Also, I am not english, so
spelling mistakes are probable as well as some comments/var names written in
portuguese.
 
 The class itself features some bugs from DMD (just search for "bug" on the
file).
 Speaking of bugs, on std.math, the documentation isn't complete for bool
approxEqual(T,U)(T lhs, U rhs); It just reads "Returns ."
 I am forced to use offline documentation (c:\dmd\html\index.html). Usually,
the docs appear fine, but when I go to the Phobos section, it gets weird, in
the sense that I no longer have an index on the left. Just open it offline to
see what I mean.
I seem to remember reading that inversion by cofactors was much inferior to using an LU decomposition / Gauss-elimination approach. --bb
Dec 04 2007
parent pedro ferreira <saqa asdf.cas> writes:
Bill Baxter Wrote:

 Pedro Ferreira wrote:
 This is a templatized matrix class coded for the lastest DMD (using const
correctness). Everytime I used a Phobos functions I enclosed it with
version(Phobos), so adding support for another library (read: Tango) shouldn't
be too difficult.
 There are a few edges left to be tackled, but this class was meant to be an
exercise of D templates and operator overloading (there was a thread in which I
talked about this class).
 Not too long ago, I found out that there was already a Matrix class available,
but this one is not based on such other class. I don't really care which you
prefer.
 The class was coded using D standards with some changes to suit my own
prefereces (tabs instead of spaces, opening bracket on new line, single space
seperating functions...).
 This class does not rely on automatic garbage collection (except the right
shift operator), so you'll see some scope(failure) to prevent action from the
GC. This is, again, personal preference (I like to clean up after myself).
 It is heavily documented and uses no "language arcana" (quoting Mr. Bright) or
obscure tricks, so even though I did not make as many comments as one would
like, it is still readable.
 It is still incomplete. There are loads of functions I wanted to add, namely
matrix reduction (.reduce()), equation solving (from previous function),
derivated triangle matrix class (speedup on certain functions, such as
.determinant()), different storage schemes, Hamming Matrix calculus, rank()
(from Gaussian Elimination), rowReduce() (usefull to invert matrices),
characteristic polynomial... Some may be partially implemented by the time I
submit this message (I don't have permanent internet access). I will also write
some guidelines on how to derivate the class (which methods should be
overloaded, standards and so on).
 This class should compile without warnings (-w flag).
 No testing has been done with complex types (several warnings and errors show
up).
 Matrix multiplication used to work. Now, it seems that "static if( is(T :
Matrix) )" no longer works.
 
 On a side note, I am not an experienced programmer, so you may think "why the
heck he did this that way?!". If so, let me know :D Also, I am not english, so
spelling mistakes are probable as well as some comments/var names written in
portuguese.
 
 The class itself features some bugs from DMD (just search for "bug" on the
file).
 Speaking of bugs, on std.math, the documentation isn't complete for bool
approxEqual(T,U)(T lhs, U rhs); It just reads "Returns ."
 I am forced to use offline documentation (c:\dmd\html\index.html). Usually,
the docs appear fine, but when I go to the Phobos section, it gets weird, in
the sense that I no longer have an index on the left. Just open it offline to
see what I mean.
I seem to remember reading that inversion by cofactors was much inferior to using an LU decomposition / Gauss-elimination approach. --bb
Yeap, as I said, other algorithms will be implemented. By the time I finished the inversion method, I hadn't finished my algorithm for gaussian elimination (echelon row reduce).
Dec 06 2007