SCM

SCM Repository

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

Diff of /pkg/src/Mutils.c

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

revision 1161, Fri Jan 13 23:46:29 2006 UTC revision 1162, Fri Jan 13 23:47:38 2006 UTC
# Line 583  Line 583 
583      ALLOC_SLOT(val, Matrix_xSym, REALSXP, nrow * ncol);      ALLOC_SLOT(val, Matrix_xSym, REALSXP, nrow * ncol);
584      return val;      return val;
585  }  }
586    
587    SEXP alloc_dgeMatrix(int m, int n, SEXP rownms, SEXP colnms)
588    {
589        SEXP ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dgeMatrix"))), dn;
590        int *dims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));
591    
592        dims[0] = m; dims[1] = n;
593        ALLOC_SLOT(ans, Matrix_xSym, REALSXP, m * n);
594        dn = ALLOC_SLOT(ans, Matrix_DimNamesSym, VECSXP, 2);
595        SET_VECTOR_ELT(dn, 0, duplicate(rownms));
596        SET_VECTOR_ELT(dn, 1, duplicate(colnms));
597        UNPROTECT(1);
598        return ans;
599    }
600    
601    SEXP alloc_dpoMatrix(int n, char *uplo, SEXP rownms, SEXP colnms)
602    {
603        SEXP ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dpoMatrix"))), dn;
604        int *dims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));
605    
606        dims[0] = dims[1] = n;
607        ALLOC_SLOT(ans, Matrix_xSym, REALSXP, n * n);
608        SET_SLOT(ans, Matrix_uploSym, mkString(uplo));
609        dn = ALLOC_SLOT(ans, Matrix_DimNamesSym, VECSXP, 2);
610        SET_VECTOR_ELT(dn, 0, duplicate(rownms));
611        SET_VECTOR_ELT(dn, 1, duplicate(colnms));
612        UNPROTECT(1);
613        return ans;
614    }
615    
616    SEXP alloc_dtrMatrix(int n, char *uplo, char *diag, SEXP rownms, SEXP colnms)
617    {
618        SEXP ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dtrMatrix"))), dn;
619        int *dims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));
620    
621        dims[0] = dims[1] = n;
622        ALLOC_SLOT(ans, Matrix_xSym, REALSXP, n * n);
623        SET_SLOT(ans, Matrix_uploSym, mkString(uplo));
624        SET_SLOT(ans, Matrix_diagSym, mkString(diag));
625        dn = ALLOC_SLOT(ans, Matrix_DimNamesSym, VECSXP, 2);
626        SET_VECTOR_ELT(dn, 0, duplicate(rownms));
627        SET_VECTOR_ELT(dn, 1, duplicate(colnms));
628        UNPROTECT(1);
629        return ans;
630    }
631    
632    SEXP alloc_dsCMatrix(int n, int nz, char *uplo, SEXP rownms, SEXP colnms)
633    {
634        SEXP ans = PROTECT(NEW_OBJECT(MAKE_CLASS("dsCMatrix"))), dn;
635        int *dims = INTEGER(ALLOC_SLOT(ans, Matrix_DimSym, INTSXP, 2));
636    
637        dims[0] = dims[1] = n;
638        ALLOC_SLOT(ans, Matrix_xSym, REALSXP, nz);
639        ALLOC_SLOT(ans, Matrix_iSym, INTSXP, nz);
640        ALLOC_SLOT(ans, Matrix_pSym, INTSXP, n + 1);
641        SET_SLOT(ans, Matrix_uploSym, mkString(uplo));
642        dn = ALLOC_SLOT(ans, Matrix_DimNamesSym, VECSXP, 2);
643        SET_VECTOR_ELT(dn, 0, duplicate(rownms));
644        SET_VECTOR_ELT(dn, 1, duplicate(colnms));
645        UNPROTECT(1);
646        return ans;
647    }
648    
649    

Legend:
Removed from v.1161  
changed lines
  Added in v.1162

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