Support for ndarrays
I was wondering if adding support for higher dimensional arrays or alternatively support for vectors of matrices or vice versa is planned:
DynamicVector<DynamicMatrix<int>> b;
This kind of functionality is what currently drives me towards using python's numpy than to using c++ for number crunching. Even given the performance penalty.
Comments (6)
-
-
reporter Thanks for the quick response! This looks great! I already read about the the support for non-fundamental types, so before posting the issue I gave it a try, got a huge amount of template errors and obviously gave up to soon. I think to simply use element-wise array operations this might suffice for my use-case. There are however quite a few other cases as e.g. slicing arrays, which would be a great additional feature for blaze (but would obviously require quite a bit of programming effort.)
-
Perhaps the following code helps to overcome the initial template-related problems:
// ( ( 1 1 ) ( 2 2 ) ) ( ( 1 ) ) ( ( 10 ) ) // ( ( 1 1 ) ( 2 2 ) ) ( ( 1 ) ) ( ( 10 ) ) // ( ) * ( ) = ( ) // ( ( 3 3 ) ( 4 4 ) ) ( ( 2 ) ) ( ( 22 ) ) // ( ( 3 3 ) ( 4 4 ) ) ( ( 2 ) ) ( ( 22 ) ) typedef StaticMatrix<int,2UL,2UL,rowMajor> M2x2; typedef StaticVector<int,2UL,columnVector> V2; DynamicMatrix<M2x2,rowMajor> A( 2UL, 2UL ); A(0,0) = M2x2(1); A(0,1) = M2x2(2); A(1,0) = M2x2(3); A(1,1) = M2x2(4); DynamicVector<V2,columnVector> x( 2UL ); x[0] = V2(1); x[1] = V2(2); DynamicVector<V2,columnVector> y( A * x ); std::cout << "\n A * x =\n" << y << "\n\n";
It compiles and computes the correct result.
In case you use
DynamicVector
orDynamicMatrix
as element type you have to make sure that all elements are sized appropriately. Else you will get an exception about a size mismatch.I'll leave this issue open for some days in case you still experience problems. After a couple of days I will close the issue and will create an issue for the documentation task.
Best regards,
Klaus!
-
-
assigned issue to
-
assigned issue to
-
The documentation for vectors and matrices with non-fundamental element type will be added in the scope of issue #37.
-
- changed status to closed
- Log in to comment
Hi Josef!
Blaze already provides support for vectors and matrices of non-fundamental data types. For instance:
The operation runs fully parallel and uses vectorization for every matrix/vector multiplication.
We have to admit that the feature is not documented properly. We have had this on our to-do list for quite some time, but didn't have the time. Sorry for that.
Please try whether the feature satisfies your requirements. If yes, I would suggest to close the issue and to create another one for the documentation task. If no, please create a comment with the problem you encountered. We will than try to fix the problem as quickly as possible. Thanks a lot,
Best regards,
Klaus!