[pure-lang-svn] SF.net SVN: pure-lang:[860] pure/trunk/runtime.cc
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-09-25 09:46:15
|
Revision: 860 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=860&view=rev Author: agraef Date: 2008-09-25 09:46:09 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Bugfixes. Modified Paths: -------------- pure/trunk/runtime.cc Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-09-25 09:37:07 UTC (rev 859) +++ pure/trunk/runtime.cc 2008-09-25 09:46:09 UTC (rev 860) @@ -4470,13 +4470,14 @@ case EXPR::MATRIX: { gsl_matrix_symbolic *m = (gsl_matrix_symbolic*)x->data.mat.p; if (n1*n2!=m->size1*m->size2) return 0; - if (m->tda == m->size2) { + if (m->tda == (m->size2>0?m->size2:1)) { // No copying necessary, just create a new view of this matrix. gsl_matrix_symbolic *m1 = (gsl_matrix_symbolic*)malloc(sizeof(gsl_matrix_symbolic)); assert(m1); *m1 = *m; m1->size1 = n1; m1->tda = m1->size2 = n2; + if (m1->tda == 0) m1->tda = 1; p = m1; } else { // Create a new matrix containing the same elements. @@ -4484,6 +4485,7 @@ if (y) { gsl_matrix_symbolic *m = (gsl_matrix_symbolic*)y->data.mat.p; m->size1 = n1; m->tda = m->size2 = n2; + if (m->tda == 0) m->tda = 1; } return y; } @@ -4493,12 +4495,13 @@ case EXPR::DMATRIX: { gsl_matrix *m = (gsl_matrix*)x->data.mat.p; if (n1*n2!=m->size1*m->size2) return 0; - if (m->tda == m->size2) { + if (m->tda == (m->size2>0?m->size2:1)) { // No copying necessary, just create a new view of this matrix. gsl_matrix *m1 = (gsl_matrix*)malloc(sizeof(gsl_matrix)); assert(m1); *m1 = *m; m1->size1 = n1; m1->tda = m1->size2 = n2; + if (m1->tda == 0) m1->tda = 1; p = m1; } else { // Create a new matrix containing the same elements. @@ -4506,6 +4509,7 @@ if (y) { gsl_matrix *m = (gsl_matrix*)y->data.mat.p; m->size1 = n1; m->tda = m->size2 = n2; + if (m->tda == 0) m->tda = 1; } return y; } @@ -4514,13 +4518,14 @@ case EXPR::CMATRIX: { gsl_matrix_complex *m = (gsl_matrix_complex*)x->data.mat.p; if (n1*n2!=m->size1*m->size2) return 0; - if (m->tda == m->size2) { + if (m->tda == (m->size2>0?m->size2:1)) { // No copying necessary, just create a new view of this matrix. gsl_matrix_complex *m1 = (gsl_matrix_complex*)malloc(sizeof(gsl_matrix_complex)); assert(m1); *m1 = *m; m1->size1 = n1; m1->tda = m1->size2 = n2; + if (m1->tda == 0) m1->tda = 1; p = m1; } else { // Create a new matrix containing the same elements. @@ -4528,6 +4533,7 @@ if (y) { gsl_matrix_complex *m = (gsl_matrix_complex*)y->data.mat.p; m->size1 = n1; m->tda = m->size2 = n2; + if (m->tda == 0) m->tda = 1; } return y; } @@ -4536,13 +4542,14 @@ case EXPR::IMATRIX: { gsl_matrix_int *m = (gsl_matrix_int*)x->data.mat.p; if (n1*n2!=m->size1*m->size2) return 0; - if (m->tda == m->size2) { + if (m->tda == (m->size2>0?m->size2:1)) { // No copying necessary, just create a new view of this matrix. gsl_matrix_int *m1 = (gsl_matrix_int*)malloc(sizeof(gsl_matrix_int)); assert(m1); *m1 = *m; m1->size1 = n1; m1->tda = m1->size2 = n2; + if (m1->tda == 0) m1->tda = 1; p = m1; } else { // Create a new matrix containing the same elements. @@ -4550,6 +4557,7 @@ if (y) { gsl_matrix_int *m = (gsl_matrix_int*)y->data.mat.p; m->size1 = n1; m->tda = m->size2 = n2; + if (m->tda == 0) m->tda = 1; } return y; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |