`uniform` function (matrix operation) doesn't seem to work as said in wiki?
Issue #373
resolved
Hi guys, according to the wiki, we should be able to use uniform
function as follows,
using blaze::uniform;
using blaze::rowMajor;
using blaze::columnMajor;
// Creates the uniform row-major matrix
// ( 1, 1, 1, 1, 1 )
// ( 1, 1, 1, 1, 1 )
auto U1 = uniform<int>( 2UL, 5UL, 1 ); // compile error
// Creates the uniform row-major matrix
// ( 1.2, 1.2 )
// ( 1.2, 1.2 )
// ( 1.2, 1.2 )
auto U2 = uniform<int,rowMajor>( 3UL, 2UL, 1.2 ); // compile error
However as I tested, the above 2 ways cannot compile.
Then I checked the implementation of uniform
as follows,
template< bool SO = defaultStorageOrder, typename T >
constexpr decltype(auto) uniform( size_t m, size_t n, T&& init )
{
return UniformMatrix< RemoveCVRef_t<T>, SO >( m, n, std::forward<T>( init ) );
}
so it has a default template arg SO
(in front of T), then in my code I tried code as follows, and compile OK finally,
auto U2 = uniform<rowMajor, int>( 3UL, 2UL, 1.2 ); // switch the positions of the 2 template args
I wonder if I misunderstood anything or the code from wiki is incorrect?
Comments (4)
-
-
-
assigned issue to
-
assigned issue to
-
- changed status to open
-
- changed status to resolved
Commit 8276157 fixes the documentation of the
uniform()
function for dense matrices. The fix is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.9. - Log in to comment
Hi Ecolss!
You are correct, the documentation in both the source code and the wiki is incorrect. You can call the
uniform()
function without any template parameter, but are able to explicitly specify the storage order. Due to type deduction it will create the correct type ofUniformMatrix
:The wiki has already been fixed and the example in the source code will be updated in the next push. We apologize for this mistake and the inconvenience,
Best regards,
Klaus!