- edited description
Feature requests
-
Add matrix reduce (sum) operation: As far as I know, there is no easy way to get a total sum of a matrix. I'm using std::accumulate on a submatrix right now. Hope there is a standard and optimized way of summing a matrix
-
const matrix views: Pulling out a vector from a row or column from a matrix with const is hard. blaze::column and blaze::row are not allowed on a const pretext. Hope I could directly pull out a vector from a matrix, or introduce const column/row views so I can assign them to a vector
-
matrix equality compare: Armadillo have a really great matrix equality compare operator with a tolerance argument. If the difference of elements in each operands is within provided tolerance, the operator returns a boolean true. Hope we could have something like that!
Thanks for this great library!
Comments (7)
-
reporter -
reporter - edited description
-
Hi Ray!
Welcome to Blaze and thanks for the proposals. Feedback about the library in general and missing features is highly appreciated.
Allow me to respond to the feature requests individually.
Add matrix (sum) operation
This feature is indeed missing and we will tackle it in one of the next releases (see issue #4). However, unfortunately this is a major task and therefore will take some time to implement. But you can rest assured that it is very high on our priority list.
const matrix views
The following code snippet shows how to extract a row from a constant matrix:
// Creating a 'const'-qualified row-major dense 3x3 matrix const blaze::DynamicMatrix<int> A{ { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; // Extracting the 1st row into a row vector blaze::DynamicVector<int,rowVector> x; x = row( A, 1UL ); std::cerr << " x = " << x << "\n"; // Extracting the 2nd row into a 'const'-qualified column vector const blaze::DynamicVector<int,columnVector> y( trans( row( A, 2UL ) ); std::cerr << " y = " << y << "\n";
This example will print
x = { 4, 5, 6 } y = { 7, 8, 9 }
Please note that
x
is a row vector. Blaze distinguishes between row and column vectors. The row of a matrix is considered a row vector, the column of a matrix is considered a column vector.The type returned from the
row()
function in this case isRow< const DynamicMatrix<int> >
(note theconst
on the template argument). However, even if you have a non-const
-qualified matrix you can at any point decide that a row should be immutable by usingRow< const DynamicMatrix<int> >
orconst Row< DynamicMatrix<int> >
explicitly.If you want to assign a row to a column vector (such as
y
), you can do this via thetrans()
function.We hope this helps. If you still encounter any problem, please post an according minimum example.
matrix equality compare
Blaze currently doesn't provide a matrix comparison with an additional tolerance value. However, this sounds like a reasonable feature. We will consider adding this in one of the next releases. Thanks for the proposal!
Best regards,
Klaus!
-
reporter Seems like I mixed up types on extracting the vector part. Thanks for your reply!
Great regards from Korea
-
An addition of reduction operation would allow for a quick implementation of many matrix norms. This feature is very useful for correctness verification of results and Blaze is missing both vector and matrix norms.
-
Sorry to bump old issue, but is the matrix/vector equality comparison with custom tolerance implemented yet? If not I’m happen to submit a PR.
-
Hi @pkerichang !
No, the feature hasn’t been implemented yet. We of course don’t mind if you provide a pull request. We would expect further overloads of the
equal()
functions in the following files:<blaze/math/expressions/DVecDVecEqualExpr.h>
<blaze/math/expressions/DVecSVecEqualExpr.h>
<blaze/math/expressions/SVecSVecEqualExpr.h>
<blaze/math/expressions/DMatDMatEqualExpr.h>
<blaze/math/expressions/DMatSMatEqualExpr.h>
<blaze/math/expressions/SMatSMatEqualExpr.h>
Based on these new functions a lot of the comparison functionality used within Blaze could be refactored. However, the pull request should be limited to the new functions. Thanks,
Best regards,
Klaus!
- Log in to comment