Git Product home page Git Product logo

Comments (5)

DrTimothyAldenDavis avatar DrTimothyAldenDavis commented on August 14, 2024 1

OK ... the fix passes this simple test. I've pushed the fix, and I'll try my exhaustive tests now. If you do a git pull on the master branch, for the draft v5.1.7, it should work now.

from graphblas.

DrTimothyAldenDavis avatar DrTimothyAldenDavis commented on August 14, 2024

Can you check it in the C API? There might be a bug in the Rust or Java interface. It works fine in C. Which version of GraphBLAS did you use? Note that in version 5.1.x, the matrix B becomes iso-valued. Does mat2.get(...) use GrB_Matrix_extractElement or does it try to get the value itself?

#include "GraphBLAS.h"

// to compile and run:
// gcc bug.c /usr/local/lib/libgraphblas.so -lm -Wl,--verbose
// ldd a.out
// ./a.out

#if java_example

fn test_matrix_apply_transpose_on_self_fail_java() {
        let mut mat1 = SparseMatrix::<i32>::empty((1, 3));
        mat1.insert((0, 0), -3); // GrB_Matrix_setElement
        mat1.insert((0, 2), -4);
        mat1.insert((0, 1), 10);

        mat1.wait();

        // GrB_Marix_apply
        let mut mat2 = mat1.apply_mut::<i32, bool>(
            UnaryOp::<i32, i32>::one(), //GxB_ONE_INT32
            None,
            None,
            &Descriptor::default(),
        );

        mat2.wait();

        assert_eq!(mat2.shape(), (1, 3));
        assert_eq!(mat2.get((0, 0)), Some(1)); //this fails
        assert_eq!(mat2.get((0, 2)), Some(1)); //this fails
        assert_eq!(mat2.get((0, 1)), Some(1)); //this fails
    }

#endif

int main (void)
{
    GrB_init (GrB_NONBLOCKING) ;
    int ver [3] ;
    GxB_get (GxB_LIBRARY_VERSION, ver) ;
    printf ("SuiteSparse:GraphBLAS v%d.%d.%d\n", ver [0], ver [1], ver [2]) ;

    GrB_Matrix A, B ;
    GrB_Matrix_new (&A, GrB_INT32, 1, 3) ;
    GxB_print (A, 3) ;

    GrB_Matrix_setElement_INT32 (A, -3, 0, 0) ;
    GrB_Matrix_setElement_INT32 (A, -4, 0, 2) ;
    GrB_Matrix_setElement_INT32 (A, 10, 0, 1) ;
    GxB_print (A, 3) ;
    GrB_Matrix_wait (&A) ;

    GrB_Matrix_new (&B, GrB_INT32, 1, 3) ;
    GrB_apply (B, NULL, NULL, GxB_ONE_INT32, A, NULL) ;
    GxB_print (B, 3) ;

    int32_t result = 42 ;
    GrB_Matrix_extractElement_INT32 (&result, B, 0, 0) ;
    printf ("B(0,0) = %d\n", result) ;
    printf ("test: %s\n", (result == 1) ? "PASS" : "FAIL") ;

    result = 99 ;
    GrB_Matrix_extractElement_INT32 (&result, B, 0, 2) ;
    printf ("B(0,2) = %d\n", result) ;
    printf ("test: %s\n", (result == 1) ? "PASS" : "FAIL") ;

    result = 101 ;
    GrB_Matrix_extractElement_INT32 (&result, B, 0, 1) ;
    printf ("B(0,1) = %d\n", result) ;
    printf ("test: %s\n", (result == 1) ? "PASS" : "FAIL") ;

    GrB_free (&A) ;
    GrB_free (&B) ;
    GrB_finalize ( ) ;
}

WIth the above code, I get this output, which is the correct result:

SuiteSparse:GraphBLAS v5.1.6

  1x3 GraphBLAS int32_t matrix, sparse by row
  A, no entries, memory: 272 bytes


  1x3 GraphBLAS int32_t matrix, bitmap by row
  A, 3 entries, memory: 280 bytes

    (0,0)   -3
    (0,1)   10
    (0,2)   -4


  1x3 GraphBLAS int32_t matrix, bitmap by row
  B, 3 entries, memory: 272 bytes
  iso value:   1

    (0,0)   1
    (0,1)   1
    (0,2)   1

B(0,0) = 1
test: PASS
B(0,2) = 1
test: PASS
B(0,1) = 1
test: PASS

from graphblas.

fabianmurariu avatar fabianmurariu commented on August 14, 2024

I narrowed down to apply with one on the matrix itself, when I call GrB_Apply on a different matrix it works.

// along these lines
GrB_apply (A, NULL, NULL, GxB_ONE_INT32, A, NULL) ;

from graphblas.

DrTimothyAldenDavis avatar DrTimothyAldenDavis commented on August 14, 2024

Oops. That's a bug. I replicated it, and when I turn on debug in the Source/GB_dev.h, one of my assertions fails in GB_apply.c in the "in-place-op" part, line 236:

ASSERT (C->iso) ;
. Thanks for catching this. Now that I have a specific assertion failing (a very simple one, even), it shouldn't take too long to fix.

from graphblas.

fabianmurariu avatar fabianmurariu commented on August 14, 2024

Awesome

from graphblas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.