Rcpp Version 1.0.14
Loading...
Searching...
No Matches
no_init.h
Go to the documentation of this file.
1// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2//
3// Vector.h: Rcpp R/C++ interface class library -- vectors
4//
5// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
6//
7// This file is part of Rcpp.
8//
9// Rcpp is free software: you can redistribute it and/or modify it
10// under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 2 of the License, or
12// (at your option) any later version.
13//
14// Rcpp is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21
22#ifndef Rcpp__vector__no_init_h
23#define Rcpp__vector__no_init_h
24
25namespace Rcpp{
26
27template <int RTYPE, template <class> class StoragePolicy>
28class Matrix;
29
31public:
32 no_init_vector(R_xlen_t size_): size(size_){}
33
34 inline R_xlen_t get() const {
35 return size;
36 }
37
38 template <int RTYPE, template <class> class StoragePolicy >
40 // Explicitly protect temporary vector to avoid false positive
41 // with rchk (#892)
44 return ret;
45 }
46
47private:
49} ;
50
52public:
53 no_init_matrix(int nr_, int nc_): nr(nr_), nc(nc_) {}
54
55 inline int nrow() const {
56 return nr;
57 }
58
59 inline int ncol() const {
60 return nc;
61 }
62
63 template <int RTYPE, template <class> class StoragePolicy >
65 // Explicitly protect temporary matrix to avoid false positive
66 // with rchk (#892)
67 Shield<SEXP> x(Rf_allocMatrix(RTYPE, nr, nc));
69 return ret;
70 }
71
72private:
73 int nr;
74 int nc;
75} ;
76
78 return no_init_vector(size);
79}
80
81inline no_init_matrix no_init(int nr, int nc) {
82 return no_init_matrix(nr, nc);
83}
84
85
86}
87#endif
no_init_matrix(int nr_, int nc_)
Definition no_init.h:53
int ncol() const
Definition no_init.h:59
int nrow() const
Definition no_init.h:55
R_xlen_t get() const
Definition no_init.h:34
no_init_vector(R_xlen_t size_)
Definition no_init.h:32
Rcpp API.
Definition algo.h:28
no_init_vector no_init(R_xlen_t size)
Definition no_init.h:77
T as(SEXP x)
Definition as.h:151