Actual source code: sendsparse.c

      1: #define PETSC_DLL

     3:  #include src/sys/src/viewer/impls/socket/socket.h

      5: /*--------------------------------------------------------------*/
      8: /*
      9:    PetscViewerSocketPutSparse_Private - Passes a sparse matrix in AIJ format
     10:              to a Socket PetscViewer.

     12:    Input Parameters:
     13: +  vw - obtained from PetscViewerSocketOpen()
     14: .  m - number of rows of matrix
     15: .  m - number of columns of matrix
     16: .  nnz - number of nonzeros in matrix
     17: .  v - the nonzero entries
     18: .  r - the row pointers (m + 1 of them)
     19: -  c - the column pointers (nnz of them)

     21:     Level: developer

     23:    Notes:
     24:    Most users should not call this routine, but instead should employ
     25: $     MatView(Mat matrix,PetscViewer viewer)

     27:    Notes for Advanced Users:
     28:    PetscViewerSocketPutSparse_Private() actually passes the matrix transpose, since
     29:    Matlab prefers column oriented storage.

     31:    Concepts: Matlab^sending data, sparse matrices
     32:    Concepts: Sockets^sending data, sparse matrices

     34: .seealso: PetscViewerSocketOpen(), MatView()
     35: */
     36: PetscErrorCode PetscViewerSocketPutSparse_Private(PetscViewer vw,PetscInt m,PetscInt n,PetscInt nnz,PetscScalar *v,PetscInt *r,PetscInt *c)
     37: {
     38:   PetscViewer_Socket *vmatlab = (PetscViewer_Socket*)vw->data;
     39:   PetscErrorCode     ierr;
     40:   int                t = vmatlab->port,type = SPARSEREAL,value;

     43:   PetscBinaryWrite(t,&type,1,PETSC_INT,PETSC_FALSE);
     44:   PetscBinaryWrite(t,&m,1,PETSC_INT,PETSC_FALSE);
     45:   PetscBinaryWrite(t,&n,1,PETSC_INT,PETSC_FALSE);
     46:   PetscBinaryWrite(t,&nnz,1,PETSC_INT,PETSC_FALSE);
     47: #if !defined(PETSC_USE_COMPLEX)
     48:   value = 0;
     49: #else
     50:   value = 1;
     51: #endif
     52:   PetscBinaryWrite(t,&value,1,PETSC_INT,PETSC_FALSE);
     53:   PetscBinaryWrite(t,v,nnz,PETSC_REAL,PETSC_FALSE);
     54:   PetscBinaryWrite(t,r,m+1,PETSC_INT,PETSC_FALSE);
     55:   PetscBinaryWrite(t,c,nnz,PETSC_INT,PETSC_FALSE);
     56:   return(0);
     57: }