Skip to content

Assigning nonsymmetric blocks into a symmetric matrix #244

@lambe

Description

@lambe

Consider the following example in the python shell:

>>> import numpy as np
>>> from cysparse.sparse.ll_mat import LLSparseMatrix
>>> A = LLSparseMatrix(size=5,size_hint=9,store_symmetric=True)
>>> B = LLSparseMatrix(nrow=1,ncol=4,size_hint=4)
>>> A.put_triplet(range(5),range(5),np.ones(5))
>>> B.put_triplet([0]*4,[0,1,2,3],5*np.ones(4,dtype=np.float64))
>>> A[4:5,:4] = B
>>> print A

The desired output should be:

 1.000000     ---        ---        ---       5.000000     
   ---      1.000000     ---        ---       5.000000   
   ---        ---      1.000000     ---       5.000000    
   ---        ---        ---      1.000000    5.000000   
 5.000000   5.000000   5.000000   5.000000    1.000000  

I.e., the nonsymmetric block is copied twice to maintain the symmetry of A. Instead, we get this:

 1.000000     ---        ---        ---        ---     
   ---      1.000000     ---        ---        ---     
   ---        ---      1.000000     ---        ---     
   ---        ---        ---      1.000000     ---     
 5.000000     ---        ---        ---      1.000000  

which is not only asymmetric but also fails to fully copy B.

The construction A[4:5,:4] = B was fine in Pysparse and it would be really nice to have the same capability in Cysparse. In the meantime, is there a workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions