SCM

SCM Repository

[matrix] Diff of /pkg/src/dsyMatrix.c
ViewVC logotype

Diff of /pkg/src/dsyMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1199, Mon Jan 23 15:02:13 2006 UTC revision 1200, Mon Jan 23 16:01:20 2006 UTC
# Line 57  Line 57 
57      return ScalarReal(rcond);      return ScalarReal(rcond);
58  }  }
59    
 static  
 void make_symmetric(double *to, SEXP from, int n)  
 {  
     int i, j;  
     if (*uplo_P(from) == 'U') {  
         for (j = 0; j < n; j++) {  
             for (i = j+1; i < n; i++) {  
                 to[i + j*n] = to[j + i*n];  
             }  
         }  
     } else {  
         for (j = 1; j < n; j++) {  
             for (i = 0; i < j && i < n; i++) {  
                 to[i + j*n] = to[j + i*n];  
             }  
         }  
     }  
 }  
   
60  SEXP dsyMatrix_solve(SEXP a)  SEXP dsyMatrix_solve(SEXP a)
61  {  {
62      SEXP trf = dsyMatrix_trf(a);      SEXP trf = dsyMatrix_trf(a);
# Line 143  Line 124 
124      SET_SLOT(val, Matrix_xSym, duplicate(GET_SLOT(from, Matrix_xSym)));      SET_SLOT(val, Matrix_xSym, duplicate(GET_SLOT(from, Matrix_xSym)));
125      SET_SLOT(val, Matrix_DimSym,      SET_SLOT(val, Matrix_DimSym,
126               duplicate(GET_SLOT(from, Matrix_DimSym)));               duplicate(GET_SLOT(from, Matrix_DimSym)));
127      make_symmetric(REAL(GET_SLOT(val, Matrix_xSym)), from,      SET_SLOT(val, Matrix_DimNamesSym,
128                     INTEGER(GET_SLOT(val, Matrix_DimSym))[0]);               duplicate(GET_SLOT(from, Matrix_DimNamesSym)));
129        make_d_matrix_symmetric(REAL(GET_SLOT(val, Matrix_xSym)), from);
130      UNPROTECT(1);      UNPROTECT(1);
131      return val;      return val;
132  }  }
# Line 154  Line 136 
136      int n = INTEGER(GET_SLOT(from, Matrix_DimSym))[0];      int n = INTEGER(GET_SLOT(from, Matrix_DimSym))[0];
137      SEXP val = PROTECT(allocMatrix(REALSXP, n, n));      SEXP val = PROTECT(allocMatrix(REALSXP, n, n));
138    
139      make_symmetric(Memcpy(REAL(val),      make_d_matrix_symmetric(Memcpy(REAL(val),
140                            REAL(GET_SLOT(from, Matrix_xSym)), n * n),                            REAL(GET_SLOT(from, Matrix_xSym)), n * n),
141                     from, n);                              from);
142      setAttrib(val, R_DimNamesSymbol, GET_SLOT(from, Matrix_DimNamesSym));      setAttrib(val, R_DimNamesSymbol, GET_SLOT(from, Matrix_DimNamesSym));
143      UNPROTECT(1);      UNPROTECT(1);
144      return val;      return val;

Legend:
Removed from v.1199  
changed lines
  Added in v.1200

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge