Actual source code: sendsparse.c
1: /*$Id: sendsparse.c,v 1.36 2001/04/12 13:32:45 balay Exp $*/
3: #include "src/sys/src/viewer/impls/socket/socket.h"
5: /*--------------------------------------------------------------*/
6: /*@C
7: PetscViewerSocketPutSparse_Private - Passes a sparse matrix in AIJ format
8: to a Socket PetscViewer.
10: Input Parameters:
11: + vw - obtained from PetscViewerSocketOpen()
12: . m, n - number of rows and columns of matrix
13: . nnz - number of nonzeros in matrix
14: . v - the nonzero entries
15: . r - the row pointers (m + 1 of them)
16: - c - the column pointers (nnz of them)
18: Level: developer
20: Notes:
21: Most users should not call this routine, but instead should employ
22: $ MatView(Mat matrix,PetscViewer viewer)
24: Notes for Advanced Users:
25: PetscViewerSocketPutSparse_Private() actually passes the matrix transpose, since
26: Matlab prefers column oriented storage.
28: Concepts: Matlab^sending data, sparse matrices
29: Concepts: Sockets^sending data, sparse matrices
31: .seealso: PetscViewerSocketOpen(), MatView()
32: @*/
33: int PetscViewerSocketPutSparse_Private(PetscViewer vw,int m,int n,int nnz,Scalar *v,int *r,int *c)
34: {
35: PetscViewer_Socket *vmatlab = (PetscViewer_Socket*)vw->data;
36: int ierr,t = vmatlab->port,type = SPARSEREAL,value;
39: PetscBinaryWrite(t,&type,1,PETSC_INT,0);
40: PetscBinaryWrite(t,&m,1,PETSC_INT,0);
41: PetscBinaryWrite(t,&n,1,PETSC_INT,0);
42: PetscBinaryWrite(t,&nnz,1,PETSC_INT,0);
43: #if !defined(PETSC_USE_COMPLEX)
44: value = 0;
45: #else
46: value = 1;
47: #endif
48: PetscBinaryWrite(t,&value,1,PETSC_INT,0);
49: PetscBinaryWrite(t,v,nnz,PETSC_REAL,0);
50: PetscBinaryWrite(t,r,m+1,PETSC_INT,0);
51: PetscBinaryWrite(t,c,nnz,PETSC_INT,0);
52: return(0);
53: }