import("methods")

importFrom("utils",
	"head",
	"tail",
	"sessionInfo",
	"capture.output",
	"object.size")

importFrom("grDevices",
	"as.raster",
	"col2rgb",
	"dev.capabilities",
	"dev.cur",
	"dev.flush",
	"dev.hold",
	"hcl.colors",
	"hcl.pals",
	"palette.colors",
	"palette.pals",
	"rgb",
	"trans3d",
	"xy.coords")

importFrom("graphics",
	"Axis",
	"abline",
	"arrows",
	"box",
	"boxplot.default",
	"co.intervals",
	"grid",
	"legend",
	"mtext",
	"par",
	"plot.new",
	"plot.window",
	"plot.xy",
	"persp",
	"points",
	"polygon",
	"rasterImage",
	"rect",
	"strheight",
	"strwidth",
	"text.default",
	"title")

importFrom("stats",
	"aggregate",
	"approx",
	"coef",
	"cor",
	"cov",
	"dnorm",
	"fft",
	"fitted",
	"kmeans",
	"loadings",
	"loess",
	"lowess",
	"median",
	"na.omit",
	"nextn",
	"nobs",
	"optim",
	"optimize",
	"predict",
	"qnorm",
	"quantile",
	"resid",
	"rlnorm",
	"rnorm",
	"runif",
	"runmed",
	"smooth.spline",
	"spline",
	"update")

importFrom("stats4",
	"plot",
	"summary",
	"update")

importFrom("Matrix",
	"nnzero",
	"rowSums",
	"rowMeans",
	"colSums",
	"colMeans")

importFrom("digest",
	"digest")

importFrom("irlba",
	"irlba")

importFrom("parallel",
	"makeCluster",
	"stopCluster",
	"clusterEvalQ",
	"nextRNGStream",
	"nextRNGSubStream")

import("BiocParallel")

import("BiocGenerics")

import("ProtGenerics")

exportClasses(
	"drle",
	"drle_fct",
	"atoms",
	"matter",
	"matter_arr",
	"matter_mat",
	"matter_vec",
	"matter_list",
	"matter_str",
	"matter_fct",
	"sparse_arr",
	"sparse_mat",
	"sparse_vec")

export(
	"drle",
	"is.drle")

export(
	"atoms",
	"read_atom",
	"write_atom",
	"read_atoms",
	"write_atoms")

export(
	"matter",
	"is.matter",
	"as.matter",
	"is.shared",
	"as.shared",
	"matter_arr",
	"matter_mat",
	"matter_vec",
	"matter_fct",
	"matter_list",
	"matter_str",
	"struct")

export(
	"is.sparse",
	"as.sparse",
	"sparse_mat",
	"sparse_vec")

exportMethods(
	"as.altrep",
	"as.vector",
	"as.matrix",
	"as.array",
	"as.list",
	"as.factor",
	"as.data.frame")

export("as.vector")

exportMethods(
	"adata",
	"atomdata",
	"atomdata<-",
	"type",
	"type<-",
	"path",
	"path<-",
	"readonly",
	"readonly<-")

exportMethods(
	"aindex",
	"atomindex",
	"atomindex<-",
	"pointers",
	"pointers<-",
	"domain",
	"domain<-",
	"tolerance",
	"tolerance<-",
	"sampler",
	"sampler<-",
	"nnzero",
	"rowMaj")

exportMethods(
	"fetch",
	"flash",
	"checksum")

exportMethods(
	"describe_for_display",
	"preview_for_display")

exportMethods(
	"%*%",
	"[",
	"[<-",
	"$",
	"$<-",
	"c",
	"combine",
	"cbind2",
	"rbind2",
	"lengths",
	"length",
	"dims",
	"dim",
	"dim<-",
	"names",
	"names<-",
	"dimnames",
	"dimnames<-",
	"levels",
	"levels<-",
	"droplevels",
	"Encoding",
	"Encoding<-",
	"t",
	"crossprod",
	"tcrossprod")

S3method("cbind", "matter_arr")
S3method("rbind", "matter_arr")
S3method("cbind", "sparse_arr")
S3method("rbind", "sparse_arr")

