[Genabel-commits] r1088 - pkg/MixABEL/src/MXlib

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 27 21:32:44 CET 2013


Author: wja
Date: 2013-01-27 21:32:44 +0100 (Sun, 27 Jan 2013)
New Revision: 1088

Modified:
   pkg/MixABEL/src/MXlib/moorepenrose.cpp
   pkg/MixABEL/src/MXlib/twovarcomp.cpp
Log:
Fixed bug #2449. Addresses of temporaries (submatrix/vector views) were being taken

Modified: pkg/MixABEL/src/MXlib/moorepenrose.cpp
===================================================================
--- pkg/MixABEL/src/MXlib/moorepenrose.cpp	2013-01-18 19:37:08 UTC (rev 1087)
+++ pkg/MixABEL/src/MXlib/moorepenrose.cpp	2013-01-27 20:32:44 UTC (rev 1088)
@@ -57,12 +57,15 @@
      return GSL_SUCCESS;
    }
    for(it=0;it<thresh;it++)
-     gsl_vector_scale(&(gsl_matrix_column(psvd_V_mat,it).vector),1.0/gsl_vector_get(psvd_S_vec,it));
-   
+    {
+	gsl_vector_view columnview = gsl_matrix_column(psvd_V_mat,it);
+     	gsl_vector_scale(&(columnview.vector),1.0/gsl_vector_get(psvd_S_vec,it));
+   }
    pUrest_mat=gsl_matrix_alloc(pA_mat->size1, thresh);
-   gsl_matrix_memcpy(pUrest_mat,&(gsl_matrix_submatrix(pA_mat,0,0,pA_mat->size1, thresh).matrix));
+  
+   gsl_matrix_view sub_mat = gsl_matrix_submatrix(pA_mat,0,0,pA_mat->size1, thresh);
+   gsl_matrix_memcpy(pUrest_mat,(&sub_mat.matrix));
    
-   
    svd_Vrest_matview=gsl_matrix_submatrix(psvd_V_mat, 0, 0, pA_mat->size1, thresh);
    
    gsl_blas_dgemm(CblasNoTrans, CblasTrans, 1.0, &(svd_Vrest_matview.matrix), pUrest_mat,0.0, pA_mat);

Modified: pkg/MixABEL/src/MXlib/twovarcomp.cpp
===================================================================
--- pkg/MixABEL/src/MXlib/twovarcomp.cpp	2013-01-18 19:37:08 UTC (rev 1087)
+++ pkg/MixABEL/src/MXlib/twovarcomp.cpp	2013-01-27 20:32:44 UTC (rev 1088)
@@ -675,8 +675,10 @@
   
   gsl_matrix_memcpy(pdev_work->pa_mat, ppRvPx_mat[pdev_work->k]);
   for(pdev_work->it=0;pdev_work->it<n;pdev_work->it++)
-    gsl_vector_scale(&(gsl_matrix_row(pdev_work->pa_mat,pdev_work->it).vector), gsl_vector_get(pdev_work->pa2_vec,pdev_work->it));
-  
+  {
+	  gsl_vector_view rowview=gsl_matrix_row(pdev_work->pa_mat,pdev_work->it);
+  	  gsl_vector_scale(&rowview.vector, gsl_vector_get(pdev_work->pa2_vec,pdev_work->it));
+  }
   gsl_vector_memcpy(pdev_work->pxPhiy_vec, ppxPVPy_vec[pdev_work->k]);
   gsl_matrix_memcpy(pdev_work->pxPhix_mat, ppxPVPx_mat[pdev_work->k]);
 
@@ -851,8 +853,10 @@
   gsl_matrix_memcpy(pdev_work->pa_mat, ppRvPx_mat[pdev_work->k]);
 
   for(pdev_work->it=0;pdev_work->it<n;pdev_work->it++)
-    gsl_vector_scale(&(gsl_matrix_row(pdev_work->pa_mat,pdev_work->it).vector), gsl_vector_get(pdev_work->pa2_vec,pdev_work->it));
-
+	{
+		gsl_vector_view rowview;
+    		gsl_vector_scale(&(rowview.vector), gsl_vector_get(pdev_work->pa2_vec,pdev_work->it));
+	}
    
   gsl_vector_memcpy(pdev_work->pxPhiy_vec, ppxPVPy_vec[pdev_work->k]);
   gsl_matrix_memcpy(pdev_work->pxPhix_mat, ppxPVPx_mat[pdev_work->k]);



More information about the Genabel-commits mailing list