-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaclasses.R
49 lines (39 loc) · 1.39 KB
/
aclasses.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
setClass("RTypeDesc", contains = "VIRTUAL")
setClass("DimensionedType", contains = c("RTypeDesc", "VIRTUAL"))
setClass("NativeMatrixType", representation(elType = "ANY", dim = "integer", dimVars = 'character'), contains = "DimensionedType")
setClass("RMatrixType", representation(elType = "ANY", dim = "integer"), contains = c("DimensionedType", "SEXPType"))
#setClass("ArrayType", contains = "RMatrixType")
setClass("DataFrameType", representation(elTypes = "list", nrow = "integer", ncol = "integer"), contains = c("DimensionedType", "SEXPType"))
NativeMatrixType =
function(elType, nrow = NA, ncol = NA, dimVars = character())
{
if(!missing(ncol))
dim = c(nrow, ncol)
else
dim = nrow
new("NativeMatrixType", elType = elType, dim = as.integer(dim), dimVars = as(dimVars, "character"))
}
RMatrixType =
function(elType, nrow = NA, ncol = NA, dimVars = character())
{
if(!missing(ncol))
dim = c(nrow, ncol)
else
dim = nrow
new("RMatrixType", elType = elType, dim = as.integer(dim))
}
ArrayType =
function(elType, dim = c(NA, NA))
{
#XXX Is this defined? Commented out above.
new("ArrayType", elType = elType, dim = as.integer(dim))
}
DataFrameType =
function(elTypes, nrow = NA, ncol = length(elTypes))
{
if(!missing(ncol))
dim = c(nrow, ncol)
else
dim = nrow
new("DataFrameType", elTypes = elTypes, nrow = as.integer(nrow), ncol = as.integer(ncol))
}