exportMethods(
	"Arith",
	"exp",
	"log",
	"log2",
	"log10",
	"log1p")

exportMethods(
	"range",
	"min",
	"max",
	"prod",
	"sum",
	"mean",
	"var",
	"sd",
	"any",
	"all",
	"rowSums",
	"rowMeans",
	"colSums",
	"colMeans")

export(
	"s_range",
	"s_min",
	"s_max",
	"s_prod",
	"s_sum",
	"s_mean",
	"s_var",
	"s_sd",
	"s_any",
	"s_all",
	"s_nnzero",
	"s_stat",
	"s_colstats",
	"s_rowstats",
	"stat_c")

S3method("c", "stream_stat")
S3method("cbind", "stream_stat")
S3method("rbind", "stream_stat")
S3method("print", "stream_stat")
S3method("nobs", "stream_stat")
S3method("[", "stream_stat")
S3method("[[", "stream_stat")

S3method("stat_c", "stream_range")
S3method("stat_c", "stream_min")
S3method("stat_c", "stream_max")
S3method("stat_c", "stream_prod")
S3method("stat_c", "stream_sum")
S3method("stat_c", "stream_mean")
S3method("stat_c", "stream_var")
S3method("stat_c", "stream_sd")
S3method("stat_c", "stream_any")
S3method("stat_c", "stream_all")
S3method("stat_c", "stream_nnzero")

S3method("as.data.frame", "stream_stat")

exportMethods(
	"rowsweep",
	"colsweep",
	"rowscale",
	"colscale")

exportMethods(
	"rowStats",
	"colStats")

export(
	".rowStats",
	".colStats")

export(
	"inpoly",
	"rowdist",
	"coldist",
	"rowdist_at",
	"coldist_at")

exportMethods(
	"rowDists",
	"colDists")

export(
	".rowDists",
	".colDists")

export(
	"chunked_vec",
	"chunked_mat",
	"chunked_list",
	"chunkify")

export(
	"chunk_apply",
	"chunk_rowapply",
	"chunk_colapply",
	"chunk_lapply",
	"chunk_mapply",
	"chunk_writer")

export(
	"chunkApply",
	"chunkLapply",
	"chunkMapply")

export(
	"uuid",
	"tempmem",
	"hex2raw",
	"raw2hex")

S3method("[", "size_bytes")
S3method("print", "size_bytes")
S3method("format", "size_bytes")

export(
	"size_bytes",
	"sizeof",
	"vm_used",
	"shm_used",
	"mem_realized")

export(
	"approx1",
	"filt1_ma",
	"filt1_conv",
	"filt1_gauss",
	"filt1_bi",
	"filt1_adapt",
	"filt1_diff",
	"filt1_guide",
	"filt1_pag",
	"filt1_sg",
	"convolve_at",
	"warp1_loc",
	"warp1_dtw",
	"warp1_cow",
	"icor",
	"roll",
	"rollvec",
	"binvec",
	"findbins",
	"downsample",
	"estbase_loc",
	"estbase_hull",
	"estbase_snip",
	"estbase_med",
	"estnoise_sd",
	"estnoise_mad",
	"estnoise_diff",
	"estnoise_quant",
	"estnoise_filt",
	"locmax",
	"locmin",
	"findpeaks",
	"findpeaks_cwt",
	"findridges",
	"rescale_rms",
	"rescale_sum",
	"rescale_ref",
	"rescale_range",
	"rescale_iqr",
	"ricker",
	"cwt",
	"peakwidths",
	"peakareas",
	"peakheights",
	"binpeaks",
	"mergepeaks",
	"estres",
	"simspec",
	"simspec1")

export(
	"approx2",
	"filt2_ma",
	"filt2_conv",
	"filt2_gauss",
	"filt2_bi",
	"filt2_adapt",
	"filt2_diff",
	"filt2_guide",
	"filtn_ma",
	"filtn_conv",
	"filtn_gauss",
	"filtn_bi",
	"filtn_adapt",
	"warp2_trans",
	"mi",
	"enhance_adj",
	"enhance_hist",
	"enhance_adapt",
	"knnmax",
	"knnmin",
	"findpeaks_knn",
	"coscore",
	"is_gridded",
	"to_raster",
	"to_raster3",
	"estdim",
	"trans2d")

