|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
New *diag* operation (and related types)Dear all,
I needed a diag operation like the Matlab's diag function and Mathematica DiagonalMatrix function. Since I've not found it in uBLAS I've decided to implemet it. Basically it allows both the creation of a *generalized* diagonal matrix * M = diag(v,k) ==> Create a square diagonal matrix M with vector V being the k-th diagonal * M = diag(v,k,l) ==> Like the above, but M has layout l (e.g., column major) * M = diag(v,m,n,k) ==> Create a rectangular diagonal matrix M of size mXn with vector V being the k-th diagonal * M = diag(v,m,n,k,l) ==> Like the above, but M has layout l (e.g., column major) and the creation of a *diagonal* view: * v = diag(M,k) ==> Create a diagonal view of the k-th diagonal of matrix M See the docs inside code for more about them (if you have Doxygen you can even type: $ make apidoc) The version of *diag* which returns a matrix, returns a new type which I've called *generalized_diagonal_matrix*. I've not used a banded_matrix since for avoid to allocated useless space in case of sub-diagonal/super-diagonal matrices; In fact banded_matrix suppose to store element from lower >= 0 sub-diagonal to upper>=0 super-diagonal; so if you implement a k-th sub-diagonal of MxN matrix with a banded_matrix you have to create an object like this banded_matrix(M,N,k,0), which allocated space even for zero elements. NOTE: Digging inside uBLAS code I've noticed an "undocumented" type for diagonal matrices; it is in banded.hpp and is called guess what..."diagonal_matrix". However it is only for ordinary diagonal matrices (not for sub-diagonal or super-diagonal matrices) and is based on banded_matrix. So I've not used it. Even for the version of *diag* returning the diagonal of a matrix, I've created a new matrix proxy called *matrix_diagonal* in the spirit of existent proxy, like matrix_row, matrix_column,... I would like to know the opinion of ublas community, possible hints/comments/suggestions And obviously your opinion about to add all of this hell into the official uBLAS! ;) Thank you very much for your feedback!! Cheers, PS: for running the test cases I've included in the attached, unzip the archive and type: "make". All the binary files are in libs/numeric/ublas/test -- Marco _______________________________________________ ublas mailing list ublas@... http://lists.boost.org/mailman/listinfo.cgi/ublas Sent to: lists@... |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |