-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCptMethod.R
More file actions
39 lines (36 loc) · 1.45 KB
/
CptMethod.R
File metadata and controls
39 lines (36 loc) · 1.45 KB
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
###### define class
CptMethod <- setClass("CptMethod", representation(
Name = "character",
Fun = "function"
))
##################################################################################################
#### RUN
##################################################################################################
setGeneric(name="runMethod", def=function(object, y){ standardGeneric("runMethod") })
setMethod("runMethod", signature="CptMethod",
function(object, y){
runtime <- system.time(cpt <- object@Fun(y))[3];
return(list(cpt=cpt, runtime=runtime))
}
)
##################################################################################################
#
#
#
#
##################################################################################################
###### define class for known K
CptKnownKMethod <- setClass("CptKnownKMethod", representation(
Name = "character",
Fun = "function"
))
##################################################################################################
#### RUN
##################################################################################################
setGeneric(name="runMethodK", def=function(object, y, K){ standardGeneric("runMethodK") })
setMethod("runMethodK", signature="CptKnownKMethod",
function(object, y, K){
runtime <- system.time(cpt <- object@Fun(y, K))[3];
return(list(cpt=cpt, runtime=runtime))
}
)