export(
	"array_ind",
	"linear_ind")

export(
	"isofun",
	"isoclos")

export(
	"pinv",
	"avg")

export("seq_rel")

export("shingles")

export(
	"RNGStreams",
	"getRNGStream",
	"setRNGStream")

export(
	"cpal",
	"cpals",
	"dpal",
	"dpals",
	"add_alpha")

exportMethods("prcomp")

export(
	"qrank",
	"qorder",
	"qselect",
	"qmedian",
	"qmad",
	"reldiff",
	"asearch",
	"bsearch",
	"kdtree",
	"kdsearch",
	"knnsearch",
	"nnpairs")

S3method("print", "kdtree")

export(
	"cv_do",
	"mi_learn",
	"predscore",
	"rocscore",
	"fastmap",
	"nndsvd",
	"nnmf_als",
	"nnmf_mult",
	"nscentroids",
	"sgmix",
	"sgmixn",
	"prcomp_lanczos",
	"pls_nipals",
	"pls_simpls",
	"pls_kernel",
	"opls_nipals",
	"vip")

S3method("fitted", "cv")
S3method("print", "cv")

S3method("fitted", "sgmix")
S3method("print", "sgmix")
S3method("logLik", "sgmix")

S3method("predict", "fastmap")
S3method("print", "fastmap")

S3method("predict", "nnmf")
S3method("print", "nnmf")

S3method("print", "prcomp_lanczos")

S3method("fitted", "nscentroids")
S3method("predict", "nscentroids")
S3method("print", "nscentroids")
S3method("logLik", "nscentroids")

S3method("fitted", "pls")
S3method("predict", "pls")
S3method("print", "pls")

S3method("coef", "opls")
S3method("residuals", "opls")
S3method("fitted", "opls")
S3method("predict", "opls")
S3method("print", "opls")

export(
	"panel_grid",
	"panel_dim",
	"panel_get",
	"panel_set",
	"panel_next",
	"panel_prev")

export(
	"vizi",
	"add_mark",
	"add_facets",
	"set_title",
	"set_channel",
	"set_coord",
	"set_par",
	"set_engine",
	"as_facets",
	"as_layers")

export(
	"vizi_par",
	"vizi_style",
	"vizi_engine")

S3method("preplot", "vizi_plot")
S3method("preplot", "vizi_facets")

S3method("plot", "vizi_plot")
S3method("plot", "vizi_facets")

S3method("print", "vizi_plot")
S3method("print", "vizi_facets")

S3method("plot", "vizi_key")
S3method("plot", "vizi_colorkey")

S3method("plot", "vizi_points")
S3method("plot", "vizi_lines")
S3method("plot", "vizi_peaks")
S3method("plot", "vizi_text")
S3method("plot", "vizi_intervals")
S3method("plot", "vizi_rules")
S3method("plot", "vizi_bars")
S3method("plot", "vizi_boxplot")
S3method("plot", "vizi_image")
S3method("plot", "vizi_pixels")
S3method("plot", "vizi_voxels")

export(
	"plot_signal",
	"plot_image")

exportMethods(
	"preplot",
	"plot")

export(
	"iQuote",
	"parse_formula",
	"eval_at",
	"eval_exprs")

export(
	"simple_logger",
	"matter_logger")

export(
	"matter_log",
	"matter_message",
	"matter_warn",
	"matter_error")

export(
	"mem",
	"memcl",
	"memtime",
	"profmem")

export(
	"matter_shared_resource",
	"matter_shared_resource_list",
	"matter_shared_resource_pool")

export("matter_defaults")

export(
	"SnowfastParam",
	"bpislocal",
	"bplocalized",
	"bptrystart",
	"bptrystop")

useDynLib("matter", .registration=TRUE, .fixes="C_")