#include <oct.h>
#include "gs_oct.h"
#include "grpc.h"
Go to the source code of this file.
Functions | |
int | sparsematrix_octcsc_to_gscsr (int m, int n, int nnz, int datatype, double *a, double *ai, int *colind, int *rowptr, void *at, int *rowind, int *colptr) |
int | sparsematrix_gscsr_to_octcsc (int m, int n, int nnz, int datatype, void *a, int *colind, int *rowptr, double *at, double *ati, int *rowind, int *colptr) |
int sparsematrix_gscsr_to_octcsc | ( | int | m, | |
int | n, | |||
int | nnz, | |||
int | datatype, | |||
void * | a, | |||
int * | colind, | |||
int * | rowptr, | |||
double * | at, | |||
double * | ati, | |||
int * | rowind, | |||
int * | colptr | |||
) |
Definition at line 65 of file oct_sparse.cpp.
{ int i, j, col, relpos; int *marker; marker = (int *)matlab_gs_calloc(n, sizeof(int)); if (marker == NULL) return -1; /* Get counts of each column of A, and set up column pointers */ for (i = 0; i < m; ++i) for (j = rowptr[i]; j < rowptr[i + 1]; ++j) ++marker[colind[j]]; colptr[0] = 0; for (j = 0; j < n; ++j) { colptr[j + 1] = colptr[j] + marker[j]; marker[j] = colptr[j]; } /* Transfer the matrix into the compressed column storage. */ for (i = 0; i < m; ++i) { for (j = rowptr[i]; j < rowptr[i + 1]; ++j) { col = colind[j]; relpos = marker[col]; rowind[relpos] = i; switch(datatype) { case GS_INT: ((double *) at)[relpos] = (double) ((int *) a)[j]; break; case GS_FLOAT: ((double *) at)[relpos] = (double) ((float *) a)[j]; break; case GS_DOUBLE: ((double *) at)[relpos] = ((double *) a)[j]; break; case GS_SCOMPLEX: ((double *) at)[relpos] = (float) (((gs_scomplex *) a)[j].r); ((double *) ati)[relpos] = (float) (((gs_scomplex *) a)[j].i); break; case GS_DCOMPLEX: ((double *) at)[relpos] = ((gs_dcomplex *) a)[j].r; ((double *) ati)[relpos] = ((gs_dcomplex *) a)[j].i; break; default: return -1; break; } ++marker[col]; } } matlab_gs_free(marker); return 0; }
int sparsematrix_octcsc_to_gscsr | ( | int | m, | |
int | n, | |||
int | nnz, | |||
int | datatype, | |||
double * | a, | |||
double * | ai, | |||
int * | colind, | |||
int * | rowptr, | |||
void * | at, | |||
int * | rowind, | |||
int * | colptr | |||
) |
Definition at line 5 of file oct_sparse.cpp.
{ int i, j, col, relpos; int *marker; marker = (int *) malloc(sizeof(int) * n); if (marker == NULL) return -1; /* Get counts of each column of A, and set up column pointers */ for (i = 0; i < m; ++i) for (j = rowptr[i]; j < rowptr[i + 1]; ++j) ++marker[colind[j]]; colptr[0] = 0; for (j = 0; j < n; ++j) { colptr[j + 1] = colptr[j] + marker[j]; marker[j] = colptr[j]; } /* Transfer the matrix into the compressed column storage. */ for (i = 0; i < m; ++i) { for (j = rowptr[i]; j < rowptr[i + 1]; ++j) { col = colind[j]; relpos = marker[col]; rowind[relpos] = i; switch(datatype) { case GS_INT: ((int *) at)[relpos] = (int) ((double *) a)[j]; break; case GS_FLOAT: ((float *) at)[relpos] = (float) ((double *) a)[j]; break; case GS_DOUBLE: ((double *) at)[relpos] = (double) ((double *) a)[j]; break; case GS_SCOMPLEX: ((gs_scomplex *) at)[relpos].r = (float) ((double *) a)[j]; ((gs_scomplex *) at)[relpos].i = (float) ((double *) ai)[j]; break; case GS_DCOMPLEX: /* ((dcomplex *)at)[relpos] = ((dcomplex *)a)[j]; */ ((gs_dcomplex *) at)[relpos].r = (double) ((double *) a)[j]; ((gs_dcomplex *) at)[relpos].i = (double) ((double *) ai)[j]; break; default: return -1; break; } ++marker[col]; } } return 0; }