26#ifndef _H_GRB_ALGORITHMS_SPY 
   27#define _H_GRB_ALGORITHMS_SPY 
   37    namespace algorithms {
 
   47            template< 
bool normalize, 
typename IOType, 
typename InputType >
 
   48            RC spy_from_bool_or_void_input(
 
   50                const size_t m, 
const size_t n,
 
   51                const size_t small_m, 
const size_t small_n
 
   53                static_assert( std::is_same< InputType, bool >::value ||
 
   54                    std::is_same< InputType, void >::value,
 
   55                    "Error in call to internal::spy_from_bool_or_void_input" 
   62                std::vector< size_t > I, J;
 
   63                std::vector< unsigned char > V;
 
   64                const double n_sample = 
static_cast< double >(n) /
 
   65                    static_cast< double >(small_n);
 
   66                for( 
size_t i = 0; i < n; ++i ) {
 
   68                    J.push_back( 
static_cast< double >(i) / n_sample );
 
   72                    Q, &(I[0]), &(J[0]), &(V[0]), n,
 
   81                    std::vector< size_t > I, J;
 
   82                    std::vector< unsigned char > V;
 
   83                    const double m_sample = 
static_cast< double >(m) /
 
   84                        static_cast< double >(small_m);
 
   85                    for( 
size_t i = 0; i < m; ++i ) {
 
   86                        I.push_back( 
static_cast< double >(i) / m_sample );
 
   91                        P, &(I[0]), &(J[0]), &(V[0]), m,
 
   97                if( ret == 
SUCCESS && m - small_m > n - small_n ) {
 
  105                    ret = ret ? ret : 
grb::mxm( tmp, P, in, leftAssignAndAdd, 
RESIZE );
 
  107                    ret = ret ? ret : 
grb::mxm( out, tmp, Q, leftAssignAndAdd, 
RESIZE );
 
  117                    ret = ret ? ret : 
grb::mxm( tmp, in, Q, rightAssignAndAdd, 
RESIZE );
 
  119                    ret = ret ? ret : 
grb::mxm( out, P, tmp, rightAssignAndAdd, 
RESIZE );
 
  123                if( ret == 
SUCCESS && normalize ) {
 
  126                        v = 
static_cast< IOType 
>( 1 ) / v;
 
  195            bool normalize = 
false,
 
  196            typename IOType, 
typename InputType
 
  199            static_assert( !normalize || std::is_floating_point< IOType >::value,
 
  200                "When requesting a normalised spy plot, the data type must be " 
  210            if( small_m > m ) { 
return ILLEGAL; }
 
  211            if( small_n > n ) { 
return ILLEGAL; }
 
  212            if( small_m == m && small_n == n ) {
 
  213                return grb::set< grb::descriptors::structural >( out, in, 1 );
 
  220            ret = ret ? ret : grb::set< grb::descriptors::structural >( tmp, in, 
true );
 
  221            ret = ret ? ret : grb::algorithms::internal::template
 
  222                spy_from_bool_or_void_input< normalize >(
 
  223                    out, tmp, m, n, small_m, small_n
 
  230        template< 
bool normalize = false, 
typename IOType >
 
  232            static_assert( !normalize || std::is_floating_point< IOType >::value,
 
  233                "When requesting a normalised spy plot, the data type must be " 
  242            if( small_m > m ) { 
return ILLEGAL; }
 
  243            if( small_n > n ) { 
return ILLEGAL; }
 
  244            if( small_m == m && small_n == n ) {
 
  245                return grb::set< grb::descriptors::structural >( out, in, 1 );
 
  250            ret = ret ? ret : grb::algorithms::internal::template
 
  251                spy_from_bool_or_void_input< normalize >(
 
  252                    out, in, m, n, small_m, small_n
 
  259        template< 
bool normalize = false, 
typename IOType >
 
  261            static_assert( !normalize || std::is_floating_point< IOType >::value,
 
  262                "When requesting a normalised spy plot, the data type must be " 
  272            if( small_m > m ) { 
return ILLEGAL; }
 
  273            if( small_n > n ) { 
return ILLEGAL; }
 
  274            if( small_m == m && small_n == n ) {
 
  275                return grb::set< grb::descriptors::structural >( out, in, 1 );
 
  280            ret = ret ? ret : grb::algorithms::internal::template
 
  281                spy_from_bool_or_void_input< normalize >(
 
  282                    out, in, m, n, small_m, small_n
 
An ALP/GraphBLAS matrix.
Definition: matrix.hpp:71
 
A generalised semiring.
Definition: semiring.hpp:186
 
Standard identity for the logical AND operator.
Definition: identities.hpp:178
 
Standard identity for numerical addition.
Definition: identities.hpp:57
 
This operator takes the sum of the two input parameters and writes it to the output variable.
Definition: ops.hpp:177
 
This operator assigns the left-hand input if the right-hand input evaluates true.
Definition: ops.hpp:88
 
This operator assigns the right-hand input if the left-hand input evaluates true.
Definition: ops.hpp:143
 
The main header to include in order to use the ALP/GraphBLAS API.
 
RC eWiseLambda(const Func f, const Vector< DataType, backend, Coords > &x, Args...)
Executes an arbitrary element-wise user-defined function f on any number of vectors of equal length.
Definition: blas1.hpp:3746
 
RC mxm(Matrix< OutputType, backend, CIT, RIT, NIT > &C, const Matrix< InputType1, backend, CIT, RIT, NIT > &A, const Matrix< InputType2, backend, CIT, RIT, NIT > &B, const Semiring &ring=Semiring(), const Phase &phase=EXECUTE)
Unmasked and in-place sparse matrix–sparse matrix multiplication (SpMSpM), .
Definition: blas3.hpp:94
 
RC buildMatrixUnique(Matrix< InputType, implementation > &A, fwd_iterator1 I, const fwd_iterator1 I_end, fwd_iterator2 J, const fwd_iterator2 J_end, fwd_iterator3 V, const fwd_iterator3 V_end, const IOMode mode)
Assigns nonzeroes to the matrix from a coordinate format.
Definition: io.hpp:1336
 
size_t nnz(const Vector< DataType, backend, Coords > &x) noexcept
Request the number of nonzeroes in a given vector.
Definition: io.hpp:479
 
size_t ncols(const Matrix< InputType, backend, RIT, CIT, NIT > &A) noexcept
Requests the column size of a given matrix.
Definition: io.hpp:339
 
size_t nrows(const Matrix< InputType, backend, RIT, CIT, NIT > &A) noexcept
Requests the row size of a given matrix.
Definition: io.hpp:286
 
RC resize(Vector< InputType, backend, Coords > &x, const size_t new_nz) noexcept
Resizes the nonzero capacity of this vector.
Definition: io.hpp:703
 
RC clear(Vector< DataType, backend, Coords > &x) noexcept
Clears a given vector of all nonzeroes.
Definition: io.hpp:574
 
RC spy(grb::Matrix< IOType > &out, const grb::Matrix< InputType > &in)
Given an input matrix and a smaller output matrix, map nonzeroes from the input matrix into the small...
Definition: spy.hpp:198
 
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
 
@ SEQUENTIAL
Sequential mode IO.
Definition: iomode.hpp:75
 
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
 
@ ILLEGAL
A call to a primitive has determined that one of its arguments was illegal as per the specification o...
Definition: rc.hpp:143
 
@ SUCCESS
Indicates the primitive has executed successfully.
Definition: rc.hpp:54
 
@ EXECUTE
Speculatively assumes that the output container of the requested operation has enough capacity to com...
Definition: phase.hpp:257
 
@ RESIZE
Speculatively assumes that the output container(s) of the requested operation lack the necessary capa...
Definition: phase.hpp:187