From 8677f5f45173de71e5818573059dfdf5dbb02054 Mon Sep 17 00:00:00 2001 From: Bharath Krishnan Date: Fri, 7 Sep 2012 12:12:54 -0400 Subject: [PATCH] Make sure that we can allocate DMat or SMat if their size is larger than max integer provided we have enough memory --- svdlib.c | 4 ++-- svdlib.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/svdlib.c b/svdlib.c index 10e7ec4..ba352de 100644 --- a/svdlib.c +++ b/svdlib.c @@ -17,7 +17,7 @@ void svdResetCounters(void) { /* Row major order. Rows are vectors that are consecutive in memory. Matrix is initialized to empty. */ -DMat svdNewDMat(int rows, int cols) { +DMat svdNewDMat(long rows, long cols) { int i; DMat D = (DMat) malloc(sizeof(struct dmat)); if (!D) {perror("svdNewDMat"); return NULL;} @@ -42,7 +42,7 @@ void svdFreeDMat(DMat D) { } -SMat svdNewSMat(int rows, int cols, int vals) { +SMat svdNewSMat(long rows, long cols, long vals) { SMat S = (SMat) calloc(1, sizeof(struct smat)); if (!S) {perror("svdNewSMat"); return NULL;} S->rows = rows; diff --git a/svdlib.h b/svdlib.h index b24a48c..edb74fa 100644 --- a/svdlib.h +++ b/svdlib.h @@ -70,12 +70,12 @@ SVD_F_DB: dense binary /******************************** Functions **********************************/ /* Creates an empty dense matrix. */ -extern DMat svdNewDMat(int rows, int cols); +extern DMat svdNewDMat(long rows, long cols); /* Frees a dense matrix. */ extern void svdFreeDMat(DMat D); /* Creates an empty sparse matrix. */ -SMat svdNewSMat(int rows, int cols, int vals); +SMat svdNewSMat(long rows, long cols, long vals); /* Frees a sparse matrix. */ void svdFreeSMat(SMat S);