Wiki
Clone wikiblaze / Vector-Vector Division
Componentwise Division
Dividing a vector by a dense vector with the same transpose flag (i.e. either blaze::columnVector
or blaze::rowVector
) via the division operator results in a componentwise division:
using blaze::DynamicVector;
using blaze::CompressedVector;
CompressedVector<int,columnVector> v1( 17UL );
DynamicVector<int,columnVector> v2( 17UL );
StaticVector<double,10UL,rowVector> v3;
DynamicVector<double,rowVector> v4( 10UL );
// ... Initialization of the vectors
CompressedVector<int,columnVector> v5( v1 / v2 ); // Componentwise division of a sparse and a
// dense column vector. The result is a sparse
// column vector.
DynamicVector<double,rowVector> v6( v3 / v4 ); // Componentwise division of two dense row
// vectors. The result is a dense row vector.
Note that all values of the divisor must be non-zero and that no checks are performed to assert this precondition!
Outer Quotient
The division between a column vector and a row vector results in the outer quotient of the two vectors:
blaze::StaticVector<double,3UL,columnVector> v1{ 2, 5, -1 };
blaze::DynamicVector<double,rowVector> v2{ -1, 5, -2, 4 };
// Results in the matrix
//
// ( -2 0.4 -1 0.5 )
// A = ( -5 1 -2.5 1.25 )
// ( 1 -0.2 0.5 -0.25 )
//
blaze::StaticMatrix<int,3UL,4UL> M1 = v1 / v2;
The trans()
function can be used to transpose a vector as necessary:
blaze::StaticVector<int,2UL,rowVector> v1{ 2, 5, -1 };
blaze::DynamicVector<int,rowVector> v2{ -1, 5, -2, 4 };
blaze::StaticMatrix<int,3UL,4UL> M1 = trans( v1 ) / v2;
Note that all values of the divisor must be non-zero and that no checks are performed to assert this precondition!
Previous: Vector/Vector Multiplication ---- Next: Matrix/Vector Multiplication
Updated