-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectiveDynLib.R
More file actions
38 lines (31 loc) · 1.76 KB
/
CollectiveDynLib.R
File metadata and controls
38 lines (31 loc) · 1.76 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
# Backward-compatibility loader for legacy scripts that do:
# source("CollectiveDynLib.R")
.silently <- function(expr) { suppressWarnings(suppressMessages(eval.parent(substitute(expr)))) }
.loaded_pkg <- FALSE
.silently({ if (requireNamespace("collectivedyn", quietly = TRUE)) { library(collectivedyn); .loaded_pkg <- TRUE } })
if (!.loaded_pkg) {
message("[CollectiveDynLib] 'collectivedyn' not installed; sourcing local R/ files...")
rdir <- "R"
if (!dir.exists(rdir)) stop("[CollectiveDynLib] Could not find R/ directory. Install the package or run from the package root.")
rfiles <- list.files(rdir, pattern = "\\.R$", full.names = TRUE)
for (f in rfiles) sys.source(f, envir = .GlobalEnv)
}
# Backward-compat aliases (extend as needed)
if (!exists("plot.MultiTS", mode = "function") && exists("plot_MultiTS", mode = "function")) {
plot.MultiTS <- function(MultiTS) plot_MultiTS(MultiTS)
}
# If old code called buildCouplingMatrix(), remap to build_coupling_matrix()
if (!exists("buildCouplingMatrix", mode = "function") && exists("build_coupling_matrix", mode = "function")) {
buildCouplingMatrix <- function(g, type = c("adj", "laplacian"), normalize = c("none", "row", "sym")) {
type <- match.arg(type); normalize <- match.arg(normalize)
build_coupling_matrix(g, type = type, normalize = normalize)
}
}
# If old code called stepMapCoupled(), remap to step_map_coupled()
if (!exists("stepMapCoupled", mode = "function") && exists("step_map_coupled", mode = "function")) {
stepMapCoupled <- function(x, f_map, A, eps) step_map_coupled(x, f_map, A, eps)
}
# Kuramoto order parameter alias (kuramotoR -> kuramoto_r) — if you add kuramoto_r later
if (!exists("kuramotoR", mode = "function")) {
kuramotoR <- function(theta) as.numeric(abs(mean(exp(1i * theta))))
}